FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

added PinkNoise + changed filter Classes to long names · 5y/processing@03bf453 · GitHub

Repository navigation

Commit 03bf453

Browse files
committed
added PinkNoise + changed filter Classes to long names
1 parent 44e6ae4 commit 03bf453

18 files changed

Lines changed: 372 additions & 33 deletions
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}
5.27 KB
Binary file not shown.
7.01 KB
Binary file not shown.
5.69 KB
Binary file not shown.
File renamed without changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff 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 */
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff 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

‎java/libraries/sound/src/cpp/include/processing_sound_MethClaInterface.h‎

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
315 KB
Binary file not shown.

‎java/libraries/sound/src/cpp/processing_sound_MethClaInterface.cpp‎

Lines changed: 125 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "methcla/plugins/soundfile_api_libsndfile.h"
1919
#include "methcla/plugins/sampler.h"
2020
#include "methcla/plugins/whitenoise.h"
21+
#include "methcla/plugins/pinknoise.h"
2122
#include "methcla/plugins/node-control.h"
2223
#include "methcla/plugins/pan2.h"
2324
#include "methcla/plugins/soundfile_api_mpg123.h"
@@ -26,6 +27,7 @@
2627
#include "methcla/plugins/hpf.h"
2728
#include "methcla/plugins/lpf.h"
2829
#include "methcla/plugins/delay.h"
30+
#include "methcla/plugins/audio_in.h"
2931

3032
#define OUTPUT_BUFFER_SIZE 1024
3133
#define SNDF_BUFFER_LEN 1024
@@ -66,13 +68,15 @@ JNIEXPORT jint JNICALL Java_processing_sound_MethClaInterface_engineNew (JNIEnv
6668
.addLibrary(methcla_plugins_patch_cable)
6769
.addLibrary(methcla_plugins_sampler)
6870
.addLibrary(methcla_plugins_white_noise)
71+
.addLibrary(methcla_plugins_pink_noise)
6972
.addLibrary(methcla_plugins_node_control)
7073
.addLibrary(methcla_plugins_pan2)
7174
.addLibrary(methcla_plugins_amplitude_follower)
7275
.addLibrary(methcla_plugins_hpf)
7376
.addLibrary(methcla_plugins_lpf)
7477
.addLibrary(methcla_plugins_delay)
75-
.addLibrary(methcla_plugins_fft);
78+
.addLibrary(methcla_plugins_fft)
79+
.addLibrary(methcla_plugins_audioin);
7680

7781
m_engine = new Methcla::Engine(options);
7882

@@ -371,6 +375,68 @@ JNIEXPORT void JNICALL Java_processing_sound_MethClaInterface_pulseSet(JNIEnv *e
371375
env->ReleaseIntArrayElements(nodeId, m_nodeId, 0);
372376
};
373377

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+
374440
JNIEXPORT jintArray JNICALL Java_processing_sound_MethClaInterface_soundFileInfo(JNIEnv *env, jobject object, jstring path){
375441
const char *str = env->GetStringUTFChars(path, 0);
376442

@@ -595,6 +661,64 @@ JNIEXPORT void JNICALL Java_processing_sound_MethClaInterface_whiteNoiseSet(JNIE
595661
env->ReleaseIntArrayElements(nodeId, m_nodeId, 0);
596662
};
597663

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+
598722
JNIEXPORT jint JNICALL Java_processing_sound_MethClaInterface_envelopePlay(JNIEnv *env, jobject object, jintArray nodeId, jfloat attackTime, jfloat sustainTime, jfloat sustainLevel, jfloat releaseTime){
599723

600724
jint* m_nodeId = env->GetIntArrayElements(nodeId, 0);
@@ -932,7 +1056,6 @@ JNIEXPORT void JNICALL Java_processing_sound_MethClaInterface_destroy_1fft(JNIEn
9321056
free(fft_ptr);
9331057
};
9341058

935-
9361059
/* OLD VARIABLE IN OUT FUNCTION
9371060
JNIEXPORT jint JNICALL Java_processing_sound_MethClaInterface_out(JNIEnv *env, jobject object, jint in, jint out, jfloatArray pos){
9381061

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL