# HG changeset patch # User Chris Cannam # Date 1413194143 -3600 # Node ID 0d3d1ec7dfde245d78e06bcfe30ef9579196ff65 # Parent 952005e252668fecdee23fed6227c52ba28cf0a3 Add MIDI channel to note data and MIDI writer diff -r 952005e25266 -r 0d3d1ec7dfde data/fileio/MIDIFileWriter.cpp --- 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 diff -r 952005e25266 -r 0d3d1ec7dfde data/model/NoteData.h --- 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) {