Making the Gamerecent

Making The Game – Teil 13: Das Soundmanagement

audio

The sound design has a large share of the overall impact of games. Thus, the right music and a properly placed sound-effect subconsciously contribute to the current situation. The desired effect is often achieved only through the interaction of images and sound.
 
Besides the host of the application, who has only a accustic appearance, several effects and music parts are played, for example if the correct answer to a question is given.
In order for this sounds to proceed simultaneously, but individually controllable, music, sound effects and speech are played on each separate audio channel. Through the use of channels we also ensure that only one voice file, per channel is played. Without this allocation, it could otherwise lead to a superposition of different effects or spoken sentences, which means that they were no longer evident.
 

  1.  var musicChannel:SoundChannel = new SoundChannel();     // music
  2.  var speakerChannel:SoundChannel = new SoundChannel();   // moderator
  3.  var effectsChannel:SoundChannel = new SoundChannel();   // effects

 
In order to create a varied experience even after several rounds, different variants of the same texts were recorded. So the gam becomese livelier and more realistic than if only a standard text would be repeated constantly.
 

    —– Player selection —–
    * selection between 1, 2 or 3 player *
     
    —– 1st roung —–
    1) How many players do we have today?
    2) Okay, I admit it … I can not count … * sigh * can you just tell me to how many of you want to play this round?
    3) So lets count how many of you want to play one, two, five, dice, three, goat … um … oh just tell me how many players we have today.

 
Shown here is an excerpt from the script of the audio assistant that guides the player through the menu. It shows different versions of how the user will be prompted at the player selection after the first start of the game while selecting the number of players. The corresponding paths of the individual audio files are stored in a separate XML file. Here, the respective related files are grouped into categories.
 
Before a audio is played back from the desired category, it first must be selected. The specially developed function to differentiate the current situation, if the player has previously been at this point in the game or whether he needs an opening statement to the current selection. If this is resolved, the number of possible audio files from the XML file is read and the path of a randomly selected file is returned.
 

  1.  function getPath():String{
  2.     var getFile:String;
  3.     var lngth:int;
  4.     var rnd:int;
  5.    
  6.     if(roundsPlayed == 0){  // if no round has been played
  7.         // get number of audio files
  8.         lngth = basicXMLGeneralAudio.MENUE.PLAYERSELECT.
  9.                 FIRST.ITEM.(@name==“play”).length();
  10.  
  11.         rnd = randomNumber(1,lngth);
  12.  
  13.         // get path of the selected audio file
  14.         getFile = basicXMLGeneralAudio.MENUE.PLAYERSELECT.
  15.             FIRST.ITEM.(@name==“play”)[rnd1];
  16.    
  17.     } else {
  18.         if(playerSelected==1){
  19.         // …
  20.     }
  21.     return getFile;
  22.  }
  23.  

 
The returned path of the audio file is then transferred to the sound management class by calling the callAudio()-function. For the effects and music channel a similar function exists.
 
The function checks in the first step, if a audio file is currently played. If this is the case, the output of the old record is stopped because we assume that the call of the new audio file was triggered from the interaction with the player. So we want to give a instant feedback to its performed action.
Afterwards, the loaded file is played on the corresponding output channel.
 
In addition to the path of the file, the name of a function also can be passed to the callAudio() function. This passed function-name is called automatically after playing the audio file. If needed there can also be a delay set between the end of the audio file and the function call.
 
With this capability, multiple audio files in a row can played without a overlap or a large pause in between.
 

  1.  function callAudio(whoToCall:String, delay:int<=0,
  2.                      whoToCallAfter:String=“voidme”):void{
  3.  
  4.     if(useAudio){
  5.         if(debugMe){ trace(“…play audio: “ + whoToCall); }
  6.        
  7.         if(audioEnabled){
  8.             speakerChannel.stop();
  9.         }
  10.        
  11.         delay = delay;
  12.         var urlString:String = pathAudio + basicLang + “/” + whoToCall;
  13.        
  14.         soundURL = new URLRequest(urlString);
  15.         mySpeaker = new Sound();
  16.         mySpeaker.load(soundURL);
  17.         callMeLater = whoToCallAfter;
  18.        
  19.         speakerChannel = mySpeaker.play(0, 1);
  20.        
  21.         audioEnabled=true;
  22.         if(delay==0){
  23.             speakerChannel.addEventListener(Event.SOUND_COMPLETE,
  24.                                              tutSoundDone);
  25.         } else {
  26.             speakerChannel.addEventListener(Event.SOUND_COMPLETE,
  27.                                              tutSoundDone_withDelay);
  28.         }
  29.        
  30.     } else {
  31.         // no audio is used
  32.         if(debugMe){ trace(“…skip audio”); }
  33.         this[whoToCallAfter]();
  34.         audioEnabled=false;
  35.        
  36.     }
  37.  }
  38.  
  39.  function tutSoundDone(e:<Event){
  40.     audioEnabled=false; this[callMeLater]();
  41.  }
  42.  
  43.  function tutSoundDone_withDelay(e:Event){
  44.     audioEnabled=false;
  45.     delayInterval = setInterval(delayCall, (delay*1000));
  46.  }
  47.  
  48.  function delayCall():void{
  49.     clearInterval(delayInterval);
  50.     this[callMeLater]();  
  51.  }
  52.  
  53.  function voidme():void{ }
  54.  

 
 
 

Upcoming blog entries
Making The Game – Teil 14: Knowledge base and question selection / Working with XML
Making The Game – Part 15: Game stages
Making The Game – Part 16: Mini-Games
Making The Game – Part 17: Evaluation and deployment of the application
Making The Game – Part 18: Concept for school use and outlook

 
 
 

Leave a Reply