-
Notifications
You must be signed in to change notification settings - Fork 1
midi transpose
senso edited this page Jun 22, 2026
·
2 revisions
#example #midi #simple
MIDI note transposition utility.
| Module Name | midi transpose |
| Type | mtSimple |
| Color | clMIDIModuleColor |
| Source | examples/MidiTranspose/ |
Transposes incoming MIDI note messages by a specified number of semitones. Demonstrates MIDI event processing using TUsineMidiCode and array-based MIDI access.
| # | Name | Type | I/O | Range | Details |
|---|---|---|---|---|---|
| 0 | in |
ptMidi |
Input | — | MIDI input stream |
| 1 | out |
ptMidi |
Output | — | Transposed MIDI output |
| 2 | pitch |
ptDataFader |
Input | -127 – +127 ht | Transposition amount (IsStoredInPreset) |
In onProcess:
- Copies MIDI input to output
- Iterates through each MIDI message in the event
- For NOTEON and NOTEOFF messages, adds the pitch offset to Data1 (note number)
- Clamps the result to 0–127
for (int i = 0; i < size; i++)
{
TUsineMidiCode code = midiOut.getArrayMidi(i);
if (code.Msg == MIDI_NOTEON || code.Msg == MIDI_NOTEOFF)
{
int note = code.Data1 + (int)pitch;
code.Data1 = std::clamp(note, 0, 127);
midiOut.setArrayMidi(i, code);
}
}-
ptMidiparameter type for MIDI streams -
TUsineMidiCodestructure: Channel, Msg, Data1, Data2 -
getArrayMidi/setArrayMidifor MIDI event access -
MIDI constants:
MIDI_NOTEON,MIDI_NOTEOFF - Process-driven module (no callbacks needed for the main logic)
-
IsStoredInPresetfor pitch offset persistence
onGetModuleInfo · onGetParamInfo · onProcess
- DataMultiply — Simple data processing
- AudioVolume — Audio stream processing