mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Removed Sound class, added Engine + Audio Device. No need to start a stream anymore.
This commit is contained in:
@@ -6,7 +6,6 @@ the mean as a float between 0 and 1.
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
SoundFile sample;
|
||||
Amplitude rms;
|
||||
|
||||
@@ -14,10 +13,7 @@ int scale=1;
|
||||
|
||||
public void setup() {
|
||||
size(640,360);
|
||||
|
||||
// Create and start the sound renderer
|
||||
stream = new Sound(this, 44100, 512);
|
||||
|
||||
|
||||
//Load and play a soundfile and loop it
|
||||
sample = new SoundFile(this, "beat.aiff");
|
||||
sample.loop();
|
||||
|
||||
@@ -7,7 +7,6 @@ two times that size) and a float array with the same size.
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
SoundFile sample;
|
||||
FFT fft;
|
||||
|
||||
@@ -19,9 +18,6 @@ public void setup() {
|
||||
size(bands,360);
|
||||
background(255);
|
||||
|
||||
// Create and start the sound renderer
|
||||
stream = new Sound(this, 44100, 256);
|
||||
|
||||
//Load and play a soundfile and loop it. This has to be called
|
||||
// before the FFT is created.
|
||||
sample = new SoundFile(this, "beat.aiff");
|
||||
|
||||
@@ -14,7 +14,6 @@ depending on pre defined time segments.
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
TriOsc triOsc;
|
||||
Env env;
|
||||
|
||||
@@ -37,9 +36,6 @@ void setup() {
|
||||
size(640, 360);
|
||||
background(255);
|
||||
|
||||
//Create and start the Sound renderer
|
||||
stream = new Sound(this);
|
||||
|
||||
// Create triangle wave and start it
|
||||
triOsc = new TriOsc(this);
|
||||
//triOsc.play();
|
||||
|
||||
@@ -7,7 +7,7 @@ Each time a sound is played a colored rect with a random color is displayed.
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
AudioDevice device;
|
||||
SoundFile[] file;
|
||||
|
||||
// Define the number of samples
|
||||
@@ -15,13 +15,12 @@ int numsounds = 5;
|
||||
|
||||
int value[] = {0,0,0};
|
||||
|
||||
|
||||
void setup(){
|
||||
size(640, 360);
|
||||
background(255);
|
||||
|
||||
// Create a Sound renderer and an array of empty soundfiles
|
||||
stream = new Sound(this, 44100, 32);
|
||||
device = new AudioDevice(this, 48000, 32);
|
||||
file = new SoundFile[numsounds];
|
||||
|
||||
// Load 5 soundfiles from a folder in a for loop. By naming the files 1., 2., 3., n.aif it is easy to iterate
|
||||
|
||||
@@ -7,7 +7,6 @@ Each time a sound is played a colored rect with a random color is displayed.
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
SoundFile[] file;
|
||||
|
||||
// Define the number of samples
|
||||
@@ -31,8 +30,7 @@ void setup(){
|
||||
size(640, 360);
|
||||
background(255);
|
||||
|
||||
// Create a Sound renderer and an array of empty soundfiles
|
||||
stream = new Sound(this);
|
||||
// Create an array of empty soundfiles
|
||||
file = new SoundFile[numsounds];
|
||||
|
||||
// Load 5 soundfiles from a folder in a for loop. By naming the files 1., 2., 3., n.aif it is easy to iterate
|
||||
|
||||
@@ -7,7 +7,6 @@ frequency of the oscillator and X the detuning of the oscillator. The basic freq
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
SinOsc[] sineWaves;
|
||||
|
||||
// The number of oscillators
|
||||
@@ -20,9 +19,6 @@ void setup() {
|
||||
size(500, 500);
|
||||
background(255);
|
||||
|
||||
//Create and start the Sound renderer
|
||||
stream = new Sound(this);
|
||||
|
||||
// Create the oscillators and amplitudes
|
||||
sineWaves = new SinOsc[numSines];
|
||||
sineVolume = new float[numSines];
|
||||
|
||||
@@ -7,7 +7,6 @@ two times that size) and a float array with the same size.
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
SoundFile sample;
|
||||
FFT fft;
|
||||
|
||||
@@ -18,14 +17,11 @@ float[] spec = new float[bands];
|
||||
public void setup() {
|
||||
size(bands,360);
|
||||
background(255);
|
||||
|
||||
// Create and start the sound renderer
|
||||
stream = new Sound(this, 44100, 256);
|
||||
|
||||
//Load and play a soundfile and loop it. This has to be called
|
||||
// before the FFT is created.
|
||||
sample = new SoundFile(this, "beat.aiff");
|
||||
sample.play(true);
|
||||
sample.loop();
|
||||
|
||||
// Create and patch the rms tracker
|
||||
fft = new FFT(this);
|
||||
|
||||
@@ -5,7 +5,6 @@ In this example it is started and stopped by clicking into the renderer window.
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
WhiteNoise noise;
|
||||
BPF bandPass;
|
||||
|
||||
@@ -15,8 +14,7 @@ void setup() {
|
||||
size(640,360);
|
||||
background(255);
|
||||
|
||||
// Create and start the sound renderer and the noise generator
|
||||
stream = new Sound(this);
|
||||
// Create the noise generator + Filter
|
||||
noise = new WhiteNoise(this);
|
||||
bandPass = new BPF(this);
|
||||
noise.play(0.5);
|
||||
|
||||
@@ -5,7 +5,6 @@ In this example it is started and stopped by clicking into the renderer window.
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
WhiteNoise noise;
|
||||
HPF highPass;
|
||||
|
||||
@@ -15,8 +14,7 @@ void setup() {
|
||||
size(640,360);
|
||||
background(255);
|
||||
|
||||
// Create and start the sound renderer and the noise generator
|
||||
stream = new Sound(this);
|
||||
// Create the noise generator + filter
|
||||
noise = new WhiteNoise(this);
|
||||
highPass = new HPF(this);
|
||||
noise.play(0.5);
|
||||
|
||||
@@ -5,25 +5,22 @@ In this example it is started and stopped by clicking into the renderer window.
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
WhiteNoise noise;
|
||||
LPF lowPass;
|
||||
|
||||
|
||||
float amp=0.0;
|
||||
|
||||
void setup() {
|
||||
size(640,360);
|
||||
background(255);
|
||||
|
||||
// Create and start the sound renderer and the noise generator
|
||||
stream = new Sound(this);
|
||||
// Create the noise generator + filter
|
||||
noise = new WhiteNoise(this);
|
||||
lowPass = new LPF(this);
|
||||
noise.play(0.5);
|
||||
lowPass.process(noise, 100);
|
||||
lowPass.process(noise, 800);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
lowPass.freq(map(mouseX, 0, 350, 20, 10000));
|
||||
lowPass.freq(map(mouseX, 0, 350, 800, 10000));
|
||||
}
|
||||
|
||||
@@ -4,17 +4,13 @@ This is a sound file player.
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
SoundFile soundfile;
|
||||
Delay delay;
|
||||
|
||||
void setup() {
|
||||
size(640,360);
|
||||
background(255);
|
||||
|
||||
// Create and start the sound renderer
|
||||
stream = new Sound(this);
|
||||
|
||||
|
||||
//Load a soundfile
|
||||
soundfile = new SoundFile(this, "vibraphon.aiff");
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ In this example it is started and stopped by clicking into the renderer window.
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
WhiteNoise noise;
|
||||
|
||||
float amp=0.0;
|
||||
@@ -14,8 +13,7 @@ void setup() {
|
||||
size(640, 360);
|
||||
background(255);
|
||||
|
||||
// Create and start the sound renderer and the noise generator
|
||||
stream = new Sound(this);
|
||||
// Create the noise generator
|
||||
noise = new WhiteNoise(this);
|
||||
noise.play();
|
||||
}
|
||||
|
||||
@@ -7,15 +7,13 @@ If you want to set all of them at the same time use
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
Pulse pulse;
|
||||
|
||||
void setup() {
|
||||
size(640,360);
|
||||
background(255);
|
||||
|
||||
// Create and start the sound renderer and the pulse wave oscillator
|
||||
stream = new Sound(this);
|
||||
// Create and start the pulse wave oscillator
|
||||
pulse = new Pulse(this);
|
||||
pulse.play();
|
||||
}
|
||||
|
||||
@@ -6,17 +6,13 @@ the same time use .set(float freq, float amp, float add, float pan)
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
SawOsc saw;
|
||||
|
||||
void setup() {
|
||||
size(640, 360);
|
||||
background(255);
|
||||
|
||||
// Create and start the sound renderer and the sine oscillator.
|
||||
// Second and Third arguments are optional, default is 44100 / 512
|
||||
// for Sample Rate and Buffer Size
|
||||
stream = new Sound(this, 44100, 256);
|
||||
// Create the sine oscillator.
|
||||
saw = new SawOsc(this);
|
||||
|
||||
//Start the Sine Oscillator. There will be no sound in the beginning
|
||||
|
||||
@@ -6,7 +6,6 @@ the same time use .set(float freq, float amp, float add, float pan)
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
SinOsc sine;
|
||||
|
||||
float freq=400;
|
||||
@@ -17,10 +16,8 @@ void setup() {
|
||||
size(640, 360);
|
||||
background(255);
|
||||
|
||||
// Create and start the sound renderer and the sine oscillator.
|
||||
// Second and Third arguments are optional, default is 44100 / 512
|
||||
// for Sample Rate and Buffer Size
|
||||
stream = new Sound(this, 44100, 256);
|
||||
// Create and start the sine oscillator.
|
||||
|
||||
sine = new SinOsc(this);
|
||||
|
||||
//Start the Sine Oscillator.
|
||||
|
||||
@@ -6,17 +6,14 @@ the same time use .set(float freq, float amp, float add, float pan)
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
SqrOsc sqr;
|
||||
|
||||
void setup() {
|
||||
size(640,360);
|
||||
background(255);
|
||||
|
||||
// Create and start the sound renderer and the sine oscillator.
|
||||
// Second and Third arguments are optional, default is 44100 / 512
|
||||
// for Sample Rate and Buffer Size
|
||||
stream = new Sound(this, 44100, 256);
|
||||
// Create and start the sine oscillator.
|
||||
|
||||
sqr = new SqrOsc(this);
|
||||
|
||||
//Start the Sine Oscillator. There will be no sound in the beginning
|
||||
|
||||
@@ -6,17 +6,14 @@ the same time use .set(float freq, float amp, float add, float pan)
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
TriOsc tri;
|
||||
|
||||
void setup() {
|
||||
size(640,360);
|
||||
background(255);
|
||||
|
||||
// Create and start the sound renderer and the sine oscillator.
|
||||
// Second and Third arguments are optional, default is 44100 / 512
|
||||
// for Sample Rate and Buffer Size
|
||||
stream = new Sound(this, 44100, 256);
|
||||
// Create and start the triangle wave oscillator.
|
||||
|
||||
tri = new TriOsc(this);
|
||||
|
||||
//Start the Sine Oscillator. There will be no sound in the beginning
|
||||
|
||||
@@ -5,16 +5,12 @@ This is a sound file player.
|
||||
|
||||
import processing.sound.*;
|
||||
|
||||
Sound stream;
|
||||
SoundFile soundfile;
|
||||
|
||||
void setup() {
|
||||
size(640,360);
|
||||
background(255);
|
||||
|
||||
// Create and start the sound renderer
|
||||
stream = new Sound(this);
|
||||
|
||||
|
||||
//Load a soundfile
|
||||
soundfile = new SoundFile(this, "vibraphon.aiff");
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@ import processing.core.*;
|
||||
public class Amplitude {
|
||||
|
||||
PApplet parent;
|
||||
private MethClaInterface m_engine;
|
||||
private Engine m_engine;
|
||||
private long ptr;
|
||||
|
||||
public Amplitude(PApplet theParent) {
|
||||
this.parent = theParent;
|
||||
parent.registerMethod("dispose", this);
|
||||
m_engine = new MethClaInterface();
|
||||
m_engine.setPreferences(theParent, 512, 44100);
|
||||
m_engine.start();
|
||||
}
|
||||
|
||||
public void input(SoundObject input){
|
||||
|
||||
+14
-31
@@ -18,47 +18,30 @@
|
||||
* Boston, MA 02111-1307 USA
|
||||
*
|
||||
* @author ##Wilm Thoben##
|
||||
* @modified ##10/23/2013##
|
||||
*
|
||||
*/
|
||||
|
||||
package processing.sound;
|
||||
import processing.core.*;
|
||||
import processing.core.PApplet;
|
||||
|
||||
|
||||
public class AudioDevice {
|
||||
|
||||
public class Sound{
|
||||
|
||||
// myParent is a reference to the parent sketch
|
||||
PApplet parent;
|
||||
MethClaInterface methCla;
|
||||
|
||||
public final static String VERSION = "##library.prettyVersion##";
|
||||
|
||||
public Sound(PApplet parent, int sampleRate, int bufferSize) {
|
||||
this.parent = parent;
|
||||
parent.registerMethod("dispose", this);
|
||||
welcome();
|
||||
methCla = new MethClaInterface();
|
||||
methCla.engineNew(sampleRate, bufferSize);
|
||||
methCla.engineStart();
|
||||
}
|
||||
static int m_test;
|
||||
private Engine m_engine;
|
||||
|
||||
public Sound(PApplet theParent) {
|
||||
this(theParent, 44100, 512);
|
||||
}
|
||||
|
||||
private void welcome() {
|
||||
System.out.println("##library.name## ##library.prettyVersion## by ##author##");
|
||||
}
|
||||
public AudioDevice(PApplet theParent, int sampleRate, int bufferSize) {
|
||||
m_engine.setPreferences(theParent, bufferSize, sampleRate);
|
||||
m_engine.start();
|
||||
}
|
||||
|
||||
public void engineStop() {
|
||||
methCla.engineStop();
|
||||
}
|
||||
|
||||
public static String version() {
|
||||
return VERSION;
|
||||
m_engine.engineStop();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
methCla.engineStop();
|
||||
m_engine.engineStop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import processing.core.PApplet;
|
||||
public class AudioIn {
|
||||
|
||||
PApplet parent;
|
||||
private MethClaInterface m_engine;
|
||||
private Engine m_engine;
|
||||
private int[] m_nodeId = {-1,-1};
|
||||
private float m_freq = 0;
|
||||
private float m_amp = 0;
|
||||
@@ -15,8 +15,9 @@ public class AudioIn {
|
||||
public AudioIn(PApplet theParent) {
|
||||
this.parent = theParent;
|
||||
parent.registerMethod("dispose", this);
|
||||
m_engine = new MethClaInterface();
|
||||
}
|
||||
m_engine.setPreferences(theParent, 512, 44100);
|
||||
m_engine.start();
|
||||
}
|
||||
|
||||
public void play(float freq, float amp, float add, float pos){
|
||||
m_freq=freq; m_amp=amp; m_add=add; m_pos=pos;
|
||||
|
||||
@@ -5,7 +5,7 @@ import processing.core.PApplet;
|
||||
public class BPF implements SoundObject{
|
||||
|
||||
PApplet parent;
|
||||
private MethClaInterface m_engine;
|
||||
private Engine m_engine;
|
||||
private int m_nodeId;
|
||||
private int[] m_m = {0,0};
|
||||
private float m_freq = 100;
|
||||
@@ -14,8 +14,9 @@ public class BPF implements SoundObject{
|
||||
public BPF(PApplet theParent) {
|
||||
this.parent = theParent;
|
||||
parent.registerMethod("dispose", this);
|
||||
m_engine = new MethClaInterface();
|
||||
}
|
||||
m_engine.setPreferences(theParent, 512, 44100);
|
||||
m_engine.start();
|
||||
}
|
||||
|
||||
public void process(SoundObject input, float freq, float res){
|
||||
m_freq=freq; m_res=res;
|
||||
|
||||
@@ -5,7 +5,7 @@ import processing.core.PApplet;
|
||||
public class Delay implements SoundObject{
|
||||
|
||||
PApplet parent;
|
||||
private MethClaInterface m_engine;
|
||||
private Engine m_engine;
|
||||
private int m_nodeId;
|
||||
private int[] m_m = {0,0};
|
||||
private float m_maxDelayTime = 2;
|
||||
@@ -15,8 +15,9 @@ public class Delay implements SoundObject{
|
||||
public Delay(PApplet theParent) {
|
||||
this.parent = theParent;
|
||||
parent.registerMethod("dispose", this);
|
||||
m_engine = new MethClaInterface();
|
||||
}
|
||||
m_engine.setPreferences(theParent, 512, 44100);
|
||||
m_engine.start();
|
||||
}
|
||||
|
||||
public void process(SoundObject input, float maxDelayTime, float delayTime, float feedBack){
|
||||
m_maxDelayTime=maxDelayTime; m_delayTime=delayTime; m_feedBack=feedBack;
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
/**
|
||||
*
|
||||
* Copyright ##copyright## ##author##
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA
|
||||
*
|
||||
* @author ##Wilm Thoben##
|
||||
*
|
||||
*/
|
||||
|
||||
package processing.sound;
|
||||
import processing.core.PApplet;
|
||||
|
||||
public class Engine {
|
||||
|
||||
private static PApplet parent;
|
||||
static MethClaInterface methCla;
|
||||
private static int m_sampleRate=44100;
|
||||
private static int m_bufferSize=512;
|
||||
|
||||
private Engine() {
|
||||
welcome();
|
||||
methCla = new MethClaInterface();
|
||||
methCla.engineNew(m_sampleRate, m_bufferSize);
|
||||
methCla.engineStart();
|
||||
}
|
||||
|
||||
private static class LazyHolder {
|
||||
private static final Engine INSTANCE = new Engine();
|
||||
}
|
||||
|
||||
public static Engine start() {
|
||||
return LazyHolder.INSTANCE;
|
||||
}
|
||||
|
||||
public static void setPreferences(PApplet theParent, int bufferSize, int sampleRate){
|
||||
parent = theParent;
|
||||
m_bufferSize = bufferSize;
|
||||
m_sampleRate = sampleRate;
|
||||
}
|
||||
|
||||
// general Synth methods
|
||||
public static void synthStop(int[] nodeId){
|
||||
methCla.synthStop(nodeId);
|
||||
}
|
||||
|
||||
// general Oscillator methods
|
||||
|
||||
public static void oscSet(float freq, float amp, float add, float pos, int[] nodeId){
|
||||
methCla.oscSet(freq, amp, add, pos, nodeId);
|
||||
};
|
||||
|
||||
// Sine Wave Oscillator
|
||||
|
||||
public static int[] sinePlay(float freq, float amp, float add, float pos){
|
||||
return methCla.sinePlay(freq, amp, add, pos);
|
||||
};
|
||||
|
||||
//Saw Wave Oscillator
|
||||
|
||||
public static int[] sawPlay(float freq, float amp, float add, float pos){
|
||||
return methCla.sawPlay(freq, amp, add, pos);
|
||||
};
|
||||
|
||||
//Square Wave Oscillator
|
||||
|
||||
public static int[] sqrPlay(float freq, float amp, float add, float pos){
|
||||
return methCla.sqrPlay(freq, amp, add, pos);
|
||||
};
|
||||
|
||||
public static void sqrSet(float freq, float amp, float add, float pos, int[] nodeId){
|
||||
methCla.sqrSet(freq, amp, add, pos, nodeId);
|
||||
};
|
||||
|
||||
// Triangle Wave Oscillator
|
||||
|
||||
public static int[] triPlay(float freq, float amp, float add, float pos){
|
||||
return methCla.triPlay(freq, amp, add, pos);
|
||||
};
|
||||
|
||||
public static int[] pulsePlay(float freq, float width, float amp, float add, float pos){
|
||||
return methCla.pulsePlay(freq, width, amp, add, pos);
|
||||
};
|
||||
|
||||
public static void pulseSet(float freq, float width, float amp, float add, float pos, int[] nodeId){
|
||||
methCla.pulseSet(freq, width, amp, add, pos, nodeId);
|
||||
};
|
||||
|
||||
// SoundFile
|
||||
|
||||
public static int[] soundFileInfo(String path){
|
||||
return methCla.soundFileInfo(path);
|
||||
};
|
||||
|
||||
public static int[] soundFilePlayMono(float rate, float pos, float amp, float add, boolean loop, String path, float dur, int cue){
|
||||
return soundFilePlayMono(rate, pos, amp, add, loop, path, dur, cue);
|
||||
};
|
||||
|
||||
public static int[] soundFilePlayMulti(float rate, float amp, float add, boolean loop, String path, float dur, int cue){
|
||||
return methCla.soundFilePlayMulti(rate, amp, add, loop, path, dur, cue);
|
||||
};
|
||||
|
||||
public static void soundFileSetMono(float rate, float pos, float amp, float add, int[] nodeId){
|
||||
methCla.soundFileSetMono(rate, pos, amp, add, nodeId);
|
||||
};
|
||||
|
||||
public static void soundFileSetStereo(float rate, float amp, float add, int[] nodeId){
|
||||
methCla.soundFileSetStereo(rate, amp, add, nodeId);
|
||||
};
|
||||
|
||||
// Noise
|
||||
|
||||
public static int[] whiteNoisePlay(float amp, float add, float pos){
|
||||
return methCla.whiteNoisePlay(amp, add, pos);
|
||||
};
|
||||
|
||||
public static void whiteNoiseSet(float amp, float add, float pos, int[] nodeId){
|
||||
methCla.whiteNoiseSet(amp, add, pos, nodeId);
|
||||
};
|
||||
|
||||
// Envelope
|
||||
|
||||
public static int envelopePlay(int[] input, float attackTime, float sustainTime, float sustainLevel, float releaseTime){
|
||||
return methCla.envelopePlay(input, attackTime, sustainTime, sustainLevel, releaseTime);
|
||||
};
|
||||
|
||||
public static int doneAfter(float seconds){
|
||||
return methCla.doneAfter(seconds);
|
||||
};
|
||||
|
||||
// Filters
|
||||
|
||||
public static int highPassPlay(int[] input, float freq, float res){
|
||||
return methCla.highPassPlay(input, freq, res);
|
||||
};
|
||||
|
||||
public static int lowPassPlay(int[] input, float freq, float res){
|
||||
return methCla.lowPassPlay(input, freq, res);
|
||||
};
|
||||
|
||||
public static int bandPassPlay(int[] input, float freq, float res){
|
||||
return methCla.bandPassPlay(input, freq, res);
|
||||
};
|
||||
|
||||
public static void filterSet(float freq, float res, int nodeId){
|
||||
methCla.filterSet(freq, res, nodeId);
|
||||
};
|
||||
|
||||
// Delay
|
||||
|
||||
public static int delayPlay(int[] input, float maxDelayTime, float delayTime, float feedBack){
|
||||
return methCla.delayPlay(input, maxDelayTime, delayTime, feedBack);
|
||||
};
|
||||
|
||||
public static void delaySet(float delayTime, float feedBack, int nodeId){
|
||||
methCla.delaySet(delayTime, feedBack, nodeId);
|
||||
};
|
||||
|
||||
// Amplitude Follower
|
||||
|
||||
public static long amplitude(int[] nodeId){
|
||||
return methCla.amplitude(nodeId);
|
||||
};
|
||||
|
||||
public static float poll_amplitude(long ptr){
|
||||
return methCla.poll_amplitude(ptr);
|
||||
};
|
||||
|
||||
public static void destroy_amplitude(long ptr){
|
||||
methCla.destroy_amplitude(ptr);
|
||||
};
|
||||
|
||||
// FFT
|
||||
|
||||
public static long fft(int[] nodeId, int fftSize){
|
||||
return methCla.fft(nodeId, fftSize);
|
||||
};
|
||||
|
||||
public static float[] poll_fft(long ptr){
|
||||
return methCla.poll_fft(ptr);
|
||||
};
|
||||
|
||||
public static void destroy_fft(long ptr){
|
||||
methCla.destroy_fft(ptr);
|
||||
};
|
||||
|
||||
public static void engineStop() {
|
||||
methCla.engineStop();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
methCla.engineStop();
|
||||
}
|
||||
|
||||
private void welcome() {
|
||||
System.out.println("processing.sound v.09 by Wilm Thoben");
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,15 @@ import processing.core.*;
|
||||
public class Env {
|
||||
|
||||
PApplet parent;
|
||||
MethClaInterface m_engine;
|
||||
private Engine m_engine;
|
||||
int m_nodeId;
|
||||
|
||||
public Env (PApplet theParent) {
|
||||
this.parent = theParent;
|
||||
parent.registerMethod("dispose", this);
|
||||
m_engine = new MethClaInterface();
|
||||
}
|
||||
m_engine.setPreferences(theParent, 512, 44100);
|
||||
m_engine.start();
|
||||
}
|
||||
|
||||
public void play(SoundObject input, float attackTime, float sustainTime, float sustainLevel, float releaseTime){
|
||||
m_nodeId = m_engine.envelopePlay(input.returnId(), attackTime, sustainTime, sustainLevel, releaseTime);
|
||||
|
||||
@@ -4,14 +4,15 @@ import processing.core.*;
|
||||
public class FFT {
|
||||
|
||||
PApplet parent;
|
||||
private MethClaInterface m_engine;
|
||||
private Engine m_engine;
|
||||
private long ptr;
|
||||
|
||||
public FFT(PApplet theParent) {
|
||||
this.parent = theParent;
|
||||
parent.registerMethod("dispose", this);
|
||||
m_engine = new MethClaInterface();
|
||||
}
|
||||
m_engine.setPreferences(theParent, 512, 44100);
|
||||
m_engine.start();
|
||||
}
|
||||
|
||||
public void input(SoundObject input, int fftSize){
|
||||
ptr = m_engine.fft(input.returnId(), fftSize);
|
||||
|
||||
@@ -5,7 +5,7 @@ import processing.core.PApplet;
|
||||
public class HPF implements SoundObject{
|
||||
|
||||
PApplet parent;
|
||||
private MethClaInterface m_engine;
|
||||
private Engine m_engine;
|
||||
private int m_nodeId;
|
||||
private int[] m_m = {0,0};
|
||||
private float m_freq = 100;
|
||||
@@ -14,8 +14,9 @@ public class HPF implements SoundObject{
|
||||
public HPF(PApplet theParent) {
|
||||
this.parent = theParent;
|
||||
parent.registerMethod("dispose", this);
|
||||
m_engine = new MethClaInterface();
|
||||
}
|
||||
m_engine.setPreferences(theParent, 512, 44100);
|
||||
m_engine.start();
|
||||
}
|
||||
|
||||
public void process(SoundObject input, float freq, float res){
|
||||
m_freq=freq; m_res=res;
|
||||
|
||||
@@ -5,7 +5,7 @@ import processing.core.PApplet;
|
||||
public class LPF implements SoundObject{
|
||||
|
||||
PApplet parent;
|
||||
private MethClaInterface m_engine;
|
||||
private Engine m_engine;
|
||||
private int m_nodeId;
|
||||
private int[] m_m = {0,0};
|
||||
private float m_freq = 100;
|
||||
@@ -14,8 +14,9 @@ public class LPF implements SoundObject{
|
||||
public LPF(PApplet theParent) {
|
||||
this.parent = theParent;
|
||||
parent.registerMethod("dispose", this);
|
||||
m_engine = new MethClaInterface();
|
||||
}
|
||||
m_engine.setPreferences(theParent, 512, 44100);
|
||||
m_engine.start();
|
||||
}
|
||||
|
||||
public void process(SoundObject input, float freq, float res){
|
||||
m_freq=freq; m_res=res;
|
||||
|
||||
@@ -5,7 +5,7 @@ import processing.core.PApplet;
|
||||
public class Pulse implements SoundObject {
|
||||
|
||||
PApplet parent;
|
||||
MethClaInterface m_engine;
|
||||
private Engine m_engine;
|
||||
private int[] m_nodeId = {-1,-1};
|
||||
private float m_freq = 440;
|
||||
private float m_width = 0.5f;
|
||||
@@ -16,8 +16,9 @@ public class Pulse implements SoundObject {
|
||||
public Pulse(PApplet theParent) {
|
||||
this.parent = theParent;
|
||||
parent.registerMethod("dispose", this);
|
||||
m_engine = new MethClaInterface();
|
||||
}
|
||||
m_engine.setPreferences(theParent, 512, 44100);
|
||||
m_engine.start();
|
||||
}
|
||||
|
||||
public void play(){
|
||||
m_nodeId = m_engine.pulsePlay(m_freq, m_width, m_amp, m_add, m_pos);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package processing.sound;
|
||||
|
||||
import processing.core.PApplet;
|
||||
import processing.core.*;
|
||||
|
||||
public class SawOsc implements Oscillator{
|
||||
|
||||
PApplet parent;
|
||||
private MethClaInterface m_engine;
|
||||
private Engine m_engine;
|
||||
private int[] m_nodeId = {-1,-1};
|
||||
private float m_freq = 440;
|
||||
private float m_amp = 0.5f;
|
||||
@@ -15,7 +14,8 @@ public class SawOsc implements Oscillator{
|
||||
public SawOsc(PApplet theParent) {
|
||||
this.parent = theParent;
|
||||
parent.registerMethod("dispose", this);
|
||||
m_engine = new MethClaInterface();
|
||||
m_engine.setPreferences(theParent, 512, 44100);
|
||||
m_engine.start();
|
||||
}
|
||||
|
||||
public void play(float freq, float amp, float add, float pos){
|
||||
|
||||
@@ -4,7 +4,7 @@ import processing.core.*;
|
||||
public class SinOsc implements Oscillator {
|
||||
|
||||
PApplet parent;
|
||||
private MethClaInterface m_engine;
|
||||
private Engine m_engine;
|
||||
private int[] m_nodeId = {-1,-1};
|
||||
private float m_freq = 440;
|
||||
private float m_amp = 0.5f;
|
||||
@@ -14,7 +14,8 @@ public class SinOsc implements Oscillator {
|
||||
public SinOsc(PApplet theParent) {
|
||||
this.parent = theParent;
|
||||
parent.registerMethod("dispose", this);
|
||||
m_engine = new MethClaInterface();
|
||||
m_engine.setPreferences(theParent, 512, 44100);
|
||||
m_engine.start();
|
||||
}
|
||||
|
||||
public void play(float freq, float amp, float add, float pos){
|
||||
|
||||
@@ -4,7 +4,8 @@ import processing.core.*;
|
||||
public class SoundFile implements SoundObject {
|
||||
|
||||
PApplet parent;
|
||||
MethClaInterface m_engine;
|
||||
private Engine m_engine;
|
||||
private MethClaInterface methCla;
|
||||
private int[] m_nodeId = {-1,-1};
|
||||
int[] m_info;
|
||||
String m_filePath;
|
||||
@@ -18,8 +19,9 @@ public class SoundFile implements SoundObject {
|
||||
public SoundFile(PApplet theParent, String path) {
|
||||
this.parent = theParent;
|
||||
parent.registerMethod("dispose", this);
|
||||
|
||||
m_engine = new MethClaInterface();
|
||||
m_engine.setPreferences(theParent, 512, 44100);
|
||||
m_engine.start();
|
||||
methCla = new MethClaInterface();
|
||||
m_filePath=theParent.dataPath(path);
|
||||
m_info = m_engine.soundFileInfo(m_filePath);
|
||||
}
|
||||
@@ -41,11 +43,11 @@ public class SoundFile implements SoundObject {
|
||||
}
|
||||
|
||||
public void play(){
|
||||
if(this.channels() < 2){
|
||||
m_nodeId = m_engine.soundFilePlayMono(m_rate, m_pos, m_amp, m_add, false, m_filePath, this.duration()*(1/m_rate), m_cue);
|
||||
if(this.channels() == 1){
|
||||
m_nodeId = methCla.soundFilePlayMono(m_rate, m_pos, m_amp, m_add, false, m_filePath, this.duration()*(1/m_rate), m_cue);
|
||||
}
|
||||
else if(this.channels() == 2){
|
||||
m_nodeId = m_engine.soundFilePlayMulti(m_rate, m_amp, m_add, false, m_filePath, this.duration()*(1/m_rate), m_cue);
|
||||
m_nodeId = methCla.soundFilePlayMulti(m_rate, m_amp, m_add, false, m_filePath, this.duration()*(1/m_rate), m_cue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,10 +78,10 @@ public class SoundFile implements SoundObject {
|
||||
|
||||
public void loop(){
|
||||
if(this.channels() < 2){
|
||||
m_nodeId = m_engine.soundFilePlayMono(m_rate, m_pos, m_amp, m_add, true, m_filePath, this.duration()*(1/m_rate), m_cue);
|
||||
m_nodeId = methCla.soundFilePlayMono(m_rate, m_pos, m_amp, m_add, true, m_filePath, this.duration()*(1/m_rate), m_cue);
|
||||
}
|
||||
else if(this.channels() == 2){
|
||||
m_nodeId = m_engine.soundFilePlayMulti(m_rate, m_amp, m_add, true, m_filePath, this.duration()*(1/m_rate), m_cue);
|
||||
m_nodeId = methCla.soundFilePlayMulti(m_rate, m_amp, m_add, true, m_filePath, this.duration()*(1/m_rate), m_cue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import processing.core.PApplet;
|
||||
public class SqrOsc implements SoundObject {
|
||||
|
||||
PApplet parent;
|
||||
MethClaInterface m_engine;
|
||||
private Engine m_engine;
|
||||
private int[] m_nodeId = {-1,-1};
|
||||
private float m_freq = 440;
|
||||
private float m_amp = 0.5f;
|
||||
@@ -15,7 +15,8 @@ public class SqrOsc implements SoundObject {
|
||||
public SqrOsc(PApplet theParent) {
|
||||
this.parent = theParent;
|
||||
parent.registerMethod("dispose", this);
|
||||
m_engine = new MethClaInterface();
|
||||
m_engine.setPreferences(theParent, 512, 44100);
|
||||
m_engine.start();
|
||||
}
|
||||
|
||||
public void play(){
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package processing.sound;
|
||||
|
||||
import processing.core.PApplet;
|
||||
|
||||
public class TriOsc implements Oscillator{
|
||||
|
||||
PApplet parent;
|
||||
private MethClaInterface m_engine;
|
||||
private Engine m_engine;
|
||||
private int[] m_nodeId = {-1,-1};
|
||||
private float m_freq = 440;
|
||||
private float m_amp = 0.5f;
|
||||
@@ -15,7 +14,8 @@ public class TriOsc implements Oscillator{
|
||||
public TriOsc(PApplet theParent) {
|
||||
this.parent = theParent;
|
||||
parent.registerMethod("dispose", this);
|
||||
m_engine = new MethClaInterface();
|
||||
m_engine.setPreferences(theParent, 512, 44100);
|
||||
m_engine.start();
|
||||
}
|
||||
|
||||
public void play(float freq, float amp, float add, float pos){
|
||||
|
||||
@@ -4,7 +4,7 @@ import processing.core.*;
|
||||
public class WhiteNoise implements SoundObject{
|
||||
|
||||
PApplet parent;
|
||||
private MethClaInterface m_engine;
|
||||
private Engine m_engine;
|
||||
private int[] m_nodeId = {-1,-1};
|
||||
private float m_amp=0.5f;
|
||||
private float m_add=0;
|
||||
@@ -13,7 +13,8 @@ public class WhiteNoise implements SoundObject{
|
||||
public WhiteNoise(PApplet theParent) {
|
||||
this.parent = theParent;
|
||||
parent.registerMethod("dispose", this);
|
||||
m_engine = new MethClaInterface();
|
||||
m_engine.setPreferences(theParent, 512, 44100);
|
||||
m_engine.start();
|
||||
}
|
||||
|
||||
public void play(){
|
||||
|
||||
Reference in New Issue
Block a user