summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Schweer <ws.seh.de>2008-06-29 13:54:54 +0000
committerWerner Schweer <ws.seh.de>2008-06-29 13:54:54 +0000
commit014ef14ff862750a21e3538fc51bf7f6e6e1816e (patch)
treee2aa1d7570497822a8da8945c6085b341e03addd
parente36628d09315ac5ff226771c1799f9712dd30e76 (diff)
send proper note offs at stop
-rw-r--r--muse/ChangeLog2
-rw-r--r--muse/muse/audio.cpp8
-rw-r--r--muse/muse/midievent.cpp1
-rw-r--r--muse/muse/midiout.cpp5
-rw-r--r--muse/muse/midioutport.cpp66
-rw-r--r--muse/muse/synth.cpp9
6 files changed, 15 insertions, 76 deletions
diff --git a/muse/ChangeLog b/muse/ChangeLog
index 6c6a0185..dc8f38a3 100644
--- a/muse/ChangeLog
+++ b/muse/ChangeLog
@@ -1,3 +1,5 @@
+29.6. (ws)
+ - fix sending proper note off's at stop
27.6. (ws)
JACK cleanups and implementation of JACK midi input
25.6. (ws)
diff --git a/muse/muse/audio.cpp b/muse/muse/audio.cpp
index 7238c2c1..1ad9eefc 100644
--- a/muse/muse/audio.cpp
+++ b/muse/muse/audio.cpp
@@ -279,9 +279,11 @@ printf("JACK: shutdown callback\n");
void Audio::process(unsigned frames, int jackState)
{
-// _seqTime.lastFrameTime = audioDriver->lastFrameTime();
_seqTime.lastFrameTime = audioDriver->frameTime();
+ for (iMidiOutPort i = song->midiOutPorts()->begin(); i != song->midiOutPorts()->end(); ++i)
+ audioDriver->startMidiCycle((*i)->jackPort(0));
+
//
// process messages from gui
//
@@ -417,9 +419,6 @@ void Audio::process(unsigned frames, int jackState)
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)
@@ -506,7 +505,6 @@ void Audio::process(unsigned frames, int jackState)
_seqTime.pos += frames;
_seqTime.curTickPos = _seqTime.nextTickPos;
}
-// midiDriver->updateConnections();
}
//---------------------------------------------------------
diff --git a/muse/muse/midievent.cpp b/muse/muse/midievent.cpp
index 88539a1c..80fd30a8 100644
--- a/muse/muse/midievent.cpp
+++ b/muse/muse/midievent.cpp
@@ -126,3 +126,4 @@ bool MidiEvent::operator<(const MidiEvent& e) const
int map[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15 };
return map[channel()] < map[e.channel()];
}
+
diff --git a/muse/muse/midiout.cpp b/muse/muse/midiout.cpp
index db9789c3..c35f115f 100644
--- a/muse/muse/midiout.cpp
+++ b/muse/muse/midiout.cpp
@@ -249,10 +249,11 @@ void MidiOut::stop()
// stop all notes
//---------------------------------------------------
+ int time = audio->seqTime()->lastFrameTime;
for (iMidiEvent i = _schedEvents.begin(); i != _schedEvents.end(); ++i) {
MidiEvent ev = *i;
if (ev.isNoteOff()) {
- ev.setTime(0);
+ ev.setTime(time);
track->routeEvent(ev);
}
}
@@ -272,7 +273,7 @@ void MidiOut::stop()
Ctrl* c = ic->second;
if (c->id() == CTRL_SUSTAIN) {
if (c->curVal().i > 0) {
- MidiEvent ev(0, dstChannel, ME_CONTROLLER, c->id(), 0);
+ MidiEvent ev(time, dstChannel, ME_CONTROLLER, c->id(), 0);
track->routeEvent(ev);
c->setCurVal(0);
}
diff --git a/muse/muse/midioutport.cpp b/muse/muse/midioutport.cpp
index 06c247d1..695f51a6 100644
--- a/muse/muse/midioutport.cpp
+++ b/muse/muse/midioutport.cpp
@@ -51,8 +51,6 @@ MidiOutPort::MidiOutPort()
MidiOutPort::~MidiOutPort()
{
-// for (int ch = 0; ch < MIDI_CHANNEL; ++ch)
-// delete _channel[ch];
}
//---------------------------------------------------------
@@ -62,12 +60,8 @@ MidiOutPort::~MidiOutPort()
void MidiOutPort::setName(const QString& s)
{
Track::setName(s);
-// if (!alsaPort().isZero())
-// midiDriver->setPortName(alsaPort(), s);
if (!jackPort().isZero())
audioDriver->setPortName(jackPort(), s);
-// for (int ch = 0; ch < MIDI_CHANNELS; ++ch)
-// _channel[ch]->setDefaultName();
}
//---------------------------------------------------------
@@ -80,10 +74,6 @@ void MidiOutPort::write(Xml& xml) const
MidiTrackBase::writeProperties(xml);
if (_instrument)
xml.tag("instrument", _instrument->iname());
-// for (int i = 0; i < MIDI_CHANNELS; ++i) {
-// if (!_channel[i]->noInRoute())
-// _channel[i]->write(xml);
-// }
xml.tag("sendSync", sendSync());
xml.tag("deviceId", deviceId());
xml.etag("MidiOutPort");
@@ -98,10 +88,6 @@ void MidiOutPort::read(QDomNode node)
for (; !node.isNull(); node = node.nextSibling()) {
QDomElement e = node.toElement();
QString tag(e.tagName());
-// if (tag == "MidiChannel") {
-// int idx = e.attribute("idx", "0").toInt();
-// _channel[idx]->read(node.firstChild());
-// }
if (tag == "instrument") {
QString iname = e.text();
_instrument = registerMidiInstrument(iname);
@@ -122,14 +108,10 @@ void MidiOutPort::read(QDomNode node)
void MidiOutPort::routeEvent(const MidiEvent& event)
{
for (iRoute r = _outRoutes.begin(); r != _outRoutes.end(); ++r) {
- switch (r->dst.type) {
- case RouteNode::JACKMIDIPORT:
- queueJackEvent(event);
- break;
- default:
- fprintf(stderr, "MidiOutPort::process(): invalid routetype\n");
- break;
- }
+ if (r->dst.type == RouteNode::JACKMIDIPORT)
+ queueJackEvent(event);
+ else
+ fprintf(stderr, "MidiOutPort::process(): invalid routetype\n");
}
}
@@ -150,7 +132,7 @@ void MidiOutPort::queueJackEvent(const MidiEvent& ev)
if (a == CTRL_PITCH) {
int v = b + 8192;
- JO(MidiEvent(t, chn, ME_PITCHBEND, v & 0x7f, (v >> 7) & 0x7f));
+ audioDriver->putEvent(jackPort(0), MidiEvent(t, chn, ME_PITCHBEND, v & 0x7f, (v >> 7) & 0x7f));
}
else if (a == CTRL_PROGRAM) {
// don't output program changes for GM drum channel
@@ -239,40 +221,6 @@ void MidiOutPort::setInstrument(MidiInstrument* i)
emit instrumentChanged();
}
-#if 0
-//---------------------------------------------------------
-// processMidiClock
-//---------------------------------------------------------
-
-void MidiSeq::processMidiClock()
- {
- if (genMCSync)
- midiPorts[txSyncPort].sendClock();
- if (state == START_PLAY) {
- // start play on sync
- state = PLAY;
- _midiTick = playTickPos;
- midiClock = playTickPos;
-
- int bar, beat, tick;
- sigmap.tickValues(_midiTick, &bar, &beat, &tick);
- midiClick = sigmap.bar2tick(bar, beat+1, 0);
-
- double cpos = tempomap.tick2time(playTickPos);
- samplePosStart = samplePos - lrint(cpos * sampleRate);
- rtcTickStart = rtcTick - lrint(cpos * realRtcTicks);
-
- endSlice = playTickPos;
- lastTickPos = playTickPos;
-
- tempoSN = tempomap.tempoSN();
-
- startRecordPos.setPosTick(playTickPos);
- }
- midiClock += config.division/24;
- }
-#endif
-
//-------------------------------------------------------------------
// process
// Collect all midi events for the current process cycle and put
@@ -280,8 +228,7 @@ void MidiSeq::processMidiClock()
// note off events. The note off events maybe played after the
// current process cycle.
// From _schedEvents queue copy all events for the current cycle
-// to all output routes. Events routed to ALSA go into the
-// _playEvents queue which is processed by the MidiSeq thread.
+// to all output routes.
//-------------------------------------------------------------------
void MidiOutPort::processMidi(const SeqTime* t)
@@ -313,4 +260,3 @@ void MidiOutPort::processMidi(const SeqTime* t)
addMidiMeter(portVelo);
}
-
diff --git a/muse/muse/synth.cpp b/muse/muse/synth.cpp
index 67673d24..bbec5e34 100644
--- a/muse/muse/synth.cpp
+++ b/muse/muse/synth.cpp
@@ -367,11 +367,6 @@ void SynthI::write(Xml& xml) const
AudioTrack::writeProperties(xml);
xml.tag("class", synth()->name());
-// for (int i = 0; i < MIDI_CHANNELS; ++i) {
-// if (!_channel[i]->noInRoute())
-// _channel[i]->write(xml);
-// }
-
//---------------------------------------------
// if soft synth is attached to a midi port,
// write out port number
@@ -437,10 +432,6 @@ void SynthI::read(QDomNode node)
}
else if (tag == "geometry")
r = AL::readGeometry(node);
-// else if (tag == "MidiChannel") {
-// int idx = e.attribute("idx", "0").toInt();
-// _channel[idx]->read(node.firstChild());
-// }
else if (AudioTrack::readProperties(node)) {
printf("MusE:SynthI: unknown tag %s\n", e.tagName().toLatin1().data());
}