Tuesday, July 9, 2013

Game Audio - Preparing and playing sound


Game Audio Workflow

  1. Make sound effects
    1. Record sound effects
    2. Trim sound effects and export selection
    3. Save into folder named "fx"
  2. Import data into sketch
    1. Copy to sketch's "data" folder
  3. Code the sound triggering function
    1. See code below
    2. Name the AudioPlayers to remind us of the sound
    3. Code up mousePressed() to quickly test the sound
  4. Parameterize the playback to make it dynamic
    1. So that they are not the same sounds every time they are played
    2. See playSound()


AudioPlayer ping1;
AudioPlayer ping2;
AudioPlayer rumble;

void setup() {
  maxim = new Maxim(this);
  ping1 = maxim.loadFile("ping1.wav");
  ping2 = maxim.loadFile("ping2.wav");
  rumble = maxim.loadFile("rumble.wav");
  ping1.setLooping(false);
  ping2.setLooping(false);
  rumble.setLooping(false);
}

void mousePressed() {
  ping1.play();
  ping2.play();
  rumble.play();
}

void playSound(int sound) {
  if (sound == 1){
    ping1.speed(random(0.1, 2));
    ping1.play();
  }
}

No comments:

Post a Comment