summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Schweer <ws.seh.de>2006-10-24 20:17:30 +0000
committerWerner Schweer <ws.seh.de>2006-10-24 20:17:30 +0000
commit1fa1e5ede877626f6e29cfd42f4d9679723aa1ea (patch)
treef08c8c04aab5fa6e72d1f66421405321d9fbfaf6
parente1e11546e52d4a87fc25a2a891ee6e74e39bed97 (diff)
updates
-rw-r--r--muse/TODO11
-rw-r--r--muse/muse/audio.cpp2
-rw-r--r--muse/muse/audio.h2
-rw-r--r--muse/muse/midi.cpp4
-rw-r--r--muse/muse/midioutport.cpp159
-rw-r--r--muse/muse/midioutport.h8
-rw-r--r--muse/muse/midiseq.cpp11
-rw-r--r--muse/muse/route.cpp12
-rw-r--r--muse/share/instruments/xg.idf6
-rw-r--r--muse/share/templates/CMakeLists.txt1
10 files changed, 88 insertions, 128 deletions
diff --git a/muse/TODO b/muse/TODO
index 48b6c643..ef350f87 100644
--- a/muse/TODO
+++ b/muse/TODO
@@ -1,14 +1,13 @@
-----------------------------TODO-------------------------------------------
* - done
-(28.6.2006)
+(24.10.2006)
----------------------------------------------------------------------------
- - check for samplerate when loading project
- * compute song len in seconds when saving project
- * save project creation date/time in project
- * create dialog to edit project comment
-
BUGS
+ - fix song len after importing midi
+ - set song "dirty" after importing midi
+ - update midi gm template
+
- updating the gui during midi recording is too slow;
a new, faster implementation is needed
diff --git a/muse/muse/audio.cpp b/muse/muse/audio.cpp
index f88a1934..53f72664 100644
--- a/muse/muse/audio.cpp
+++ b/muse/muse/audio.cpp
@@ -435,7 +435,7 @@ void Audio::process(unsigned frames, int jackState)
for (iMidiOutPort i = mol->begin(); i != mol->end(); ++i)
audioDriver->startMidiCycle((*i)->jackPort(0));
- processMidi(frames);
+ processMidi();
GroupList* gl = song->groups();
SynthIList* sl = song->syntis();
diff --git a/muse/muse/audio.h b/muse/muse/audio.h
index 3a0eacbd..19f76b9b 100644
--- a/muse/muse/audio.h
+++ b/muse/muse/audio.h
@@ -194,7 +194,7 @@ class Audio {
Pos endRecordPos;
void process(unsigned frames, int jackState);
- void processMidi(unsigned frames);
+ void processMidi();
bool sync(int state, unsigned frame);
void shutdown();
diff --git a/muse/muse/midi.cpp b/muse/muse/midi.cpp
index 8e15b9d4..3bab9108 100644
--- a/muse/muse/midi.cpp
+++ b/muse/muse/midi.cpp
@@ -639,12 +639,12 @@ void Audio::initDevices()
// Process one time slice of midi events
//---------------------------------------------------------
-void Audio::processMidi(unsigned frames)
+void Audio::processMidi()
{
midiBusy = true;
MidiOutPortList* ol = song->midiOutPorts();
for (iMidiOutPort id = ol->begin(); id != ol->end(); ++id) {
- (*id)->process(_curTickPos, _nextTickPos, _pos, frames);
+ (*id)->process(_curTickPos, _nextTickPos);
}
MidiInPortList* il = song->midiInPorts();
diff --git a/muse/muse/midioutport.cpp b/muse/muse/midioutport.cpp
index bc3b7968..845f6feb 100644
--- a/muse/muse/midioutport.cpp
+++ b/muse/muse/midioutport.cpp
@@ -39,7 +39,6 @@ MidiOutPort::MidiOutPort()
_instrument = genericMidiInstrument;
for (int ch = 0; ch < MIDI_CHANNELS; ++ch)
_channel[ch] = new MidiChannel(this, ch);
- _nextPlayEvent = _playEvents.end();
_sendSync = false;
_deviceId = 127; // all
addMidiController(_instrument, CTRL_MASTER_VOLUME);
@@ -47,16 +46,6 @@ MidiOutPort::MidiOutPort()
}
//---------------------------------------------------------
-// playFifo
-//---------------------------------------------------------
-
-void MidiOutPort::playFifo()
- {
- while (!eventFifo.isEmpty())
- putEvent(eventFifo.get());
- }
-
-//---------------------------------------------------------
// MidiOutPort
//---------------------------------------------------------
@@ -128,9 +117,12 @@ void MidiOutPort::read(QDomNode node)
//---------------------------------------------------------
// putEvent
-// send event to midi driver
+// send event to alsa midi driver
+// called from MidiSeq::processTimerTick
//---------------------------------------------------------
+#define playEvent(a) midiDriver->putEvent(alsaPort(), a);
+
void MidiOutPort::putEvent(const MidiEvent& ev)
{
if (ev.type() == ME_CONTROLLER) {
@@ -154,7 +146,7 @@ void MidiOutPort::putEvent(const MidiEvent& ev)
}
if (a == CTRL_PITCH) {
- routeEvent(MidiEvent(0, chn, ME_PITCHBEND, b, 0));
+ playEvent(MidiEvent(0, chn, ME_PITCHBEND, b, 0));
return;
}
if (a == CTRL_PROGRAM) {
@@ -164,10 +156,10 @@ void MidiOutPort::putEvent(const MidiEvent& ev)
int lb = (b >> 8) & 0xff;
int pr = b & 0x7f;
if (hb != 0xff)
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HBANK, hb));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HBANK, hb));
if (lb != 0xff)
- midiDriver->putEvent(alsaPort(), MidiEvent(0, chn, ME_CONTROLLER, CTRL_LBANK, lb));
- routeEvent(MidiEvent(0, chn, ME_PROGRAM, pr, 0));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_LBANK, lb));
+ playEvent(MidiEvent(0, chn, ME_PROGRAM, pr, 0));
return;
// }
}
@@ -179,73 +171,63 @@ void MidiOutPort::putEvent(const MidiEvent& ev)
sysex[4] = b & 0x7f;
sysex[5] = (b >> 7) & 0x7f;
MidiEvent e(ev.time(), ME_SYSEX, sysex, 6);
- routeEvent(e);
+ playEvent(e);
return;
}
#if 1 // if ALSA cannot handle RPN NRPN etc.
if (a < 0x1000) { // 7 Bit Controller
//putMidiEvent(MidiEvent(0, chn, ME_CONTROLLER, a, b));
- routeEvent(ev);
+ playEvent(ev);
}
else if (a < 0x20000) { // 14 bit high resolution controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
int dataH = (b >> 7) & 0x7f;
int dataL = b & 0x7f;
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, ctrlH, dataH));
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, ctrlL, dataL));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, ctrlH, dataH));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, ctrlL, dataL));
}
else if (a < 0x30000) { // RPN 7-Bit Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL));
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HDATA, b));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HDATA, b));
}
else if (a < 0x40000) { // NRPN 7-Bit Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HDATA, b));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HDATA, b));
}
else if (a < 0x60000) { // RPN14 Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
int dataH = (b >> 7) & 0x7f;
int dataL = b & 0x7f;
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL));
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HDATA, dataH));
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_LDATA, dataL));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HDATA, dataH));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_LDATA, dataL));
}
else if (a < 0x70000) { // NRPN14 Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
int dataH = (b >> 7) & 0x7f;
int dataL = b & 0x7f;
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HDATA, dataH));
- routeEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_LDATA, dataL));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_HDATA, dataH));
+ playEvent(MidiEvent(0, chn, ME_CONTROLLER, CTRL_LDATA, dataL));
}
else {
printf("putEvent: unknown controller type 0x%x\n", a);
}
#endif
}
- routeEvent(ev);
- }
-
-//---------------------------------------------------------
-// playEventList
-//---------------------------------------------------------
-
-void MidiOutPort::playEventList()
- {
- for (; _nextPlayEvent != _playEvents.end(); ++_nextPlayEvent)
- routeEvent(*_nextPlayEvent);
+ playEvent(ev);
}
//---------------------------------------------------------
@@ -403,20 +385,19 @@ void MidiOutPort::playMidiEvent(MidiEvent* ev)
//---------------------------------------------------------
// process
// "play" events for this process cycle
+// from/to are midi ticks
// if (from != to) then transport state is "playing"
//---------------------------------------------------------
-void MidiOutPort::process(unsigned from, unsigned to, const Pos& pos, unsigned frames)
+void MidiOutPort::process(unsigned from, unsigned to)
{
- //
- // erase already played events:
- //
- _playEvents.erase(_playEvents.begin(), _nextPlayEvent);
- playFifo();
-
if (mute())
return;
+ MPEventList el;
+ while (!eventFifo.isEmpty())
+ el.add(eventFifo.get());
+
// collect port controller
if (from != to) {
CtrlList* cl = controller();
@@ -429,7 +410,7 @@ void MidiOutPort::process(unsigned from, unsigned to, const Pos& pos, unsigned f
Event ev(Controller);
ev.setA(c->id());
ev.setB(ic->second.i);
- _playEvents.add(MidiEvent(frame, -1, ev));
+ el.add(MidiEvent(frame, -1, ev));
}
}
}
@@ -452,7 +433,7 @@ void MidiOutPort::process(unsigned from, unsigned to, const Pos& pos, unsigned f
Event ev(Controller);
ev.setA(c->id());
ev.setB(is->second.i);
- _playEvents.add(MidiEvent(frame, ch, ev));
+ el.add(MidiEvent(frame, ch, ev));
}
}
}
@@ -463,13 +444,13 @@ void MidiOutPort::process(unsigned from, unsigned to, const Pos& pos, unsigned f
MidiTrackBase* track = (MidiTrackBase*)i->track;
if (track->isMute())
continue;
- MPEventList el;
- track->getEvents(from, to, 0, &el);
+ MPEventList ell;
+ track->getEvents(from, to, 0, &ell);
int velo = 0;
- for (iMPEvent i = el.begin(); i != el.end(); ++i) {
+ for (iMPEvent i = ell.begin(); i != ell.end(); ++i) {
MidiEvent ev(*i);
ev.setChannel(ch);
- _playEvents.insert(ev);
+ el.insert(ev);
if (ev.type() == ME_NOTEON)
velo += ev.dataB();
}
@@ -479,29 +460,30 @@ void MidiOutPort::process(unsigned from, unsigned to, const Pos& pos, unsigned f
}
addMidiMeter(portVelo);
- // TODO: maybe this copying can be avoided
- //
- MPEventList il;
- for (iMPEvent i = _playEvents.begin(); i != _playEvents.end(); ++i) {
- il.add(*i);
- }
- _playEvents.clear();
- pipeline()->apply(from, to, &il, &_playEvents);
-
- _nextPlayEvent = _playEvents.begin();
+ MPEventList ol;
+ pipeline()->apply(from, to, &el, &ol);
//
// route events to destination
//
- unsigned endFrame = pos.frame() + frames;
- iMPEvent is = _playEvents.begin();
- iMPEvent ie = _playEvents.end();
-
- for (_nextPlayEvent = is; _nextPlayEvent != ie; _nextPlayEvent++) {
- if ((from != to) && (_nextPlayEvent->time() >= endFrame))
- break;
- routeEvent(*_nextPlayEvent);
+ for (iMPEvent i = ol.begin(); i != ol.end(); ++i) {
+ for (iRoute r = _outRoutes.begin(); r != _outRoutes.end(); ++r) {
+ switch (r->type) {
+ case Route::MIDIPORT:
+ _playEvents.add(*i); // schedule
+ break;
+ case Route::SYNTIPORT:
+ ((SynthI*)(r->track))->playEvents()->insert(*i);
+ break;
+ case Route::JACKMIDIPORT:
+ audioDriver->putEvent(jackPort(0), *i);
+ break;
+ default:
+ fprintf(stderr, "MidiOutPort::process(): invalid routetype\n");
+ break;
+ }
+ }
}
}
@@ -524,28 +506,3 @@ void MidiOutPort::setSendSync(bool val)
_sendSync = val;
emit sendSyncChanged(val);
}
-
-//---------------------------------------------------------
-// routeEvent
-//---------------------------------------------------------
-
-void MidiOutPort::routeEvent(const MidiEvent& event)
- {
- for (iRoute r = _outRoutes.begin(); r != _outRoutes.end(); ++r) {
- switch (r->type) {
- case Route::MIDIPORT:
- midiDriver->putEvent(alsaPort(0), event);
- break;
- case Route::SYNTIPORT:
- ((SynthI*)(r->track))->playEvents()->insert(event);
- break;
- case Route::JACKMIDIPORT:
- audioDriver->putEvent(jackPort(0), event);
- break;
- default:
- fprintf(stderr, "MidiOutPort::process(): invalid routetype\n");
- break;
- }
- }
- }
-
diff --git a/muse/muse/midioutport.h b/muse/muse/midioutport.h
index 9999a92d..70e3c97c 100644
--- a/muse/muse/midioutport.h
+++ b/muse/muse/midioutport.h
@@ -37,7 +37,6 @@ class MidiOutPort : public MidiTrackBase {
int _deviceId; // 0-126; 127 == all
MPEventList _playEvents; // scheduled events to play
- iMPEvent _nextPlayEvent;
// fifo for midi events send from gui
// direct to midi port:
@@ -72,12 +71,9 @@ class MidiOutPort : public MidiTrackBase {
void putEvent(const MidiEvent&);
MPEventList* playEvents() { return &_playEvents; }
- iMPEvent nextPlayEvent() { return _nextPlayEvent; }
- void process(unsigned from, unsigned to, const AL::Pos&, unsigned frames);
+ void process(unsigned from, unsigned to);
- void setNextPlayEvent(iMPEvent i) { _nextPlayEvent = i; }
- void playFifo();
void playMidiEvent(MidiEvent*);
void sendSysex(const unsigned char*, int);
@@ -90,8 +86,6 @@ class MidiOutPort : public MidiTrackBase {
void sendContinue();
void sendClock();
- void playEventList();
-
bool sendSync() const { return _sendSync; }
void setSendSync(bool val);
diff --git a/muse/muse/midiseq.cpp b/muse/muse/midiseq.cpp
index 3072d784..f569237d 100644
--- a/muse/muse/midiseq.cpp
+++ b/muse/muse/midiseq.cpp
@@ -162,7 +162,6 @@ void MidiSeq::processStop()
}
}
pel->clear();
- md->setNextPlayEvent(pel->begin());
}
//---------------------------------------------------
@@ -274,8 +273,8 @@ void MidiSeq::processSeek()
}
el->clear();
}
- else
- el->erase(el->begin(), op->nextPlayEvent());
+// else
+// el->erase(el->begin(), op->nextPlayEvent());
for (int ch = 0; ch < MIDI_CHANNELS; ++ch) {
MidiChannel* mc = op->channel(ch);
if (mc->mute() || mc->noInRoute() || !mc->autoRead())
@@ -289,7 +288,7 @@ void MidiSeq::processSeek()
}
}
}
- op->setNextPlayEvent(op->playEvents()->begin());
+// op->setNextPlayEvent(op->playEvents()->begin());
}
}
@@ -534,14 +533,14 @@ void MidiSeq::processTimerTick()
for (iMidiOutPort id = ol->begin(); id != ol->end(); ++id) {
MidiOutPort* mp = *id;
MPEventList* el = mp->playEvents();
- iMPEvent i = mp->nextPlayEvent();
+ iMPEvent i = el->begin();
for (; i != el->end(); ++i) {
if (i->time() > curFrame)
break;
mp->putEvent(*i);
}
- mp->setNextPlayEvent(i);
+ el->erase(el->begin(), i);
}
}
diff --git a/muse/muse/route.cpp b/muse/muse/route.cpp
index 8748f009..39f9a802 100644
--- a/muse/muse/route.cpp
+++ b/muse/muse/route.cpp
@@ -280,12 +280,16 @@ void Song::readRoute(QDomNode n)
else
printf("MusE:readRoute: unknown tag %s\n", e.tagName().toLatin1().data());
}
- if (!s.isValid()) { // source port not found
- printf("invalid source port\n");
+ if (!s.isValid()) { // source port not found?
+ printf("Song::readRoute(): invalid source port: %s.%d:<%s> - %s.%d:<%s>\n",
+ s.tname(), s.channel, s.name().toLatin1().data(),
+ d.tname(), d.channel, d.name().toLatin1().data());
return;
}
- if (!d.isValid()) { // destination port not found
- printf("invalid destination port\n");
+ if (!d.isValid()) { // destination port not found?
+ printf("Song::readRoute(): invalid destination port: %s.%d:<%s> - %s.%d:<%s>\n",
+ s.tname(), s.channel, s.name().toLatin1().data(),
+ d.tname(), d.channel, d.name().toLatin1().data());
return;
}
diff --git a/muse/share/instruments/xg.idf b/muse/share/instruments/xg.idf
index 2d3a895a..29628e90 100644
--- a/muse/share/instruments/xg.idf
+++ b/muse/share/instruments/xg.idf
@@ -2,6 +2,12 @@
<muse version="1.0">
<MidiInstrument name="XG">
<Init>
+ <event tick="0" type="2" datalen="4">
+ 7e 7f 09 01
+ </event>
+ <event tick="0" type="2" datalen="7">
+ 43 10 4c 00 00 7e 00
+ </event>
</Init>
<PatchGroup name="Piano">
<Patch name="Grand Piano" hbank="0" lbank="0" prog="0"/>
diff --git a/muse/share/templates/CMakeLists.txt b/muse/share/templates/CMakeLists.txt
index 2a8b3527..9c8a8c17 100644
--- a/muse/share/templates/CMakeLists.txt
+++ b/muse/share/templates/CMakeLists.txt
@@ -25,5 +25,6 @@ install_files ( /share/${MusE_INSTALL_NAME}/templates .med
midiGM.med
monorecord.med
synti.med
+ ns5r.med
)