Game Audio Workflow
- Make sound effects
- Record sound effects
- Trim sound effects and export selection
- Save into folder named "fx"
- Import data into sketch
- Copy to sketch's "data" folder
- Code the sound triggering function
- See code below
- Name the AudioPlayers to remind us of the sound
- Code up mousePressed() to quickly test the sound
- Parameterize the playback to make it dynamic
- So that they are not the same sounds every time they are played
- 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