
We've got GUI, we've got 3D objects... now the next step: Sound!. Adding sounds and music is very simple with SDE. First you have to understand that there will be two types of sounds: streaming and FX. By streaming sounds I mean basically music. SDE can load every file your OS can load. First you have to setup a tracklist (just like in every media player):
SDE.Sound.Manager sMan = SDE.Engine.Instance.SoundManager;
string[] playList = new string[]{"../../../Bin/Media/Cubes/music.wma"};
sMan.Music.LoadPlayList(playList);
sMan.Music.Play();
Then just hit Play and we're gone. There are properties to change the volume, activate shuffle or repeat and other things. Usually music files are much bigger than FX files. So they use streaming techniques to load into memory. On the other hand, sound FX are very small so they are fully loaded into memory. Sound FX are 3D, so they are a bit more complicated to understand than music. We've got a Listener object (only one, and you can't create more) that object will be your 'ears'. Then we can have several Emitters, which emmit the sound in 3D space. They're usually mono (if you need stereo, just add two emitters, one per channel). Let's add an emitter:
SDE.Sound.Emitter emitter = sMan.CreateEmitter("../../../Bin/Media/Cubes/hit.wav");
Now, if you change the position this way, the sound will be on the right speaker (Listener is on (0,0,0) by default):
emitter.Position = new Vector3(10,0,0);
emitter.Repeat = true;
emitter.Volume = 120;
You can also change the frequency, make it loop, modify the volume and other things. Finally use Play to start the sound (remember that there's also a Stop command):
emitter.Play();
You know what else can you do? Add effects to you sound. Effects like Reverb or Echo. They're similar like materials in 3D objects so you can have one Effect named 'Cave' and use it with different emitters.
SDE.Sound.Effect effect = sMan.CreateEffect("cave");
effect.ReverbEnabled = true;
emitter.Effect = effect;