Created
April 14, 2020 21:41
-
-
Save slambert/11bb425def11abdd29370d8faa220aae to your computer and use it in GitHub Desktop.
Computersounds
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
import processing.sound.*; | |
/* | |
The Computer Is Working Sounds | |
Now with cool black and white graphics | |
Steve Lambert December 1, 2015 | |
*/ | |
// initializing variables | |
int freq_ = 440; // sound frequency/pitch | |
int interval; // how often the sound changes | |
SinOsc sine; // sine | |
void setup() { | |
size(300,300); | |
smooth(); | |
noStroke(); | |
// sine wave stuff | |
sine = new SinOsc(this); | |
sine.play(); | |
} // end setup | |
void draw() { | |
int xPos = 0; | |
int yPos = 0; | |
//println(interval); | |
sine.freq(freq_); // this sets the frequency of the wave | |
// we want to the change the frequency, but not on every | |
// cycle of the draw loop, so we're using modulo to have | |
// happen every 8th (or whatever you like) time. | |
if (interval % 8 == 0) { | |
freq_ = round(random(80,2500)); | |
for (int i_ = 0; i_ < 5; i_ = i_+1){ | |
for (int i = 0; i < 5; i = i+1) { | |
rect(xPos+(i*width/5),yPos,width/5,height/5); | |
//fill(random(0,255),random(0,255),random(0,255)); | |
fill(random(0,255)); | |
} | |
yPos = yPos+(height/5); | |
println(i_); | |
println(yPos); | |
} | |
} | |
interval = interval+ 1; // count each loop! | |
} // end draw |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment