summaryrefslogtreecommitdiff
path: root/muse2/muse/driver
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-10-08 13:47:24 +0000
committerFlorian Jung <flo@windfisch.org>2011-10-08 13:47:24 +0000
commita347445db32f51562aee5c6a786c312d1f612d2f (patch)
treeba3dc9a6e03eec2edf2c213b7f4d7e5e49903edc /muse2/muse/driver
parent375d6a53630f364c6560eb40255a8cc4c0496b8c (diff)
parent5367067f7a36dce8a362dcc000d41ac581bffdfe (diff)
merged namespace changes. HOPEFULLY the last one.
Diffstat (limited to 'muse2/muse/driver')
-rw-r--r--muse2/muse/driver/alsamidi.cpp90
-rw-r--r--muse2/muse/driver/alsamidi.h6
-rw-r--r--muse2/muse/driver/alsatimer.cpp4
-rw-r--r--muse2/muse/driver/alsatimer.h3
-rw-r--r--muse2/muse/driver/audiodev.h5
-rw-r--r--muse2/muse/driver/dummyaudio.cpp40
-rw-r--r--muse2/muse/driver/jack.cpp204
-rw-r--r--muse2/muse/driver/jackaudio.h7
-rw-r--r--muse2/muse/driver/jackmidi.cpp91
-rw-r--r--muse2/muse/driver/jackmidi.h6
-rw-r--r--muse2/muse/driver/rtctimer.cpp5
-rw-r--r--muse2/muse/driver/rtctimer.h3
-rw-r--r--muse2/muse/driver/timerdev.h4
13 files changed, 254 insertions, 214 deletions
diff --git a/muse2/muse/driver/alsamidi.cpp b/muse2/muse/driver/alsamidi.cpp
index 8ad9c510..eae695db 100644
--- a/muse2/muse/driver/alsamidi.cpp
+++ b/muse2/muse/driver/alsamidi.cpp
@@ -39,6 +39,8 @@
#include "part.h"
#include "gconfig.h"
+namespace MusECore {
+
static int alsaSeqFdi = -1;
static int alsaSeqFdo = -1;
@@ -407,12 +409,12 @@ void MidiAlsaDevice::processMidi()
if (_playEvents.empty())
return;
int port = midiPort();
- MidiPort* mp = port != -1 ? &midiPorts[port] : 0;
- unsigned curFrame = audio->curFrame();
- int tickpos = audio->tickPos();
- bool extsync = extSyncFlag.value();
+ MidiPort* mp = port != -1 ? &MusEGlobal::midiPorts[port] : 0;
+ unsigned curFrame = MusEGlobal::audio->curFrame();
+ int tickpos = MusEGlobal::audio->tickPos();
+ bool extsync = MusEGlobal::extSyncFlag.value();
//int frameOffset = getFrameOffset();
- //int nextTick = audio->nextTick();
+ //int nextTick = MusEGlobal::audio->nextTick();
// Play all events up to current frame.
iMPEvent i = _playEvents.begin();
@@ -443,12 +445,12 @@ void MidiAlsaDevice::processMidi()
while(!stuckNotesFifo.isEmpty())
_stuckNotes.add(stuckNotesFifo.get());
- bool extsync = extSyncFlag.value();
+ bool extsync = MusEGlobal::extSyncFlag.value();
//int frameOffset = getFrameOffset();
- //int nextTick = audio->nextTick();
+ //int nextTick = MusEGlobal::audio->nextTick();
- // We're in the ALSA midi thread. audio->isPlaying() might not be true during seek right now.
- //if(stop || (seek && audio->isPlaying()))
+ // We're in the ALSA midi thread. MusEGlobal::audio->isPlaying() might not be true during seek right now.
+ //if(stop || (seek && MusEGlobal::audio->isPlaying()))
if(stop || seek)
{
//---------------------------------------------------
@@ -473,7 +475,7 @@ void MidiAlsaDevice::processMidi()
_playEvents.add(playEventFifo.get());
/* TODO Handle these more directly than putting them into play events list.
- //if(audio->isPlaying())
+ //if(MusEGlobal::audio->isPlaying())
{
iMPEvent k;
for (k = _stuckNotes.begin(); k != _stuckNotes.end(); ++k) {
@@ -496,7 +498,7 @@ void MidiAlsaDevice::processMidi()
if(stop)
{
// reset sustain...
- MidiPort* mp = &midiPorts[_port];
+ MidiPort* mp = &MusEGlobal::midiPorts[_port];
for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
{
if(mp->hwCtrlState(ch, CTRL_SUSTAIN) == 127)
@@ -528,9 +530,9 @@ void MidiAlsaDevice::processMidi()
return;
int port = midiPort();
- MidiPort* mp = port != -1 ? &midiPorts[port] : 0;
- unsigned curFrame = audio->curFrame();
- int tickpos = audio->tickPos();
+ MidiPort* mp = port != -1 ? &MusEGlobal::midiPorts[port] : 0;
+ unsigned curFrame = MusEGlobal::audio->curFrame();
+ int tickpos = MusEGlobal::audio->tickPos();
// Play all events up to current frame.
iMPEvent i = _playEvents.begin();
@@ -564,7 +566,7 @@ void MidiAlsaDevice::handleStop()
// reset sustain
//---------------------------------------------------
- MidiPort* mp = &midiPorts[_port];
+ MidiPort* mp = &MusEGlobal::midiPorts[_port];
for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
{
if(mp->hwCtrlState(ch, CTRL_SUSTAIN) == 127)
@@ -580,7 +582,7 @@ void MidiAlsaDevice::handleStop()
//---------------------------------------------------
// Don't send if external sync is on. The master, and our sync routing system will take care of that.
- if(!extSyncFlag.value())
+ if(!MusEGlobal::extSyncFlag.value())
{
// Shall we check open flags?
//if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
@@ -600,7 +602,7 @@ void MidiAlsaDevice::handleStop()
// Hmm, is this required? Seems to make other devices unhappy.
// (Could try now that this is in MidiDevice. p4.0.22 )
//if(!si.sendContNotStart())
- // mp->sendSongpos(audio->tickPos() * 4 / config.division);
+ // mp->sendSongpos(MusEGlobal::audio->tickPos() * 4 / config.division);
}
}
}
@@ -617,9 +619,9 @@ void MidiAlsaDevice::handleSeek()
seekPending = true; // Trigger seek handling in processMidi.
- MidiPort* mp = &midiPorts[_port];
+ MidiPort* mp = &MusEGlobal::midiPorts[_port];
MidiCtrlValListList* cll = mp->controller();
- int pos = audio->tickPos();
+ int pos = MusEGlobal::audio->tickPos();
//---------------------------------------------------
// Send new contoller values
@@ -646,7 +648,7 @@ void MidiAlsaDevice::handleSeek()
//---------------------------------------------------
// Don't send if external sync is on. The master, and our sync routing system will take care of that. p3.3.31
- if(!extSyncFlag.value())
+ if(!MusEGlobal::extSyncFlag.value())
{
if(mp->syncInfo().MRTOut())
{
@@ -657,10 +659,10 @@ void MidiAlsaDevice::handleSeek()
//if(!(openFlags() & 1))
// continue;
- int beat = (pos * 4) / MusEConfig::config.division;
+ int beat = (pos * 4) / MusEGlobal::config.division;
//bool isPlaying = (state == PLAY);
- bool isPlaying = audio->isPlaying(); // TODO Check this it includes LOOP1 and LOOP2 besides PLAY. p4.0.22
+ bool isPlaying = MusEGlobal::audio->isPlaying(); // TODO Check this it includes LOOP1 and LOOP2 besides PLAY. p4.0.22
mp->sendStop();
mp->sendSongpos(beat);
@@ -721,18 +723,18 @@ bool initMidiAlsa()
snd_seq_port_info_get_name(pinfo),
adr.client, adr.port,
flags, capability);
- midiDevices.add(dev);
+ MusEGlobal::midiDevices.add(dev);
/*
// Experimental... Need to list 'sensible' devices first and ignore unwanted ones...
// Add instance last in midi device list.
for(int i = 0; i < MIDI_PORTS; ++i)
{
- MidiPort* mp = &midiPorts[i];
+ MidiPort* mp = &MusEGlobal::midiPorts[i];
if(mp->device() == 0)
{
// midiSeq might not be initialzed yet!
- //midiSeq->msgSetMidiDevice(mp, dev);
+ //MusEGlobal::midiSeq->msgSetMidiDevice(mp, dev);
mp->setMidiDevice(dev);
//muse->changeConfig(true); // save configuration file
@@ -746,7 +748,7 @@ bool initMidiAlsa()
}
//snd_seq_set_client_name(alsaSeq, "MusE Sequencer");
- snd_seq_set_client_name(alsaSeq, audioDevice->clientName());
+ snd_seq_set_client_name(alsaSeq, MusEGlobal::audioDevice->clientName());
int ci = snd_seq_poll_descriptors_count(alsaSeq, POLLIN);
int co = snd_seq_poll_descriptors_count(alsaSeq, POLLOUT);
@@ -795,7 +797,6 @@ bool initMidiAlsa()
return false;
}
-namespace MusEApp {
//---------------------------------------------------------
// exitMidiAlsa
@@ -813,8 +814,6 @@ void exitMidiAlsa()
}
}
-} // namespace MusEApp
-
struct AlsaPort {
snd_seq_addr_t adr;
@@ -873,7 +872,7 @@ void alsaScanMidiPorts()
//
// check for devices to delete
//
- for (iMidiDevice i = midiDevices.begin(); i != midiDevices.end();) {
+ for (iMidiDevice i = MusEGlobal::midiDevices.begin(); i != MusEGlobal::midiDevices.end();) {
MidiAlsaDevice* d = dynamic_cast<MidiAlsaDevice*>(*i);
if (d == 0) {
++i;
@@ -888,11 +887,11 @@ void alsaScanMidiPorts()
}
if (k == portList.end()) {
if (d->midiPort() != -1)
- midiPorts[d->midiPort()].setMidiDevice(0);
+ MusEGlobal::midiPorts[d->midiPort()].setMidiDevice(0);
iMidiDevice k = i;
// printf("erase device\n");
++i;
- midiDevices.erase(k);
+ MusEGlobal::midiDevices.erase(k);
}
else {
++i;
@@ -902,9 +901,9 @@ void alsaScanMidiPorts()
// check for devices to add
//
for (std::list<AlsaPort>::iterator k = portList.begin(); k != portList.end(); ++k) {
- iMidiDevice i = midiDevices.begin();
+ iMidiDevice i = MusEGlobal::midiDevices.begin();
// printf("ALSA port: <%s>\n", k->name);
- for (;i != midiDevices.end(); ++i) {
+ for (;i != MusEGlobal::midiDevices.end(); ++i) {
MidiAlsaDevice* d = dynamic_cast<MidiAlsaDevice*>(*i);
if (d == 0)
continue;
@@ -912,12 +911,12 @@ void alsaScanMidiPorts()
break;
}
}
- if (i == midiDevices.end()) {
+ if (i == MusEGlobal::midiDevices.end()) {
// add device
MidiAlsaDevice* dev = new MidiAlsaDevice(k->adr,
QString(k->name));
dev->setrwFlags(k->flags);
- midiDevices.add(dev);
+ MusEGlobal::midiDevices.add(dev);
// printf("add device\n");
}
}
@@ -971,7 +970,7 @@ void alsaProcessMidiInput()
case SND_SEQ_EVENT_PORT_START:
case SND_SEQ_EVENT_PORT_EXIT:
alsaScanMidiPorts();
- audio->midiPortsChanged(); // signal gui
+ MusEGlobal::audio->midiPortsChanged(); // signal gui
snd_seq_free_event(ev);
return;
}
@@ -981,7 +980,7 @@ void alsaProcessMidiInput()
//
// find real source device
//
- for (iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i) {
+ for (iMidiDevice i = MusEGlobal::midiDevices.begin(); i != MusEGlobal::midiDevices.end(); ++i) {
MidiAlsaDevice* d = dynamic_cast<MidiAlsaDevice*>(*i);
if (d && d->adr.client == ev->source.client
&& d->adr.port == ev->source.port) {
@@ -1046,24 +1045,24 @@ void alsaProcessMidiInput()
break;
case SND_SEQ_EVENT_CLOCK:
- midiSeq->realtimeSystemInput(curPort, ME_CLOCK);
+ MusEGlobal::midiSeq->realtimeSystemInput(curPort, ME_CLOCK);
//mdev->syncInfo().trigMCSyncDetect();
break;
case SND_SEQ_EVENT_START:
- midiSeq->realtimeSystemInput(curPort, ME_START);
+ MusEGlobal::midiSeq->realtimeSystemInput(curPort, ME_START);
break;
case SND_SEQ_EVENT_CONTINUE:
- midiSeq->realtimeSystemInput(curPort, ME_CONTINUE);
+ MusEGlobal::midiSeq->realtimeSystemInput(curPort, ME_CONTINUE);
break;
case SND_SEQ_EVENT_STOP:
- midiSeq->realtimeSystemInput(curPort, ME_STOP);
+ MusEGlobal::midiSeq->realtimeSystemInput(curPort, ME_STOP);
break;
case SND_SEQ_EVENT_TICK:
- midiSeq->realtimeSystemInput(curPort, ME_TICK);
+ MusEGlobal::midiSeq->realtimeSystemInput(curPort, ME_TICK);
//mdev->syncInfo().trigTickDetect();
break;
@@ -1087,12 +1086,12 @@ void alsaProcessMidiInput()
case SND_SEQ_EVENT_PORT_UNSUBSCRIBED: // write port is released
break;
case SND_SEQ_EVENT_SONGPOS:
- midiSeq->setSongPosition(curPort, ev->data.control.value);
+ MusEGlobal::midiSeq->setSongPosition(curPort, ev->data.control.value);
break;
case SND_SEQ_EVENT_SENSING:
break;
case SND_SEQ_EVENT_QFRAME:
- midiSeq->mtcInputQuarter(curPort, ev->data.control.value);
+ MusEGlobal::midiSeq->mtcInputQuarter(curPort, ev->data.control.value);
break;
// case SND_SEQ_EVENT_CLIENT_START:
// case SND_SEQ_EVENT_CLIENT_EXIT:
@@ -1124,3 +1123,4 @@ void alsaProcessMidiInput()
}
}
+} // namespace MusECore
diff --git a/muse2/muse/driver/alsamidi.h b/muse2/muse/driver/alsamidi.h
index 9badd7c4..2054a7d3 100644
--- a/muse2/muse/driver/alsamidi.h
+++ b/muse2/muse/driver/alsamidi.h
@@ -30,6 +30,8 @@
#include "mpevent.h"
#include "mididev.h"
+namespace MusECore {
+
class Xml;
//---------------------------------------------------------
@@ -77,12 +79,14 @@ class MidiAlsaDevice : public MidiDevice {
};
extern bool initMidiAlsa();
-extern bool exitMidiAlsa();
+extern void exitMidiAlsa();
extern int alsaSelectRfd();
extern int alsaSelectWfd();
extern void alsaProcessMidiInput();
extern void alsaScanMidiPorts();
+} // namespace MusECore
+
#endif
diff --git a/muse2/muse/driver/alsatimer.cpp b/muse2/muse/driver/alsatimer.cpp
index dee661fe..ee72d679 100644
--- a/muse2/muse/driver/alsatimer.cpp
+++ b/muse2/muse/driver/alsatimer.cpp
@@ -28,6 +28,8 @@
#include <climits>
#define TIMER_DEBUG 0
+
+namespace MusECore {
AlsaTimer::AlsaTimer()
{
@@ -238,3 +240,5 @@
}
return tr.ticks;
}
+
+} // namespace MusECore
diff --git a/muse2/muse/driver/alsatimer.h b/muse2/muse/driver/alsatimer.h
index b906c02d..79e9193e 100644
--- a/muse2/muse/driver/alsatimer.h
+++ b/muse2/muse/driver/alsatimer.h
@@ -30,6 +30,7 @@
#include "alsa/asoundlib.h"
#include "timerdev.h"
+namespace MusECore {
//---------------------------------------------------------
// AlsaTimer
@@ -64,4 +65,6 @@ class AlsaTimer : public Timer{
void setFindBestTimer(bool b) { findBest = b; }
};
+} // namespace MusECore
+
#endif //__ALSATIMER_H__
diff --git a/muse2/muse/driver/audiodev.h b/muse2/muse/driver/audiodev.h
index 3fe06fb9..14fb60b3 100644
--- a/muse2/muse/driver/audiodev.h
+++ b/muse2/muse/driver/audiodev.h
@@ -28,7 +28,8 @@
class QString;
-class MidiPlayEvent;
+namespace MusECore {
+
class Pos;
//---------------------------------------------------------
@@ -87,5 +88,7 @@ class AudioDevice {
virtual int setMaster(bool f) = 0;
};
+} // namespace MusECore
+
#endif
diff --git a/muse2/muse/driver/dummyaudio.cpp b/muse2/muse/driver/dummyaudio.cpp
index 4466e293..1738027d 100644
--- a/muse2/muse/driver/dummyaudio.cpp
+++ b/muse2/muse/driver/dummyaudio.cpp
@@ -38,9 +38,12 @@
#include "gconfig.h"
#include "utils.h"
+#define DEBUG_DUMMY 0
+
+namespace MusECore {
+
class MidiPlayEvent;
-#define DEBUG_DUMMY 0
//---------------------------------------------------------
// DummyAudioDevice
//---------------------------------------------------------
@@ -140,7 +143,7 @@ class DummyAudioDevice : public AudioDevice {
return _framePos; }
virtual unsigned frameTime() const {
- return lrint(MusEUtil::curTime() * MusEGlobal::sampleRate);
+ return lrint(curTime() * MusEGlobal::sampleRate);
}
virtual bool isRealtime() { return realtimeFlag; }
//virtual int realtimePriority() const { return 40; }
@@ -215,19 +218,18 @@ DummyAudioDevice::DummyAudioDevice()
// Added by Tim. p3.3.15
// p3.3.30
//posix_memalign((void**)&buffer, 16, sizeof(float) * dummyFrames);
- posix_memalign((void**)&buffer, 16, sizeof(float) * MusEConfig::config.dummyAudioBufSize);
+ posix_memalign((void**)&buffer, 16, sizeof(float) * MusEGlobal::config.dummyAudioBufSize);
dummyThread = 0;
realtimeFlag = false;
seekflag = false;
state = Audio::STOP;
- //startTime = MusEUtil::curTime();
+ //startTime = curTime();
_framePos = 0;
playPos = 0;
cmdQueue.clear();
}
-namespace MusEApp {
//---------------------------------------------------------
// exitDummyAudio
@@ -238,10 +240,9 @@ void exitDummyAudio()
if(dummyAudio)
delete dummyAudio;
dummyAudio = NULL;
- audioDevice = NULL;
+ MusEGlobal::audioDevice = NULL;
}
-} // namespace MusEApp
//---------------------------------------------------------
// initDummyAudio
@@ -250,7 +251,7 @@ void exitDummyAudio()
bool initDummyAudio()
{
dummyAudio = new DummyAudioDevice();
- audioDevice = dummyAudio;
+ MusEGlobal::audioDevice = dummyAudio;
return false;
}
@@ -294,9 +295,9 @@ static void* dummyLoop(void* ptr)
// p3.3.30
//MusEGlobal::sampleRate = 25600;
- MusEGlobal::sampleRate = MusEConfig::config.dummyAudioSampleRate;
+ MusEGlobal::sampleRate = MusEGlobal::config.dummyAudioSampleRate;
//MusEGlobal::segmentSize = dummyFrames;
- MusEGlobal::segmentSize = MusEConfig::config.dummyAudioBufSize;
+ MusEGlobal::segmentSize = MusEGlobal::config.dummyAudioBufSize;
#if 0
//unsigned int tickRate = MusEGlobal::sampleRate / dummyFrames;
unsigned int tickRate = MusEGlobal::sampleRate / MusEGlobal::segmentSize;
@@ -455,19 +456,19 @@ static void* dummyLoop(void* ptr)
for(;;)
{
//if(audioState == AUDIO_RUNNING)
- if(audio->isRunning())
- //audio->process(MusEGlobal::segmentSize, drvPtr->state);
- audio->process(MusEGlobal::segmentSize);
+ if(MusEGlobal::audio->isRunning())
+ //MusEGlobal::audio->process(MusEGlobal::segmentSize, drvPtr->state);
+ MusEGlobal::audio->process(MusEGlobal::segmentSize);
//else if (audioState == AUDIO_START1)
// audioState = AUDIO_START2;
- //usleep(dummyFrames*1000000/AL::MusEGlobal::sampleRate);
+ //usleep(dummyFrames*1000000/AL::sampleRate);
usleep(MusEGlobal::segmentSize*1000000/MusEGlobal::sampleRate);
//if(dummyAudio->seekflag)
if(drvPtr->seekflag)
{
- //audio->sync(Audio::STOP, dummyAudio->pos);
- //audio->sync(drvPtr->state, drvPtr->playPos);
- audio->sync(Audio::STOP, drvPtr->playPos);
+ //MusEGlobal::audio->sync(Audio::STOP, dummyAudio->pos);
+ //MusEGlobal::audio->sync(drvPtr->state, drvPtr->playPos);
+ MusEGlobal::audio->sync(Audio::STOP, drvPtr->playPos);
//dummyAudio->seekflag = false;
drvPtr->seekflag = false;
@@ -515,7 +516,7 @@ void DummyAudioDevice::start(int priority)
}
}
- int rv = pthread_create(&dummyThread, attributes, ::dummyLoop, this);
+ int rv = pthread_create(&dummyThread, attributes, dummyLoop, this);
if(rv)
{
// p4.0.16: MusEGlobal::realTimeScheduling is unreliable. It is true even in some clearly non-RT cases.
@@ -523,7 +524,7 @@ void DummyAudioDevice::start(int priority)
// MusE was failing with a stock kernel because of PTHREAD_EXPLICIT_SCHED.
// So we'll just have to try again without attributes.
if (MusEGlobal::realTimeScheduling && _realTimePriority > 0)
- rv = pthread_create(&dummyThread, NULL, ::dummyLoop, this);
+ rv = pthread_create(&dummyThread, NULL, dummyLoop, this);
}
if(rv)
@@ -543,3 +544,4 @@ void DummyAudioDevice::stop ()
dummyThread = 0;
}
+} // namespace MusECore
diff --git a/muse2/muse/driver/jack.cpp b/muse2/muse/driver/jack.cpp
index 31179ea3..733353d8 100644
--- a/muse2/muse/driver/jack.cpp
+++ b/muse2/muse/driver/jack.cpp
@@ -53,15 +53,35 @@
//#include "errorhandler.h"
-#ifndef RTCAP
-extern void MusEGlobal::doSetuid();
-extern void MusEGlobal::undoSetuid();
-#endif
-
#ifdef VST_SUPPORT
#include <fst.h>
#endif
+namespace MusEGlobal {
+
+#ifndef RTCAP
+extern void doSetuid();
+extern void undoSetuid();
+#endif
+
+//---------------------------------------------------------
+// checkAudioDevice - make sure audioDevice exists
+//---------------------------------------------------------
+
+bool checkAudioDevice()
+ {
+ if (audioDevice == NULL) {
+ if(debugMsg)
+ printf("Muse:checkAudioDevice: no audioDevice\n");
+ return false;
+ }
+ return true;
+ }
+
+} // namespace MusEGlobal
+
+namespace MusECore {
+
//extern int jackmidi_pi[2];
//extern int jackmidi_po[2];
@@ -275,8 +295,8 @@ int JackAudioDevice::processAudio(jack_nframes_t frames, void*)
// if (JACK_DEBUG)
// printf("processAudio - >>>>\n");
MusEGlobal::segmentSize = frames;
- if (audio->isRunning())
- audio->process((unsigned long)frames);
+ if (MusEGlobal::audio->isRunning())
+ MusEGlobal::audio->process((unsigned long)frames);
else {
if (MusEGlobal::debugMsg)
puts("jack calling when audio is disconnected!\n");
@@ -296,7 +316,7 @@ static int processSync(jack_transport_state_t state, jack_position_t* pos, void*
if (JACK_DEBUG)
printf("processSync()\n");
- if(!useJackTransport.value())
+ if(!MusEGlobal::useJackTransport.value())
return 1;
int audioState = Audio::STOP;
@@ -327,10 +347,10 @@ static int processSync(jack_transport_state_t state, jack_position_t* pos, void*
//printf("processSync valid:%d frame:%d\n", pos->valid, frame);
// p3.3.23
- //printf("Jack processSync() before audio->sync frame:%d\n", frame);
- //return audio->sync(audioState, frame);
- int rv = audio->sync(audioState, frame);
- //printf("Jack processSync() after audio->sync frame:%d\n", frame);
+ //printf("Jack processSync() before MusEGlobal::audio->sync frame:%d\n", frame);
+ //return MusEGlobal::audio->sync(audioState, frame);
+ int rv = MusEGlobal::audio->sync(audioState, frame);
+ //printf("Jack processSync() after MusEGlobal::audio->sync frame:%d\n", frame);
return rv;
}
@@ -344,13 +364,13 @@ static void timebase_callback(jack_transport_state_t /* state */,
int /* new_pos */,
void*)
{
- //printf("Jack timebase_callback pos->frame:%u audio->tickPos:%d song->cpos:%d\n", pos->frame, audio->tickPos(), song->cpos());
+ //printf("Jack timebase_callback pos->frame:%u MusEGlobal::audio->tickPos:%d MusEGlobal::song->cpos:%d\n", pos->frame, MusEGlobal::audio->tickPos(), MusEGlobal::song->cpos());
// p3.3.27
//Pos p(pos->frame, false);
- Pos p(extSyncFlag.value() ? audio->tickPos() : pos->frame, extSyncFlag.value() ? true : false);
+ Pos p(MusEGlobal::extSyncFlag.value() ? MusEGlobal::audio->tickPos() : pos->frame, MusEGlobal::extSyncFlag.value() ? true : false);
// Can't use song pos - it is only updated every (slow) GUI heartbeat !
- //Pos p(extSyncFlag.value() ? song->cpos() : pos->frame, extSyncFlag.value() ? true : false);
+ //Pos p(MusEGlobal::extSyncFlag.value() ? MusEGlobal::song->cpos() : pos->frame, MusEGlobal::extSyncFlag.value() ? true : false);
pos->valid = JackPositionBBT;
p.mbt(&pos->bar, &pos->beat, &pos->tick);
@@ -381,8 +401,8 @@ static void timebase_callback(jack_transport_state_t /* state */,
//pos->ticks_per_beat = config.division;
pos->ticks_per_beat = 24;
- int tempo = tempomap.tempo(p.tick());
- pos->beats_per_minute = (60000000.0 / tempo) * tempomap.globalTempo()/100.0;
+ int tempo = MusEGlobal::tempomap.tempo(p.tick());
+ pos->beats_per_minute = (60000000.0 / tempo) * MusEGlobal::tempomap.globalTempo()/100.0;
}
//---------------------------------------------------------
@@ -395,7 +415,7 @@ static void processShutdown(void*)
printf("processShutdown()\n");
//printf("processShutdown\n");
jackAudio->nullify_client();
- audio->shutdown();
+ MusEGlobal::audio->shutdown();
int c=0;
while(MusEGlobal::midiSeqRunning == true) {
@@ -407,7 +427,7 @@ static void processShutdown(void*)
}
delete jackAudio;
jackAudio=0;
- audioDevice=0;
+ MusEGlobal::audioDevice=0;
}
//---------------------------------------------------------
@@ -630,7 +650,7 @@ bool initJackAudio()
*/
if (client) {
- audioDevice = jackAudio;
+ MusEGlobal::audioDevice = jackAudio;
jackAudio->scanMidiPorts();
return false;
}
@@ -651,7 +671,7 @@ static void freewheel_callback(int starting, void*)
{
if (MusEGlobal::debugMsg || JACK_DEBUG)
printf("JACK: freewheel_callback: starting%d\n", starting);
- audio->setFreewheel(starting);
+ MusEGlobal::audio->setFreewheel(starting);
}
static int srate_callback(jack_nframes_t n, void*)
@@ -670,7 +690,7 @@ static void registration_callback(jack_port_id_t, int, void*)
if(MusEGlobal::debugMsg || JACK_DEBUG)
printf("JACK: registration changed\n");
- audio->sendMsgToGui('R');
+ MusEGlobal::audio->sendMsgToGui('R');
}
//---------------------------------------------------------
@@ -699,7 +719,7 @@ void JackAudioDevice::connectJackMidiPorts()
if(JACK_DEBUG)
printf("JackAudioDevice::connectJackMidiPorts()\n");
- for (iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i)
+ for (iMidiDevice i = MusEGlobal::midiDevices.begin(); i != MusEGlobal::midiDevices.end(); ++i)
{
//MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(*i);
//if(!mjd)
@@ -794,7 +814,7 @@ void JackAudioDevice::connectJackMidiPorts()
if(JACK_DEBUG)
printf("JackAudioDevice::graphChanged %s\n", name.toLatin1());
- for(iMidiDevice imd = midiDevices.begin(); imd != midiDevices.end(); ++imd)
+ for(iMidiDevice imd = MusEGlobal::midiDevices.begin(); imd != MusEGlobal::midiDevices.end(); ++imd)
{
// Is it a Jack midi device?
MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(*imd);
@@ -823,7 +843,7 @@ void JackAudioDevice::connectJackMidiPorts()
{
if(JACK_DEBUG)
printf("JackAudioDevice::graphChanged connecting MusE output\n");
- audioDevice->connect(port, devport);
+ MusEGlobal::audioDevice->connect(port, devport);
}
else
// If Jack port can send data to us and we actually want it...
@@ -831,7 +851,7 @@ void JackAudioDevice::connectJackMidiPorts()
{
if(JACK_DEBUG)
printf("JackAudioDevice::graphChanged connecting MusE input\n");
- audioDevice->connect(devport, port);
+ MusEGlobal::audioDevice->connect(devport, port);
}
break;
@@ -881,7 +901,7 @@ static int graph_callback(void*)
// we cannot call JackAudioDevice::graphChanged() from this
// context, so we send a message to the gui thread which in turn
// calls graphChanged()
- audio->sendMsgToGui('C');
+ MusEGlobal::audio->sendMsgToGui('C');
if (MusEGlobal::debugMsg)
printf("JACK: graph changed\n");
return 0;
@@ -898,7 +918,7 @@ void JackAudioDevice::graphChanged()
if (JACK_DEBUG)
printf("graphChanged()\n");
if(!checkJackClient(_client)) return;
- InputList* il = song->inputs();
+ InputList* il = MusEGlobal::song->inputs();
for (iAudioInput ii = il->begin(); ii != il->end(); ++ii) {
AudioInput* it = *ii;
int channels = it->channels();
@@ -935,7 +955,7 @@ void JackAudioDevice::graphChanged()
++pn;
}
if (!found) {
- audio->msgRemoveRoute1(
+ MusEGlobal::audio->msgRemoveRoute1(
//Route(portName, false, channel),
Route(portName, false, channel, Route::JACK_ROUTE),
Route(it, channel)
@@ -968,7 +988,7 @@ void JackAudioDevice::graphChanged()
}
}
if (!found) {
- audio->msgAddRoute1(
+ MusEGlobal::audio->msgAddRoute1(
//Route(*pn, false, channel),
Route(*pn, false, channel, Route::JACK_ROUTE),
Route(it, channel)
@@ -986,7 +1006,7 @@ void JackAudioDevice::graphChanged()
}
}
}
- OutputList* ol = song->outputs();
+ OutputList* ol = MusEGlobal::song->outputs();
for (iAudioOutput ii = ol->begin(); ii != ol->end(); ++ii) {
AudioOutput* it = *ii;
int channels = it->channels();
@@ -1022,7 +1042,7 @@ void JackAudioDevice::graphChanged()
++pn;
}
if (!found) {
- audio->msgRemoveRoute1(
+ MusEGlobal::audio->msgRemoveRoute1(
Route(it, channel),
//Route(portName, false, channel)
Route(portName, false, channel, Route::JACK_ROUTE)
@@ -1055,7 +1075,7 @@ void JackAudioDevice::graphChanged()
}
}
if (!found) {
- audio->msgAddRoute1(
+ MusEGlobal::audio->msgAddRoute1(
Route(it, channel),
//Route(*pn, false, channel)
Route(*pn, false, channel, Route::JACK_ROUTE)
@@ -1074,7 +1094,7 @@ void JackAudioDevice::graphChanged()
}
}
- for (iMidiDevice ii = midiDevices.begin(); ii != midiDevices.end(); ++ii)
+ for (iMidiDevice ii = MusEGlobal::midiDevices.begin(); ii != MusEGlobal::midiDevices.end(); ++ii)
{
MidiDevice* md = *ii;
if(md->deviceType() != MidiDevice::JACK_MIDI)
@@ -1135,7 +1155,7 @@ void JackAudioDevice::graphChanged()
++pn;
}
if (!found) {
- audio->msgRemoveRoute1(
+ MusEGlobal::audio->msgRemoveRoute1(
//Route(it, channel),
//Route(mjd),
Route(md, -1),
@@ -1172,7 +1192,7 @@ void JackAudioDevice::graphChanged()
}
}
if (!found) {
- audio->msgAddRoute1(
+ MusEGlobal::audio->msgAddRoute1(
//Route(it, channel),
//Route(mjd),
Route(md, -1),
@@ -1234,7 +1254,7 @@ void JackAudioDevice::graphChanged()
++pn;
}
if (!found) {
- audio->msgRemoveRoute1(
+ MusEGlobal::audio->msgRemoveRoute1(
//Route(portName, false, channel),
//Route(portName, false, -1),
Route(portName, false, -1, Route::JACK_ROUTE),
@@ -1271,7 +1291,7 @@ void JackAudioDevice::graphChanged()
}
}
if (!found) {
- audio->msgAddRoute1(
+ MusEGlobal::audio->msgAddRoute1(
//Route(*pn, false, channel),
//Route(*pn, false, -1),
Route(*pn, false, -1, Route::JACK_ROUTE),
@@ -1370,46 +1390,6 @@ void* JackAudioDevice::registerOutPort(const char* name, bool midi)
return p;
}
-namespace MusEGlobal {
-
-//---------------------------------------------------------
-// checkAudioDevice - make sure audioDevice exists
-//---------------------------------------------------------
-
-bool checkAudioDevice()
- {
- if (audioDevice == NULL) {
- if(MusEGlobal::debugMsg)
- printf("Muse:checkAudioDevice: no audioDevice\n");
- return false;
- }
- return true;
- }
-
-} // namespace MusEGlobal
-
-namespace MusEApp {
-
-//---------------------------------------------------------
-// exitJackAudio
-//---------------------------------------------------------
-
-void exitJackAudio()
- {
- if (JACK_DEBUG)
- printf("exitJackAudio()\n");
- if (jackAudio)
- delete jackAudio;
-
- if (JACK_DEBUG)
- printf("exitJackAudio() after delete jackAudio\n");
-
- // Added by Tim. p3.3.14
- audioDevice = NULL;
-
- }
-} // namespace MusEApp
-
//---------------------------------------------------------
// connect
//---------------------------------------------------------
@@ -1494,7 +1474,7 @@ void JackAudioDevice::start(int /*priority*/)
running.
*/
- InputList* il = song->inputs();
+ InputList* il = MusEGlobal::song->inputs();
for (iAudioInput i = il->begin(); i != il->end(); ++i) {
AudioInput* ai = *i;
int channel = ai->channels();
@@ -1507,7 +1487,7 @@ void JackAudioDevice::start(int /*priority*/)
}
}
}
- OutputList* ol = song->outputs();
+ OutputList* ol = MusEGlobal::song->outputs();
for (iAudioOutput i = ol->begin(); i != ol->end(); ++i) {
AudioOutput* ai = *i;
int channel = ai->channels();
@@ -1571,7 +1551,7 @@ unsigned int JackAudioDevice::getCurFrame()
if (JACK_DEBUG)
printf("JackAudioDevice::getCurFrame pos.frame:%d\n", pos.frame);
- if(!useJackTransport.value())
+ if(!MusEGlobal::useJackTransport.value())
return (unsigned int)dummyPos;
return pos.frame;
@@ -1583,7 +1563,7 @@ unsigned int JackAudioDevice::getCurFrame()
int JackAudioDevice::framePos() const
{
- //if(!useJackTransport.value())
+ //if(!MusEGlobal::useJackTransport.value())
//{
// if (JACK_DEBUG)
// printf("JackAudioDevice::framePos dummyPos:%d\n", dummyPos);
@@ -1805,11 +1785,11 @@ void JackAudioDevice::unregisterPort(void* p)
int JackAudioDevice::getState()
{
// If we're not using Jack's transport, just return current state.
- if(!useJackTransport.value())
+ if(!MusEGlobal::useJackTransport.value())
{
//pos.valid = jack_position_bits_t(0);
- //pos.frame = audio->pos().frame();
- //return audio->getState();
+ //pos.frame = MusEGlobal::audio->pos().frame();
+ //return MusEGlobal::audio->getState();
//if (JACK_DEBUG)
// printf("JackAudioDevice::getState dummyState:%d\n", dummyState);
return dummyState;
@@ -1868,14 +1848,14 @@ bool JackAudioDevice::dummySync(int state)
//timespec ts = { 0, (1000000000 * MusEGlobal::segmentSize) / MusEGlobal::sampleRate }; // In nanoseconds.
unsigned int sl = (1000000 * MusEGlobal::segmentSize) / MusEGlobal::sampleRate; // In microseconds.
- double ct = MusEUtil::curTime();
+ double ct = curTime();
// Wait for a default maximum of 5 seconds.
// Similar to how Jack is supposed to wait a default of 2 seconds for slow clients.
// TODO: Make this timeout a 'settings' option so it can be applied both to Jack and here.
- while((MusEUtil::curTime() - ct) < 5.0)
+ while((curTime() - ct) < 5.0)
{
// Is MusE audio ready to roll?
- if(audio->sync(state, dummyPos))
+ if(MusEGlobal::audio->sync(state, dummyPos))
return true;
// Not ready. Wait a 'segment', try again...
@@ -1900,7 +1880,7 @@ void JackAudioDevice::startTransport()
// If we're not using Jack's transport, just pass PLAY and current frame along
// as if processSync was called.
- if(!useJackTransport.value())
+ if(!MusEGlobal::useJackTransport.value())
{
//dummyState = Audio::START_PLAY;
@@ -1934,7 +1914,7 @@ void JackAudioDevice::stopTransport()
dummyState = Audio::STOP;
- if(!useJackTransport.value())
+ if(!MusEGlobal::useJackTransport.value())
{
//dummyState = Audio::STOP;
return;
@@ -1958,7 +1938,7 @@ void JackAudioDevice::seekTransport(unsigned frame)
printf("JackAudioDevice::seekTransport() frame:%d\n", frame);
dummyPos = frame;
- if(!useJackTransport.value())
+ if(!MusEGlobal::useJackTransport.value())
{
// If we're not using Jack's transport, just pass the current state and new frame along
// as if processSync was called.
@@ -1967,7 +1947,7 @@ void JackAudioDevice::seekTransport(unsigned frame)
//dummyState = Audio::START_PLAY;
// Is MusE audio ready yet?
- //audio->sync(dummyState, dummyPos);
+ //MusEGlobal::audio->sync(dummyState, dummyPos);
//if(dummySync(dummyState))
if(dummySync(Audio::START_PLAY))
{
@@ -2001,7 +1981,7 @@ void JackAudioDevice::seekTransport(const Pos &p)
printf("JackAudioDevice::seekTransport() frame:%d\n", p.frame());
dummyPos = p.frame();
- if(!useJackTransport.value())
+ if(!MusEGlobal::useJackTransport.value())
{
// If we're not using Jack's transport, just pass the current state and new frame along
// as if processSync was called.
@@ -2010,7 +1990,7 @@ void JackAudioDevice::seekTransport(const Pos &p)
//dummyState = Audio::START_PLAY;
// Is MusE audio ready yet?
- //audio->sync(dummyState, dummyPos);
+ //MusEGlobal::audio->sync(dummyState, dummyPos);
//if(dummySync(dummyState))
if(dummySync(Audio::START_PLAY))
{
@@ -2040,8 +2020,8 @@ void JackAudioDevice::seekTransport(const Pos &p)
jp.beats_per_bar = 4;
jp.beat_type = 4;
jp.ticks_per_beat = 384;
- int tempo = tempomap.tempo(p.tick());
- jp.beats_per_minute = (60000000.0 / tempo) * tempomap.globalTempo()/100.0;
+ int tempo = MusEGlobal::tempomap.tempo(p.tick());
+ jp.beats_per_minute = (60000000.0 / tempo) * MusEGlobal::tempomap.globalTempo()/100.0;
jack_transport_reposition(_client, &jp);
*/
@@ -2076,7 +2056,7 @@ int JackAudioDevice::setMaster(bool f)
int r = 0;
if(f)
{
- if(useJackTransport.value())
+ if(MusEGlobal::useJackTransport.value())
{
// Make Muse the Jack timebase master. Do it unconditionally (second param = 0).
r = jack_set_timebase_callback(_client, 0, (JackTimebaseCallback) timebase_callback, 0);
@@ -2163,7 +2143,7 @@ void JackAudioDevice::scanMidiPorts()
free(ports);
std::list<MidiDevice*> to_del;
- for(iMidiDevice imd = midiDevices.begin(); imd != midiDevices.end(); ++imd)
+ for(iMidiDevice imd = MusEGlobal::midiDevices.begin(); imd != MusEGlobal::midiDevices.end(); ++imd)
{
// Only Jack midi devices.
if(dynamic_cast<MidiJackDevice*>(*imd) == 0)
@@ -2176,7 +2156,7 @@ void JackAudioDevice::scanMidiPorts()
{
if(MusEGlobal::debugMsg)
printf(" removing port device:%s\n", (*imd)->name().toLatin1());
- midiDevices.remove(*imd);
+ MusEGlobal::midiDevices.remove(*imd);
// This will close (and unregister) the client port.
delete (*imd);
}
@@ -2218,7 +2198,7 @@ void JackAudioDevice::scanMidiPorts()
QString qname(is->c_str());
// Port already exists?
- if(midiDevices.find(qname))
+ if(MusEGlobal::midiDevices.find(qname))
continue;
int flags = 0;
@@ -2240,8 +2220,30 @@ void JackAudioDevice::scanMidiPorts()
MidiJackDevice* dev = new MidiJackDevice(0, qname);
dev->setrwFlags(flags);
- midiDevices.add(dev);
+ MusEGlobal::midiDevices.add(dev);
}
*/
}
+
+//---------------------------------------------------------
+// exitJackAudio
+//---------------------------------------------------------
+
+void exitJackAudio()
+ {
+ if (JACK_DEBUG)
+ printf("exitJackAudio()\n");
+ if (jackAudio)
+ delete jackAudio;
+
+ if (JACK_DEBUG)
+ printf("exitJackAudio() after delete jackAudio\n");
+
+ // Added by Tim. p3.3.14
+ MusEGlobal::audioDevice = NULL;
+
+ }
+} // namespace MusECore
+
+
diff --git a/muse2/muse/driver/jackaudio.h b/muse2/muse/driver/jackaudio.h
index d116a2ff..bd78d481 100644
--- a/muse2/muse/driver/jackaudio.h
+++ b/muse2/muse/driver/jackaudio.h
@@ -26,12 +26,13 @@
#include <jack/jack.h>
#include "audiodev.h"
-class MidiPlayEvent;
-
namespace MusEGlobal {
bool checkAudioDevice();
}
+namespace MusECore {
+class MidiPlayEvent;
+
//---------------------------------------------------------
// JackAudioDevice
//---------------------------------------------------------
@@ -111,5 +112,7 @@ class JackAudioDevice : public AudioDevice {
//static bool jackStarted;
};
+} // namespace MusECore
+
#endif
diff --git a/muse2/muse/driver/jackmidi.cpp b/muse2/muse/driver/jackmidi.cpp
index a4577f0b..fa23d336 100644
--- a/muse2/muse/driver/jackmidi.cpp
+++ b/muse2/muse/driver/jackmidi.cpp
@@ -47,7 +47,11 @@
// Turn on debug messages.
//#define JACK_MIDI_DEBUG
+namespace MusEGlobal {
extern unsigned int volatile lastExtMidiSyncTick;
+}
+
+namespace MusECore {
//---------------------------------------------------------
// MidiJackDevice
@@ -68,12 +72,12 @@ MidiJackDevice::~MidiJackDevice()
printf("MidiJackDevice::~MidiJackDevice()\n");
#endif
- if(audioDevice)
+ if(MusEGlobal::audioDevice)
{
if(_in_client_jackport)
- audioDevice->unregisterPort(_in_client_jackport);
+ MusEGlobal::audioDevice->unregisterPort(_in_client_jackport);
if(_out_client_jackport)
- audioDevice->unregisterPort(_out_client_jackport);
+ MusEGlobal::audioDevice->unregisterPort(_out_client_jackport);
}
//close();
@@ -92,7 +96,7 @@ MidiDevice* MidiJackDevice::createJackMidiDevice(QString name, int rwflags) // 1
for( ; ni < 65536; ++ni)
{
name.sprintf("jack-midi-%d", ni);
- if(!midiDevices.find(name))
+ if(!MusEGlobal::midiDevices.find(name))
break;
}
}
@@ -104,7 +108,7 @@ MidiDevice* MidiJackDevice::createJackMidiDevice(QString name, int rwflags) // 1
MidiJackDevice* dev = new MidiJackDevice(name);
dev->setrwFlags(rwflags);
- midiDevices.add(dev);
+ MusEGlobal::midiDevices.add(dev);
return dev;
}
@@ -120,9 +124,9 @@ void MidiJackDevice::setName(const QString& s)
_name = s;
if(inClientPort())
- audioDevice->setPortName(inClientPort(), (s + QString(JACK_MIDI_IN_PORT_SUFFIX)).toLatin1().constData());
+ MusEGlobal::audioDevice->setPortName(inClientPort(), (s + QString(JACK_MIDI_IN_PORT_SUFFIX)).toLatin1().constData());
if(outClientPort())
- audioDevice->setPortName(outClientPort(), (s + QString(JACK_MIDI_OUT_PORT_SUFFIX)).toLatin1().constData());
+ MusEGlobal::audioDevice->setPortName(outClientPort(), (s + QString(JACK_MIDI_OUT_PORT_SUFFIX)).toLatin1().constData());
}
//---------------------------------------------------------
@@ -142,10 +146,10 @@ QString MidiJackDevice::open()
{
if(!_out_client_jackport)
{
- if(audioDevice->deviceType() == AudioDevice::JACK_AUDIO)
+ if(MusEGlobal::audioDevice->deviceType() == AudioDevice::JACK_AUDIO)
{
s = name() + QString(JACK_MIDI_OUT_PORT_SUFFIX);
- _out_client_jackport = (jack_port_t*)audioDevice->registerOutPort(s.toLatin1().constData(), true);
+ _out_client_jackport = (jack_port_t*)MusEGlobal::audioDevice->registerOutPort(s.toLatin1().constData(), true);
if(!_out_client_jackport)
{
fprintf(stderr, "MusE: MidiJackDevice::open failed creating output port name %s\n", s.toLatin1().constData());
@@ -178,8 +182,8 @@ QString MidiJackDevice::open()
// When I toggle the lights again (which kills, then recreates the ports here), the problem can disappear or come back again.
// Also once observed a weird double connection from the port to two different Jack ports but one of
// the connections should not have been there and kept toggling along with the other (like a 'ghost' connection).
- audio->msgRemoveRoutes(Route(this, 0), Route()); // New function msgRemoveRoutes simply uses Routes, for their pointers.
- audioDevice->unregisterPort(_out_client_jackport);
+ MusEGlobal::audio->msgRemoveRoutes(Route(this, 0), Route()); // New function msgRemoveRoutes simply uses Routes, for their pointers.
+ MusEGlobal::audioDevice->unregisterPort(_out_client_jackport);
}
_out_client_jackport = NULL;
}
@@ -188,10 +192,10 @@ QString MidiJackDevice::open()
{
if(!_in_client_jackport)
{
- if(audioDevice->deviceType() == AudioDevice::JACK_AUDIO)
+ if(MusEGlobal::audioDevice->deviceType() == AudioDevice::JACK_AUDIO)
{
s = name() + QString(JACK_MIDI_IN_PORT_SUFFIX);
- _in_client_jackport = (jack_port_t*)audioDevice->registerInPort(s.toLatin1().constData(), true);
+ _in_client_jackport = (jack_port_t*)MusEGlobal::audioDevice->registerInPort(s.toLatin1().constData(), true);
if(!_in_client_jackport)
{
fprintf(stderr, "MusE: MidiJackDevice::open failed creating input port name %s\n", s.toLatin1().constData());
@@ -204,8 +208,8 @@ QString MidiJackDevice::open()
{
if(_in_client_jackport)
{
- audio->msgRemoveRoutes(Route(), Route(this, 0));
- audioDevice->unregisterPort(_in_client_jackport);
+ MusEGlobal::audio->msgRemoveRoutes(Route(), Route(this, 0));
+ MusEGlobal::audioDevice->unregisterPort(_in_client_jackport);
}
_in_client_jackport = NULL;
}
@@ -241,7 +245,7 @@ void MidiJackDevice::close()
else
if(pf & JackPortIsInput)
_nextInIdNum--;
- audioDevice->unregisterPort(_client_jackport);
+ MusEGlobal::audioDevice->unregisterPort(_client_jackport);
_client_jackport = 0;
_writeEnable = false;
_readEnable = false;
@@ -327,9 +331,9 @@ bool MidiJackDevice::putMidiEvent(const MidiPlayEvent& /*event*/)
void MidiJackDevice::recordEvent(MidiRecordEvent& event)
{
// Set the loop number which the event came in at.
- //if(audio->isRecording())
- if(audio->isPlaying())
- event.setLoopNum(audio->loopCount());
+ //if(MusEGlobal::audio->isRecording())
+ if(MusEGlobal::audio->isPlaying())
+ event.setLoopNum(MusEGlobal::audio->loopCount());
if (MusEGlobal::midiInputTrace) {
printf("Jack MidiInput: ");
@@ -340,7 +344,7 @@ void MidiJackDevice::recordEvent(MidiRecordEvent& event)
if(_port != -1)
{
- int idin = midiPorts[_port].syncInfo().idIn();
+ int idin = MusEGlobal::midiPorts[_port].syncInfo().idIn();
//---------------------------------------------------
// filter some SYSEX events
@@ -355,25 +359,25 @@ void MidiJackDevice::recordEvent(MidiRecordEvent& event)
&& ((p[1] == 0x7f) || (idin == 0x7f) || (p[1] == idin))) {
if (p[2] == 0x06) {
//mmcInput(p, n);
- midiSeq->mmcInput(_port, p, n);
+ MusEGlobal::midiSeq->mmcInput(_port, p, n);
return;
}
if (p[2] == 0x01) {
//mtcInputFull(p, n);
- midiSeq->mtcInputFull(_port, p, n);
+ MusEGlobal::midiSeq->mtcInputFull(_port, p, n);
return;
}
}
else if (p[0] == 0x7e) {
//nonRealtimeSystemSysex(p, n);
- midiSeq->nonRealtimeSystemSysex(_port, p, n);
+ MusEGlobal::midiSeq->nonRealtimeSystemSysex(_port, p, n);
return;
}
}
}
else
// Trigger general activity indicator detector. Sysex has no channel, don't trigger.
- midiPorts[_port].syncInfo().trigActDetect(event.channel());
+ MusEGlobal::midiPorts[_port].syncInfo().trigActDetect(event.channel());
}
//
@@ -398,11 +402,11 @@ void MidiJackDevice::recordEvent(MidiRecordEvent& event)
//
if (typ == ME_NOTEON) {
int pv = ((event.dataA() & 0xff)<<8) + (event.dataB() & 0xff);
- song->putEvent(pv);
+ MusEGlobal::song->putEvent(pv);
}
else if (typ == ME_NOTEOFF) {
int pv = ((event.dataA() & 0xff)<<8) + (0x00); //send an event with velo=0
- song->putEvent(pv);
+ MusEGlobal::song->putEvent(pv);
}
//if(_recordFifo.put(MidiPlayEvent(event)))
@@ -438,10 +442,10 @@ void MidiJackDevice::eventReceived(jack_midi_event_t* ev)
// catch process play
//
- //int frameOffset = audio->getFrameOffset();
- unsigned pos = audio->pos().frame();
+ //int frameOffset = MusEGlobal::audio->getFrameOffset();
+ unsigned pos = MusEGlobal::audio->pos().frame();
- event.setTime(extSyncFlag.value() ? lastExtMidiSyncTick : (pos + ev->time)); // p3.3.25
+ event.setTime(MusEGlobal::extSyncFlag.value() ? MusEGlobal::lastExtMidiSyncTick : (pos + ev->time)); // p3.3.25
event.setChannel(*(ev->buffer) & 0xf);
int type = *(ev->buffer) & 0xf0;
@@ -486,11 +490,11 @@ void MidiJackDevice::eventReceived(jack_midi_event_t* ev)
break;
case ME_MTC_QUARTER:
if(_port != -1)
- midiSeq->mtcInputQuarter(_port, *(ev->buffer + 1));
+ MusEGlobal::midiSeq->mtcInputQuarter(_port, *(ev->buffer + 1));
return;
case ME_SONGPOS:
if(_port != -1)
- midiSeq->setSongPosition(_port, *(ev->buffer + 1) | (*(ev->buffer + 2) >> 2 )); // LSB then MSB
+ MusEGlobal::midiSeq->setSongPosition(_port, *(ev->buffer + 1) | (*(ev->buffer + 2) >> 2 )); // LSB then MSB
return;
//case ME_SONGSEL:
//case ME_TUNE_REQ:
@@ -501,7 +505,7 @@ void MidiJackDevice::eventReceived(jack_midi_event_t* ev)
case ME_CONTINUE:
case ME_STOP:
if(_port != -1)
- midiSeq->realtimeSystemInput(_port, type);
+ MusEGlobal::midiSeq->realtimeSystemInput(_port, type);
return;
//case ME_SYSEX_END:
//break;
@@ -609,8 +613,8 @@ bool MidiJackDevice::queueEvent(const MidiPlayEvent& e)
void* pb = jack_port_get_buffer(_out_client_jackport, MusEGlobal::segmentSize);
//unsigned frameCounter = ->frameTime();
- int frameOffset = audio->getFrameOffset();
- unsigned pos = audio->pos().frame();
+ int frameOffset = MusEGlobal::audio->getFrameOffset();
+ unsigned pos = MusEGlobal::audio->pos().frame();
int ft = e.time() - frameOffset - pos;
if (ft < 0)
@@ -715,8 +719,8 @@ bool MidiJackDevice::queueEvent(const MidiPlayEvent& e)
bool MidiJackDevice::processEvent(const MidiPlayEvent& event)
{
- //int frameOffset = audio->getFrameOffset();
- //unsigned pos = audio->pos().frame();
+ //int frameOffset = MusEGlobal::audio->getFrameOffset();
+ //unsigned pos = MusEGlobal::audio->pos().frame();
int chn = event.channel();
unsigned t = event.time();
@@ -730,11 +734,11 @@ bool MidiJackDevice::processEvent(const MidiPlayEvent& event)
// Just do this 'standard midi 64T timing thing' for now until we figure out more precise external timings.
// Does require relatively short audio buffers, in order to catch the resolution, but buffer <= 256 should be OK...
// Tested OK so far with 128.
- //if(extSyncFlag.value())
+ //if(MusEGlobal::extSyncFlag.value())
// p4.0.15 Or, is the event marked to be played immediately?
// Nothing to do but stamp the event to be queued for frame 0+.
- if(t == 0 || extSyncFlag.value())
- t = audio->getFrameOffset() + audio->pos().frame();
+ if(t == 0 || MusEGlobal::extSyncFlag.value())
+ t = MusEGlobal::audio->getFrameOffset() + MusEGlobal::audio->pos().frame();
//t = frameOffset + pos;
#ifdef JACK_MIDI_DEBUG
@@ -744,7 +748,7 @@ bool MidiJackDevice::processEvent(const MidiPlayEvent& event)
if(event.type() == ME_PROGRAM)
{
// don't output program changes for GM drum channel
- //if (!(song->mtype() == MT_GM && chn == 9)) {
+ //if (!(MusEGlobal::song->mtype() == MT_GM && chn == 9)) {
int hb = (a >> 16) & 0xff;
int lb = (a >> 8) & 0xff;
int pr = a & 0x7f;
@@ -782,7 +786,7 @@ bool MidiJackDevice::processEvent(const MidiPlayEvent& event)
int nvl = 0xff;
if(_port != -1)
{
- int nv = midiPorts[_port].nullSendValue();
+ int nv = MusEGlobal::midiPorts[_port].nullSendValue();
if(nv != -1)
{
nvh = (nv >> 8) & 0xff;
@@ -800,7 +804,7 @@ bool MidiJackDevice::processEvent(const MidiPlayEvent& event)
else if (a == CTRL_PROGRAM)
{
// don't output program changes for GM drum channel
- //if (!(song->mtype() == MT_GM && chn == 9)) {
+ //if (!(MusEGlobal::song->mtype() == MT_GM && chn == 9)) {
int hb = (b >> 16) & 0xff;
int lb = (b >> 8) & 0xff;
int pr = b & 0x7f;
@@ -1016,7 +1020,7 @@ void MidiJackDevice::processMidi()
// Same code as in MidiPort::sendEvent()
if(_port != -1)
{
- MidiPort* mp = &midiPorts[_port];
+ MidiPort* mp = &MusEGlobal::midiPorts[_port];
if(i->type() == ME_CONTROLLER)
{
int da = i->dataA();
@@ -1063,3 +1067,4 @@ bool initMidiJack()
return false;
}
+} // namespace MusECore
diff --git a/muse2/muse/driver/jackmidi.h b/muse2/muse/driver/jackmidi.h
index e79e9288..d2c14190 100644
--- a/muse2/muse/driver/jackmidi.h
+++ b/muse2/muse/driver/jackmidi.h
@@ -36,9 +36,11 @@
class QString;
//class MidiFifo;
+//class RouteList;
+
+namespace MusECore {
class MidiRecordEvent;
class MidiPlayEvent;
-//class RouteList;
class Xml;
// It appears one client port per remote port will be necessary.
@@ -93,6 +95,8 @@ class MidiJackDevice : public MidiDevice {
extern bool initMidiJack();
+} // namespace MusECore
+
#endif
diff --git a/muse2/muse/driver/rtctimer.cpp b/muse2/muse/driver/rtctimer.cpp
index 8410bb04..365b8501 100644
--- a/muse2/muse/driver/rtctimer.cpp
+++ b/muse2/muse/driver/rtctimer.cpp
@@ -41,6 +41,7 @@
#include "globals.h"
#include "gconfig.h"
+namespace MusECore {
RtcTimer::RtcTimer()
{
@@ -70,7 +71,7 @@ signed int RtcTimer::initTimer()
MusEGlobal::undoSetuid();
return timerFd;
}
- if (!setTimerFreq(MusEConfig::config.rtcTicks)) {
+ if (!setTimerFreq(MusEGlobal::config.rtcTicks)) {
// unable to set timer frequency
return -1;
}
@@ -168,3 +169,5 @@ unsigned int RtcTimer::getTimerTicks(bool /*printTicks*/)// prevent compiler war
}
return nn;
}
+
+} // namespace MusECore
diff --git a/muse2/muse/driver/rtctimer.h b/muse2/muse/driver/rtctimer.h
index 5befdf22..425ea643 100644
--- a/muse2/muse/driver/rtctimer.h
+++ b/muse2/muse/driver/rtctimer.h
@@ -29,6 +29,7 @@
#include "timerdev.h"
+namespace MusECore {
//---------------------------------------------------------
// AlsaTimer
@@ -56,4 +57,6 @@ class RtcTimer : public Timer{
};
+} // namespace MusECore
+
#endif //__ALSATIMER_H__
diff --git a/muse2/muse/driver/timerdev.h b/muse2/muse/driver/timerdev.h
index 960cf2f4..56f9216e 100644
--- a/muse2/muse/driver/timerdev.h
+++ b/muse2/muse/driver/timerdev.h
@@ -31,6 +31,8 @@
#define TIMER_DEBUG 0
+namespace MusECore {
+
//---------------------------------------------------------
// AlsaTimer
//---------------------------------------------------------
@@ -53,4 +55,6 @@ class Timer {
};
+} // namespace MusECore
+
#endif //__ALSATIMER_H__