You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
587 B

import processing.sound.*;
Pulse pulse;
void setup() {
size(640, 360);
background(255);
// Create and start the pulse wave oscillator
pulse = new Pulse(this);
// pulse waves can appear very loud to the human ear, so make it a bit more quiet
pulse.amp(0.3);
pulse.play();
}
void draw() {
// Map mouseX from 20Hz to 500Hz for frequency
float frequency = map(mouseX, 0, width, 1.0, 100.0);
pulse.freq(frequency);
// Map mouseY from 0.0 to 1.0 for the relative width of the pulse.
float pulseWidth = map(mouseY, 0, height, 0.0, 1.0);
pulse.width(pulseWidth);
}