News:

Simutrans Chat Room
Where cool people of Simutrans can meet up.

Ambient sounds

Started by An_dz, May 02, 2012, 04:38:19 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

An_dz

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.

prissi

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.

Isaac Eiland-Hall

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. :)

yorkeiser

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.

Fabio

Quote from: yorkeiser on May 02, 2012, 01:36:37 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?

yorkeiser

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++.

Fabio

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.

prissi

#7
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, ...

An_dz

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.

Ters

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.

derajjared

this would be a step to please me that simutrans ambientaran areas.
I like to see this happen soon

prissi

Here three testsounds:

An_dz

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?

yorkeiser

Quote from: Ters 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.
You're right, mp3 is proprietary, in fact most open source projects (e.g. frets on fire, freeorion...) use ogg vorbis format.

prissi

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 ...

VS

Are you sure about these format requirements?

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

prissi

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.

Ters

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.

prissi

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.

greenling

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?
Opening hours 20:00 - 23:00
(In Night from friday on saturday and saturday on sunday it possibly that i be keep longer in Forum.)
I am The Assistant from Pakfilearcheologist!
Working on a big Problem!

Roads

@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.