Mozzi  version v2.0
sound synthesis library for Arduino
WavePacket< ALGORITHM > Class Template Reference

Wavepacket synthesis, with two overlapping streams of wave packets. More...

#include <WavePacket.h>

+ Inheritance diagram for WavePacket< ALGORITHM >:

Detailed Description

template<int8_t ALGORITHM>
class WavePacket< ALGORITHM >

Wavepacket synthesis, with two overlapping streams of wave packets.

Draws on Miller Puckette's Pure Data example, F14.wave.packet.pd. Each packet is an enveloped grain of a sin (or cos) wave. The frequency of the wave, the width of the envelopes and the rate of release of envelopes are the parameters which can be changed.

Template Parameters
ALGORITHMoptions are SINGLE or DOUBLE, for a single non-overlapping stream of packets or a double, overlapping stream.

Definition at line 36 of file WavePacket.h.

Public Member Functions

 WavePacket ()
 Constructor.
 
void set (int fundamental, int bandwidth, int centrefreq)
 Set all the parameters for the synthesis. More...
 
void setFundamental (int fundamental)
 Set the fundamental frequency. More...
 
void setBandwidth (int bandwidth)
 Set the bandwidth. More...
 
void setCentreFreq (int centrefreq)
 Set the centre frequency. More...
 
int next ()
 Calculate the next synthesised sample. More...
 

Member Function Documentation

◆ next()

template<int8_t ALGORITHM>
int WavePacket< ALGORITHM >::next ( )
inline

Calculate the next synthesised sample.

Returns
a full-scale 16 bit value, which needs to be scaled to suit your sketch. If you're using it straight as the sketch output, then that will be yourThing.next()>>2 for HIFI 14 bit output, or >>8 for STANDARD 8+ bit output.

Definition at line 113 of file WavePacket.h.

◆ set()

template<int8_t ALGORITHM>
void WavePacket< ALGORITHM >::set ( int  fundamental,
int  bandwidth,
int  centrefreq 
)
inline

Set all the parameters for the synthesis.

The function is designed so that usable ranges for parameters can come from analog inputs, ie. 0-1023.

Parameters
fundamentalthe rate at which packets are produced.
bandwidththe width of each packet. A lower value allows more of the centre frequency to be audible, a rounder sound.
A higher value produces narrower packets, a more buzzing sound.
centrefreqthe oscillation frequency within each packet.

Definition at line 57 of file WavePacket.h.

◆ setBandwidth()

template<int8_t ALGORITHM>
void WavePacket< ALGORITHM >::setBandwidth ( int  bandwidth)
inline

Set the bandwidth.

The function is designed so that usable ranges for parameters can come from analog inputs, ie. 0-1023.

Parameters
bandwidththe width of each packet. A lower value allows more of the centre frequency to be audible, a rounder sound.
A higher value produces narrower packets, a more buzzing sound.

Definition at line 85 of file WavePacket.h.

◆ setCentreFreq()

template<int8_t ALGORITHM>
void WavePacket< ALGORITHM >::setCentreFreq ( int  centrefreq)
inline

Set the centre frequency.

The function is designed so that usable ranges for parameters can come from analog inputs, ie. 0-1023.

Parameters
centrefreqthe oscillation frequency within each packet.

Definition at line 100 of file WavePacket.h.

◆ setFundamental()

template<int8_t ALGORITHM>
void WavePacket< ALGORITHM >::setFundamental ( int  fundamental)
inline

Set the fundamental frequency.

The function is designed so that usable ranges for parameters can come from analog inputs, ie. 0-1023.

Parameters
fundamentalthe rate at which packets are produced.

Definition at line 70 of file WavePacket.h.