EM MIDI Arduino Lib 1.0.1
Loading...
Searching...
No Matches
em::Midi Class Reference

Midi is a driver class for the MIDI module, used for synthesizing music. More...

#include <midi.h>

Public Member Functions

 Midi (Stream &stream)
 Constructor.
 
void NoteOn (const uint8_t channel, const uint8_t midi_note, const uint8_t z)
 Generate the given MIDI note on the designated channel (0-15).
 
void NoteOff (const uint8_t channel, const uint8_t midi_note)
 Close the note in the specified channel, which was previously opened at a given pitch using the noteOn() command.
 
void SetChannelTimbre (const uint8_t channel, const uint8_t bank, const uint8_t timbre)
 Change the tone of the specified channel. Among them, channel 9 is a dedicated drum channel, and the timbre and notes of channel 9 can be found in reference midi_percussion_note.h .
 
void PitchBend (const uint8_t channel, uint16_t pitch_bend_value)
 Bend the pitch upwards or downwards, with a default swing of+/-1 semitone.
 
void PitchBendRange (const uint8_t channel, const uint8_t pitch_bend_range_value)
 Set the pitch bend range (sensitivity).
 
void MidiReset ()
 MIDI system reset sends MIDI system reset command (0xFF) to reset all connected MIDI devices to their initial state.
 
void ChannelAllNotesOff (const uint8_t channel)
 Send a noteOff() for each note on the specified channel.
 
void SetChannelVolume (const uint8_t channel, const uint8_t volume)
 Set specific channel volume.
 
void SetAllChannelVolume (const uint8_t volume)
 Set the volume for all channels.
 
void SetReverberation (const uint8_t channel, const uint8_t reverberation_type, const uint8_t reverberation_volume, const uint8_t delay_feedback)
 Apply reverberation effect to the specified channel.
 
void SetChorus (const uint8_t channel, const uint8_t chorus_effect_type, const uint8_t chorus_effect_volume, const uint8_t chorus_effect_feedback, const uint8_t chorus_delay_time)
 Apply a chorus effect to a specified channel.
 
void SetPanPosition (const uint8_t channel, const uint8_t pan_position_value)
 Set the pan position.
 
void SetEqualizer (const uint8_t channel, const EqualizerParameter &equalizer_parameter)
 Set up a four segment equalizer.
 
void SetTuning (const uint8_t channel, const uint8_t fine_tuning, const uint8_t coarse_tuning)
 Set tone (coarse/fine).
 
void SetVibrato (const uint8_t channel, const uint8_t vibrato_rate, const uint8_t vibrato_depth, const uint8_t vibrato_delay_modify)
 Set vibrato parameters.
 
void SetTimeVaryingFilter (const uint8_t channel, const uint8_t cutoff, const uint8_t resonance)
 Set Time Varying Filter (TVF).
 
void SetEnvelope (const uint8_t channel, const uint8_t attack_time, const uint8_t attenuation_time, const uint8_t release_time)
 Set envelope parameters.
 
void SetScaleTuning (const uint8_t channel, const ScaleTuningParameter &scale_tuning_parameter)
 Set the 12 scale tuning parameters for the specified MIDI channel (independent pitch offset for each semitone).
 
void SetModulationWheel (const uint8_t channel, const ModulationWheelParameter &modulation_wheel_parameter)
 Set modulation wheel parameters and configure multiple control effects for modulation wheel sound.
 
void AllDrums ()
 Activate all drum channels and set all 16 MIDI channels (0-15) as drum channels.
 

Detailed Description

Midi is a driver class for the MIDI module, used for synthesizing music.

Examples
drum_pattern_player.ino, and play_music.ino.

Definition at line 335 of file midi.h.

Constructor & Destructor Documentation

◆ Midi()

em::Midi::Midi ( Stream & stream)

Constructor.

Parameters
streamA data stream reference used for MIDI communication.

Definition at line 5 of file midi.cpp.

Member Function Documentation

◆ AllDrums()

void em::Midi::AllDrums ( )

Activate all drum channels and set all 16 MIDI channels (0-15) as drum channels.

Definition at line 203 of file midi.cpp.

◆ ChannelAllNotesOff()

void em::Midi::ChannelAllNotesOff ( const uint8_t channel)

Send a noteOff() for each note on the specified channel.

Parameters
channelDesignated channel (0-15).

Definition at line 50 of file midi.cpp.

◆ MidiReset()

void em::Midi::MidiReset ( )

MIDI system reset sends MIDI system reset command (0xFF) to reset all connected MIDI devices to their initial state.

Definition at line 46 of file midi.cpp.

◆ NoteOff()

void em::Midi::NoteOff ( const uint8_t channel,
const uint8_t midi_note )

Close the note in the specified channel, which was previously opened at a given pitch using the noteOn() command.

Parameters
channelDesignated channel (0-15).
midi_noteMIDI notes (0-127), please refer to midi_note.h for reference; Among them, for the notes of channel 9, please refer to midi_percussion_note.h.
Examples
drum_pattern_player.ino, and play_music.ino.

Definition at line 13 of file midi.cpp.

◆ NoteOn()

void em::Midi::NoteOn ( const uint8_t channel,
const uint8_t midi_note,
const uint8_t z )

Generate the given MIDI note on the designated channel (0-15).

Parameters
channelDesignated channel (0-15).
midi_noteMIDI notes (0-127), please refer to midi_note.h for reference; Among them, for the notes of channel 9, please refer to midi_percussion_note.h.
note_velocityNote velocity (0-127), controls the volume and tone brightness of notes, on a keyboard this corresponds to how hard the key,0: silent (equivalent to noteOff), 1-126: from weak to strong, 127: maximum strength.
Examples
drum_pattern_player.ino, and play_music.ino.

Definition at line 8 of file midi.cpp.

◆ PitchBend()

void em::Midi::PitchBend ( const uint8_t channel,
uint16_t pitch_bend_value )

Bend the pitch upwards or downwards, with a default swing of+/-1 semitone.

Parameters
channelDesignated channel (0-15).
pitch_bend_valuePitch bend value (0-1023), 0: maximum downward bend, 512: center position (no bend), 1023: maximum upward bend.

Definition at line 31 of file midi.cpp.

◆ PitchBendRange()

void em::Midi::PitchBendRange ( const uint8_t channel,
const uint8_t pitch_bend_range_value )

Set the pitch bend range (sensitivity).

Parameters
channelDesignated channel (0-15).
pitch_bend_range_valuePitch bend range value (number of semitones, 0-127), typical value: 1-24 (semitones), default value: 2 (± 2 semitones).

Definition at line 40 of file midi.cpp.

◆ SetAllChannelVolume()

void em::Midi::SetAllChannelVolume ( const uint8_t volume)

Set the volume for all channels.

Parameters
volumeVolume level (0-127), 0: mute, 127: maximum volume.

Definition at line 60 of file midi.cpp.

◆ SetChannelTimbre()

void em::Midi::SetChannelTimbre ( const uint8_t channel,
const uint8_t bank,
const uint8_t timbre )

Change the tone of the specified channel. Among them, channel 9 is a dedicated drum channel, and the timbre and notes of channel 9 can be found in reference midi_percussion_note.h .

Parameters
channelDesignated channels (0-15), where channel 9 is a dedicated drum group channel.
bankSelection of timbre library, with parameter values of MIDI_BANK_0 or MIDI_BANK_127.
timbreTimbre number (0-127), please refer to the macro in reference midi_timbre.h (e.g. EM_MIDI_TIMBRE_BANK_0_GRAND_PIANO); Among them, for the timbre of channel 9, please refer to midi_percussion_note.h .

Definition at line 18 of file midi.cpp.

◆ SetChannelVolume()

void em::Midi::SetChannelVolume ( const uint8_t channel,
const uint8_t volume )

Set specific channel volume.

Parameters
channelDesignated channel (0-15).
volumeVolume level (0-127), 0: mute, 127: maximum volume.

Definition at line 55 of file midi.cpp.

◆ SetChorus()

void em::Midi::SetChorus ( const uint8_t channel,
const uint8_t chorus_effect_type,
const uint8_t chorus_effect_volume,
const uint8_t chorus_effect_feedback,
const uint8_t chorus_delay_time )

Apply a chorus effect to a specified channel.

Parameters
channelDesignated channel (0-15).
chorus_effect_typechorus effect type, refer to macros in midi_chorus_reverberation.h (e.g., EM_MIDI_CHORUS_1).
chorus_effect_volumechorus effect sending volume (0-127), 0: none, 127: maximum sending volume.
chorus_effect_feedbackEffect feedback amount (0-127, 0 means not set).
chorus_delay_timechorus delay time (0-127, 0 indicates not set), unit: ms.

Definition at line 80 of file midi.cpp.

◆ SetEnvelope()

void em::Midi::SetEnvelope ( const uint8_t channel,
const uint8_t attack_time,
const uint8_t attenuation_time,
const uint8_t release_time )

Set envelope parameters.

Parameters
channelDesignated channel (0-15).
attack_timeAttack time (0-127) - controls the time for the sound to reach its maximum amplitude from zero, unit: ms.
attenuation_timeAttenuation time (0-127) - controls the time for sound to decay from maximum amplitude to maintain a level, unit: ms.
release_timeRelease time (0-127) - controls the time it takes for the volume to decay to zero after the note is released, unit: ms.

Definition at line 139 of file midi.cpp.

◆ SetEqualizer()

void em::Midi::SetEqualizer ( const uint8_t channel,
const EqualizerParameter & equalizer_parameter )

Set up a four segment equalizer.

Parameters
channelDesignated channel (0-15).
equalizer_parameterEqualizer parameters structure.

Definition at line 104 of file midi.cpp.

◆ SetModulationWheel()

void em::Midi::SetModulationWheel ( const uint8_t channel,
const ModulationWheelParameter & modulation_wheel_parameter )

Set modulation wheel parameters and configure multiple control effects for modulation wheel sound.

Parameters
channelDesignated channel (0-15).
modulation_wheel_parameterModulation wheel parameters structure.

Definition at line 173 of file midi.cpp.

◆ SetPanPosition()

void em::Midi::SetPanPosition ( const uint8_t channel,
const uint8_t pan_position_value )

Set the pan position.

Parameters
channelDesignated channel (0-15).
pan_position_valuepan position value (0-127), 0: far left (completely left channel), 64: center position (balanced left and right channel),127: far right (completely right channel).

Definition at line 99 of file midi.cpp.

◆ SetReverberation()

void em::Midi::SetReverberation ( const uint8_t channel,
const uint8_t reverberation_type,
const uint8_t reverberation_volume,
const uint8_t delay_feedback )

Apply reverberation effect to the specified channel.

Parameters
channelDesignated channel (0-15).
reverberation_typeReverberation type, refer to macros in midi_chorus_reverberation.h (e.g., EM_MIDI_REVERBERATION_ROOM_1).
reverberation_volumeReverberation transmission amount (0-127), 0: no reverberation, 127: maximum reverberation amount.
delay_feedbackDelayed feedback quantity (0-127), 0: no feedback, 127: maximum feedback.

Definition at line 65 of file midi.cpp.

◆ SetScaleTuning()

void em::Midi::SetScaleTuning ( const uint8_t channel,
const ScaleTuningParameter & scale_tuning_parameter )

Set the 12 scale tuning parameters for the specified MIDI channel (independent pitch offset for each semitone).

Parameters
channelDesignated channel (0-15).
scale_tuning_parameterSet the 12 scale tuning parameters(C, C#, D, D#, E, F, F#, G, G#, A, A#, B) for the specified channel (independent pitch offset for each semitone).

Definition at line 147 of file midi.cpp.

◆ SetTimeVaryingFilter()

void em::Midi::SetTimeVaryingFilter ( const uint8_t channel,
const uint8_t cutoff,
const uint8_t resonance )

Set Time Varying Filter (TVF).

Parameters
channelDesignated channel (0-15).
cutoffCut off frequency value (0-127) - controls the frequency range that the filter passes through.
resonanceResonance peak/resonance value (0-127) - Control the gain of the filter near the cutoff frequency.

Definition at line 132 of file midi.cpp.

◆ SetTuning()

void em::Midi::SetTuning ( const uint8_t channel,
const uint8_t fine_tuning,
const uint8_t coarse_tuning )

Set tone (coarse/fine).

Parameters
channelDesignated channel (0-15).
fine_tuningFine tuning value (0-127), affecting subtle changes in pitch.
coarse_tuningCoarse tuning values (0-127), affect the octave variation of pitch.

Definition at line 117 of file midi.cpp.

◆ SetVibrato()

void em::Midi::SetVibrato ( const uint8_t channel,
const uint8_t vibrato_rate,
const uint8_t vibrato_depth,
const uint8_t vibrato_delay_modify )

Set vibrato parameters.

Parameters
channelDesignated channel (0-15).
vibrato_rateVibrato rate (0-127) - controls the speed of vibrato oscillation.
vibrato_depthVibrato depth (0-127) - controls the amplitude of vibrato oscillation.
vibrato_delay_modifyVibrato Delay Modification (0-127) - Control the delay time before the start of vibrato.

Definition at line 124 of file midi.cpp.


The documentation for this class was generated from the following files: