I'm utilizing the Mozzie Library to create audio signal processing sketches. The sketches are based off of pure data sketches. Specifically, I'm trying to recreate the expr~ object so I can write directly to the PWM~ pin waveforms.
I don't quite get how to handle audio signal flow in C. Any advice would be welcome. Thanks in advance.
#include <MozziGuts.h>
#include <Phasor.h>
Phasor <AUDIO_RATE> aPhasor1;
float freq = 0.125f;
void setup(){
aPhasor1.setFreq(freq);
startMozzi(); // :)
}
int updateAudio(){
int phasor = (int)(aPhasor1.next()>>24);
int signal = (int)(0.125>>24);
int v1 = phasor * 44800 * signal * 4;
int v2 = 44800 * signal;
int v3 = cos(phasor/signal/3)/phasor;
int final_signal = cos(v1*v2);
return (final_signal);
}
void loop(){
audioHook(); // required here
}