This repository was archived by the owner on Nov 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
examples/bela/cpp/cpp-osc-resonator Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 1+ #include < stdlib.h>
12#include < Bela.h>
23#include < libraries/OscSender/OscSender.h>
34#include < libraries/OscReceiver/OscReceiver.h>
@@ -10,6 +11,11 @@ const int localPort = 7562;
1011Resonator res;
1112ResonatorOptions options; // will initialise to default
1213
14+ bool audioInput = false ;
15+ float impulseInterval = 44100 ;
16+ float impulseWidth = 0.125 ;
17+ float impulseCount = 0 ;
18+
1319void onReceive (oscpkt::Message* msg, const char * addr, void * arg) {
1420
1521 if (msg->match (" /resonator" )) {
@@ -67,7 +73,14 @@ void render (BelaContext *context, void *userData) {
6773
6874 for (unsigned int n = 0 ; n < context->audioFrames ; ++n) {
6975
70- float in = audioRead (context, n, 0 ); // an excitation signal
76+ float in = 0 .0f ;
77+ if (audioInput)
78+ in = audioRead (context, n, 0 ); // an excitation signal
79+ else {
80+ if (++impulseCount >= impulseInterval * (1 -impulseWidth))
81+ in = 1 .0f * ( rand () / (float )RAND_MAX * 2 .f - 1 .f ); // noise
82+ if (impulseCount >= impulseInterval) impulseCount = 0 ;
83+ }
7184 float out = 0 .0f ;
7285
7386 out = res.render (in);
You can’t perform that action at this time.
0 commit comments