Mercurial > hg > svcore
changeset 996:0d3d1ec7dfde
Add MIDI channel to note data and MIDI writer
author | Chris Cannam |
---|---|
date | Mon, 13 Oct 2014 10:55:43 +0100 |
parents | 952005e25266 |
children | 2104ea2204d2 |
files | data/fileio/MIDIFileWriter.cpp data/model/NoteData.h |
diffstat | 2 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/data/fileio/MIDIFileWriter.cpp Mon Oct 13 10:00:54 2014 +0100 +++ b/data/fileio/MIDIFileWriter.cpp Mon Oct 13 10:55:43 2014 +0100 @@ -317,7 +317,6 @@ m_numberOfTracks = 1; int track = 0; - int midiChannel = 0; MIDIEvent *event; @@ -349,10 +348,14 @@ int duration = i->duration; int pitch = i->midiPitch; int velocity = i->velocity; + int channel = i->channel; if (pitch < 0) pitch = 0; if (pitch > 127) pitch = 127; + if (channel < 0) channel = 0; + if (channel > 15) channel = 0; + // Convert frame to MIDI time double seconds = double(frame) / double(m_sampleRate); @@ -370,13 +373,13 @@ // in place). event = new MIDIEvent(midiTime, - MIDI_NOTE_ON | midiChannel, + MIDI_NOTE_ON | channel, pitch, velocity); m_midiComposition[track].push_back(event); event = new MIDIEvent(endTime, - MIDI_NOTE_OFF | midiChannel, + MIDI_NOTE_OFF | channel, pitch, 127); // loudest silence you can muster
--- a/data/model/NoteData.h Mon Oct 13 10:00:54 2014 +0100 +++ b/data/model/NoteData.h Mon Oct 13 10:55:43 2014 +0100 @@ -23,14 +23,15 @@ { NoteData(int _start, int _dur, int _mp, int _vel) : start(_start), duration(_dur), midiPitch(_mp), frequency(0), - isMidiPitchQuantized(true), velocity(_vel) { }; + isMidiPitchQuantized(true), velocity(_vel), channel(0) { }; - int start; // audio sample frame - int duration; // in audio sample frames - int midiPitch; // 0-127 + int start; // audio sample frame + int duration; // in audio sample frames + int midiPitch; // 0-127 float frequency; // Hz, to be used if isMidiPitchQuantized false bool isMidiPitchQuantized; - int velocity; // MIDI-style 0-127 + int velocity; // MIDI-style 0-127 + int channel; // MIDI 0-15 float getFrequency() const { if (isMidiPitchQuantized) {