summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2013-08-20 15:48:55 +0200
committerFlorian Jung <flo@windfisch.org>2013-08-20 15:48:55 +0200
commitd308ae99892b9413da9f134347e84746dea0a943 (patch)
tree4b0f6d78223738c89e3a2495eb8049de8ed3876e
parent013294f58a6433671da3b34775de5a3a7ea91464 (diff)
clean disabled code in midiseq
-rw-r--r--muse2/muse/midiseq.cpp256
-rw-r--r--muse2/muse/midiseq.h1
2 files changed, 3 insertions, 254 deletions
diff --git a/muse2/muse/midiseq.cpp b/muse2/muse/midiseq.cpp
index 8aa6c289..a3537e25 100644
--- a/muse2/muse/midiseq.cpp
+++ b/muse2/muse/midiseq.cpp
@@ -162,35 +162,12 @@ void MidiSeq::processStop()
// TODO Try to move this into Audio::stopRolling().
playStateExt = false; // not playing
- //
- // clear Alsa midi device notes and stop stuck notes
- //
+ // clear Alsa midi device notes and stop stuck notes
for(iMidiDevice id = MusEGlobal::midiDevices.begin(); id != MusEGlobal::midiDevices.end(); ++id)
- {
- //MidiDevice* md = *id; DELETETHIS 3
- // Only ALSA devices are handled by this thread.
- //if((*id)->deviceType() == MidiDevice::ALSA_MIDI)
(*id)->handleStop();
- /* DELETETHIS 14
- if (md->midiPort() == -1)
- continue;
- MPEventList* pel = md->playEvents();
- MPEventList* sel = md->stuckNotes();
- pel->clear();
- for(iMPEvent i = sel->begin(); i != sel->end(); ++i)
- {
- MidiPlayEvent ev = *i;
- ev.setTime(0);
- pel->add(ev);
- }
- sel->clear();
- //md->setNextPlayEvent(pel->begin()); // Removed p4.0.15
- */
- }
}
#endif
-#if 1 //DELETETHIS #if and #endif
//---------------------------------------------------------
// processSeek
//---------------------------------------------------------
@@ -202,62 +179,8 @@ void MidiSeq::processSeek()
//---------------------------------------------------
for (iMidiDevice i = MusEGlobal::midiDevices.begin(); i != MusEGlobal::midiDevices.end(); ++i)
- {
- //MidiDevice* md = *i; DELETETHIS 3
- // Only ALSA devices are handled by this thread.
- //if((*i)->deviceType() == MidiDevice::ALSA_MIDI)
(*i)->handleSeek();
- /* DELETETHIS 47
- int port = md->midiPort();
- if (port == -1)
- continue;
- MidiPort* mp = &MusEGlobal::midiPorts[port];
- MidiCtrlValListList* cll = mp->controller();
-
- MPEventList* el = md->playEvents();
-
- if (MusEGlobal::audio->isPlaying())
- {
- // stop all notes
- el->clear();
- MPEventList* sel = dev->stuckNotes();
- for (iMPEvent i = sel->begin(); i != sel->end(); ++i)
- {
- MidiPlayEvent ev = *i;
- ev.setTime(0);
- el->add(ev);
- }
- sel->clear();
- }
- //else
- // Removed p4.0.15 Device now leaves beginning pointing at next event,
- // immediately after playing some notes.
- // NOTE: This removal needs testing. I'm not sure about this.
- //el->erase(el->begin(), dev->nextPlayEvent());
-
- for (iMidiCtrlValList ivl = cll->begin(); ivl != cll->end(); ++ivl)
- {
- MidiCtrlValList* vl = ivl->second;
- //int val = vl->value(pos);
- //if (val != CTRL_VAL_UNKNOWN) {
- // int channel = ivl->first >> 24;
- // el->add(MidiPlayEvent(0, port, channel, ME_CONTROLLER, vl->num(), val));
- // }
- iMidiCtrlVal imcv = vl->iValue(pos);
- if(imcv != vl->end())
- {
- Part* p = imcv->second.part;
- unsigned t = (unsigned)imcv->first;
- // Do not add values that are outside of the part.
- if(p && t >= p->tick() && t < (p->tick() + p->lenTick()) )
- el->add(MidiPlayEvent(0, port, ivl->first >> 24, ME_CONTROLLER, vl->num(), imcv->second.val));
- }
- }
- //dev->setNextPlayEvent(el->begin()); // Removed p4.0.15
- */
- }
}
-#endif
//---------------------------------------------------------
// MidiSeq
@@ -346,22 +269,6 @@ signed int MidiSeq::selectTimer()
void MidiSeq::threadStart(void*)
{
- // Removed by Tim. p3.3.17 DELETETHIS 13
- /*
- struct sched_param rt_param;
- memset(&rt_param, 0, sizeof(rt_param));
- int prio_min = sched_get_priority_min(SCHED_FIFO);
- int prio_max = sched_get_priority_max(SCHED_FIFO);
-
- if (prio < prio_min) prio = prio_min;
- else if (prio > prio_max) prio = prio_max;
-
- rt_param.sched_priority = prio;
- int rv = pthread_setschedparam(pthread_self(), SCHED_FIFO, &rt_param);
- if (rv != 0)
- perror("set realtime scheduler");
- */
-
int policy;
if ((policy = sched_getscheduler (0)) < 0) {
printf("Cannot get current client scheduler: %s\n", strerror(errno));
@@ -391,19 +298,6 @@ static void midiRead(void*, void* d)
dev->processInput();
}
-// DELETETHIS 12
-//---------------------------------------------------------
-// synthIRead
-//---------------------------------------------------------
-
-#if 0
-static void synthIRead(void*, void* d)
- {
- SynthI* syn = (SynthI*) d;
- syn->processInput();
- }
-#endif
-
//---------------------------------------------------------
// midiWrite
//---------------------------------------------------------
@@ -583,42 +477,6 @@ void MidiSeq::setSyncRecFilterPreset(MidiSyncInfo::SyncRecFilterPresetType type)
}
-//---------------------------------------------------------
-// processMidiClock
-//---------------------------------------------------------
-
-void MidiSeq::processMidiClock()
- {
- // DELETETHIS 30, maybe remove entire function?
-// if (genMCSync) {
-// MusEGlobal::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 = MusEGlobal::tempomap.tick2time(playTickPos);
- samplePosStart = samplePos - lrint(cpos * MusEGlobal::sampleRate);
- rtcTickStart = rtcTick - lrint(cpos * realRtcTicks);
-
- endSlice = playTickPos;
- recTick = playTickPos;
- lastTickPos = playTickPos;
-
- tempoSN = MusEGlobal::tempomap.tempoSN();
-
- startRecordPos.setPosTick(playTickPos);
- }
-*/
-// midiClock += MusEGlobal::config.division/24;
- }
//---------------------------------------------------------
// midiTick
@@ -691,126 +549,18 @@ void MidiSeq::processTimerTick()
mp->sendClock();
}
- // DELETETHIS 35 ??
- /*
- for(iMidiDevice imd = MusEGlobal::midiDevices.begin(); imd != MusEGlobal::midiDevices.end(); ++imd)
- {
- MidiDevice* dev = *imd;
-
- if(!dev->syncInfo().MCOut())
- continue;
-
- // Shall we check open flags?
- //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
- //if(!(dev->openFlags() & 1))
- // continue;
-
- int port = dev->midiPort();
- // Without this -1 check, interesting sync things can be done by the user without ever
- // assigning any devices to ports !
- //if(port < 0 || port > MIDI_PORTS)
- if(port < -1 || port > MIDI_PORTS)
- continue;
-
- if(port == -1)
- // Send straight to the device... Copied from MidiPort.
- {
- MidiPlayEvent event(0, 0, 0, ME_CLOCK, 0, 0);
- dev->putEvent(event);
- }
- else
- // Go through the port...
- MusEGlobal::midiPorts[port].sendClock();
- }
- */
-
if(MusEGlobal::debugMsg && used && perr > 1)
printf("Dropped %d midi out clock(s). curTick:%d midiClock:%d div:%d\n", perr, curTick, midiClock, div);
- //} DELETETHIS and maybe the below ???
-
- // Increment as if we had caught the timer exactly on the mark, even if the timer
- // has passed beyond the mark, or even beyond 2 * div.
- // If we missed some chances to send clock, resume the count where it would have been,
- // had we not missed chances.
- // We can't do anything about missed chances except send right away, and make up
- // for gained time by losing time in the next count...
- // In other words, use equalization periods to counter gained/lost time, so that
- // ultimately, over time, the receiver remains in phase, despite any short dropouts / phase glitches.
- // (midiClock only increments by div units).
- //
- // Tested: With midi thread set to high priority, very few clock dropouts ocurred (P4 1.6Ghz).
- // But target device tick drifts out of phase with muse tick slowly over time, say 20 bars or so.
- // May need more tweaking, possibly use round with/instead of lrint (above), and/or
- // do not use equalization periods - set midiClock to fractions of div.
- // Tested: With RTC resolution at 1024, stability was actually better than with 8192!
- // It stayed in sync more than 64 bars...
- //
- //
+
// Using equalization periods...
midiClock += (perr * div);
- //midiClock += perr; DELETETHIS
- //
- // No equalization periods... TODO: or DELETETHIS?
- //midiClock += (perr * div);
}
}
// play all events upto curFrame
- for (iMidiDevice id = MusEGlobal::midiDevices.begin(); id != MusEGlobal::midiDevices.end(); ++id) {
- //MidiDevice* md = *id; DELETETHIS 10
- // Is it a Jack midi device? They are iterated in Audio::processMidi. p3.3.36
- //MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(md);
- //if(mjd)
- //if(md->deviceType() == MidiDevice::JACK_MIDI)
- // continue;
- //if(md->isSynti()) // syntis are handled by audio thread
- // continue;
- // Only ALSA midi devices are handled by this thread.
+ for (iMidiDevice id = MusEGlobal::midiDevices.begin(); id != MusEGlobal::midiDevices.end(); ++id)
if((*id)->deviceType() == MidiDevice::ALSA_MIDI)
(*id)->processMidi();
-
- // Moved into MidiAlsaDevice. p4.0.34 DELETETHIS 40
- /*
- int port = md->midiPort();
- MidiPort* mp = port != -1 ? &MusEGlobal::midiPorts[port] : 0;
- MPEventList* el = md->playEvents();
- if (el->empty())
- continue;
-
- ///iMPEvent i = md->nextPlayEvent();
- iMPEvent i = el->begin(); // p4.0.15 Tim.
-
- for (; i != el->end(); ++i) {
- // p3.3.25
- // If syncing to external midi sync, we cannot use the tempo map.
- // Therefore we cannot get sub-tick resolution. Just use ticks instead of frames.
- //if (i->time() > curFrame) {
- if (i->time() > (extsync ? tickpos : curFrame)) {
- //printf(" curT %d frame %d\n", i->time(), curFrame);
- break; // skip this event
- }
-
- if (mp) {
- if (mp->sendEvent(*i))
- break;
- }
- else {
- if (md->putEvent(*i))
- break;
- }
- }
- ///md->setNextPlayEvent(i);
- // p4.0.15 We are done with these events. Let us erase them here instead of Audio::processMidi.
- // That way we can simply set the next play event to the beginning.
- // This also allows other events to be inserted without the problems caused by the next play event
- // being at the 'end' iterator and not being *easily* set to some new place beginning of the newer insertions.
- // The way that MPEventList sorts made it difficult to predict where the iterator of the first newly inserted items was.
- // The erasure in Audio::processMidi was missing some events because of that.
- el->erase(el->begin(), i);
- //md->setNextPlayEvent(el->begin()); // Removed p4.0.15
- */
-
- }
}
//---------------------------------------------------------
diff --git a/muse2/muse/midiseq.h b/muse2/muse/midiseq.h
index 08adcdce..4a7fd829 100644
--- a/muse2/muse/midiseq.h
+++ b/muse2/muse/midiseq.h
@@ -78,7 +78,6 @@ class MidiSeq : public Thread {
void processTimerTick();
void processSeek();
void processStop();
- void processMidiClock();
virtual void processMsg(const ThreadMsg*);
void updatePollFd();