class: mSample
an improved version of MOZZI’s Sample class
Description
A copy of MOZZI’s Sample class with a few improvements as follows:
8-bit or 16-bit samples can be used; just specify the bitrate of your sample in the template when creating your object
linear interpolation can be used, also specified in template
playing sample in reverse is supported as documented below
samples of arbitrary length are supported
Aside from these changes, mSample class functions exactly as MOZZI’s Sample class so full documentation can be found on their website
Template Parameters
template <uint64_t NUM_TABLE_CELLS, uint32_t UPDATE_RATE, class T = int8_t, uint8_t INTERP = mINTERP_NONE>NUM_TABLE_CELLS: length of sample
UPDATE_RATE: how often .next() will be called (likely AUDIO_RATE or CONTROL_RATE)
T: data type used in sample (likely int8_t or int16_t)
INTERP: interpolation type used in playback (mINTERP_NONE or mINTERP_LINEAR)
Class Methods
void setReverseOn()Enables reverse mode: sample will play backwards
void setReverseOff()Disables reverse mode: sample will play forwards
void setSpeed(float speed)Sets the playback speed of the sample (it is recommended to use this over setFreq because it is more intuitive). For example a speed of 1 plays back the sample at the same rate it was recorded, 2 will play it back at double speed (which also has the effect of pitching it up an octave), 0.5 will play it back at half speed (which also has the effect of pitching it down an octave)