Update of /cvsroot/lmuse/muse/muse In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18064/muse Modified Files: Makefile.am app.cpp audio.h importmidi.cpp midi.cpp midiport.cpp song.cpp songfile.cpp track.cpp track.h Log Message: drum maps Index: track.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/track.cpp,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** track.cpp 24 May 2005 15:27:57 -0000 1.75 --- track.cpp 26 May 2005 10:52:18 -0000 1.76 *************** *** 803,807 **** len = 100; // percent compression = 100; // percent - _useDrumMap = false; } --- 803,806 ---- *************** *** 832,839 **** MidiTrackBase::writeProperties(xml); - if (useDrumMap()) - xml.intTag("useDrumMap", 1); xml.intTag("locked", _locked); - xml.intTag("transposition", transposition); xml.intTag("velocity", velocity); --- 831,835 ---- *************** *** 876,882 **** else if (tag == "locked") _locked = i; - else if (tag == "useDrumMap") { - _useDrumMap = i; - } else if (MidiTrackBase::readProperties(node)) printf("MusE:MidiTrack: unknown tag %s\n", e.tagName().latin1()); --- 872,875 ---- *************** *** 886,901 **** //--------------------------------------------------------- - // setUseDrumMap - //--------------------------------------------------------- - - void MidiTrack::setUseDrumMap(bool val) - { - if (_useDrumMap != val) { - _useDrumMap = val; - emit useDrumMapChanged(_useDrumMap); - } - } - - //--------------------------------------------------------- // channel //--------------------------------------------------------- --- 879,882 ---- Index: audio.h =================================================================== RCS file: /cvsroot/lmuse/muse/muse/audio.h,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** audio.h 20 May 2005 18:32:15 -0000 1.51 --- audio.h 26 May 2005 10:52:18 -0000 1.52 *************** *** 87,91 **** MS_PROCESS, ! /*26*/ MS_START, MS_STOP, MS_SET_RTC, --- 87,91 ---- MS_PROCESS, ! /*26*/ MS_START, MS_STOP, MS_SET_RTC, *************** *** 182,186 **** void processMsg(AudioMsg* msg); void collectEvents(MidiTrack*, unsigned startTick, unsigned endTick); - void midiPlayTransformation(MidiEvent& event, MidiTrack* track); public: --- 182,185 ---- Index: importmidi.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/importmidi.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** importmidi.cpp 24 May 2005 15:27:57 -0000 1.39 --- importmidi.cpp 26 May 2005 10:52:18 -0000 1.40 *************** *** 123,128 **** MidiTrack* track = new MidiTrack(); ! if ((*t)->isDrumTrack) ! track->setUseDrumMap(true); addRoute(Route(track, -1), Route(outPort->channel(channel), -1)); --- 123,128 ---- MidiTrack* track = new MidiTrack(); ! //TODO3 if ((*t)->isDrumTrack) ! // track->setUseDrumMap(true); addRoute(Route(track, -1), Route(outPort->channel(channel), -1)); *************** *** 143,147 **** } } ! if (channel == 9) { track->setUseDrumMap(true); --- 143,147 ---- } } ! #if 0 //TODO3 if (channel == 9) { track->setUseDrumMap(true); *************** *** 158,161 **** --- 158,162 ---- } } + #endif processTrack(track); if (track->name().isEmpty()) Index: track.h =================================================================== RCS file: /cvsroot/lmuse/muse/muse/track.h,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** track.h 24 May 2005 15:27:57 -0000 1.87 --- track.h 26 May 2005 10:52:19 -0000 1.88 *************** *** 27,30 **** --- 27,31 ---- typedef void* Port; + class DrumMap; class Pipeline; class MidiPipeline; *************** *** 205,209 **** // signal interface: ! void emitControllerChanged(int id) { emit controllerChanged(id); } void updateController(); --- 206,210 ---- // signal interface: ! virtual void emitControllerChanged(int id) { emit controllerChanged(id); } void updateController(); *************** *** 321,332 **** Q_OBJECT - bool _useDrumMap; EventList* _events; // tmp Events during midi import MPEventList* _mpevents; // tmp Events druring recording MREventList _recordEvents; - signals: - void useDrumMapChanged(bool); - public: MidiTrack(); --- 322,329 ---- *************** *** 354,360 **** virtual Part* newPart(Part*p=0, bool clone=false); - bool useDrumMap() const { return _useDrumMap; } - void setUseDrumMap(bool val); - virtual bool isMute() const; virtual bool canRecord() const { return true; } --- 351,354 ---- *************** *** 400,403 **** --- 394,399 ---- Q_OBJECT + DrumMap* _drumMap; + bool _useDrumMap; MidiOutPort* _port; int _channelNo; *************** *** 406,411 **** signals: ! void autoReadChanged(int,bool); ! void autoWriteChanged(int,bool); public: --- 402,407 ---- signals: ! void drumMapChanged(DrumMap*); ! void useDrumMapChanged(bool); public: *************** *** 429,432 **** --- 425,434 ---- // void putEvent(const MidiEvent&); void playMidiEvent(MidiEvent* ev); + + bool useDrumMap() const { return _useDrumMap; } + void setUseDrumMap(bool val); + DrumMap* drumMap() const { return _drumMap; } + + virtual void emitControllerChanged(int id); }; *************** *** 506,510 **** void sendClock(); ! void collectEvents(MidiTrack*, int channel, unsigned cts, unsigned nts); void playEventList(); --- 508,512 ---- void sendClock(); ! void collectEvents(MidiTrack*, MidiChannel*, unsigned cts, unsigned nts); void playEventList(); Index: song.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/song.cpp,v retrieving revision 1.114 retrieving revision 1.115 diff -C2 -d -r1.114 -r1.115 *** song.cpp 24 May 2005 14:08:55 -0000 1.114 --- song.cpp 26 May 2005 10:52:18 -0000 1.115 *************** *** 1437,1441 **** dirty = false; _backupWritten = false; - initDrumMap(); if (signal) { emit loopChanged(false); --- 1437,1440 ---- Index: app.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/app.cpp,v retrieving revision 1.166 retrieving revision 1.167 diff -C2 -d -r1.166 -r1.167 *** app.cpp 24 May 2005 15:27:49 -0000 1.166 --- app.cpp 26 May 2005 10:52:18 -0000 1.167 *************** *** 48,51 **** --- 48,52 ---- #include "midiplugin.h" #include "widgets/menutitle.h" + #include "midiedit/drummap.h" static pthread_t watchdogThread; *************** *** 1368,1374 **** switch (track->type()) { case Track::MIDI: ! if (((MidiTrack*)track)->useDrumMap()) startDrumEditor(pl, true); else startPianoroll(pl, true); break; --- 1369,1376 ---- switch (track->type()) { case Track::MIDI: ! /*TODO3 if (((MidiTrack*)track)->useDrumMap()) startDrumEditor(pl, true); else + */ startPianoroll(pl, true); break; *************** *** 1749,1752 **** --- 1751,1755 ---- initShortCuts(); + gmDrumMap.initGm(); // init default drum map readConfiguration(); QApplication::setFont(config.fonts[0], true); Index: midiport.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/midiport.cpp,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** midiport.cpp 24 May 2005 15:27:57 -0000 1.68 --- midiport.cpp 26 May 2005 10:52:18 -0000 1.69 *************** *** 16,19 **** --- 16,20 ---- #include "driver/alsamidi.h" #include "audio.h" + #include "midiedit/drummap.h" //--------------------------------------------------------- *************** *** 100,109 **** xml.tag("MidiOutPort"); MidiTrackBase::writeProperties(xml); for (int i = 0; i < MIDI_CHANNELS; ++i) { if (!_channel[i]->noInRoute()) _channel[i]->write(xml); } - if (_instrument) - xml.strTag("instrument", _instrument->iname()); xml.etag("MidiOutPort"); } --- 101,110 ---- xml.tag("MidiOutPort"); MidiTrackBase::writeProperties(xml); + if (_instrument) + xml.strTag("instrument", _instrument->iname()); for (int i = 0; i < MIDI_CHANNELS; ++i) { if (!_channel[i]->noInRoute()) _channel[i]->write(xml); } xml.etag("MidiOutPort"); } *************** *** 627,632 **** : MidiTrackBase(MIDI_CHANNEL) { ! _port = p; ! _channelNo = ch; initMidiController(); --- 628,635 ---- : MidiTrackBase(MIDI_CHANNEL) { ! _port = p; ! _channelNo = ch; ! _drumMap = 0; ! _useDrumMap = false; initMidiController(); *************** *** 660,663 **** --- 663,667 ---- xml.tag("MidiChannel idx=\"%d\"", _channelNo); MidiTrackBase::writeProperties(xml); + xml.intTag("useDrumMap", _useDrumMap); xml.etag("MidiChannel"); } *************** *** 669,679 **** void MidiChannel::read(QDomNode node) { while (!node.isNull()) { QDomElement e = node.toElement(); QString tag(e.tagName()); ! if (MidiTrackBase::readProperties(node)) printf("MusE:MidiChannel: unknown tag %s\n", tag.latin1()); node = node.nextSibling(); } } --- 673,692 ---- void MidiChannel::read(QDomNode node) { + QString drumMapName; while (!node.isNull()) { QDomElement e = node.toElement(); QString tag(e.tagName()); ! if (tag == "useDrumMap") ! _useDrumMap = e.text().toInt(); ! else if (MidiTrackBase::readProperties(node)) printf("MusE:MidiChannel: unknown tag %s\n", tag.latin1()); node = node.nextSibling(); } + MidiOutPort* op = port(); + if (op) { + MidiInstrument* mi = op->instrument(); + int val = ctrlVal(CTRL_PROGRAM).i; + _drumMap = mi->getDrumMap(val); + } } *************** *** 693,694 **** --- 706,752 ---- } + //--------------------------------------------------------- + // setUseDrumMap + //--------------------------------------------------------- + + void MidiChannel::setUseDrumMap(bool val) + { + if (_useDrumMap != val) { + _useDrumMap = val; + if (_useDrumMap) { + int val = ctrlVal(CTRL_PROGRAM).i; + MidiOutPort* op = port(); + MidiInstrument* mi = op->instrument(); + DrumMap* dm = mi->getDrumMap(val); + if (dm == 0) + dm = &gmDrumMap; + _drumMap = dm; + } + else + _drumMap = &noDrumMap; + emit drumMapChanged(_drumMap); + emit useDrumMapChanged(_useDrumMap); + } + } + + //--------------------------------------------------------- + // emitControllerChanged + //--------------------------------------------------------- + + void MidiChannel::emitControllerChanged(int id) + { + if (id == CTRL_PROGRAM && _useDrumMap) { + int val = ctrlVal(id).i; + MidiOutPort* op = port(); + MidiInstrument* mi = op->instrument(); + DrumMap* dm = mi->getDrumMap(val); + if (dm == 0) + dm = &gmDrumMap; + if (dm != _drumMap) { + _drumMap = dm; + emit drumMapChanged(_drumMap); + } + } + emit controllerChanged(id); + } + Index: songfile.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/songfile.cpp,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** songfile.cpp 20 May 2005 13:58:45 -0000 1.50 --- songfile.cpp 26 May 2005 10:52:18 -0000 1.51 *************** *** 292,296 **** else if (tag == "drumtrack") { MidiTrack* track = new MidiTrack(); ! track->setUseDrumMap(true); track->read(node.firstChild()); insertTrack0(track, -1); --- 292,296 ---- else if (tag == "drumtrack") { MidiTrack* track = new MidiTrack(); ! //TODO track->setUseDrumMap(true); track->read(node.firstChild()); insertTrack0(track, -1); *************** *** 359,364 **** setPos(Song::RPOS, p, false, false, false); } ! else if (tag == "drummap") ! readDrumMap(node.firstChild(), false); else if (tag == "snGen") Part::setsnGen(i); --- 359,364 ---- setPos(Song::RPOS, p, false, false, false); } ! // else if (tag == "drummap") ! // readDrumMap(node.firstChild(), false); else if (tag == "snGen") Part::setsnGen(i); *************** *** 419,423 **** _markerList->write(xml); ! writeDrumMap(xml, false); xml.intTag("snGen", Part::getsnGen()); xml.etag("song"); --- 419,423 ---- _markerList->write(xml); ! // writeDrumMap(xml, false); xml.intTag("snGen", Part::getsnGen()); xml.etag("song"); Index: Makefile.am =================================================================== RCS file: /cvsroot/lmuse/muse/muse/Makefile.am,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Makefile.am 11 May 2005 14:18:39 -0000 1.30 --- Makefile.am 26 May 2005 10:52:02 -0000 1.31 *************** *** 92,95 **** --- 92,96 ---- muse_LDADD = \ + instruments/libinstruments.a \ midiedit/libmidiedit.a \ ctrl/libctrl.a \ *************** *** 102,106 **** mplugins/libmplugins.a \ arranger/libarranger.a \ - instruments/libinstruments.a \ widgets/libwidgets.a \ ../awl/libawl.a \ --- 103,106 ---- Index: midi.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/midi.cpp,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** midi.cpp 23 May 2005 17:30:10 -0000 1.84 --- midi.cpp 26 May 2005 10:52:18 -0000 1.85 *************** *** 198,203 **** e.setType(Note); ! if (track->useDrumMap()) { ! int instr = drumInmap[ev.dataA()]; e.setPitch(instr); } --- 198,203 ---- e.setType(Note); ! if (mc && mc->useDrumMap()) { ! int instr = mc->drumMap()->inmap(ev.dataA()); e.setPitch(instr); } *************** *** 210,215 **** case ME_NOTEOFF: e.setType(Note); ! if (track->useDrumMap()) { ! int instr = drumInmap[ev.dataA()]; e.setPitch(instr); } --- 210,215 ---- case ME_NOTEOFF: e.setType(Note); ! if (mc && mc->useDrumMap()) { ! int instr = mc->drumMap()->inmap(ev.dataA()); e.setPitch(instr); } *************** *** 560,571 **** //--------------------------------------------------------- ! void Audio::midiPlayTransformation(MidiEvent& event, MidiTrack* track) { if (event.isNote()) { ! if (track->useDrumMap()) { int a = event.dataA(); ! event.setA(drumMap[a].anote); ! //TODO3 event.setPort(drumMap[a].port); ! event.setChannel(drumMap[a].channel); } else { --- 560,572 ---- //--------------------------------------------------------- ! static void midiPlayTransformation(MidiEvent& event, MidiChannel* mc, MidiTrack* track) { if (event.isNote()) { ! if (mc->useDrumMap()) { int a = event.dataA(); ! event.setA(mc->drumMap()->anote(a)); ! int ch = mc->drumMap()->channel(a); ! if (ch != -1) ! event.setChannel(ch); } else { *************** *** 594,598 **** //--------------------------------------------------------- ! void MidiOutPort::collectEvents(MidiTrack* track, int channel, unsigned cts, unsigned nts) { if (cts > nts) { --- 595,599 ---- //--------------------------------------------------------- ! void MidiOutPort::collectEvents(MidiTrack* track, MidiChannel* mc, unsigned cts, unsigned nts) { if (cts > nts) { *************** *** 600,603 **** --- 601,606 ---- return; } + int channel = mc->channelNo(); + DrumMap* dm = mc->drumMap(); PartList* pl = track->parts(); for (iPart p = pl->begin(); p != pl->end(); ++p) { *************** *** 620,624 **** continue; // ignore muted drums ! if (track->useDrumMap() && ev.isNote() && drumMap[ev.pitch()].mute) continue; unsigned tick = ev.tick() + offset; --- 623,627 ---- continue; // ignore muted drums ! if (mc->useDrumMap() && ev.isNote() && dm->mute(ev.pitch())) continue; unsigned tick = ev.tick() + offset; *************** *** 627,638 **** int len = ev.lenTick(); int pitch = ev.pitch(); ! if (track->useDrumMap()) { // // Map drum-notes to the drum-map values // int instr = ev.pitch(); ! pitch = drumMap[instr].anote; ! //TODO3 port = drumMap[instr].port; //This changes to non-default port ! channel = drumMap[instr].channel; } else { --- 630,640 ---- int len = ev.lenTick(); int pitch = ev.pitch(); ! if (mc->useDrumMap()) { // // Map drum-notes to the drum-map values // int instr = ev.pitch(); ! pitch = dm->anote(instr); ! channel = dm->channel(instr); } else { *************** *** 744,748 **** continue; if (isPlaying()) ! md->collectEvents(track, ch, curTickPos, nextTickPos); // // process recorded events --- 746,750 ---- continue; if (isPlaying()) ! md->collectEvents(track, mc, curTickPos, nextTickPos); // // process recorded events *************** *** 753,758 **** MidiEvent event(*ie); ! if (event.isNote() && track->useDrumMap()) { ! event.setA(drumMap[drumInmap[event.dataA()]].enote); } event.setChannel(ch); --- 755,761 ---- MidiEvent event(*ie); ! if (event.isNote() && mc->useDrumMap()) { ! DrumMap* dm = mc->drumMap(); ! event.setA(dm->enote(dm->inmap(event.dataA()))); } event.setChannel(ch); *************** *** 765,769 **** } if (track->monitor()) { ! midiPlayTransformation(event, track); unsigned time = eventTime + segmentSize*(segmentCount-1); --- 768,772 ---- } if (track->monitor()) { ! midiPlayTransformation(event, mc, track); unsigned time = eventTime + segmentSize*(segmentCount-1); |