Audio Signal Flow in Arduino

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


}

You can write directly to the PWM registers if you like. Depending on the register they take simple binary 8 or 16 bit numbers, nothing else. You can use the math functions etc in the arduino to do your calculations. The Arduino is missing MAC , or “Multiply And Accumulate and MAD Multiply and Add. Try this link it may help you: ARDUINODSP. Have Fun!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.