Wintermute Engine Forum

Wintermute Engine => Scripts, plugins, utilities, goodies => Topic started by: MrBehemoth on January 05, 2014, 06:41:25 PM

Title: Soundscape Manager
Post by: MrBehemoth on January 05, 2014, 06:41:25 PM
Hi Muties! I made this soundscape manager and thought I would share it. The download link is at the bottom of the post.

What is it for?
Soundscape Manager will generate layered, randomised ambient sound enviromnents (soundscapes) on the fly. For example, lets say you have a cave scene. You can use a soundscape to play randomly placed dripping sounds and rock noises. Other uses could be crowd scenes, cities with traffic, wind, forest sounds, etc.. Use it instead of creating a single looped ambient sound track and it will be less repetitive, more realistic and reduce file size.

What does it do?
The soundscape manager is an entity that you load from your game.script. The soundscapes themselves are defined by text files called something.soundscape. There are 3 channels. Each channel can be either randomised or looped. Randomised channels can have up to 5 sound files. The volume, pan and delay between each channel is randomised based on the values in the text file. You start a soundscape by calling a method from your scene_init.script (or wherever your like). The soundscape will continue playing across scenes (without a gap) until you stop it or change to a different soundscape.

How do I use it?
Copy the contents of the zip into your project folder. You'll now have a soundscapes folder. In there you will find an example soundscape called cave.soundscape and a template.soundscape to help you with making your own. Into this folder goes your sound files such as drips, wind bursts, birds tweeting etc.. There is also a subfolder that contains the Soundscape Manager entity and script.

To load the Soundscape Manager, add this to your game.script:
Code: WME Script
  1. global SoundscapeMgr = Game.LoadEntity("soundscapes\soundscapeMgr\soundscapeMgr.entity");

To start a soundscape or change to a different one, call this method:
Code: WME Script
  1. global SoundscapeMgr;
  2. SoundscapeMgr.ChangeSoundscape("cave");
Where cave is the name of the soundscape file (e.g. cave.soundscape).

What goes in the something.soundscape text file?
Compare the example and the template files. The template.soundscape file looks like this:
Code: [Select]
fade_in_time (ms: time for whole soundscape to fade in when started)
fade_out_time (ms: time for whole soundscape to fade out when stopped/changed)
////////////////////
type (bool: 0=random sounds, 1=single looping sound)
channel_0_sound (filename without path or ext, or "null")
channel_0_sound (filename without path or ext, or "null")
channel_0_sound (filename without path or ext, or "null")
channel_0_sound (filename without path or ext, or "null")
channel_0_sound (filename without path or ext, or "null")
channel_0_min_volume (%: minimum random volume)
channel_0_max_volume (%: maximum random volume)
channel_0_min_delay (ms: minimum length of the random time between sounds)
channel_0_max_delay (ms: maximum length of the random time between sounds)
channel_0_random_pan (bool: 0=centred, 1=randomly panned)
////////////////////
type (bool: 0=random sounds, 1=single looping sound)
channel_1_sound (filename without path or ext, or "null")
channel_1_sound (filename without path or ext, or "null")
channel_1_sound (filename without path or ext, or "null")
channel_1_sound (filename without path or ext, or "null")
channel_1_sound (filename without path or ext, or "null")
channel_1_min_volume (%: minimum random volume)
channel_1_max_volume (%: maximum random volume)
channel_1_min_delay (ms: minimum length of the random time between sounds)
channel_1_max_delay (ms: maximum length of the random time between sounds)
channel_1_random_pan (bool: 0=centred, 1=randomly panned)
////////////////////
type (bool: 0=random sounds, 1=single looping sound)
channel_2_sound (filename without path or ext, or "null")
channel_2_sound (filename without path or ext, or "null")
channel_2_sound (filename without path or ext, or "null")
channel_2_sound (filename without path or ext, or "null")
channel_2_sound (filename without path or ext, or "null")
channel_2_min_volume (%: minimum random volume)
channel_2_max_volume (%: maximum random volume)
channel_2_min_delay (ms: minimum length of the random time between sounds)
channel_2_max_delay (ms: maximum length of the random time between sounds)
channel_2_random_pan (bool: 0=centred, 1=randomly panned)

To make a new soundscape, just edit the template and you should end with something that looks like the "cave.soundscapes" file:
Code: [Select]
2000
2000
////////////////////
0
drip1
drip2
drip3
null
null
10
100
3000
6000
1
////////////////////
0
rockfall1
rockfall2
null
null
null
50
100
5000
15000
1
////////////////////
1
cave_ambience
null
null
null
null
100
100
0
0
0
This soundscape takes 2000ms to fade in or out. In channel 0 there are 3 drip sounds which play at a volume between 10-100% with a random gap of 3000-6000ms between each play. The channel is randomly panned, so each play will be at a different left-right position. Channel 1 is similar. In channel 2 there is a single looped sound that plays continuously at full volume and does not pan.

Notes
Here's the half-baked pseudo license note from the script:
Originally developed for Black Aether by Behemotronic Games. This code is distributed free for non-commercial use. Please feel free to use it in your own projects as long as you let me know so that I can check out what you've done with it. Please don't plagiarise or use it in commercial projects. This is provided "as-is" and has only had minimal testing. I take no responsibility blah blah blah.

Finally, here's the download link: https://www.dropbox.com/s/p8f77eqqh2skc12/soundscapeMgr.zip (https://www.dropbox.com/s/p8f77eqqh2skc12/soundscapeMgr.zip)
And if you just want to try it out, here's a simple test project of Molly in a cave: https://www.dropbox.com/s/k3tf4q1nn4be5kv/SoundscapeMgrTest.zip (https://www.dropbox.com/s/k3tf4q1nn4be5kv/SoundscapeMgrTest.zip)


Obviously, you can do a lot more with this than just make cave sounds. Thanks and have fun! Any questions, just ask.
Title: Re: Soundscape Manager
Post by: Myrm on January 06, 2014, 01:35:28 PM
 Cool, sounds (huhu) useful, thanks!
Title: Re: Soundscape Manager
Post by: metamorphium on January 06, 2014, 07:01:53 PM
Cool thing! I did something along these lines as well. You can watch my talk about it here:

http://www.youtube.com/watch?v=L3K2HkpJSeY
Title: Re: Soundscape Manager
Post by: piere on January 07, 2014, 03:41:12 AM
Thanks for posting, very interesting script, but surly there should be a more simple way to achieve this? Having the sounds defined in a separate file seems a bit awkward.
Title: Re: Soundscape Manager
Post by: MrBehemoth on January 07, 2014, 07:51:12 PM
Thanks everyone for the comments!

@piagent - I see what you mean but I was thinking of re-usability (in multiple projects) and of readability. I originally made a simplified version of this for Bickadoodle, with the intention of re-using it in Black Aether (my "serious" project). The Bickadoodle version is all in one script with the soundscapes defined as properties of objects. That came to 700 lines. Black Aether could potentially have up to 40 different soundscapes, so that script would be a bit unwieldy.

@metamorphium - I will definitely have a look at that vid later, as I am also hoping to implement interactive music too.
Title: Update
Post by: MrBehemoth on January 12, 2014, 03:07:43 PM
12/01/14: Fixed a bug that was causing looped sounds to fade back in after the soundscape was changed, if 2 changes overlapped. Link above updated.


@Metamorphium - I watched your talk. Very interesting! I agree that interactive music is underrated. iMuse was a revolution that never happened - but maybe people are starting to catch on. I was already planning to do something similar to your ideas, but I'm not a musician, so your music objects, moods and pools is awesome but a bit beyond my abilities. :-[  What I did yesterday though is I made another entity, MusicMgr, similar to this one, that uses Spellbreaker's aMuse (http://forum.dead-code.org/index.php?topic=4768 (http://forum.dead-code.org/index.php?topic=4768)) and the Bass library to mix simple loops interactively. It's very basic, but for simple repetitive industrial-esque music (think Silent Hill) it works quite well, especially coupled with the soundscapes. (I kept music and soundscapes separate for simplicity's sake.) Is part 2 of your talk on it's way?
Title: Re: Soundscape Manager
Post by: mihaipuiucernea on September 11, 2017, 06:04:12 PM
Sorry to revive an old topic, but I would like to try the plugin. Anyone still hs it and is willing to upload it? Assuming the plugn creator is ok with it