mRompler
casio keyboard-style multi-sample playback instrument
Description
mRompler is an instrument intended for chromatic playback of multiple samples. Load up as many samples as you want, switch between programs or play multiple timbres simultaneously.
Template Parameters
template <uint64_t mMAX_SAMPLE_LENGTH, uint8_t mPOLYPHONY, class Y = int8_t, meap_interpolation INTERP = mINTERP_NONE>mMAX_SAMPLE_LENGTH: length of the longest sample being included in the rack
mPOLYPHONY: maximum number of notes mRompler can play at once
T: data type of samples loaded into mRompler (NOTE: all samples must be of same type)
INTERP: kind of interpolation used in sample playback (mINTERP_NONE or mINTERP_LINEAR)
Class Methods
Constructor
mRompler(const T **sample_list, uint64_t *sample_lengths)sample_list array of samples to be loaded into rack
sample_lengths: array of lengths of each sample listed in sample_list
void setADSR(uint32_t attack_time, uint32_t decay_time, uint32_t sustain_level, uint32_t release_time)Sets ADSR envelope parameters for an operator
operator_num: number of operator to modify (0 to 3)
attack_time: attack time in ms
decay_time: decay time in ms
sustain_level: sustain level (0-255)
release_time: release time in ms
void setProgram()Choose which of the loaded samples to use. Must be between 0 and the number of samples you loaded minus one.
void setLoopingOn()Enables looping. Sample will restart from beginning once it reaches end
void setLoopingOff()Disables looping. Sample will stope playing once it reaches end
void setReverseOn()Samples will play in reverse.
void setReverseOff()Samples will not play in reverse
void setStart(uint64_t start)Sets starting point of samples to be played. Must be between 0 and the length of the current sample.
void setEnd(uint64_t end)Sets ending point of samples to be played. Must be between 0 and the length of the current sample.
void noteOn(uint16_t note, uint16_t vel)Plays a note with given MIDI note number (0-127) and MIDI velocity (0-127)
void noteOn(uint16_t note, uint16_t vel, int16_t program_overridePlays a note with given MIDI note number (0-127), MIDI velocity (0-127) and a specific program.
program_override: represents which sample is played and must be between 0 and the number of samples loaded into the mRompler minus one
void noteOff(uint16_t note)Turns off a note. Will only turn off notes played with the same program as the current program, meaning that if you turn a note on, switch programs and then try to turn that note off, it will stay on.
void noteOff(uint16_t note, uint16_t program_override)Turns off a note being played on a specific program.
void flush()Turns off all currently playing notes.
void update()Updates internal states of all envelopes used in voices. MUST BE CALLED IN updateControl
void next()Calculates a sample of audio. Output will be nominally 16 bits no matter what bit-rate of samples you used. MUST BE CALLED IN updateAudio ### Example
===== GLOBAL VARIABLE DECLARATIONS =====
// assuming we have the following 16-bit samples playing a single C note in the same directory as our sketch
#include "piano.h"
#include "guitar.h"
#include "trumpet.h"
#define NUM_SAMPLES 3
const int16_t *sample_list[NUM_SAMPLES] = {
piano_DATA,
guitar_DATA,
trumpet_DATA,
};
uint64_t sample_lengths[NUM_SAMPLES] = {
piano_NUM_CELLS,
guitar_NUM_CELLS,
trumpet_NUM_CELLS
};
#include "midi_sequence.h" // optional MIDI sequence converted with MIDI converter script. If not using this, leave the last constructor argument below blank
mRompler<300000, 4, int16_t> my_rompler(sample_list, sample_lengths, midi_sequence_data); // exact value of first template argument doesn't really matter, it just needs to be at least as large as the length of the longest sample you're using
// ===== in updateControl =====
my_rompler.update(); // this internally updates the rompler's envelopes. It needs to be called in updateControl
// ===== in updateAudio() =====
int64_t out_sample = my_rompler.next(); // calculates a sample of audio output. output will be nominally 16 bits no matter what bitrate of samples you load into the rompler.
// ===== if using a MIDI sequence; call updateMidi() within a 24PPQ process, such as the clockStep function of MEAP_MIDI_TEMPLATE_WITH_CLOCK.h =====
my_rompler.updateMidi();