1919#include " methcla/plugins/sampler.h"
2020#include " methcla/plugins/whitenoise.h"
2121#include " methcla/plugins/pinknoise.h"
22+ #include " methcla/plugins/brownnoise.h"
2223#include " methcla/plugins/node-control.h"
2324#include " methcla/plugins/pan2.h"
2425#include " methcla/plugins/soundfile_api_mpg123.h"
3233#define OUTPUT_BUFFER_SIZE 1024
3334#define SNDF_BUFFER_LEN 1024
3435
35- #define MAX_CHANNELS 2
36+ #define MAX_CHANNELS 4
3637
3738Methcla::Engine* m_engine;
3839Methcla::Engine& engine () { return *m_engine; }
@@ -58,6 +59,7 @@ JNIEXPORT jint JNICALL Java_processing_sound_MethClaInterface_engineNew (JNIEnv
5859
5960 Methcla::EngineOptions options;
6061 options.audioDriver .bufferSize = bufferSize;
62+ options.audioDriver .numInputs = 2 ;
6163 options.realtimeMemorySize = 1024 * 1024 * 20 ;
6264 options.maxNumNodes = 1024 * 20 ;
6365 options.addLibrary (methcla_plugins_sine)
@@ -68,7 +70,8 @@ JNIEXPORT jint JNICALL Java_processing_sound_MethClaInterface_engineNew (JNIEnv
6870 .addLibrary (methcla_plugins_patch_cable)
6971 .addLibrary (methcla_plugins_sampler)
7072 .addLibrary (methcla_plugins_white_noise)
71- .addLibrary (methcla_plugins_pink_noise)
73+ .addLibrary (methcla_plugins_pink_noise)
74+ .addLibrary (methcla_plugins_brown_noise)
7275 .addLibrary (methcla_plugins_node_control)
7376 .addLibrary (methcla_plugins_pan2)
7477 .addLibrary (methcla_plugins_amplitude_follower)
@@ -717,6 +720,61 @@ JNIEXPORT void JNICALL Java_processing_sound_MethClaInterface_pinkNoiseSet(JNIEn
717720 env->ReleaseIntArrayElements (nodeId, m_nodeId, 0 );
718721};
719722
723+ JNIEXPORT jintArray JNICALL Java_processing_sound_MethClaInterface_brownNoisePlay (JNIEnv *env, jobject object, jfloat amp, jfloat add, jfloat pos){
724+ jintArray nodeId = env->NewIntArray (2 );
725+ jint *m_nodeId = env->GetIntArrayElements (nodeId, NULL );
726+
727+ Methcla::AudioBusId bus = m_engine->audioBusId ().alloc ();
728+ Methcla::Request request (engine ());
729+
730+ request.openBundle (Methcla::immediately);
731+
732+ auto synth = request.synth (
733+ METHCLA_PLUGINS_BROWN_NOISE_URI,
734+ engine ().root (),
735+ { amp, add },
736+ {}
737+ );
738+
739+ auto pan = request.synth (
740+ METHCLA_PLUGINS_PAN2_URI,
741+ engine ().root (),
742+ {pos, 1 .f },
743+ {Methcla::Value (1 .f )}
744+ );
745+
746+ request.mapOutput (synth.id (), 0 , bus);
747+ request.mapInput (pan.id (), 0 , bus);
748+ request.mapOutput (pan.id (), 0 , Methcla::AudioBusId (0 ), Methcla::kBusMappingExternal );
749+ request.mapOutput (pan.id (), 1 , Methcla::AudioBusId (1 ), Methcla::kBusMappingExternal );
750+
751+ request.activate (synth.id ());
752+ request.activate (pan.id ());
753+
754+ request.closeBundle ();
755+ request.send ();
756+
757+ m_nodeId[0 ]=synth.id ();
758+ m_nodeId[1 ]=pan.id ();
759+
760+ env->ReleaseIntArrayElements (nodeId, m_nodeId, 0 );
761+
762+ return nodeId;
763+ };
764+
765+ JNIEXPORT void JNICALL Java_processing_sound_MethClaInterface_brownNoiseSet (JNIEnv *env, jobject object, jfloat amp, jfloat add, jfloat pos, jintArray nodeId){
766+
767+ jint* m_nodeId = env->GetIntArrayElements (nodeId, 0 );
768+
769+ Methcla::Request request (engine ());
770+ request.openBundle (Methcla::immediately);
771+ request.set (m_nodeId[0 ], 0 , amp);
772+ request.set (m_nodeId[1 ], 0 , pos);
773+ request.closeBundle ();
774+ request.send ();
775+
776+ env->ReleaseIntArrayElements (nodeId, m_nodeId, 0 );
777+ };
720778
721779
722780JNIEXPORT jint JNICALL Java_processing_sound_MethClaInterface_envelopePlay (JNIEnv *env, jobject object, jintArray nodeId, jfloat attackTime, jfloat sustainTime, jfloat sustainLevel, jfloat releaseTime){
0 commit comments