16 #include <MozziGuts.h> 18 #include <tables/cos8192_int8.h> 19 #include <mozzi_fixmath.h> 25 enum algorithms {SINGLE,DOUBLE};
35 template <int8_t ALGORITHM>
44 aCos.setTable(COS8192_DATA);
57 void set(
int fundamental,
int bandwidth,
int centrefreq)
72 aPhasor.setFreq(fundamental);
87 Q15n16 bw = invFreq*bandwidth;
90 aBandwidth.set(bw, AUDIO_STEPS_PER_CONTROL);
102 Q15n16 cf = invFreq * centrefreq;
104 aCentrefreq.set(cf, AUDIO_STEPS_PER_CONTROL);
115 gcentrefreq = aCentrefreq.next();
116 gbandwidth = aBandwidth.next();
117 int phase1 = aPhasor.next()>>16;
118 if (ALGORITHM == DOUBLE) {
119 return (signalPath(params1, phase1)+signalPath(params2, phase1+32768))>>1;
121 return signalPath(params1, phase1);
148 const unsigned int AUDIO_STEPS_PER_CONTROL;
155 int signalPath(
struct parameters ¶m,
int phase)
160 if(phase<param.previous_phase)
162 param.centrefreq = gcentrefreq>>8;
163 param.bandwidth = Q15n16_to_Q23n8(gbandwidth);
165 param.previous_phase = phase;
168 index = (param.centrefreq * phase)>>16;
170 index += COS8192_NUM_CELLS>>1;
171 index &= COS8192_NUM_CELLS-1;
172 int8_t sig1 = aCos.atIndex(index);
175 Q23n8 bwphase = (param.bandwidth * phase)>>8;
176 bwphase += COS8192_NUM_CELLS>>1;
177 index = constrain(bwphase, 0, (COS8192_NUM_CELLS-1));
178 uint8_t packet_width = 128 + aCos.atIndex(index);
185 return ((
int) sig1 * packet_width);
void setCentreFreq(int centrefreq)
Set the centre frequency.
int next()
Calculate the next synthesised sample.
int32_t Q15n16
signed fractional number using 15 integer bits and 16 fractional bits, represents -32767...
Oscil plays a wavetable, cycling through the table to generate an audio or control signal...
void set(int fundamental, int bandwidth, int centrefreq)
Set all the parameters for the synthesis.
void setFundamental(int fundamental)
Set the fundamental frequency.
#define AUDIO_RATE
Holds the audio rate setting.
For linear changes with a minimum of calculation at each step.
#define Q15n16_FIX1
1 in Q15n16 format
void setBandwidth(int bandwidth)
Set the bandwidth.
Wavepacket synthesis, with two overlapping streams of wave packets.
uint32_t Q16n16
unsigned fractional number using 16 integer bits and 16 fractional bits, represents 0 to 65535...
uint32_t Q8n24
signed fractional number using 8 integer bits and 24 fractional bits, represents 0 to 255...
#define Q8n24_FIX1
1 in Q8n24 format
Phasor repeatedly generates a high resolution ramp at a variable frequency.
int32_t Q23n8
signed fractional number using 23 integer bits and 8 fractional bits, represents -8388607.996 to 8388607.996