diff options
author | Florian Jung <flo@windfisch.org> | 2011-10-10 12:00:09 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-10-10 12:00:09 +0000 |
commit | 182474fce42414f8f8c5545c4ce822aa5ce73c2c (patch) | |
tree | 72190d062480fdcedeb0079aeb269f3246731a6d /muse2/muse/midiedit/dcanvas.cpp | |
parent | 0e67ba1af056a0df0b6b01c70bb6cb12063479a8 (diff) |
steprec and dlist-enote-changing fixes
steprec now works for new style drum tracks
Diffstat (limited to 'muse2/muse/midiedit/dcanvas.cpp')
-rw-r--r-- | muse2/muse/midiedit/dcanvas.cpp | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp index 7daaff29..3431eabf 100644 --- a/muse2/muse/midiedit/dcanvas.cpp +++ b/muse2/muse/midiedit/dcanvas.cpp @@ -158,7 +158,8 @@ DrumCanvas::~DrumCanvas() if (must_delete_our_drum_map && ourDrumMap!=NULL) delete [] ourDrumMap; - delete steprec; + + delete steprec; } //--------------------------------------------------------- @@ -808,19 +809,22 @@ void DrumCanvas::dragLeaveEvent(QDragLeaveEvent*) // keyPressed - called from DList //--------------------------------------------------------- -void DrumCanvas::keyPressed(int index, int velocity) //FINDMICH later +void DrumCanvas::keyPressed(int index, int velocity) { + using MusECore::MidiTrack; + // called from DList - play event - int port = ourDrumMap[index].port; - int channel = ourDrumMap[index].channel; - int pitch = ourDrumMap[index].anote; + int port = old_style_drummap_mode ? ourDrumMap[index].port : dynamic_cast<MidiTrack*>(*instrument_map[index].tracks.begin())->outPort(); + int channel = old_style_drummap_mode ? ourDrumMap[index].channel : dynamic_cast<MidiTrack*>(*instrument_map[index].tracks.begin())->outChannel(); + int pitch = old_style_drummap_mode ? ourDrumMap[index].anote : instrument_map[index].pitch; // play note: MusECore::MidiPlayEvent e(0, port, channel, 0x90, pitch, velocity); MusEGlobal::audio->msgPlayMidiEvent(&e); - if (_steprec && pos[0] >= start_tick /* && pos[0] < end_tick [removed by flo93: this is handled in steprec->record] */ && curPart) - steprec->record(curPart,index,ourDrumMap[index].len,editor->raster(),velocity,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier); + if (_steprec && pos[0] >= start_tick /* && pos[0] < end_tick [removed by flo93: this is handled in steprec->record] */ && + curPart && instrument_map[index].tracks.contains(curPart->track()) ) + steprec->record(curPart,instrument_map[index].pitch,ourDrumMap[index].len,editor->raster(),velocity,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier, -1 /* invalid pitch as "really played" -> the "insert rest" feature is never triggered */); } @@ -828,12 +832,14 @@ void DrumCanvas::keyPressed(int index, int velocity) //FINDMICH later // keyReleased //--------------------------------------------------------- -void DrumCanvas::keyReleased(int index, bool) //FINDMICH later +void DrumCanvas::keyReleased(int index, bool) { + using MusECore::MidiTrack; + // called from DList - silence playing event - int port = ourDrumMap[index].port; - int channel = ourDrumMap[index].channel; - int pitch = ourDrumMap[index].anote; + int port = old_style_drummap_mode ? ourDrumMap[index].port : dynamic_cast<MidiTrack*>(*instrument_map[index].tracks.begin())->outPort(); + int channel = old_style_drummap_mode ? ourDrumMap[index].channel : dynamic_cast<MidiTrack*>(*instrument_map[index].tracks.begin())->outChannel(); + int pitch = old_style_drummap_mode ? ourDrumMap[index].anote : instrument_map[index].pitch; // release note: MusECore::MidiPlayEvent e(0, port, channel, 0x90, pitch, 0); @@ -1283,7 +1289,7 @@ void DrumCanvas::moveAwayUnused() //--------------------------------------------------------- // midiNote //--------------------------------------------------------- -void DrumCanvas::midiNote(int pitch, int velo) //FINDMICH later. +void DrumCanvas::midiNote(int pitch, int velo) { if (debugMsg) printf("DrumCanvas::midiNote: pitch=%i, velo=%i\n", pitch, velo); @@ -1291,7 +1297,17 @@ void DrumCanvas::midiNote(int pitch, int velo) //FINDMICH later. && !MusEGlobal::audio->isPlaying() && velo && pos[0] >= start_tick /* && pos[0] < end_tick [removed by flo93: this is handled in steprec->record()] */ && !(MusEGlobal::globalKeyState & Qt::AltModifier)) { - steprec->record(curPart,MusEGlobal::drumInmap[pitch],ourDrumMap[(int)MusEGlobal::drumInmap[pitch]].len,editor->raster(),velo,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier); + + int ourDrumMapSize=getOurDrumMapSize(); + int i; + for (i=0;i<ourDrumMapSize;i++) + { + if ( instrument_map[i].tracks.contains(curPart->track()) && ourDrumMap[i].enote==pitch) + break; + } + + if (i!=ourDrumMapSize) + steprec->record(curPart,instrument_map[i].pitch,ourDrumMap[i].len,editor->raster(),velo,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier, pitch); } } |