Last active
November 26, 2016 01:06
-
-
Save cansik/bb40a793766e1da225d25847c4b06164 to your computer and use it in GitHub Desktop.
Revisions
-
cansik revised this gist
Nov 26, 2016 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes. -
cansik renamed this gist
Nov 26, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
cansik revised this gist
Nov 26, 2016 . No changes.There are no files selected for viewing
-
cansik created this gist
Nov 26, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,78 @@ class InfinityAudioPlayer implements AudioListener { private Minim minim; private AudioPlayer player; private int loopStart; private int loopEnd; private boolean stopping = false; public InfinityAudioPlayer(Minim minim) { this.minim = minim; } public boolean isPlaying() { return player.isPlaying(); } public void loadFile(String fileName, int bufferSize) { player = minim.loadFile(fileName, bufferSize); player.addListener(this); setLoop(0, player.length()); } public void setLoop(int start, int end) { loopStart = start; loopEnd = end; } public void play() { player.play(0); } public void stop() { stopping = true; } public void fastStop() { player.pause(); } void update() { if (!player.isPlaying()) return; if (!stopping && player.position() >= loopEnd) player.play(loopStart); if (stopping && player.position() < loopStart) { player.skip(loopEnd); } } public AudioPlayer getPlayer() { return this.player; } synchronized void samples(float[] samp) { update(); } synchronized void samples(float[] sampL, float[] sampR) { update(); } } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ import ddf.minim.*; import ddf.minim.effects.*; Minim minim; InfinityAudioPlayer player; LowPassSP lowPass; float frequency = 0; void setup() { size(500, 100); minim = new Minim(this); player = new InfinityAudioPlayer(minim); player.loadFile("test.wav", 1024); player.setLoop(500, 1500); // lowpass lowPass = new LowPassSP(0, player.getPlayer().sampleRate()); player.getPlayer().addEffect(lowPass); player.play(); } void draw() { background(55); text("Lowpass: " + frequency, 50, 50); } void mouseMoved() { frequency = map(mouseX, 0, width, 0, 14000); lowPass.setFreq(frequency); } void keyPressed() { println("Stopping..."); player.stop(); }