Skip to content

Instantly share code, notes, and snippets.

@bakercp
Last active September 21, 2015 04:53
Show Gist options
  • Save bakercp/40500412747ce368b0a8 to your computer and use it in GitHub Desktop.
Save bakercp/40500412747ce368b0a8 to your computer and use it in GitHub Desktop.
Sound Example
ofSoundPlayer dubstep; // From bensound.com
ofSoundPlayer ping; // From bensound.com
ofSoundPlayer pong; // From freesound.org.
ofSoundPlayer laser; // From freesound.org
void setup() {
dubstep.loadSound("bensound-dubstep.mp3");
dubstep.setVolume(0.75f);
dubstep.play();
laser.loadSound("151022__bubaproducer__laser-shot-silenced.wav");
laser.setMultiPlay(true);
ping.loadSound("ping.wav");
ping.setMultiPlay(true);
pong.loadSound("pong.wav");
pong.setMultiPlay(true);
ofBackground(0);
}
void draw() {
// put your main code here, to run once each frame:
ofDrawBitmapString("press buttons 1 - 4", 12, 12);
}
void keyPressed(int key)
{
switch (key)
{
case '1':
if (dubstep.getIsPlaying())
{
dubstep.play();
}
else
{
dubstep.stop();
}
break;
case '2':
ping.play();
break;
case '3':
pong.play();
break;
case '4':
laser.play();
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment