18 #include "tables/cos8192_int8.h"
19 #include "mozzi_fixmath.h"
25 enum algorithms {SINGLE,DOUBLE};
35 template <
int8_t ALGORITHM>
57 void set(
int fundamental,
int bandwidth,
int centrefreq)
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;
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);
T next()
Increments one step along the line.
void set(T value)
Set the current value of the line.
void setTable(const int8_t *TABLE_NAME)
Change the sound table which will be played by the Oscil.
int8_t atIndex(unsigned int index)
Returns the sample at the given table index.
uint32_t next()
Increments one step along the phase.
void setFreq(int frequency)
Set the Phasor frequency with an unsigned int.
Wavepacket synthesis, with two overlapping streams of wave packets.
int next()
Calculate the next synthesised sample.
void setBandwidth(int bandwidth)
Set the bandwidth.
void set(int fundamental, int bandwidth, int centrefreq)
Set all the parameters for the synthesis.
void setCentreFreq(int centrefreq)
Set the centre frequency.
void setFundamental(int fundamental)
Set the fundamental frequency.
#define MOZZI_CONTROL_RATE
Control rate setting.
#define MOZZI_AUDIO_RATE
Defines the audio rate, i.e.
int32_t Q15n16
signed fractional number using 15 integer bits and 16 fractional bits, represents -32767....
#define Q8n24_FIX1
1 in Q8n24 format
uint32_t Q8n24
signed fractional number using 8 integer bits and 24 fractional bits, represents 0 to 255....
Q23n8 Q15n16_to_Q23n8(Q15n16 a)
Convert Q15n16 fixed to Q23n8 signed int32_t.
#define Q15n16_FIX1
1 in Q15n16 format
int32_t Q23n8
signed fractional number using 23 integer bits and 8 fractional bits, represents -8388607....