summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--muse/muse/audio.cpp6
-rw-r--r--muse/muse/midioutport.h2
-rw-r--r--muse/muse/miditrack.cpp32
-rw-r--r--muse/muse/miditrack.h3
-rw-r--r--muse/muse/synth.h2
-rw-r--r--muse/muse/track.h1
6 files changed, 33 insertions, 13 deletions
diff --git a/muse/muse/audio.cpp b/muse/muse/audio.cpp
index 124506a3..aa58b30d 100644
--- a/muse/muse/audio.cpp
+++ b/muse/muse/audio.cpp
@@ -306,7 +306,6 @@ printf("JACK: shutdown callback\n");
void Audio::process(unsigned frames, int jackState)
{
-// printf("process %d\n", frames);
extern int watchAudio;
++watchAudio; // make a simple watchdog happy
@@ -441,15 +440,20 @@ void Audio::process(unsigned frames, int jackState)
{
MidiOutPortList* ol = song->midiOutPorts();
MidiInPortList* mil = song->midiInPorts();
+ MidiTrackList* mtl = song->midis();
for (iMidiOutPort i = ol->begin(); i != ol->end(); ++i)
audioDriver->startMidiCycle((*i)->jackPort(0));
+
for (iMidiInPort i = mil->begin(); i != mil->end(); ++i)
(*i)->beforeProcess();
+ for (iMidiTrack i = mtl->begin(); i != mtl->end(); ++i)
+ (*i)->processMidi(_curTickPos, _nextTickPos, _pos.frame(), _pos.frame() + segmentSize);
for (iMidiOutPort i = ol->begin(); i != ol->end(); ++i)
(*i)->processMidi(_curTickPos, _nextTickPos, _pos.frame(), _pos.frame() + segmentSize);
for (iSynthI i = sl->begin(); i != sl->end(); ++i)
(*i)->processMidi(_curTickPos, _nextTickPos, _pos.frame(), _pos.frame() + segmentSize);
+
for (iMidiInPort i = mil->begin(); i != mil->end(); ++i)
(*i)->afterProcess();
}
diff --git a/muse/muse/midioutport.h b/muse/muse/midioutport.h
index 75620283..aa056db5 100644
--- a/muse/muse/midioutport.h
+++ b/muse/muse/midioutport.h
@@ -57,7 +57,7 @@ class MidiOutPort : public MidiTrackBase, public MidiOut {
bool guiVisible() const;
bool hasGui() const;
- void processMidi(unsigned fromTick, unsigned toTick, unsigned fromFrame, unsigned toFrame);
+ virtual void processMidi(unsigned fromTick, unsigned toTick, unsigned fromFrame, unsigned toFrame);
};
typedef QList<MidiOutPort*> MidiOutPortList;
diff --git a/muse/muse/miditrack.cpp b/muse/muse/miditrack.cpp
index e10cacf3..b7e3a53d 100644
--- a/muse/muse/miditrack.cpp
+++ b/muse/muse/miditrack.cpp
@@ -224,8 +224,8 @@ void MidiTrack::recordBeat()
unsigned time = me.time();
if (song->punchin() && time < song->lpos())
continue;
- bool isOff = (me.type() == ME_NOTEON && me.dataB() == 0)
- || (me.type() == ME_NOTEOFF);
+ bool isOff = me.isNoteOff();
+
if (song->punchout() && (time >= song->rpos()) && !isOff)
continue;
@@ -466,12 +466,12 @@ bool MidiTrack::isMute() const
}
//---------------------------------------------------------
-// getEvents
-// from/to - midi ticks
+// processMidi
//---------------------------------------------------------
-void MidiTrack::getEvents(unsigned from, unsigned to, int, MidiEventList* dst)
+void MidiTrack::processMidi(unsigned from, unsigned to, unsigned, unsigned)
{
+ schedEvents.clear();
//
// collect events only when transport is rolling
//
@@ -524,14 +524,14 @@ void MidiTrack::getEvents(unsigned from, unsigned to, int, MidiEventList* dst)
int veloOff = ev.veloOff();
unsigned eframe = AL::tempomap.tick2frame(tick+elen);
- dst->insert(MidiEvent(frame, 0, ME_NOTEON, pitch, velo));
- dst->insert(MidiEvent(eframe, 0, veloOff ? ME_NOTEOFF : ME_NOTEON, pitch, veloOff));
+ schedEvents.insert(MidiEvent(frame, 0, ME_NOTEON, pitch, velo));
+ schedEvents.insert(MidiEvent(eframe, 0, veloOff ? ME_NOTEOFF : ME_NOTEON, pitch, veloOff));
_meter[0] += velo/2;
if (_meter[0] > 127.0f)
_meter[0] = 127.0f;
}
else {
- dst->insert(MidiEvent(frame, 0, ev));
+ schedEvents.insert(MidiEvent(frame, 0, ev));
}
}
}
@@ -578,7 +578,7 @@ void MidiTrack::getEvents(unsigned from, unsigned to, int, MidiEventList* dst)
}
unsigned time = 0; // eventTime + segmentSize*(segmentCount-1);
event.setTime(time);
- dst->insert(event);
+ schedEvents.insert(event);
}
}
}
@@ -594,12 +594,24 @@ void MidiTrack::getEvents(unsigned from, unsigned to, int, MidiEventList* dst)
Event ev(Controller);
ev.setA(c->id());
ev.setB(ic.value().i);
- dst->insert(MidiEvent(frame, -1, ev));
+ schedEvents.insert(MidiEvent(frame, -1, ev));
}
}
}
//---------------------------------------------------------
+// getEvents
+// from/to - midi ticks
+//---------------------------------------------------------
+
+void MidiTrack::getEvents(unsigned from, unsigned to, int, MidiEventList* dst)
+ {
+ for (iMidiEvent i = schedEvents.begin(); i != schedEvents.end(); ++i) {
+ dst->insert(*i);
+ }
+ }
+
+//---------------------------------------------------------
// emitControllerChanged
//---------------------------------------------------------
diff --git a/muse/muse/miditrack.h b/muse/muse/miditrack.h
index de7723a1..d8b0d231 100644
--- a/muse/muse/miditrack.h
+++ b/muse/muse/miditrack.h
@@ -59,6 +59,8 @@ class MidiTrack : public MidiTrackBase {
int _len;
int _compression;
+ MidiEventList schedEvents; // scheduled events by process()
+
signals:
void drumMapChanged() const;
void useDrumMapChanged(bool);
@@ -99,6 +101,7 @@ class MidiTrack : public MidiTrackBase {
virtual bool canRecord() const { return true; }
void playMidiEvent(MidiEvent*);
+ virtual void processMidi(unsigned fromTick, unsigned toTick, unsigned fromFrame, unsigned toFrame);
virtual void getEvents(unsigned from, unsigned to, int channel, MidiEventList* dst);
bool useDrumMap() const { return _useDrumMap; }
diff --git a/muse/muse/synth.h b/muse/muse/synth.h
index 62ae5c05..109a9994 100644
--- a/muse/muse/synth.h
+++ b/muse/muse/synth.h
@@ -178,7 +178,7 @@ class SynthI : public AudioTrack, public MidiOut, public MidiInstrument
void deactivate3();
bool isActivated() const { return synthesizer && _sif; }
virtual bool hasAuxSend() const { return _sif->hasAuxSend(); }
- void processMidi(unsigned fromTick, unsigned toTick, unsigned fromFrame, unsigned toFrame);
+ virtual void processMidi(unsigned fromTick, unsigned toTick, unsigned fromFrame, unsigned toFrame);
virtual MidiOut* midiOut() { return this; }
virtual MidiInstrument* instrument() { return this; }
diff --git a/muse/muse/track.h b/muse/muse/track.h
index d71a9e64..1953e5a6 100644
--- a/muse/muse/track.h
+++ b/muse/muse/track.h
@@ -351,6 +351,7 @@ class MidiTrackBase : public Track {
void addPlugin(MidiPluginI* plugin, int idx);
MidiPluginI* plugin(int idx) const;
+ virtual void processMidi(unsigned, unsigned, unsigned, unsigned) {}
virtual void getEvents(unsigned /*from*/, unsigned /*to*/, int /*channel*/, MidiEventList* /*dst*/) {}
};