The International Simutrans Forum

 

Author Topic: Ambient sounds  (Read 4442 times)

0 Members and 1 Guest are viewing this topic.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2914
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Ambient sounds
« on: May 02, 2012, 04:38:19 AM »
I was thinking about add the option for Ambient sounds. The idea is add ambient sound depending where the center of the screen is.

I would add 6 different sounds: 1. Ocean(water shaking, wind), 2. Beach(waves breaking, water shaking, wind), 3. forest/out of city(birds, wind, trees shaking, etc.), 4. big city(Traffic, dogs, people, etc.), 5. small city(Sparse traffic, people walking, bikes, etc.), 6. Rural area(tractors, trucks, traffic, cows, pigs, etc.)

The sound volume goes high and low as where the center of the map is, any tile without anything on it or tiles with rural factories and attractions use sound 3, the water tiles use sound 1, and the tiles with lake/sea transition use sound 2. For city sounds I don't know much, I would like to know more how Simutrans handle the city grow, I would like to know what parameters Simutrans uses to make the city change houses to skyscrapers.

It would have a radius for that sound, where right over the tile the volume is 100%, but as you move away it lowers it and raise other sound. This radius could be set in simuconf.tab.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9989
  • Languages: De,EN,JP
Re: Ambient sounds
« Reply #1 on: May 02, 2012, 07:37:29 AM »
THis is implemented (or at least I made a patch for it). It was played, when the cursor was not moving for 10-15 seconds. The sound would also play on factories and so.

I had waves, forest, city no rural area, but that would be trivial. The problem was, that those sound did double the size of a pakset.

A radius is not working, as there is no flag telling you what kind of ground a certain tile is.

Offline Isaac Eiland-Hall

  • Benevolent Dictator
  • Administrator
  • *
  • Posts: 3792
  • Providing hosting for Simutrans projects
    • pc2.io
  • Languages: EN
Re: Ambient sounds
« Reply #2 on: May 02, 2012, 01:05:12 PM »
Bandwidth isn't a problem for us, is it? At least it could be made available as an addon? IMHO, sound is one of the most important aspects of a good game - if done right, it makes immersion so much more complete. :)

Offline yorkeiser

  • *
  • Posts: 107
  • Beer guru
  • Languages: IT EN FR
Re: Ambient sounds
« Reply #3 on: May 02, 2012, 01:36:37 PM »
If the problem is only disk size, maybe greater compression for wav files could be preferable.
Or better, sounds could be encoded in mp3 and sound decoding could be declined to an external dll (lame encoder is free, by example). This could also allow to play good ingame music, instead of actual midi files, that are not anymore actual tech imho.
An mp3 decoder would surely affect performance, but in my experience cpu load would not be so heavy.

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Ambient sounds
« Reply #4 on: May 02, 2012, 01:39:33 PM »
An mp3 decoder would surely affect performance, but in my experience cpu load would not be so heavy.

And surely sound engind could be multithreaded, couldn't it?

Offline yorkeiser

  • *
  • Posts: 107
  • Beer guru
  • Languages: IT EN FR
Re: Ambient sounds
« Reply #5 on: May 02, 2012, 01:48:54 PM »
In c++ it surely could be, but it's dangerous on slower machines: if you assign ingame sound processing to a thread with less priority, you can have music lagging or stopping. Also music effects must have a good timing with what is drawn on the screen: if you see a river, you must hear water flowing, and not hear it when you already moved the view on a mountain. However, yes, having Java in mind I think it certainly could be, and probably would have to be on a different thread, but I don't know how thread synchronizing works in c++.

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Ambient sounds
« Reply #6 on: May 02, 2012, 02:03:10 PM »
There are talks about multithreading some routines and some patches are already released/incorporated. Prissi, Dwachs and Kierongreen are taking care of it.

Not being a programmer myself, I could suggest that the sound engine thread could act in a way that if it turns out to be running late, it just skips playing the sounds scheduled and refreshes its queue. So that if you see a river, either it plays its sound, either it doesn't play any sound at all, according to the system resources. Background music, OTOH, cares less about synchronization, so sound engine could be split in two threads, one with low priority playing music and one with higher priority playing the sound effects.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9989
  • Languages: De,EN,JP
Re: Ambient sounds
« Reply #7 on: May 02, 2012, 02:35:23 PM »
Compressed sound has one problem: cross plattform support is lacking. Even mp3 needs a different playback tool on each platform. SDL-mixer supported native mp3, Windows wants them in WAV-container for SDL on some architectures. And linking a new backend just for mp3 sound is also not satisfying.

But as an addon sould be no problem. Then modem/ISDN users (still about 5% of the population in germany only gets max. 128 kB/s) could decide whether they would like to spend time on download.

I have to did the code; maybe most parts were already incorporated. But then I really need nice sound snippets; that was the second problem.

Ok, this incorporated for water sound, beach sound, sound per climate and snow sound (in winter). Just copy wav files with the names "beaches.wav", "forest.wav", adn xxx.wav, with xxx the name of the climate like in the buildings:  "Water", "desert", "tropic", "mediterran", "temperate", "tundra", "rocky", "arctic" (please look at upper/lower case for Water!) artic.wav is played also in winter.

Currently sounds are player after 13s no movement, then 26s, 52s, ...
« Last Edit: May 02, 2012, 02:46:35 PM by prissi »

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2914
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Ambient sounds
« Reply #8 on: May 02, 2012, 04:14:54 PM »
I'll try it when I get home.

Having it as an addon is better, this way people with low internet can have the game without having to download a big file.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5642
  • Languages: EN, NO
Re: Ambient sounds
« Reply #9 on: May 02, 2012, 04:22:21 PM »
Doesn't mp3 have some patent issues? Ogg Vorbis is free, but maybe few contributors would know how to export/convert to that format. We might need to bridge the Ogg Vorbis decoder and the audio output library, though.

Offline derajjared

  • *
  • Posts: 200
  • DERAJJARED_MEXICO
    • EL GRAN PAK.........
Re: Ambient sounds
« Reply #10 on: May 02, 2012, 04:42:55 PM »
this would be a step to please me that simutrans ambientaran areas.
I like to see this happen soon

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9989
  • Languages: De,EN,JP
Re: Ambient sounds
« Reply #11 on: May 02, 2012, 06:58:47 PM »
Here three testsounds:

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2914
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Ambient sounds
« Reply #12 on: May 03, 2012, 01:38:19 AM »
I have a very nice sound here that could be used to keep playing, unfortunately it is copyrighted. But it is very nice. And it have 12 minutes.

Is there nay place that show all sound.tab options?

Offline yorkeiser

  • *
  • Posts: 107
  • Beer guru
  • Languages: IT EN FR
Re: Ambient sounds
« Reply #13 on: May 03, 2012, 09:23:52 AM »
Doesn't mp3 have some patent issues? Ogg Vorbis is free, but maybe few contributors would know how to export/convert to that format. We might need to bridge the Ogg Vorbis decoder and the audio output library, though.
You're right, mp3 is proprietary, in fact most open source projects (e.g. frets on fire, freeorion...) use ogg vorbis format.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9989
  • Languages: De,EN,JP
Re: Ambient sounds
« Reply #14 on: May 03, 2012, 10:33:43 AM »
Copyrighted sounds are a big problem. The above sounds are from an entirely free archive and are remixed then.

And mp3 is not so much a patent problem as that a special file format is required for playback on windows and Linux (not sure about MAC). I.e. on windows the system MUST have WAV with mp3 content, while this is not understood on Linux. SDL can play there mp3 but not WAV with MP3 inside ...

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4856
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Ambient sounds
« Reply #15 on: May 03, 2012, 11:25:26 AM »
Are you sure about these format requirements?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9989
  • Languages: De,EN,JP
Re: Ambient sounds
« Reply #16 on: May 03, 2012, 03:18:12 PM »
It changes of course with SDL version and so on.

But the last time I tried playback of wav-files with mp3 content on Linux, plain SDL could not play and SDL_mixer froze the system. SDL_mixer could playback mp3 files. However, on windows SDL (and Windows) could only playback mp3 files in WAV-container. It worked on some versions of windows and hardware with plain mp3 files with SDL, but not a majority.

However, this was two years ago, maybe Lunix-SDL does now support mp3 in wav-container.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5642
  • Languages: EN, NO
Re: Ambient sounds
« Reply #17 on: May 03, 2012, 03:49:07 PM »
I guess we can get away with mp3 as long as the codec is not shipped with the game, but must be installed on the user's system already.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9989
  • Languages: De,EN,JP
Re: Ambient sounds
« Reply #18 on: May 03, 2012, 07:33:48 PM »
Sigh: Does anybody actually READ my postings? There is currently no portabel way to use mp3 together with SDL or GDI version.

More on topi: Those abmient sounds are actually contained in pak64 for some time, with sounds for forest, water, artic, desert and tropic.

Offline greenling

  • Lounger
  • *
  • Posts: 1728
  • Simutransarchology it my hobby!
  • Languages: DE,EN
Re: Ambient sounds
« Reply #19 on: May 27, 2012, 08:11:16 PM »
Excuse me
i want make some new soundfiles!
What must i remake thats the soundfiles be play in simutrans?
De
Ich möchte für mich ein paar neues Soundfiles machen.
Was muss ich dabei beachten das die Soundfiles von simutrans abgespielt werden?

Offline Roads

  • Devotees (Inactive)
  • *
  • Posts: 645
Re: Ambient sounds
« Reply #20 on: May 30, 2012, 07:32:31 PM »
@Prissi

I downloaded and listened to your sounds and think they are great.  The only thing I would suggest is that the sounds go off when the game is paused.  Can't remember what it was now but some game I played once had a dog barking that drove me nuts.  It seems to me sounds are a mixed bag and that is they are absolutely great if they don't get monotonous but awful if they do.