Skip to content

Commit 61ce2bf

Browse files
committed
added start() play() for AudioIn
1 parent c25bc08 commit 61ce2bf

File tree

8 files changed

+79
-40
lines changed

8 files changed

+79
-40
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
*.o
33
*.DS_Store
44
*.class
5+
*./bin
6+

examples/IO/AudioInput/AudioInput.pde

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void setup() {
1919
input = new AudioIn(this, 0);
2020

2121
// start the Audio Input
22-
input.play();
22+
input.start();
2323

2424
// create a new Amplitude analyzer
2525
rms = new Amplitude(this);
@@ -44,3 +44,4 @@ void draw() {
4444
// We draw an ellispe coupled to the audio analysis
4545
ellipse(width/2, height/2, 1*scale, 1*scale);
4646
}
47+
248 Bytes
Binary file not shown.

src/cpp/include/processing_sound_MethClaInterface.h

Lines changed: 18 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cpp/processing_sound_MethClaInterface.cpp

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -465,49 +465,59 @@ JNIEXPORT void JNICALL Java_processing_sound_MethClaInterface_pulseSet(JNIEnv *e
465465
env->ReleaseIntArrayElements(nodeId, m_nodeId, 0);
466466
};
467467

468-
JNIEXPORT jintArray JNICALL Java_processing_sound_MethClaInterface_audioInPlay(JNIEnv *env, jobject object, jfloat amp, jfloat add, jfloat pos, jint in){
469-
468+
JNIEXPORT jintArray JNICALL Java_processing_sound_MethClaInterface_audioInStart(JNIEnv *env , jobject object, jfloat amp, jfloat add, jfloat pos, jint in){
469+
470470
jintArray nodeId = env->NewIntArray(2);
471471
jint *m_nodeId = env->GetIntArrayElements(nodeId, NULL);
472-
472+
473473
Methcla::AudioBusId bus = m_engine->audioBusId().alloc();
474-
474+
475475
Methcla::Request request(engine());
476476
request.openBundle(Methcla::immediately);
477477

478478
auto synth = request.synth(
479-
METHCLA_PLUGINS_AUDIOIN_URI,
480-
engine().root(),
481-
{amp, add, pos}
482-
);
483-
479+
METHCLA_PLUGINS_AUDIOIN_URI,
480+
engine().root(),
481+
{amp, add, pos}
482+
);
483+
484484
auto pan = request.synth(
485-
METHCLA_PLUGINS_PAN2_URI,
486-
engine().root(),
487-
{pos, 1.f},
488-
{Methcla::Value(1.f)}
489-
);
490-
491-
request.mapInput(synth.id(), 0, Methcla::AudioBusId(in), Methcla::kBusMappingExternal);
492-
request.mapOutput(synth.id(), 0, bus);
493-
request.mapInput(pan.id(), 0, bus);
485+
METHCLA_PLUGINS_PAN2_URI,
486+
engine().root(),
487+
{pos, 1.f},
488+
{Methcla::Value(1.f)}
489+
);
494490

495-
request.mapOutput(pan.id(), 0, Methcla::AudioBusId(0), Methcla::kBusMappingExternal);
496-
request.mapOutput(pan.id(), 1, Methcla::AudioBusId(1), Methcla::kBusMappingExternal);
491+
request.mapInput(synth.id(), 0, Methcla::AudioBusId(in), Methcla::kBusMappingExternal);
492+
request.mapOutput(synth.id(), 0, bus);
493+
request.mapInput(pan.id(), 0, bus);
497494

498-
499495
request.activate(synth.id());
500496
request.activate(pan.id());
501-
497+
502498
request.closeBundle();
503499
request.send();
504-
500+
505501
m_nodeId[0]=synth.id();
506502
m_nodeId[1]= pan.id();
507-
503+
508504
env->ReleaseIntArrayElements(nodeId, m_nodeId, 0);
509-
505+
510506
return nodeId;
507+
508+
};
509+
510+
JNIEXPORT void JNICALL Java_processing_sound_MethClaInterface_audioInPlay(JNIEnv *env, jobject object, jint nodeId){
511+
512+
Methcla::Request request(engine());
513+
request.openBundle(Methcla::immediately);
514+
515+
request.mapOutput(nodeId, 0, Methcla::AudioBusId(0), Methcla::kBusMappingExternal);
516+
request.mapOutput(nodeId, 1, Methcla::AudioBusId(1), Methcla::kBusMappingExternal);
517+
518+
request.closeBundle();
519+
request.send();
520+
511521
};
512522

513523
JNIEXPORT void JNICALL Java_processing_sound_MethClaInterface_audioInSet(JNIEnv *env, jobject object, jfloat amp, jfloat add, jfloat pos, jintArray nodeId){

src/processing/sound/AudioIn.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,27 @@ public AudioIn (PApplet theParent, int in) {
2020
m_in = in;
2121
}
2222

23-
public void play(){
24-
m_nodeId = m_engine.audioInPlay(m_amp, m_add, m_pos, m_in);
23+
public void start(){
24+
m_nodeId = m_engine.audioInStart(m_amp, m_add, m_pos, m_in);
2525
}
26-
27-
public void play(float amp, float add, float pos){
26+
27+
public void start(float amp, float add, float pos){
2828
m_amp=amp; m_add=add; m_pos=pos;
29-
this.play();
29+
this.start();
3030
}
3131

32-
public void play(float amp, float add){
32+
public void start(float amp, float add){
3333
m_amp=amp; m_add=add;
34-
this.play();
34+
this.start();
3535
}
3636

37-
public void play(float amp){
37+
public void start(float amp){
3838
m_amp=amp;
39-
this.play();
39+
this.start();
40+
}
41+
42+
public void play(){
43+
m_engine.audioInPlay(m_nodeId[1]);
4044
}
4145

4246
private void set(){

src/processing/sound/Engine.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,12 @@ public static void pulseSet(float freq, float width, float amp, float add, float
105105

106106
// AudioIn
107107

108-
public static int[] audioInPlay(float amp, float add, float pos, int in){
109-
return methCla.audioInPlay(amp, add, pos, in);
108+
public static int[] audioInStart(float amp, float add, float pos, int in){
109+
return methCla.audioInStart(amp, add, pos, in);
110+
};
111+
112+
public static void audioInPlay(int nodeId){
113+
methCla.audioInPlay(nodeId);
110114
};
111115

112116
public static void audioInSet(float amp, float add, float pos, int[] nodeId){

src/processing/sound/MethClaInterface.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ else if (osName.equals("Linux")){
8080

8181
// Audio In
8282

83-
public native int[] audioInPlay(float amp, float add, float pos, int in);
83+
public native int[] audioInStart(float amp, float add, float pos, int in);
84+
85+
public native void audioInPlay(int nodeId);
8486

8587
public native void audioInSet(float amp, float add, float pos, int[] nodeId);
8688

0 commit comments

Comments
 (0)