summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--muse2/muse/importmidi.cpp14
-rw-r--r--muse2/muse/midi.cpp17
-rw-r--r--muse2/muse/midiedit/dcanvas.cpp6
-rw-r--r--muse2/muse/midiedit/dcanvas.h2
-rw-r--r--muse2/muse/midiedit/dlist.cpp6
-rw-r--r--muse2/muse/track.cpp14
-rw-r--r--muse2/muse/track.h5
7 files changed, 42 insertions, 22 deletions
diff --git a/muse2/muse/importmidi.cpp b/muse2/muse/importmidi.cpp
index 593ddb79..90e8cecb 100644
--- a/muse2/muse/importmidi.cpp
+++ b/muse2/muse/importmidi.cpp
@@ -181,7 +181,8 @@ bool MusE::importMidi(const QString name, bool merge)
MusECore::MidiTrack* track = new MusECore::MidiTrack();
if ((*t)->isDrumTrack)
- track->setType(MusECore::Track::DRUM); //FINDMICHJETZT
+ track->setType(MusECore::Track::NEW_DRUM); //FINDMICHJETZT config option
+ //track->setType(MusECore::Track::DRUM);
track->setOutChannel(channel);
track->setOutPort(port);
@@ -200,15 +201,17 @@ bool MusE::importMidi(const QString name, bool merge)
// Hmm. buildMidiEventList already takes care of this.
// But it seems to work. How? Must test.
if (channel == 9 && MusEGlobal::song->mtype() != MT_UNKNOWN) {
- track->setType(MusECore::Track::DRUM); //FINDMICHJETZT
+ track->setType(MusECore::Track::NEW_DRUM); //FINDMICHJETZT config option
+ /*
+ track->setType(MusECore::Track::DRUM);
//
- // remap drum pitch with drumInmap
+ // remap drum pitch with drumOutmap
//
MusECore::EventList* tevents = track->events();
for (MusECore::iEvent i = tevents->begin(); i != tevents->end(); ++i) {
MusECore::Event ev = i->second;
if (ev.isNote()) {
- int pitch = MusEGlobal::drumInmap[ev.pitch()];
+ int pitch = MusEGlobal::drumOutmap[ev.pitch()];
ev.setPitch(pitch);
}
else
@@ -217,9 +220,10 @@ bool MusE::importMidi(const QString name, bool merge)
int ctl = ev.dataA();
MusECore::MidiController *mc = mport->drumController(ctl);
if(mc)
- ev.setA((ctl & ~0xff) | MusEGlobal::drumInmap[ctl & 0x7f]);
+ ev.setA((ctl & ~0xff) | MusEGlobal::drumOutmap[ctl & 0x7f]);
}
}
+ */
}
processTrack(track);
diff --git a/muse2/muse/midi.cpp b/muse2/muse/midi.cpp
index 65bccc70..0138f1d8 100644
--- a/muse2/muse/midi.cpp
+++ b/muse2/muse/midi.cpp
@@ -262,9 +262,7 @@ void buildMidiEventList(EventList* del, const MPEventList* el, MidiTrack* track,
e.setPitch(instr);
}
else
- {
e.setPitch(ev.dataA());
- }
e.setVelo(ev.dataB());
e.setLenTick(0);
@@ -277,6 +275,7 @@ void buildMidiEventList(EventList* del, const MPEventList* el, MidiTrack* track,
}
else
e.setPitch(ev.dataA());
+
e.setVelo(0);
e.setVeloOff(ev.dataB());
e.setLenTick(0);
@@ -751,19 +750,15 @@ void Audio::collectEvents(MusECore::MidiTrack* track, unsigned int cts, unsigned
int pitch = ev.pitch();
int velo = ev.velo();
if (track->type() == Track::DRUM) {
- //
// Map drum-notes to the drum-map values
- //
int instr = ev.pitch();
pitch = MusEGlobal::drumMap[instr].anote;
port = MusEGlobal::drumMap[instr].port; //This changes to non-default port
channel = MusEGlobal::drumMap[instr].channel;
velo = int(double(velo) * (double(MusEGlobal::drumMap[instr].vol) / 100.0)) ;
}
- else { //FINDMICHJETZT don't transpose for new style drum tracks
- //
+ else if (track->type() != Track::NEW_DRUM) {
// transpose non drum notes
- //
pitch += (track->transposition + MusEGlobal::song->globalPitchShift());
}
@@ -985,7 +980,7 @@ void Audio::processMidi()
//
//Apply drum inkey:
- if (track->type() == Track::DRUM) //FINDMICHJETZT schwierig...
+ if (track->type() == Track::DRUM) //FINDMICHJETZT does this work?
{
int pitch = event.dataA();
//Map note that is played according to MusEGlobal::drumInmap
@@ -996,7 +991,11 @@ void Audio::processMidi()
event.setA(MusEGlobal::drumMap[(unsigned int)MusEGlobal::drumInmap[pitch]].anote);
event.setChannel(channel);
}
- else
+ else if (track->type() == Track::NEW_DRUM)
+ {
+ event.setA(track->map_drum_in(event.dataA()));
+ }
+ else
{ //Track transpose if non-drum
prePitch = event.dataA();
int pitch = prePitch + track->transposition;
diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp
index 22db70d0..7daaff29 100644
--- a/muse2/muse/midiedit/dcanvas.cpp
+++ b/muse2/muse/midiedit/dcanvas.cpp
@@ -1306,13 +1306,17 @@ int DrumCanvas::pitch_and_track_to_instrument(int pitch, MusECore::Track* track)
return -1;
}
-void DrumCanvas::propagate_drummap_change(int instr)
+void DrumCanvas::propagate_drummap_change(int instr, bool update_druminmap)
{
const QSet<MusECore::Track*>& tracks=instrument_map[instr].tracks;
int index=instrument_map[instr].pitch;
for (QSet<MusECore::Track*>::const_iterator it = tracks.begin(); it != tracks.end(); it++)
+ {
dynamic_cast<MusECore::MidiTrack*>(*it)->drummap()[index] = ourDrumMap[instr];
+ if (update_druminmap)
+ dynamic_cast<MusECore::MidiTrack*>(*it)->update_drum_in_map();
+ }
}
diff --git a/muse2/muse/midiedit/dcanvas.h b/muse2/muse/midiedit/dcanvas.h
index 581de9d7..2911862e 100644
--- a/muse2/muse/midiedit/dcanvas.h
+++ b/muse2/muse/midiedit/dcanvas.h
@@ -166,7 +166,7 @@ class DrumCanvas : public EventCanvas {
MusECore::DrumMap* getOurDrumMap() { return ourDrumMap; } //FINDMICH UGLY
int getOurDrumMapSize() { return instrument_map.size(); } //FINDMICH UGLY
QVector<instrument_number_mapping_t>& get_instrument_map() { return instrument_map; } //FINDMICH UGLY
- void propagate_drummap_change(int instrument); //FINDMICH move to drumedit
+ void propagate_drummap_change(int instrument, bool update_druminmap); //FINDMICH move to drumedit
void rebuildOurDrumMap();
};
diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp
index 4ad971e7..3399b78e 100644
--- a/muse2/muse/midiedit/dlist.cpp
+++ b/muse2/muse/midiedit/dlist.cpp
@@ -517,7 +517,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev)
}
if (!old_style_drummap_mode && dm_old != *dm) //something changed and we're in new style mode?
- dcanvas->propagate_drummap_change(dm-ourDrumMap);
+ dcanvas->propagate_drummap_change(dm-ourDrumMap, (dm_old.enote != dm->enote));
MusEGlobal::song->update(SC_DRUMMAP);
//redraw(); //this is done by the songChanged slot
@@ -787,7 +787,7 @@ void DList::returnPressed()
}
if (editEntryOld != *editEntry)
- dcanvas->propagate_drummap_change(editEntry-ourDrumMap);
+ dcanvas->propagate_drummap_change(editEntry-ourDrumMap, false);
selectedColumn = -1;
editor->hide();
@@ -854,7 +854,7 @@ void DList::pitchEdited()
}
if (editEntryOld != *editEntry)
- dcanvas->propagate_drummap_change(editEntry-ourDrumMap);
+ dcanvas->propagate_drummap_change(editEntry-ourDrumMap, (editEntryOld.enote!=editEntry->enote));
selectedColumn = -1;
pitch_editor->hide();
diff --git a/muse2/muse/track.cpp b/muse2/muse/track.cpp
index e24ddad9..8f213616 100644
--- a/muse2/muse/track.cpp
+++ b/muse2/muse/track.cpp
@@ -431,6 +431,7 @@ MidiTrack::MidiTrack(const MidiTrack& mt, bool cloneParts)
_drummap_hidden=new bool[128];
memcpy(_drummap, mt._drummap, 128*sizeof(*_drummap));
memcpy(_drummap_hidden, mt._drummap_hidden, 128*sizeof(*_drummap_hidden));
+ update_drum_in_map();
for (MusEGlobal::global_drum_ordering_t::iterator it=MusEGlobal::global_drum_ordering.begin(); it!=MusEGlobal::global_drum_ordering.end(); it++)
if (it->first == &mt)
@@ -495,11 +496,17 @@ void MidiTrack::init_drummap(bool write_ordering)
MusEGlobal::global_drum_ordering.push_back(std::pair<MidiTrack*,int>(this,idx));
}
+ update_drum_in_map();
+
for (int i=0;i<128;i++)
_drummap_hidden[i]=false;
}
-
+void MidiTrack::update_drum_in_map()
+{
+ for (int i=0;i<127;i++)
+ drum_in_map[_drummap[i].enote]=i;
+}
//---------------------------------------------------------
// height
@@ -966,7 +973,7 @@ void MidiTrack::readOurDrumSettings(Xml& xml)
case Xml::TagStart:
if (tag == "tied")
_drummap_tied_to_patch = xml.parseInt();
- else if (tag == "our_drummap")
+ else if (tag == "our_drummap")
readOurDrumMap(xml);
else
xml.unknown("MidiTrack::readOurDrumSettings");
@@ -1068,7 +1075,10 @@ void MidiTrack::readOurDrumMap(Xml& xml)
case Xml::TagEnd:
if (tag == "our_drummap")
+ {
+ update_drum_in_map();
return;
+ }
default:
break;
diff --git a/muse2/muse/track.h b/muse2/muse/track.h
index a958ca74..73f18cc2 100644
--- a/muse2/muse/track.h
+++ b/muse2/muse/track.h
@@ -232,7 +232,8 @@ class MidiTrack : public Track {
DrumMap* _drummap; // _drummap[foo].anote is always equal to foo
bool* _drummap_hidden; // _drummap und _drummap_hidden will be an array[128]
bool _drummap_tied_to_patch; //if true, changing patch also changes drummap
-
+ int drum_in_map[128];
+
void init();
void init_drummap(bool write_ordering=false);
void remove_ourselves_from_drum_ordering();
@@ -311,6 +312,8 @@ class MidiTrack : public Track {
DrumMap* drummap() { return _drummap; }
bool* drummap_hidden() { return _drummap_hidden; }
+ int map_drum_in(int enote) { return drum_in_map[enote]; }
+ void update_drum_in_map();
};
} // namespace MusECore