| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,27 @@ | |||
| 1 | + /* | ||
| 2 | + This is a simple WhiteNoise generator. It can be started with .play(float amp). | ||
| 3 | + In this example it is started and stopped by clicking into the renderer window. | ||
| 4 | + */ | ||
| 5 | + | ||
| 6 | + import processing.sound.*; | ||
| 7 | + | ||
| 8 | + PinkNoise noise; | ||
| 9 | + | ||
| 10 | + float amp=0.0; | ||
| 11 | + | ||
| 12 | + void setup() { | ||
| 13 | + size(640, 360); | ||
| 14 | + background(255); | ||
| 15 | + | ||
| 16 | + // Create and start noise generator | ||
| 17 | + noise = new PinkNoise(this); | ||
| 18 | + noise.play(); | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + void draw() { | ||
| 22 | + // Map mouseX from 0.0 to 1.0 for amplitude | ||
| 23 | + noise.amp(map(mouseX, 0, width, 0.0, 1.0)); | ||
| 24 | + | ||
| 25 | + // Map mouseY from -1.0 to 1.0 for left to right | ||
| 26 | + noise.pan(map(mouseY, 0, width, -1.0, 1.0)); | ||
| 27 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,25 @@ | |||
| 1 | + /* | ||
| 2 | + Copyright 2012-2013 Samplecount S.L. | ||
| 3 | + | ||
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + you may not use this file except in compliance with the License. | ||
| 6 | + You may obtain a copy of the License at | ||
| 7 | + | ||
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + | ||
| 10 | + Unless required by applicable law or agreed to in writing, software | ||
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + See the License for the specific language governing permissions and | ||
| 14 | + limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | + #ifndef METHCLA_PLUGINS_AUDIOIN_H_INCLUDED | ||
| 18 | + #define METHCLA_PLUGINS_AUDIOIN_H_INCLUDED | ||
| 19 | + | ||
| 20 | + #include <methcla/plugin.h> | ||
| 21 | + | ||
| 22 | + METHCLA_EXPORT const Methcla_Library* methcla_plugins_audioin(const Methcla_Host*, const char*); | ||
| 23 | + #define METHCLA_PLUGINS_AUDIOIN_URI METHCLA_PLUGINS_URI "/audioin" | ||
| 24 | + | ||
| 25 | + #endif /* METHCLA_PLUGINS_AUDIOIN_H_INCLUDED */ | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,19 @@ | |||
| 1 | + // | ||
| 2 | + // whitenoise.h | ||
| 3 | + // | ||
| 4 | + // | ||
| 5 | + // Created by wirsing on 13.12.13. | ||
| 6 | + // | ||
| 7 | + // | ||
| 8 | + | ||
| 9 | + | ||
| 10 | + #ifndef METHCLA_PLUGINS_PINK_NOISE_H_INCLUDED | ||
| 11 | + #define METHCLA_PLUGINS_PINK_NOISE_H_INCLUDED | ||
| 12 | + | ||
| 13 | + #include <methcla/plugin.h> | ||
| 14 | + | ||
| 15 | + METHCLA_EXPORT const Methcla_Library* methcla_plugins_pink_noise(const Methcla_Host*, const char*); | ||
| 16 | + | ||
| 17 | + #define METHCLA_PLUGINS_PINK_NOISE_URI METHCLA_PLUGINS_URI "/pink_noise" | ||
| 18 | + | ||
| 19 | + #endif // METHCLA_PLUGINS_PINK_NOISE_H_INCLUDED | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,7 @@ | |||
| 18 | 18 | #include "methcla/plugins/soundfile_api_libsndfile.h" | |
| 19 | 19 | #include "methcla/plugins/sampler.h" | |
| 20 | 20 | #include "methcla/plugins/whitenoise.h" | |
| 21 | + #include "methcla/plugins/pinknoise.h" | ||
| 21 | 22 | #include "methcla/plugins/node-control.h" | |
| 22 | 23 | #include "methcla/plugins/pan2.h" | |
| 23 | 24 | #include "methcla/plugins/soundfile_api_mpg123.h" | |
@@ -26,6 +27,7 @@ | |||
| 26 | 27 | #include "methcla/plugins/hpf.h" | |
| 27 | 28 | #include "methcla/plugins/lpf.h" | |
| 28 | 29 | #include "methcla/plugins/delay.h" | |
| 30 | + #include "methcla/plugins/audio_in.h" | ||
| 29 | 31 | ||
| 30 | 32 | #define OUTPUT_BUFFER_SIZE 1024 | |
| 31 | 33 | #define SNDF_BUFFER_LEN 1024 | |
@@ -66,13 +68,15 @@ JNIEXPORT jint JNICALL Java_processing_sound_MethClaInterface_engineNew (JNIEnv | |||
| 66 | 68 | .addLibrary(methcla_plugins_patch_cable) | |
| 67 | 69 | .addLibrary(methcla_plugins_sampler) | |
| 68 | 70 | .addLibrary(methcla_plugins_white_noise) | |
| 71 | + .addLibrary(methcla_plugins_pink_noise) | ||
| 69 | 72 | .addLibrary(methcla_plugins_node_control) | |
| 70 | 73 | .addLibrary(methcla_plugins_pan2) | |
| 71 | 74 | .addLibrary(methcla_plugins_amplitude_follower) | |
| 72 | 75 | .addLibrary(methcla_plugins_hpf) | |
| 73 | 76 | .addLibrary(methcla_plugins_lpf) | |
| 74 | 77 | .addLibrary(methcla_plugins_delay) | |
| 75 | - .addLibrary(methcla_plugins_fft); | ||
| 78 | + .addLibrary(methcla_plugins_fft) | ||
| 79 | + .addLibrary(methcla_plugins_audioin); | ||
| 76 | 80 | ||
| 77 | 81 | m_engine = new Methcla::Engine(options); | |
| 78 | 82 | ||
@@ -371,6 +375,68 @@ JNIEXPORT void JNICALL Java_processing_sound_MethClaInterface_pulseSet(JNIEnv *e | |||
| 371 | 375 | env->ReleaseIntArrayElements(nodeId, m_nodeId, 0); | |
| 372 | 376 | }; | |
| 373 | 377 | ||
| 378 | + JNIEXPORT jintArray JNICALL Java_processing_sound_MethClaInterface_audioInPlay(JNIEnv *env, jobject object, jfloat amp, jfloat add, jfloat pos, jboolean out){ | ||
| 379 | + | ||
| 380 | + jintArray nodeId = env->NewIntArray(2); | ||
| 381 | + jint *m_nodeId = env->GetIntArrayElements(nodeId, NULL); | ||
| 382 | + | ||
| 383 | + Methcla::AudioBusId bus = m_engine->audioBusId().alloc(); | ||
| 384 | + Methcla::AudioBusId in = m_engine->audioBusId().alloc(); | ||
| 385 | + | ||
| 386 | + Methcla::Request request(engine()); | ||
| 387 | + request.openBundle(Methcla::immediately); | ||
| 388 | + | ||
| 389 | + auto synth = request.synth( | ||
| 390 | + METHCLA_PLUGINS_AUDIOIN_URI, | ||
| 391 | + engine().root(), | ||
| 392 | + {amp, add, pos} | ||
| 393 | + ); | ||
| 394 | + | ||
| 395 | + auto pan = request.synth( | ||
| 396 | + METHCLA_PLUGINS_PAN2_URI, | ||
| 397 | + engine().root(), | ||
| 398 | + {pos, 0}, | ||
| 399 | + {Methcla::Value(1.f)} | ||
| 400 | + ); | ||
| 401 | + | ||
| 402 | + request.mapInput(synth.id(), 0, in, Methcla::kBusMappingExternal); | ||
| 403 | + request.mapOutput(synth.id(), 0, bus); | ||
| 404 | + request.mapInput(pan.id(), 0, bus); | ||
| 405 | + | ||
| 406 | + request.mapOutput(pan.id(), 0, Methcla::AudioBusId(0), Methcla::kBusMappingExternal); | ||
| 407 | + request.mapOutput(pan.id(), 1, Methcla::AudioBusId(1), Methcla::kBusMappingExternal); | ||
| 408 | + | ||
| 409 | + | ||
| 410 | + request.activate(synth.id()); | ||
| 411 | + request.activate(pan.id()); | ||
| 412 | + | ||
| 413 | + request.closeBundle(); | ||
| 414 | + request.send(); | ||
| 415 | + | ||
| 416 | + m_nodeId[0]=synth.id(); | ||
| 417 | + m_nodeId[1]=pan.id(); | ||
| 418 | + | ||
| 419 | + env->ReleaseIntArrayElements(nodeId, m_nodeId, 0); | ||
| 420 | + | ||
| 421 | + return nodeId; | ||
| 422 | + }; | ||
| 423 | + | ||
| 424 | + JNIEXPORT void JNICALL Java_processing_sound_MethClaInterface_audioInSet(JNIEnv *env, jobject object, jfloat amp, jfloat add, jfloat pos, jintArray nodeId){ | ||
| 425 | + jint* m_nodeId = env->GetIntArrayElements(nodeId, 0); | ||
| 426 | + | ||
| 427 | + Methcla::Request request(engine()); | ||
| 428 | + request.openBundle(Methcla::immediately); | ||
| 429 | + request.set(m_nodeId[0], 0 , amp); | ||
| 430 | + request.set(m_nodeId[0], 1 , add); | ||
| 431 | + request.set(m_nodeId[1], 0 , pos); | ||
| 432 | + request.closeBundle(); | ||
| 433 | + request.send(); | ||
| 434 | + | ||
| 435 | + env->ReleaseIntArrayElements(nodeId, m_nodeId, 0); | ||
| 436 | + }; | ||
| 437 | + | ||
| 438 | + | ||
| 439 | + | ||
| 374 | 440 | JNIEXPORT jintArray JNICALL Java_processing_sound_MethClaInterface_soundFileInfo(JNIEnv *env, jobject object, jstring path){ | |
| 375 | 441 | const char *str = env->GetStringUTFChars(path, 0); | |
| 376 | 442 | ||
@@ -595,6 +661,64 @@ JNIEXPORT void JNICALL Java_processing_sound_MethClaInterface_whiteNoiseSet(JNIE | |||
| 595 | 661 | env->ReleaseIntArrayElements(nodeId, m_nodeId, 0); | |
| 596 | 662 | }; | |
| 597 | 663 | ||
| 664 | + JNIEXPORT jintArray JNICALL Java_processing_sound_MethClaInterface_pinkNoisePlay(JNIEnv *env, jobject object, jfloat amp, jfloat add, jfloat pos){ | ||
| 665 | + jintArray nodeId = env->NewIntArray(2); | ||
| 666 | + jint *m_nodeId = env->GetIntArrayElements(nodeId, NULL); | ||
| 667 | + | ||
| 668 | + Methcla::AudioBusId bus = m_engine->audioBusId().alloc(); | ||
| 669 | + Methcla::Request request(engine()); | ||
| 670 | + | ||
| 671 | + request.openBundle(Methcla::immediately); | ||
| 672 | + | ||
| 673 | + auto synth = request.synth( | ||
| 674 | + METHCLA_PLUGINS_PINK_NOISE_URI, | ||
| 675 | + engine().root(), | ||
| 676 | + { amp, add }, | ||
| 677 | + {} | ||
| 678 | + ); | ||
| 679 | + | ||
| 680 | + auto pan = request.synth( | ||
| 681 | + METHCLA_PLUGINS_PAN2_URI, | ||
| 682 | + engine().root(), | ||
| 683 | + {pos, 1.f}, | ||
| 684 | + {Methcla::Value(1.f)} | ||
| 685 | + ); | ||
| 686 | + | ||
| 687 | + request.mapOutput(synth.id(), 0, bus); | ||
| 688 | + request.mapInput(pan.id(), 0, bus); | ||
| 689 | + request.mapOutput(pan.id(), 0, Methcla::AudioBusId(0), Methcla::kBusMappingExternal); | ||
| 690 | + request.mapOutput(pan.id(), 1, Methcla::AudioBusId(1), Methcla::kBusMappingExternal); | ||
| 691 | + | ||
| 692 | + request.activate(synth.id()); | ||
| 693 | + request.activate(pan.id()); | ||
| 694 | + | ||
| 695 | + request.closeBundle(); | ||
| 696 | + request.send(); | ||
| 697 | + | ||
| 698 | + m_nodeId[0]=synth.id(); | ||
| 699 | + m_nodeId[1]=pan.id(); | ||
| 700 | + | ||
| 701 | + env->ReleaseIntArrayElements(nodeId, m_nodeId, 0); | ||
| 702 | + | ||
| 703 | + return nodeId; | ||
| 704 | + }; | ||
| 705 | + | ||
| 706 | + JNIEXPORT void JNICALL Java_processing_sound_MethClaInterface_pinkNoiseSet(JNIEnv *env, jobject object, jfloat amp, jfloat add, jfloat pos, jintArray nodeId){ | ||
| 707 | + | ||
| 708 | + jint* m_nodeId = env->GetIntArrayElements(nodeId, 0); | ||
| 709 | + | ||
| 710 | + Methcla::Request request(engine()); | ||
| 711 | + request.openBundle(Methcla::immediately); | ||
| 712 | + request.set(m_nodeId[0], 0, amp); | ||
| 713 | + request.set(m_nodeId[1], 0, pos); | ||
| 714 | + request.closeBundle(); | ||
| 715 | + request.send(); | ||
| 716 | + | ||
| 717 | + env->ReleaseIntArrayElements(nodeId, m_nodeId, 0); | ||
| 718 | + }; | ||
| 719 | + | ||
| 720 | + | ||
| 721 | + | ||
| 598 | 722 | JNIEXPORT jint JNICALL Java_processing_sound_MethClaInterface_envelopePlay(JNIEnv *env, jobject object, jintArray nodeId, jfloat attackTime, jfloat sustainTime, jfloat sustainLevel, jfloat releaseTime){ | |
| 599 | 723 | ||
| 600 | 724 | jint* m_nodeId = env->GetIntArrayElements(nodeId, 0); | |
@@ -932,7 +1056,6 @@ JNIEXPORT void JNICALL Java_processing_sound_MethClaInterface_destroy_1fft(JNIEn | |||
| 932 | 1056 | free(fft_ptr); | |
| 933 | 1057 | }; | |
| 934 | 1058 | ||
| 935 | - | ||
| 936 | 1059 | /* OLD VARIABLE IN OUT FUNCTION | |
| 937 | 1060 | JNIEXPORT jint JNICALL Java_processing_sound_MethClaInterface_out(JNIEnv *env, jobject object, jint in, jint out, jfloatArray pos){ | |
| 938 | 1061 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments