SynthLab SDK
MIDIFunctions

Functions

double SynthLab::midi14_bitToBipolar (uint32_t midiDataLSB, uint32_t midiDataMSB)
 Converts MIDI data bytes 1 and 2 (14-bit) into a bipolar [-1, +1] value. More...
 
uint32_t SynthLab::midi14_bitToUnipolarInt (uint32_t midiDataLSB, uint32_t midiDataMSB)
 Converts MIDI data bytes 1 and 2 (14-bit) into a unipolar value 0 -> 16383. More...
 
double SynthLab::midi14_bitToUnipolarDouble (uint32_t midiDataLSB, uint32_t midiDataMSB)
 Converts MIDI data bytes 1 and 2 (14-bit) into a unipolar double value 0.0 -> 1.0. More...
 
double SynthLab::midi14_bitToDouble (uint32_t midiDataLSB, uint32_t midiDataMSB, double minValue, double maxValue)
 Converts MIDI data bytes 1 and 2 (14-bit) into a double value on the range [minValue, maxValue]. More...
 
void SynthLab::unipolarIntToMIDI14_bit (uint32_t unipolarValue, uint32_t &midiDataLSB, uint32_t &midiDataMSB)
 Converts value from 0 -> 16383 into 14-bit MIDI bytes, pass by reference. More...
 
void SynthLab::bipolarIntToMIDI14_bit (int32_t biPolarValue, int32_t minValue, int32_t maxValue, uint32_t &midiDataLSB, uint32_t &midiDataMSB)
 Converts int value on the range [minValue, maxValue] into 14-bit MIDI bytes, pass by reference. More...
 
void SynthLab::unipolarDoubleToMIDI14_bit (double unipolarValue, uint32_t &midiDataLSB, uint32_t &midiDataMSB)
 Converts double value on the range [0, 1] into 14-bit MIDI bytes, pass by reference. More...
 
double SynthLab::midiPitchBendToBipolar (uint32_t midiData1, uint32_t midiData2)
 Converts MIDI data bytes 1 and 2 into a bipolar [-1, +1] value. More...
 
uint32_t SynthLab::midiNoteNumberFromOscFrequency (double oscillatorFrequency, double frequencyA440=440.0)
 use lookup table to find pitch shift multipliers, uses linear interpolation More...
 
double SynthLab::midiNoteNumberToOscFrequency (uint32_t midiNoteNumber, double frequencyA440=440.0)
 converts a MIDI note number into a corresponding oscillator frequency in Hz More...
 
double SynthLab::mmaMIDItoAtten (uint32_t midiValue)
 calculates the raw attenuation according to MMA DLS spec midiValue = the MIDI (0 -> 127) value to convert More...
 
double SynthLab::calculatePitchBend (IMidiInputData *midiInputData)
 Second method to calculate a pitch bend multiplier value based on the global MIDI input values: More...
 
double SynthLab::calculateMasterTuning (IMidiInputData *midiInputData)
 Method to calculate a tuning (pitch bend) multiplier value based on the global MIDI input values: More...
 
void SynthLab::initDMConfig (std::shared_ptr< MidiInputData > midiInputData, DMConfig *config)
 Initializes the MIDI aux data with configuration information; for DM only. More...
 
void SynthLab::initMIDIInputData (std::shared_ptr< MidiInputData > midiInputData)
 Initializes the MIDI input data arrays with values that prevent the synth from appearing to be malfunctioning. This includes bringing volume controls up to unity gain (max output) and pan to the center as well as setting pitch bend range and overall tuning (known as master volume and master tuning in the MMA documentation) More...
 

Detailed Description

Function Documentation

◆ bipolarIntToMIDI14_bit()

void SynthLab::bipolarIntToMIDI14_bit ( int32_t  biPolarValue,
int32_t  minValue,
int32_t  maxValue,
uint32_t &  midiDataLSB,
uint32_t &  midiDataMSB 
)
inline

Converts int value on the range [minValue, maxValue] into 14-bit MIDI bytes, pass by reference.

Parameters
biPolarValuevalue to convert
minValueminimum value of input range
maxValuemaximum value of input range
midiDataLSBreturned MIDI LSB (7 bits are valid)
midiDataMSBreturned MIDI MSB (7 bits are valid)

◆ calculateMasterTuning()

double SynthLab::calculateMasterTuning ( IMidiInputData midiInputData)
inline

Method to calculate a tuning (pitch bend) multiplier value based on the global MIDI input values:

  • kMIDIMasterTuneCoarseMSB (from master controls)
  • kMIDIMasterTuneFineLSB (from master controls)
  • NOTE: the term "Master" is verbatim from the MIDI specifiction as of this writing
Parameters
midiInputDataMIDI input data array as a naked pointer
Returns
pitch bend multiplier value as a double

◆ calculatePitchBend()

double SynthLab::calculatePitchBend ( IMidiInputData midiInputData)
inline

Second method to calculate a pitch bend multiplier value based on the global MIDI input values:

  • kMIDIMasterPBSensCoarse (from master controls)
  • kMIDIMasterPBSensFine (from master controls)
  • kMIDIPitchBendDataLSB (from pitch bend wheel)
  • kMIDIPitchBendDataMSB (from pitch bend wheel)
  • NOTE: the term "Master" is verbatim from the MIDI specifiction as of this writing
Parameters
midiInputDataMIDI input data array as a naked pointer
Returns
pitch bend multiplier value as a double

◆ initDMConfig()

void SynthLab::initDMConfig ( std::shared_ptr< MidiInputData midiInputData,
DMConfig config 
)
inline

Initializes the MIDI aux data with configuration information; for DM only.

Parameters
midiInputDatashared pointer to MIDI input data array

◆ initMIDIInputData()

void SynthLab::initMIDIInputData ( std::shared_ptr< MidiInputData midiInputData)
inline

Initializes the MIDI input data arrays with values that prevent the synth from appearing to be malfunctioning. This includes bringing volume controls up to unity gain (max output) and pan to the center as well as setting pitch bend range and overall tuning (known as master volume and master tuning in the MMA documentation)

Parameters
midiInputDatashared pointer to MIDI input data array

◆ midi14_bitToBipolar()

double SynthLab::midi14_bitToBipolar ( uint32_t  midiDataLSB,
uint32_t  midiDataMSB 
)
inline

Converts MIDI data bytes 1 and 2 (14-bit) into a bipolar [-1, +1] value.

Parameters
midiDataLSBMIDI LSB (7 bits are valid)
midiDataMSBMIDI MSB (7 bits are valid)
Returns
the bipolar version of the 14-bit MIDI value

◆ midi14_bitToDouble()

double SynthLab::midi14_bitToDouble ( uint32_t  midiDataLSB,
uint32_t  midiDataMSB,
double  minValue,
double  maxValue 
)
inline

Converts MIDI data bytes 1 and 2 (14-bit) into a double value on the range [minValue, maxValue].

Parameters
midiDataLSBMIDI LSB (7 bits are valid)
midiDataMSBMIDI MSB (7 bits are valid)
minValueminimum mapped value
maxValuemaximum mapped value
Returns
the unipolar double version of the 14-bit MIDI value value on the range [minValue, maxValue]

◆ midi14_bitToUnipolarDouble()

double SynthLab::midi14_bitToUnipolarDouble ( uint32_t  midiDataLSB,
uint32_t  midiDataMSB 
)
inline

Converts MIDI data bytes 1 and 2 (14-bit) into a unipolar double value 0.0 -> 1.0.

Parameters
midiDataLSBMIDI LSB (7 bits are valid)
midiDataMSBMIDI MSB (7 bits are valid)
Returns
the unipolar double version of the 14-bit MIDI value

◆ midi14_bitToUnipolarInt()

uint32_t SynthLab::midi14_bitToUnipolarInt ( uint32_t  midiDataLSB,
uint32_t  midiDataMSB 
)
inline

Converts MIDI data bytes 1 and 2 (14-bit) into a unipolar value 0 -> 16383.

Parameters
midiDataLSBMIDI LSB (7 bits are valid)
midiDataMSBMIDI MSB (7 bits are valid)
Returns
the unipolar version of the 14-bit MIDI value

◆ midiNoteNumberFromOscFrequency()

uint32_t SynthLab::midiNoteNumberFromOscFrequency ( double  oscillatorFrequency,
double  frequencyA440 = 440.0 
)
inline

use lookup table to find pitch shift multipliers, uses linear interpolation

Parameters
semitonesthe number of semitones to pitch shift (fractional)
Returns
the pitch shift multiplier (+12 semitones -> 2.0, -12 semitones -> 0.5)

converts an oscillator frequency in Hz to the corresponding MIDI note number

Parameters
oscillatorFrequencyfrequency in Hz to convert
frequencyA440reference frequency of concert-A
Returns
the MIDI note number for the oscillator pitch

◆ midiNoteNumberToOscFrequency()

double SynthLab::midiNoteNumberToOscFrequency ( uint32_t  midiNoteNumber,
double  frequencyA440 = 440.0 
)
inline

converts a MIDI note number into a corresponding oscillator frequency in Hz

Parameters
midiNoteNumbernote number to convert
frequencyA440reference frequency of concert-A
Returns
the frequency in Hz of the pitch

◆ midiPitchBendToBipolar()

double SynthLab::midiPitchBendToBipolar ( uint32_t  midiData1,
uint32_t  midiData2 
)
inline

Converts MIDI data bytes 1 and 2 into a bipolar [-1, +1] value.

Parameters
midiData1LSB
midiData2MSB
Returns
the double, unipolar version of the pitch shift value

◆ mmaMIDItoAtten()

double SynthLab::mmaMIDItoAtten ( uint32_t  midiValue)
inline

calculates the raw attenuation according to MMA DLS spec midiValue = the MIDI (0 -> 127) value to convert

  • uses simple square-law power conversion
Parameters
midiValuethe MIDI velocity value
Returns
the attenuation level

◆ unipolarDoubleToMIDI14_bit()

void SynthLab::unipolarDoubleToMIDI14_bit ( double  unipolarValue,
uint32_t &  midiDataLSB,
uint32_t &  midiDataMSB 
)
inline

Converts double value on the range [0, 1] into 14-bit MIDI bytes, pass by reference.

Parameters
unipolarValuevalue to convert
midiDataLSBreturned MIDI LSB (7 bits are valid)
midiDataMSBreturned MIDI MSB (7 bits are valid)

◆ unipolarIntToMIDI14_bit()

void SynthLab::unipolarIntToMIDI14_bit ( uint32_t  unipolarValue,
uint32_t &  midiDataLSB,
uint32_t &  midiDataMSB 
)
inline

Converts value from 0 -> 16383 into 14-bit MIDI bytes, pass by reference.

Parameters
unipolarValuevalue to convert
midiDataLSBreturned MIDI LSB (7 bits are valid)
midiDataMSBreturned MIDI MSB (7 bits are valid)