-
-
Save pstoica/11362245 to your computer and use it in GitHub Desktop.
This file contains 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
import arb.soundcipher.*; | |
SoundCipher midi = new SoundCipher(this); | |
int beat; | |
//float[] pitches = {60, 64, 66, 67, 62, 71, 69, 61, 65, 63, 68, 70}; | |
void setup() { | |
//frameRate(2); | |
beat = 0; | |
} | |
void draw() { | |
frameRate(random(.5, 10)); | |
if (beat == 0) { | |
float pitches[] = newPitches(); | |
println(pitches); | |
} | |
midi.playNote(pitches[beat], random(50, 100), random(.25, 2)); | |
beat = (beat + 1) % pitches.length; // mod so it goes back to 0 after passing 11 | |
} | |
float[] newPitches() { | |
switch(floor(random(0, 4))) { | |
case 0: | |
float[] pitches = {60, 64, 66, 67, 62, 71, 69, 61, 65, 63, 68, 70}; | |
break; | |
case 1: | |
float[] pitches = {68, 60, 62, 63, 70, 67, 65, 69, 61, 71, 64, 66}; | |
break; | |
case 2: | |
float[] pitches = {66, 70, 60, 61, 68, 65, 63, 67, 71, 69, 62, 64}; | |
break; | |
case 3: | |
float[] pitches = {65, 69, 71, 60, 67, 64, 62, 66, 70, 68, 61, 63}; | |
break; | |
case 4: | |
float[] pitches = {70, 62, 64, 65, 60, 69, 67, 71, 63, 61, 66, 68}; | |
break; | |
} | |
return pitches; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment