MEAP The Library

MOZZI
MEAP The Class
C++ tips
Mozzi Reworks
mOscil
mSample
Generators
mDust
mNoise
mOperator
mSineLFO
mEnvSection
Effects
mBitcrusher
mChorus
mDigitalDelay
mFlanger
mPlateReverb
mSchroederReverb
DSP
mDelayLine
mFeedbackComb
mFeedforwardComb
mFIR
mIIR
mNaturalComb
mOnePoleLPF
mResonz
mRingz
mSchroederAllpass
mInstruments
mDrumRack
mFM4Instrument
mMarimbaInstrument
mPopInstrument
mRompler
mStringInstrument
mStringSynthInstrument
Composition
mMML
mTransitionTable
Utilities
mEventDelayMicros
mRandomDistribution

Meap The Class


the heart of MEAP

Description

The Meap class is the primary interface between software and hardware on MEAP. It also provides a few general and useful tools.

Every meap program has one and only one Meap object, defined globally. This class definition is how you tell the Meap library what version of the Meap board you have.

Template Parameters

template <meap_hardware_versions hardware_versions = MEAP_DEFAULT_VERSION>

hardware_versions: The version of Meap board that you have. One of the following:

If you have an older MEAP version and want to keep using it, contact Mason and he will add support for your version!

Main Class Methods

void begin()

Sets up a variety of hardware and software processes. MUST BE CALLED IN setup()


void readInputs()

Reads DIP switches, touch inputs and potentiometers. SHOULD BE CALLED IN updateControl()


Tools

static int64_t irand(int64_t min, int64_t max)

Generates a random integer within a specified range, inclusive of both limit numbers

min: lower limit of range, inclusive

max: upper limit of range, inclusive


static float frand()

Generates a random decimal number between 0 and 1


static StereoSample pan2(int64_t sample, uint8_t pos)

An equal-power stereo panner.

sample: Sample that you want to pan between left and right channels

pos: Position in stereo field. 0 is hard left, 127 is center, 255 is hard right

Returns two samples as a StereoSample struct. Samples can be retrieved from .l and .r members

struct StereoSample
{
  int32_t l;
  int32_t r;
};

Example:

// in updateAudio
StereoSample out_samples = meap.pan2(my_osc.next(), 63); // pan halfway left
int32_t left_sample = out_samples.l;
int32_t right_sample = out_samples.r;

float tempoToQuarter(float tempo)

Calculates the length (in milliseconds) of a quarter note at a specified tempo (in BPM)


float midiPulseMicros(float tempo)

Calculates the length (in microseconds) of a 24PPQ MIDI clock pulse at a specified tempo (in BPM)


float normalize(int16_t input)

Normalizes value from potentiometer (in range 0-4095) to range 0-1.0

Example usage:

float my_val = meap.normalize(meap.pot_vals[0]); // my_val now contains a number between 0 and 1 which is controlled by pot 0

void setMuxChannel(int8_t channel)

Sets multiplexer channel (0-7). Used internally by readInputs(). Could be useful if you want to bypass readInputs() and writes your own input reading function (for example, if you have modified your hardware)


Audio codec initialization

Meap uses an SGTL5000 audio codec chip. It is configured in begin() and you generally won’t need to make any changes to this configuration, however the following are some cases where you may need to.


static void setCodecGain(uint16_t gain)

Sets master volume of codec chip output (60 to 252, where 60 is the default gain of 0dB, decreases in 0.5017 dB steps)


static void setCodecInputGain(uint16_t gain)

Sets ADC input gain (0 to 15 between 0 dB and +22.5dB in 1.5dB steps


void setCodecInputMic()

Sets codec to use Mic input as ADC input


void setCodecInputLine()

Sets codec to use Line as ADC input. This is the case by default.


static void setCodecMicGain(int gain)

Sets gain of microphone input. 0-3 corresponding to 0dB, +20dB, +30dB and +40dB (the default)


static uint32_t SGread(uint32_t reg)

Reads a register on SGTL5000 chip.

reg: address of register


static bool SGwrite(uint32_t reg, uint32_t val)

Write to a register on SGTL5000 chip.

reg: address of register

val: value to write to register


static uint32_t SGmodify(uint32_t reg, uint32_t val, uint32_t iMask)

Modifies specified bits of SGTL5000 register.

reg: address of register

val: value to write to register

iMask: bit mask of values to modify in register (1s get modified)