Last active
December 8, 2015 21:24
-
-
Save tado/3e478fd114646b960e17 to your computer and use it in GitHub Desktop.
Processing Beads library Granular synthesis
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 beads.*; | |
import java.util.Arrays; | |
AudioContext ac; | |
GranularSamplePlayer player; | |
void setup() { | |
size(800, 600); | |
ac = new AudioContext(); | |
Sample sample = SampleManager.sample(dataPath("Violet.mp3")); | |
player = new GranularSamplePlayer(ac, sample); | |
player.setLoopType(SamplePlayer.LoopType.LOOP_FORWARDS); | |
Gain g = new Gain(ac, 2, 1.0); | |
g.addInput(player); | |
ac.out.addInput(g); | |
ac.start(); | |
} | |
void draw() { | |
background(0); | |
if (player != null) { | |
float rate = map(mouseX, 0, width, 0.0, 3.0); | |
Static rateValue = new Static(ac, rate); | |
player.setRate(rateValue); | |
float speed = map(mouseY, 0, height, 0.0, 3.0); | |
Static speedValue = new Static(ac, speed); | |
player.setPitch(speedValue); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment