This is an example of how to use the WaveShaper class.
#include <MozziGuts.h>
#include <Oscil.h>
#include <WaveShaper.h>
#include <EventDelay.h>
#include <mozzi_rand.h>
#include <mozzi_midi.h>
#include <Smooth.h>
#include <tables/sin2048_int8.h>
#include <tables/waveshape_chebyshev_3rd_256_int8.h>
#include <tables/waveshape_chebyshev_6th_256_int8.h>
#include <tables/waveshape_compress_512_to_488_int16.h>
#define CONTROL_RATE 64 // powers of 2 please
Q8n0 octave_start_note = 42;
int target_freq, smoothed_freq;
void setup(){
aSin.setFreq(110);
aGain1.setFreq(2.f);
aGain2.setFreq(.4f);
kChangeNoteDelay.
set(4000);
}
byte rndPentatonic(){
byte note =
rand((byte)5);
switch(note){
case 0:
note = 0;
break;
case 1:
note = 3;
break;
case 2:
note = 5;
break;
case 3:
note = 7;
break;
case 4:
note = 10;
break;
}
return note;
}
if(kChangeNoteDelay.
ready()){
octave_start_note = (
rand((byte)4)*12)+36;
}
kChangeNoteDelay.
start();
}
smoothed_freq = kSmoothFreq.next(target_freq*4);
aSin.setFreq(smoothed_freq/4);
}
char asig0 = aSin.next();
byte asig1 = (byte)128+((asig0*((byte)128+aGain1.next()))>>8);
byte asig2 = (byte)128+((asig0*((byte)128+aGain2.next()))>>8);
char awaveshaped1 = aCheby3rd.next(asig1);
char awaveshaped2 = aCheby6th.next(asig2);
int awaveshaped3 = aCompress.next(256u + awaveshaped1 + awaveshaped2);
return awaveshaped3;
}
void loop(){
}