Created
November 25, 2015 16:33
-
-
Save slambert/a6d4e100b1bc66698877 to your computer and use it in GitHub Desktop.
Changes speed of a sound file up to 3 times forward or backward
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Changes speed of a sound file up to 3 times forward or backward | |
use with an analog input. | |
Remember to add youw own sound file | |
Reconfigure to use whatever analog input you like | |
Steve Lambert November 24, 2015 | |
*/ | |
// Variables | |
float knobPos = 500; | |
// Sound stuff | |
import processing.sound.*; | |
SoundFile hitit; | |
void setup() { | |
size(200, 200); | |
background(255); | |
// Load a soundfile from the data folder of the sketch and play it back in a loop | |
// CHANGE THE NAME OF THIS SOUND FILE TO SOMETHING YOU PUT IN THE DATA FOLDER // | |
hitit = new SoundFile(this, "hitit.wav"); | |
} | |
void draw() { | |
knobPos = constrain(knobPos, 0, 1000); | |
} | |
void keyPressed() { | |
if (key == '1'){ | |
hitit.play(); | |
hitit.amp(1.5); | |
} //end if 1 | |
} // end keyPressed | |
void mouseWheel(MouseEvent event) { | |
float e = event.getCount(); | |
float speed = map(knobPos,0,1000,-3,3); | |
knobPos = knobPos - e; | |
//println("knobPos: " + knobPos + " e: " + e); | |
println("speed: " + speed); | |
hitit.rate(speed); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment