summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim E. Real <termtech@rogers.com>2010-02-18 11:30:50 +0000
committerTim E. Real <termtech@rogers.com>2010-02-18 11:30:50 +0000
commit8225442c1aa4b8d9c618188184c1e86202b663fe (patch)
treed77175115bb88de0b0201d938eaf422d19d3c084
parent763c632b5f8f2be720901d9ff83ac1945442ca16 (diff)
See ChangeLog
-rw-r--r--muse/ChangeLog9
-rw-r--r--muse/al/dsp.cpp6
-rw-r--r--muse/muse/app.cpp27
-rw-r--r--muse/muse/driver/alsamidi.cpp19
-rw-r--r--muse/muse/driver/audiodev.h8
-rw-r--r--muse/muse/driver/dummyaudio.cpp6
-rw-r--r--muse/muse/driver/jack.cpp279
-rw-r--r--muse/muse/driver/jackaudio.h9
-rw-r--r--muse/muse/driver/jackmidi.cpp561
-rw-r--r--muse/muse/driver/jackmidi.h26
-rw-r--r--muse/muse/exportmidi.cpp19
-rw-r--r--muse/muse/midi.cpp3
-rw-r--r--muse/muse/midictrl.cpp41
-rw-r--r--muse/muse/midictrl.h15
-rw-r--r--muse/muse/mididev.cpp20
-rw-r--r--muse/muse/midiseq.cpp4
-rw-r--r--muse/muse/node.cpp6
-rw-r--r--muse/muse/seqmsg.cpp6
-rw-r--r--muse/muse/song.cpp8
19 files changed, 603 insertions, 469 deletions
diff --git a/muse/ChangeLog b/muse/ChangeLog
index d77a3d83..a9505d58 100644
--- a/muse/ChangeLog
+++ b/muse/ChangeLog
@@ -1,3 +1,12 @@
+18.02.2010
+ * Added: Separate Jack midi client ports per MusE port. (T356)
+ - For now, you will have to manually add further connections to those ports if desired, each session.
+ - Tested OK rec/play so far.
+ * Fixed: Some inconsistencies in midi controller number decoding. (T356)
+ - Everything now references the values listed in midictrl.h
+ * Fixed: Some Jack code was not calling free after calling certain functions. (T356)
+ * Changed: Midi priority now deaults to audio priority +1. (T356)
+ - Thanks to RJ for the convincing argument.
14.02.2010
* Added: Jack midi input should be working now. Controllers, too. (T356)
- Tested with large 1024 frame buffer. Events are recorded with good sub-tick (frame) resolution,
diff --git a/muse/al/dsp.cpp b/muse/al/dsp.cpp
index 2cdf6495..9d549ed7 100644
--- a/muse/al/dsp.cpp
+++ b/muse/al/dsp.cpp
@@ -93,10 +93,10 @@ class DspSSE86 : public Dsp {
void initDsp()
{
#if defined(__i386__) || defined(__x86_64__)
- //if(debugMsg)
+ if(debugMsg)
printf("Muse: __i386__ or __x86_64__ defined. Using optimized float buffer copying (asm movsl).\n");
#else
- //if(debugMsg)
+ if(debugMsg)
printf("Muse: __i386__ or __x86_64__ not defined. Using non-optimized memcpy for float buffer copying.\n");
#endif
@@ -133,7 +133,7 @@ void initDsp()
}
// fall through to not hardware optimized routines
#endif
- //if(debugMsg)
+ if(debugMsg)
printf("Muse: using unoptimized non-SSE dsp routines\n");
dsp = new Dsp();
}
diff --git a/muse/muse/app.cpp b/muse/muse/app.cpp
index e3ec67fe..6bc52319 100644
--- a/muse/muse/app.cpp
+++ b/muse/muse/app.cpp
@@ -186,6 +186,8 @@ void microSleep(long msleep)
sleepOk=usleep(msleep);
}
+// Removed p3.3.17
+/*
//---------------------------------------------------------
// watchdog thread
//---------------------------------------------------------
@@ -250,6 +252,7 @@ static void* watchdog(void*)
printf("watchdog exit\n");
exit(-1);
}
+*/
//---------------------------------------------------------
// seqStart
@@ -419,24 +422,32 @@ bool MusE::seqStart()
if(realTimePriority == 3)
{
pfprio = 1;
- midiprio = 2;
+ //midiprio = 2;
+ // p3.3.37
+ midiprio = 4;
}
else
if(realTimePriority == 4)
{
pfprio = 1;
- midiprio = 3;
+ //midiprio = 3;
+ // p3.3.37
+ midiprio = 5;
}
else
if(realTimePriority == 5)
{
pfprio = 1;
- midiprio = 3;
+ //midiprio = 3;
+ // p3.3.37
+ midiprio = 6;
}
else
{
pfprio = realTimePriority - 5;
- midiprio = realTimePriority - 2;
+ //midiprio = realTimePriority - 2;
+ // p3.3.37
+ midiprio = realTimePriority + 1;
}
}
@@ -473,7 +484,11 @@ bool MusE::seqStart()
usleep(1000);
printf("looping waiting for sequencer thread to start\n");
}
- printf("midiSeq started, is it running? %d \n",midiSeqRunning);
+ if(!midiSeqRunning)
+ {
+ fprintf(stderr, "midiSeq is not running! Exiting...\n");
+ exit(33);
+ }
return true;
}
@@ -2349,7 +2364,7 @@ static void usage(const char* prog, const char* txt)
fprintf(stderr, " -a no audio\n");
//fprintf(stderr, " -P n set real time priority to n (default: 50)\n");
fprintf(stderr, " -P n set audio driver real time priority to n (Dummy only, default 40. Else fixed by Jack.)\n");
- fprintf(stderr, " -Y n force midi real time priority to n (default: audio driver prio -2)\n");
+ fprintf(stderr, " -Y n force midi real time priority to n (default: audio driver prio +1)\n");
fprintf(stderr, " -p don't load LADSPA plugins\n");
#ifdef ENABLE_PYTHON
fprintf(stderr, " -y enable Python control support\n");
diff --git a/muse/muse/driver/alsamidi.cpp b/muse/muse/driver/alsamidi.cpp
index bbf320da..c9e14bbc 100644
--- a/muse/muse/driver/alsamidi.cpp
+++ b/muse/muse/driver/alsamidi.cpp
@@ -206,17 +206,21 @@ bool MidiAlsaDevice::putMidiEvent(const MidiPlayEvent& e)
int a = e.dataA();
int b = e.dataB();
int chn = e.channel();
- if (a < 0x1000) { // 7 Bit Controller
+ // p3.3.37
+ //if (a < 0x1000) { // 7 Bit Controller
+ if (a < CTRL_14_OFFSET) { // 7 Bit Controller
snd_seq_ev_set_controller(&event, chn, a, b);
}
- else if (a < 0x20000) { // 14 bit high resolution controller
+ //else if (a < 0x20000) { // 14 bit high resolution controller
+ else if (a < CTRL_RPN_OFFSET) { // 14 bit high resolution controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
a = (ctrlH << 7) + ctrlL;
snd_seq_ev_set_controller(&event, chn, a, b);
event.type = SND_SEQ_EVENT_CONTROL14;
}
- else if (a < 0x30000) { // RPN 7-Bit Controller
+ //else if (a < 0x30000) { // RPN 7-Bit Controller
+ else if (a < CTRL_NRPN_OFFSET) { // RPN 7-Bit Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
a = (ctrlH << 7) + ctrlL;
@@ -224,7 +228,8 @@ bool MidiAlsaDevice::putMidiEvent(const MidiPlayEvent& e)
snd_seq_ev_set_controller(&event, chn, a, b);
event.type = SND_SEQ_EVENT_REGPARAM;
}
- else if (a < 0x40000) { // NRPN 7-Bit Controller
+ //else if (a < 0x40000) { // NRPN 7-Bit Controller
+ else if (a < CTRL_INTERNAL_OFFSET) { // NRPN 7-Bit Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
a = (ctrlH << 7) + ctrlL;
@@ -232,14 +237,16 @@ bool MidiAlsaDevice::putMidiEvent(const MidiPlayEvent& e)
snd_seq_ev_set_controller(&event, chn, a, b);
event.type = SND_SEQ_EVENT_NONREGPARAM;
}
- else if (a < 0x60000) { // RPN14 Controller
+ //else if (a < 0x60000) { // RPN14 Controller
+ else if (a < CTRL_NRPN14_OFFSET) { // RPN14 Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
a = (ctrlH << 7) + ctrlL;
snd_seq_ev_set_controller(&event, chn, a, b);
event.type = SND_SEQ_EVENT_REGPARAM;
}
- else if (a < 0x70000) { // NRPN14 Controller
+ //else if (a < 0x70000) { // NRPN14 Controller
+ else if (a < CTRL_NONE_OFFSET) { // NRPN14 Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
a = (ctrlH << 7) + ctrlL;
diff --git a/muse/muse/driver/audiodev.h b/muse/muse/driver/audiodev.h
index e0ddb3b9..f66627b8 100644
--- a/muse/muse/driver/audiodev.h
+++ b/muse/muse/driver/audiodev.h
@@ -38,8 +38,11 @@ class AudioDevice {
virtual void registerClient() = 0;
- virtual void* registerOutPort(const char* name) = 0;
- virtual void* registerInPort(const char* name) = 0;
+ //virtual void* registerOutPort(const char* name) = 0;
+ //virtual void* registerInPort(const char* name) = 0;
+ virtual void* registerOutPort(const char* /*name*/, bool /*midi*/) = 0;
+ virtual void* registerInPort(const char* /*name*/, bool /*midi*/) = 0;
+
virtual void unregisterPort(void*) = 0;
virtual void connect(void*, void*) = 0;
virtual void disconnect(void*, void*) = 0;
@@ -56,6 +59,7 @@ class AudioDevice {
virtual void seekTransport(const Pos &p) = 0;
virtual void setFreewheel(bool f) = 0;
virtual void graphChanged() {}
+ virtual void registrationChanged() {}
virtual int setMaster(bool f) = 0;
};
diff --git a/muse/muse/driver/dummyaudio.cpp b/muse/muse/driver/dummyaudio.cpp
index e22c44da..2695f705 100644
--- a/muse/muse/driver/dummyaudio.cpp
+++ b/muse/muse/driver/dummyaudio.cpp
@@ -93,10 +93,12 @@ class DummyAudioDevice : public AudioDevice {
virtual void registerClient() {}
- virtual void* registerOutPort(const char*) {
+ //virtual void* registerOutPort(const char*) {
+ virtual void* registerOutPort(const char*, bool) {
return (void*)1;
}
- virtual void* registerInPort(const char*) {
+ //virtual void* registerInPort(const char*) {
+ virtual void* registerInPort(const char*, bool) {
return (void*)2;
}
virtual void unregisterPort(void*) {}
diff --git a/muse/muse/driver/jack.cpp b/muse/muse/driver/jack.cpp
index ee15c4b3..53002edc 100644
--- a/muse/muse/driver/jack.cpp
+++ b/muse/muse/driver/jack.cpp
@@ -7,6 +7,7 @@
#include "config.h"
#include <stdio.h>
+#include <stdlib.h>
#include <errno.h>
#include <stdarg.h>
//#include <time.h>
@@ -25,6 +26,7 @@
#include "utils.h"
#include "midi.h"
+#include "mididev.h"
#include "mpevent.h"
#include "jackmidi.h"
@@ -46,33 +48,12 @@ extern void undoSetuid();
//extern int jackmidi_pi[2];
//extern int jackmidi_po[2];
-jack_port_t *midi_port_in[JACK_MIDI_CHANNELS];
-jack_port_t *midi_port_out[JACK_MIDI_CHANNELS];
+//jack_port_t *midi_port_in[JACK_MIDI_CHANNELS];
+//jack_port_t *midi_port_out[JACK_MIDI_CHANNELS];
//muse_jack_midi_buffer jack_midi_out_data[JACK_MIDI_CHANNELS];
//muse_jack_midi_buffer jack_midi_in_data[JACK_MIDI_CHANNELS];
-//jack_port_t *jackMidiInPort = 0;
-//jack_port_t *jackMidiOutPort = 0;
-/*
-struct JackPort
-{
- int adr;
- //char* name;
- QString name;
- int flags;
- //JackPort(int a, const char* s, int f) {
- JackPort(int a, const QString& s, int f)
- {
- adr = a;
- //name = strdup(s);
- name = QString(s);
- flags = f;
- }
-};
-static std::list<JackPort> portList;
-*/
-
JackAudioDevice* jackAudio;
//---------------------------------------------------------
@@ -470,6 +451,7 @@ JackAudioDevice::~JackAudioDevice()
printf("~JackAudioDevice()\n");
if (_client) {
+ /*
// p3.3.35
for(int i = 0; i < JACK_MIDI_CHANNELS; i++)
{
@@ -478,6 +460,7 @@ JackAudioDevice::~JackAudioDevice()
if(midi_port_out[i])
jack_port_unregister(_client, midi_port_out[i]);
}
+ */
if (jack_client_close(_client)) {
//error->logError("jack_client_close() failed: %s\n", strerror(errno));
@@ -529,12 +512,14 @@ char* JackAudioDevice::getJackName()
bool initJackAudio()
{
+ /*
// p3.3.35
for(int i = 0; i < JACK_MIDI_CHANNELS; i++)
{
midi_port_in[i] = 0;
midi_port_out[i] = 0;
}
+ */
if (JACK_DEBUG)
printf("initJackAudio()\n");
@@ -575,6 +560,7 @@ bool initJackAudio()
}
undoSetuid();
+ /*
// setup midi input/output
//memset(jack_midi_out_data, 0, JACK_MIDI_CHANNELS * sizeof(muse_jack_midi_buffer));
//memset(jack_midi_in_data, 0, JACK_MIDI_CHANNELS * sizeof(muse_jack_midi_buffer));
@@ -605,6 +591,7 @@ bool initJackAudio()
{
fprintf(stderr, "WARNING NO muse-jack midi connection\n");
}
+ */
if (client) {
audioDevice = jackAudio;
@@ -643,9 +630,153 @@ static int srate_callback(jack_nframes_t n, void*)
//---------------------------------------------------------
static void registration_callback(jack_port_id_t, int, void*)
+{
+ if(debugMsg || JACK_DEBUG)
+ printf("JACK: registration changed\n");
+
+ audio->sendMsgToGui('R');
+}
+
+//---------------------------------------------------------
+// JackAudioDevice::registrationChanged
+// this is called from song in gui context triggered
+// by registration_callback()
+//---------------------------------------------------------
+
+void JackAudioDevice::registrationChanged()
+{
+ if(JACK_DEBUG)
+ printf("JackAudioDevice::registrationChanged()\n");
+
+ // Connect the Jack midi client ports to the device ports.
+ connectJackMidiPorts();
+}
+
+//---------------------------------------------------------
+// JackAudioDevice::connectJackMidiPorts
+//---------------------------------------------------------
+
+void JackAudioDevice::connectJackMidiPorts()
+{
+ if(JACK_DEBUG)
+ printf("JackAudioDevice::connectJackMidiPorts()\n");
+
+ const char* type = JACK_DEFAULT_MIDI_TYPE;
+ const char** ports = jack_get_ports(_client, 0, type, 0);
+ for (const char** p = ports; p && *p; ++p)
+ {
+ jack_port_t* port = jack_port_by_name(_client, *p);
+ if(!port)
+ continue;
+ int nsz = jack_port_name_size();
+ char buffer[nsz];
+ strncpy(buffer, *p, nsz);
+ // Ignore the MusE Jack port.
+ //if(strncmp(buffer, "MusE", 4) == 0)
+ // continue;
+
+ // If there are aliases for this port, use the first one - much better for identifying.
+ //char a1[nsz];
+ char a2[nsz];
+ char* aliases[2];
+ //aliases[0] = a1;
+ aliases[0] = buffer;
+ aliases[1] = a2;
+ // To disable aliases, just rem this line.
+ jack_port_get_aliases(port, aliases);
+ //int na = jack_port_get_aliases(port, aliases);
+ //char* namep = (na >= 1) ? aliases[0] : buffer;
+ char* namep = aliases[0];
+
+ //int flags = 0;
+ int pf = jack_port_flags(port);
+ // If Jack port can send data to us...
+ //if(pf & JackPortIsOutput)
+ // Mark as input capable.
+ // flags |= 2;
+ // If Jack port can receive data from us...
+ //if(pf & JackPortIsInput)
+ // Mark as output capable.
+ // flags |= 1;
+
+ //JackPort jp(0, QString(buffer), flags);
+ //portList.append(jp);
+
+ QString name(namep);
+
+ if(JACK_DEBUG)
+ printf("JackAudioDevice::graphChanged %s\n", name.latin1());
+
+ for(iMidiDevice imd = midiDevices.begin(); imd != midiDevices.end(); ++imd)
+ {
+ // Is it a Jack midi device?
+ MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(*imd);
+ if(!mjd)
+ continue;
+
+ //if(dev->name() != name)
+ // continue;
+
+ // Is this port the one created for the Jack midi device?
+ if(!mjd->clientJackPort() || (mjd->clientJackPort() != port))
+ continue;
+
+ jack_port_t* devport = jack_port_by_name(_client, mjd->name().latin1());
+ if(!devport)
+ continue;
+
+ int ofl = mjd->openFlags();
+
+ if(JACK_DEBUG)
+ printf("JackAudioDevice::graphChanged found MidiJackDevice:%s\n", mjd->name().latin1());
+
+ // Note docs say it can't be both input and output. src, dest
+ // If Jack port can receive data from us and we actually want to...
+ if((pf & JackPortIsOutput) && (ofl & 1))
+ {
+ if(JACK_DEBUG)
+ printf("JackAudioDevice::graphChanged connecting MusE output\n");
+ audioDevice->connect(port, devport);
+ }
+ else
+ // If Jack port can send data to us and we actually want it...
+ if((pf & JackPortIsInput) && (ofl & 2))
+ {
+ if(JACK_DEBUG)
+ printf("JackAudioDevice::graphChanged connecting MusE input\n");
+ audioDevice->connect(devport, port);
+ }
+
+ break;
+ }
+ }
+
+ if(ports)
+ free(ports);
+}
+//---------------------------------------------------------
+// client_registration_callback
+//---------------------------------------------------------
+
+static void client_registration_callback(const char *name, int isRegister, void*)
{
if (debugMsg || JACK_DEBUG)
- printf("JACK: registration changed\n");
+ printf("JACK: client registration changed:%s register:%d\n", name, isRegister);
+ }
+
+//---------------------------------------------------------
+// port_connect_callback
+//---------------------------------------------------------
+
+static void port_connect_callback(jack_port_id_t a, jack_port_id_t b, int isConnect, void*)
+ {
+ if (debugMsg || JACK_DEBUG)
+ {
+ //jack_port_t* ap = jack_port_by_id(_client, a);
+ //jack_port_t* bp = jack_port_by_id(_client, b);
+ //printf("JACK: port connections changed: A:%d:%s B:%d:%s isConnect:%d\n", a, jack_port_name(ap), b, jack_port_name(bp), isConnect);
+ printf("JACK: port connections changed: A:%d B:%d isConnect:%d\n", a, b, isConnect);
+ }
}
//---------------------------------------------------------
@@ -674,7 +805,7 @@ static int graph_callback(void*)
//---------------------------------------------------------
void JackAudioDevice::graphChanged()
- {
+{
if (JACK_DEBUG)
printf("graphChanged()\n");
if(!checkJackClient(_client)) return;
@@ -753,7 +884,10 @@ void JackAudioDevice::graphChanged()
++pn;
}
- delete ports;
+ // p3.3.37
+ //delete ports;
+ free(ports);
+
ports = NULL;
}
}
@@ -832,12 +966,16 @@ void JackAudioDevice::graphChanged()
++pn;
}
- delete ports;
+ // p3.3.37
+ //delete ports;
+ free(ports);
+
ports = NULL;
}
}
}
- }
+
+}
//static int xrun_callback(void*)
// {
@@ -866,6 +1004,10 @@ void JackAudioDevice::registerClient()
jack_set_buffer_size_callback(_client, bufsize_callback, 0);
jack_set_sample_rate_callback(_client, srate_callback, 0);
jack_set_port_registration_callback(_client, registration_callback, 0);
+ // p3.3.37
+ jack_set_client_registration_callback(_client, client_registration_callback, 0);
+ jack_set_port_connect_callback(_client, port_connect_callback, 0);
+
jack_set_graph_order_callback(_client, graph_callback, 0);
// jack_set_xrun_callback(client, xrun_callback, 0);
jack_set_freewheel_callback (_client, freewheel_callback, 0);
@@ -875,12 +1017,15 @@ void JackAudioDevice::registerClient()
// registerInPort
//---------------------------------------------------------
-void* JackAudioDevice::registerInPort(const char* name)
+//void* JackAudioDevice::registerInPort(const char* name)
+void* JackAudioDevice::registerInPort(const char* name, bool midi)
{
if (JACK_DEBUG)
printf("registerInPort()\n");
if(!checkJackClient(_client)) return NULL;
- void* p = jack_port_register(_client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
+ const char* type = midi ? JACK_DEFAULT_MIDI_TYPE : JACK_DEFAULT_AUDIO_TYPE;
+ //void* p = jack_port_register(_client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
+ void* p = jack_port_register(_client, name, type, JackPortIsInput, 0);
// printf("JACK: registerInPort: <%s> %p\n", name, p);
return p;
}
@@ -889,12 +1034,15 @@ void* JackAudioDevice::registerInPort(const char* name)
// registerOutPort
//---------------------------------------------------------
-void* JackAudioDevice::registerOutPort(const char* name)
+//void* JackAudioDevice::registerOutPort(const char* name)
+void* JackAudioDevice::registerOutPort(const char* name, bool midi)
{
if (JACK_DEBUG)
printf("registerOutPort()\n");
if(!checkJackClient(_client)) return NULL;
- void* p = jack_port_register(_client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
+ const char* type = midi ? JACK_DEFAULT_MIDI_TYPE : JACK_DEFAULT_AUDIO_TYPE;
+ //void* p = jack_port_register(_client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
+ void* p = jack_port_register(_client, name, type, JackPortIsOutput, 0);
// printf("JACK: registerOutPort: <%s> %p\n", name, p);
return p;
}
@@ -923,7 +1071,7 @@ void exitJackAudio()
//---------------------------------------------------------
void JackAudioDevice::connect(void* src, void* dst)
- {
+{
if (JACK_DEBUG)
printf("JackAudioDevice::connect()\n");
if(!checkJackClient(_client)) return;
@@ -933,18 +1081,26 @@ void JackAudioDevice::connect(void* src, void* dst)
fprintf(stderr, "JackAudio::connect: unknown jack ports\n");
return;
}
- if (jack_connect(_client, sn, dn)) {
- fprintf(stderr, "jack connect <%s>%p - <%s>%p failed\n",
- sn, src, dn, dst);
+ int err = jack_connect(_client, sn, dn);
+ //if (jack_connect(_client, sn, dn)) {
+ if (err) {
+ fprintf(stderr, "jack connect <%s>%p - <%s>%p failed with err:%d\n",
+ sn, src, dn, dst, err);
}
- }
+ else
+ if (JACK_DEBUG)
+ {
+ fprintf(stderr, "jack connect <%s>%p - <%s>%p succeeded\n",
+ sn, src, dn, dst);
+ }
+}
//---------------------------------------------------------
// disconnect
//---------------------------------------------------------
void JackAudioDevice::disconnect(void* src, void* dst)
- {
+{
if (JACK_DEBUG)
printf("JackAudioDevice::disconnect()\n");
if(!checkJackClient(_client)) return;
@@ -954,11 +1110,19 @@ void JackAudioDevice::disconnect(void* src, void* dst)
fprintf(stderr, "JackAudio::disconnect: unknown jack ports\n");
return;
}
- if (jack_disconnect(_client, sn, dn)) {
- fprintf(stderr, "jack disconnect <%s> - <%s> failed\n",
- sn, dn);
+ int err = jack_disconnect(_client, sn, dn);
+ //if (jack_disconnect(_client, sn, dn)) {
+ if (err) {
+ fprintf(stderr, "jack disconnect <%s> - <%s> failed with err:%d\n",
+ sn, dn, err);
}
- }
+ else
+ if (JACK_DEBUG)
+ {
+ fprintf(stderr, "jack disconnect <%s> - <%s> succeeded\n",
+ sn, dn);
+ }
+}
//---------------------------------------------------------
// start
@@ -1011,6 +1175,10 @@ void JackAudioDevice::start(int /*priority*/)
}
}
+ // p3.3.37
+ // Connect the Jack midi client ports to device ports.
+ connectJackMidiPorts();
+
undoSetuid();
//MUSE_DEBUG("JackAudioDevice::start()\n");
@@ -1078,8 +1246,8 @@ int JackAudioDevice::framePos() const
if(!checkJackClient(_client)) return 0;
jack_nframes_t n = jack_frame_time(_client);
- if (JACK_DEBUG)
- printf("JackAudioDevice::framePos jack frame:%d\n", (int)n);
+ //if (JACK_DEBUG)
+ // printf("JackAudioDevice::framePos jack frame:%d\n", (int)n);
return (int)n;
}
@@ -1129,6 +1297,10 @@ std::list<QString> JackAudioDevice::outputPorts()
continue;
clientList.push_back(QString(buffer));
}
+ // p3.3.37
+ if(ports)
+ free(ports);
+
return clientList;
}
@@ -1154,6 +1326,10 @@ std::list<QString> JackAudioDevice::inputPorts()
continue;
clientList.push_back(QString(buffer));
}
+ // p3.3.37
+ if(ports)
+ free(ports);
+
return clientList;
}
@@ -1199,8 +1375,8 @@ int JackAudioDevice::getState()
//pos.valid = jack_position_bits_t(0);
//pos.frame = audio->pos().frame();
//return audio->getState();
- if (JACK_DEBUG)
- printf("JackAudioDevice::getState dummyState:%d\n", dummyState);
+ //if (JACK_DEBUG)
+ // printf("JackAudioDevice::getState dummyState:%d\n", dummyState);
return dummyState;
}
@@ -1208,8 +1384,8 @@ int JackAudioDevice::getState()
// printf("JackAudioDevice::getState ()\n");
if(!checkJackClient(_client)) return 0;
transportState = jack_transport_query(_client, &pos);
- if (JACK_DEBUG)
- printf("JackAudioDevice::getState transportState:%d\n", transportState);
+ //if (JACK_DEBUG)
+ // printf("JackAudioDevice::getState transportState:%d\n", transportState);
switch (transportState) {
case JackTransportStopped:
@@ -1500,8 +1676,6 @@ int JackAudioDevice::setMaster(bool f)
void JackAudioDevice::scanMidiPorts()
{
- #ifdef JACK_MIDI_SHOW_MULTIPLE_DEVICES
-
const char* type = JACK_DEFAULT_MIDI_TYPE;
const char** ports = jack_get_ports(_client, 0, type, 0);
for (const char** p = ports; p && *p; ++p)
@@ -1547,7 +1721,8 @@ void JackAudioDevice::scanMidiPorts()
dev->setrwFlags(flags);
midiDevices.add(dev);
}
- #endif
-
+ // p3.3.37
+ if(ports)
+ free(ports);
}
diff --git a/muse/muse/driver/jackaudio.h b/muse/muse/driver/jackaudio.h
index e8a74ac1..086e36db 100644
--- a/muse/muse/driver/jackaudio.h
+++ b/muse/muse/driver/jackaudio.h
@@ -57,8 +57,10 @@ class JackAudioDevice : public AudioDevice {
virtual void registerClient();
- virtual void* registerOutPort(const char* name);
- virtual void* registerInPort(const char* name);
+ //virtual void* registerOutPort(const char* name);
+ //virtual void* registerInPort(const char* name);
+ virtual void* registerOutPort(const char* /*name*/, bool /*midi*/);
+ virtual void* registerInPort(const char* /*name*/, bool /*midi*/);
virtual char* getJackName();
@@ -79,6 +81,9 @@ class JackAudioDevice : public AudioDevice {
virtual void setFreewheel(bool f);
jack_transport_state_t transportQuery(jack_position_t* pos);
void graphChanged();
+ void registrationChanged();
+ void connectJackMidiPorts();
+
virtual int setMaster(bool f);
//static bool jackStarted;
diff --git a/muse/muse/driver/jackmidi.cpp b/muse/muse/driver/jackmidi.cpp
index c603d1be..efc70602 100644
--- a/muse/muse/driver/jackmidi.cpp
+++ b/muse/muse/driver/jackmidi.cpp
@@ -34,14 +34,17 @@
//extern muse_jack_midi_buffer jack_midi_out_data[JACK_MIDI_CHANNELS];
//extern muse_jack_midi_buffer jack_midi_in_data[JACK_MIDI_CHANNELS];
-extern jack_port_t *midi_port_in[JACK_MIDI_CHANNELS];
-extern jack_port_t *midi_port_out[JACK_MIDI_CHANNELS];
+///extern jack_port_t *midi_port_in[JACK_MIDI_CHANNELS];
+///extern jack_port_t *midi_port_out[JACK_MIDI_CHANNELS];
-MidiJackDevice* gmdev = NULL;
+///MidiJackDevice* gmdev = NULL;
-int* jackSeq;
+///int* jackSeq;
//static snd_seq_addr_t musePort;
+int MidiJackDevice::_nextOutIdNum = 0;
+int MidiJackDevice::_nextInIdNum = 0;
+
//---------------------------------------------------------
// MidiAlsaDevice
//---------------------------------------------------------
@@ -49,10 +52,20 @@ int* jackSeq;
MidiJackDevice::MidiJackDevice(const int& a, const QString& n)
: MidiDevice(n)
{
+ _client_jackport = 0;
adr = a;
init();
}
+MidiJackDevice::~MidiJackDevice()
+{
+ #ifdef JACK_MIDI_USE_MULTIPLE_CLIENT_PORTS
+ if(_client_jackport)
+ //audioDevice->unregisterPort(_client_jackport);
+ close();
+ #endif
+}
+
/*
//---------------------------------------------------------
// select[RW]fd
@@ -75,15 +88,20 @@ int MidiJackDevice::selectWfd()
QString MidiJackDevice::open()
{
- #ifdef JACK_MIDI_SHOW_MULTIPLE_DEVICES
_openFlags &= _rwFlags; // restrict to available bits
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::open %s\n", name.latin1());
+ #endif
+
//jack_port_t* jp = jack_port_by_name(_client, name().latin1());
jack_port_t* jp = (jack_port_t*)audioDevice->findPort(name().latin1());
if(!jp)
{
printf("MidiJackDevice::open: Jack midi port %s not found!\n", name().latin1());
+ _writeEnable = false;
+ _readEnable = false;
return QString("Jack midi port not found");
}
@@ -92,23 +110,43 @@ QString MidiJackDevice::open()
// If Jack port can receive data from us and we actually want to...
if((pf & JackPortIsInput) && (_openFlags & 1))
{
- // src, dest
- //TODO: Having trouble here, may need to coordinate or move to graphChanged.
- audioDevice->connect(midi_port_out[0], jp);
- _writeEnable = true;
+ char buf[80];
+ snprintf(buf, 80, "muse-jack-midi-out-%d", _nextOutIdNum);
+ _client_jackport = (jack_port_t*)audioDevice->registerOutPort(buf, true);
+ if(_client_jackport == NULL)
+ {
+ fprintf(stderr, "MidiJackDevice::open failed to register jack-midi-out\n");
+ _writeEnable = false;
+ return QString("Could not register jack-midi-out client port");
+ }
+ else
+ {
+ _nextOutIdNum++;
+ // src, dest
+ ///audioDevice->connect(_client_jackport, jp);
+ _writeEnable = true;
+ }
}
-
+ else // Note docs say it can't be both input and output.
// If Jack port can send data to us and we actually want it...
if((pf & JackPortIsOutput) && (_openFlags & 2))
{
- audioDevice->connect(jp, midi_port_in[0]);
- _readEnable = true;
+ char buf[80];
+ snprintf(buf, 80, "muse-jack-midi-in-%d", _nextInIdNum);
+ _client_jackport = (jack_port_t*)audioDevice->registerInPort(buf, true);
+ if(_client_jackport == NULL)
+ {
+ fprintf(stderr, "MidiJackDevice::open failed to register jack-midi-in\n");
+ _readEnable = false;
+ return QString("Could not register jack-midi-in client port");
+ }
+ else
+ {
+ _nextInIdNum++;
+ ///audioDevice->connect(jp, _client_jackport);
+ _readEnable = true;
+ }
}
- #else
- _writeEnable = true;
- _readEnable = true;
- #endif
-
return QString("OK");
}
@@ -118,14 +156,35 @@ QString MidiJackDevice::open()
void MidiJackDevice::close()
{
- #ifdef JACK_MIDI_SHOW_MULTIPLE_DEVICES
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::close %s\n", name.latin1());
+ #endif
+ if(_client_jackport)
+ {
+ int pf = jack_port_flags(_client_jackport);
+
+ if(pf & JackPortIsOutput)
+ _nextOutIdNum--;
+ else
+ if(pf & JackPortIsInput)
+ _nextInIdNum--;
+ audioDevice->unregisterPort(_client_jackport);
+ _client_jackport = 0;
+ _writeEnable = false;
+ _readEnable = false;
+ return;
+ }
+
+ /*
//jack_port_t* jp = jack_port_by_name(_client, name().latin1());
jack_port_t* jp = (jack_port_t*)audioDevice->findPort(name().latin1());
if(!jp)
{
printf("MidiJackDevice::close: Jack midi port %s not found!\n", name().latin1());
+ _writeEnable = false;
+ _readEnable = false;
return;
}
@@ -136,21 +195,18 @@ void MidiJackDevice::close()
if(jack_port_connected_to(midi_port_out[0], name().latin1()))
{
// src, dest
- audioDevice->disconnect(midi_port_out[0], jp);
+/// audioDevice->disconnect(midi_port_out[0], jp);
_writeEnable = false;
}
-
+ else // Note docs say it can't be both input and output.
// If Jack port can send data to us and we actually want it...
//if((pf & JackPortIsOutput) && (_openFlags & 2))
if(jack_port_connected_to(midi_port_in[0], name().latin1()))
{
- audioDevice->disconnect(jp, midi_port_in[0]);
+/// audioDevice->disconnect(jp, midi_port_in[0]);
_readEnable = false;
}
- #else
- _writeEnable = false;
- _readEnable = false;
- #endif
+ */
}
//---------------------------------------------------------
@@ -222,110 +278,6 @@ bool MidiJackDevice::putMidiEvent(const MidiPlayEvent& /*event*/)
return false;
*/
- /*
- //
- // NOTICE: Only one MusE port (port 0) is supported for now ! MusE has no mechanism to create
- // or select other MusE ports. MusE ALSA midi only creates one port as well.
- //
- const int museport = 0;
-
- if(event.type() == ME_CONTROLLER)
- {
- int a = event.dataA();
- int b = event.dataB();
- int chn = event.channel();
- unsigned t = event.time();
-
- if(a == CTRL_PITCH)
- {
- int v = b + 8192;
- audioDriver->putEvent(museport, MidiPlayEvent(t, chn, ME_PITCHBEND, v & 0x7f, (v >> 7) & 0x7f));
- }
- else if (a == CTRL_PROGRAM)
- {
- // don't output program changes for GM drum channel
- //if (!(song->mtype() == MT_GM && chn == 9)) {
- int hb = (b >> 16) & 0xff;
- int lb = (b >> 8) & 0xff;
- int pr = b & 0x7f;
- if (hb != 0xff)
- audioDriver->putEvent(museport, MidiPlayEvent(t, chn, ME_CONTROLLER, CTRL_HBANK, hb));
- if (lb != 0xff)
- audioDriver->putEvent(museport, MidiPlayEvent(t+1, chn, ME_CONTROLLER, CTRL_LBANK, lb));
- audioDriver->putEvent(museport, MidiPlayEvent(t+2, chn, ME_PROGRAM, pr, 0));
- // }
- }
- else if (a == CTRL_MASTER_VOLUME)
- {
- unsigned char sysex[] = {
- 0x7f, 0x7f, 0x04, 0x01, 0x00, 0x00
- };
- sysex[1] = deviceId();
- sysex[4] = b & 0x7f;
- sysex[5] = (b >> 7) & 0x7f;
- audioDriver->putEvent(museport, MidiPlayEvent(t, ME_SYSEX, sysex, 6));
- }
- else if (a < CTRL_14_OFFSET)
- { // 7 Bit Controller
- audioDriver->putEvent(museport, event);
- }
- else if (a < CTRL_RPN_OFFSET)
- { // 14 bit high resolution controller
- int ctrlH = (a >> 8) & 0x7f;
- int ctrlL = a & 0x7f;
- int dataH = (b >> 7) & 0x7f;
- int dataL = b & 0x7f;
- audioDriver->putEvent(museport, MidiPlayEvent(t, chn, ME_CONTROLLER, ctrlH, dataH));
- audioDriver->putEvent(museport, MidiPlayEvent(t+1, chn, ME_CONTROLLER, ctrlL, dataL));
- }
- else if (a < CTRL_NRPN_OFFSET)
- { // RPN 7-Bit Controller
- int ctrlH = (a >> 8) & 0x7f;
- int ctrlL = a & 0x7f;
- audioDriver->putEvent(museport, MidiPlayEvent(t, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
- audioDriver->putEvent(museport, MidiPlayEvent(t+1, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL));
- audioDriver->putEvent(museport, MidiPlayEvent(t+2, chn, ME_CONTROLLER, CTRL_HDATA, b));
- }
- else if (a < CTRL_RPN14_OFFSET)
- { // NRPN 7-Bit Controller
- int ctrlH = (a >> 8) & 0x7f;
- int ctrlL = a & 0x7f;
- audioDriver->putEvent(museport, MidiPlayEvent(t, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
- audioDriver->putEvent(museport, MidiPlayEvent(t+1, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
- audioDriver->putEvent(museport, MidiPlayEvent(t+2, chn, ME_CONTROLLER, CTRL_HDATA, b));
- }
- else if (a < CTRL_NRPN14_OFFSET)
- { // RPN14 Controller
- int ctrlH = (a >> 8) & 0x7f;
- int ctrlL = a & 0x7f;
- int dataH = (b >> 7) & 0x7f;
- int dataL = b & 0x7f;
- audioDriver->putEvent(museport, MidiPlayEvent(t, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
- audioDriver->putEvent(museport, MidiPlayEvent(t+1, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL));
- audioDriver->putEvent(museport, MidiPlayEvent(t+2, chn, ME_CONTROLLER, CTRL_HDATA, dataH));
- audioDriver->putEvent(museport, MidiPlayEvent(t+3, chn, ME_CONTROLLER, CTRL_LDATA, dataL));
- }
- else if (a < CTRL_NONE_OFFSET)
- { // NRPN14 Controller
- int ctrlH = (a >> 8) & 0x7f;
- int ctrlL = a & 0x7f;
- int dataH = (b >> 7) & 0x7f;
- int dataL = b & 0x7f;
- audioDriver->putEvent(museport, MidiPlayEvent(t, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
- audioDriver->putEvent(museport, MidiPlayEvent(t+1, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
- audioDriver->putEvent(museport, MidiPlayEvent(t+2, chn, ME_CONTROLLER, CTRL_HDATA, dataH));
- audioDriver->putEvent(museport, MidiPlayEvent(t+3, chn, ME_CONTROLLER, CTRL_LDATA, dataL));
- }
- else
- {
- printf("MidiJackDevice::putMidiEvent: unknown controller type 0x%x\n", a);
- }
- }
- else
- {
- audioDriver->putEvent(museport, event);
- }
- */
return false;
}
@@ -348,7 +300,7 @@ bool MidiJackDevice::putEvent(int* event)
void MidiJackDevice::recordEvent(MidiRecordEvent& event)
{
- // By T356. Set the loop number which the event came in at.
+ // Set the loop number which the event came in at.
//if(audio->isRecording())
if(audio->isPlaying())
event.setLoopNum(audio->loopCount());
@@ -362,8 +314,6 @@ void MidiJackDevice::recordEvent(MidiRecordEvent& event)
{
int idin = midiPorts[_port].syncInfo().idIn();
-// p3.3.26 1/23/10 Section was disabled, enabled by Tim.
-//#if 0
int typ = event.type();
//---------------------------------------------------
@@ -396,12 +346,8 @@ void MidiJackDevice::recordEvent(MidiRecordEvent& event)
}
}
else
- // p3.3.26 1/23/10 Moved here from alsaProcessMidiInput(). Anticipating Jack midi support, so don't make it ALSA specific. Tim.
// Trigger general activity indicator detector. Sysex has no channel, don't trigger.
midiPorts[_port].syncInfo().trigActDetect(event.channel());
-
-//#endif
-
}
//
@@ -442,7 +388,7 @@ void MidiJackDevice::eventReceived(jack_midi_event_t* ev)
MidiRecordEvent event;
event.setB(0);
- //
+ // NOTE: From MusE-2. Not done here in Muse-1 (yet).
// move all events 2*segmentSize into the future to get
// jitterfree playback
//
@@ -518,28 +464,31 @@ void MidiJackDevice::eventReceived(jack_midi_event_t* ev)
// collectMidiEvents
//---------------------------------------------------------
-//void MidiJackDevice::collectMidiEvents(MidiInPort* track, Port port)
-void MidiJackDevice::collectMidiEvents(int port)
- {
- //void* port_buf = jack_port_get_buffer(port.jackPort(), segmentSize);
- void* port_buf = jack_port_get_buffer(midi_port_in[port], segmentSize);
- jack_midi_event_t event;
- jack_nframes_t eventCount = jack_midi_get_event_count(port_buf);
- for (jack_nframes_t i = 0; i < eventCount; ++i) {
- jack_midi_event_get(&event, port_buf, i);
-
- #ifdef JACK_MIDI_DEBUG
- printf("MidiJackDevice::collectMidiEvents number:%d time:%d\n", i, event.time);
- #endif
-
- //track->eventReceived(&event);
- eventReceived(&event);
- }
- }
+void MidiJackDevice::collectMidiEvents()
+{
+ if(!_readEnable)
+ return;
+
+ if(!_client_jackport)
+ return;
+ void* port_buf = jack_port_get_buffer(_client_jackport, segmentSize);
+
+ jack_midi_event_t event;
+ jack_nframes_t eventCount = jack_midi_get_event_count(port_buf);
+ for (jack_nframes_t i = 0; i < eventCount; ++i)
+ {
+ jack_midi_event_get(&event, port_buf, i);
+
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::collectMidiEvents number:%d time:%d\n", i, event.time);
+ #endif
+ eventReceived(&event);
+ }
+}
//---------------------------------------------------------
-// queueEvent
+// putEvent
// return true if event cannot be delivered
//---------------------------------------------------------
@@ -566,15 +515,15 @@ bool MidiJackDevice::putEvent(const MidiPlayEvent& ev)
//---------------------------------------------------------
//void JackAudioDevice::putEvent(Port port, const MidiEvent& e)
-bool MidiJackDevice::queueEvent(int port, const MidiPlayEvent& e)
+bool MidiJackDevice::queueEvent(const MidiPlayEvent& e)
//bool MidiJackDevice::queueEvent(const MidiPlayEvent& e)
{
// Perhaps we can find use for this value later, together with the Jack midi MusE port(s).
// No big deal if not. Not used for now.
//int port = e.port();
- if(port >= JACK_MIDI_CHANNELS)
- return false;
+ //if(port >= JACK_MIDI_CHANNELS)
+ // return false;
//if (midiOutputTrace) {
// printf("MidiOut<%s>: jackMidi: ", portName(port).toLatin1().data());
@@ -583,21 +532,14 @@ bool MidiJackDevice::queueEvent(int port, const MidiPlayEvent& e)
//if(debugMsg)
// printf("MidiJackDevice::queueEvent\n");
-
- //void* pb = jack_port_get_buffer(port.jackPort(), segmentSize);
- void* pb = jack_port_get_buffer(midi_port_out[port], segmentSize);
-
- //jack_port_t* jp = (jack_port_t*)audioDevice->findPort(name().latin1());
- //if(!jp)
- // printf("MidiJackDevice::queueEvent: Jack midi port %s not found!\n", name().latin1());
- //void* pb = jack_port_get_buffer(jp ? jp : midi_port_out[port], segmentSize);
-
+ if(!_client_jackport)
+ return false;
+ void* pb = jack_port_get_buffer(_client_jackport, segmentSize);
+
//unsigned frameCounter = ->frameTime();
int frameOffset = audio->getFrameOffset();
unsigned pos = audio->pos().frame();
- //int ft = e.time() - _frameCounter;
- //int ft = e.time() - frameOffset - frameCounter;
int ft = e.time() - frameOffset - pos;
if (ft < 0)
@@ -685,7 +627,7 @@ bool MidiJackDevice::queueEvent(int port, const MidiPlayEvent& e)
// processEvent
//---------------------------------------------------------
-void MidiJackDevice::processEvent(int museport, const MidiPlayEvent& event)
+void MidiJackDevice::processEvent(const MidiPlayEvent& event)
{
//int frameOffset = audio->getFrameOffset();
//unsigned pos = audio->pos().frame();
@@ -713,10 +655,22 @@ void MidiJackDevice::processEvent(int museport, const MidiPlayEvent& event)
// No big deal if not. Not used for now.
int port = event.port();
+ int nvh = 0xff;
+ int nvl = 0xff;
+ if(_port != -1)
+ {
+ int nv = midiPorts[_port].nullSendValue();
+ if(nv != -1)
+ {
+ nvh = (nv >> 8) & 0xff;
+ nvl = nv & 0xff;
+ }
+ }
+
if(a == CTRL_PITCH)
{
int v = b + 8192;
- queueEvent(museport, MidiPlayEvent(t, port, chn, ME_PITCHBEND, v & 0x7f, (v >> 7) & 0x7f));
+ queueEvent(MidiPlayEvent(t, port, chn, ME_PITCHBEND, v & 0x7f, (v >> 7) & 0x7f));
}
else if (a == CTRL_PROGRAM)
{
@@ -726,10 +680,10 @@ void MidiJackDevice::processEvent(int museport, const MidiPlayEvent& event)
int lb = (b >> 8) & 0xff;
int pr = b & 0x7f;
if (hb != 0xff)
- queueEvent(museport, MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HBANK, hb));
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HBANK, hb));
if (lb != 0xff)
- queueEvent(museport, MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LBANK, lb));
- queueEvent(museport, MidiPlayEvent(t+2, port, chn, ME_PROGRAM, pr, 0));
+ queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LBANK, lb));
+ queueEvent(MidiPlayEvent(t+2, port, chn, ME_PROGRAM, pr, 0));
// }
}
/*
@@ -741,12 +695,12 @@ void MidiJackDevice::processEvent(int museport, const MidiPlayEvent& event)
sysex[1] = deviceId();
sysex[4] = b & 0x7f;
sysex[5] = (b >> 7) & 0x7f;
- queueEvent(museport, MidiPlayEvent(t, port, ME_SYSEX, sysex, 6));
+ queueEvent(MidiPlayEvent(t, port, ME_SYSEX, sysex, 6));
}
*/
else if (a < CTRL_14_OFFSET)
{ // 7 Bit Controller
- queueEvent(museport, event);
+ queueEvent(event);
//queueEvent(museport, MidiPlayEvent(t, port, chn, event));
}
else if (a < CTRL_RPN_OFFSET)
@@ -755,24 +709,46 @@ void MidiJackDevice::processEvent(int museport, const MidiPlayEvent& event)
int ctrlL = a & 0x7f;
int dataH = (b >> 7) & 0x7f;
int dataL = b & 0x7f;
- queueEvent(museport, MidiPlayEvent(t, port, chn, ME_CONTROLLER, ctrlH, dataH));
- queueEvent(museport, MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, ctrlL, dataL));
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, ctrlH, dataH));
+ queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, ctrlL, dataL));
}
else if (a < CTRL_NRPN_OFFSET)
{ // RPN 7-Bit Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
- queueEvent(museport, MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
- queueEvent(museport, MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL));
- queueEvent(museport, MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, b));
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
+ queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL));
+ queueEvent(MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, b));
+
+ t += 3;
+ // Select null parameters so that subsequent data controller events do not upset the last *RPN controller.
+ //sendNullRPNParams(chn, false);
+ if(nvh != 0xff)
+ {
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HRPN, nvh & 0x7f));
+ t += 1;
+ }
+ if(nvl != 0xff)
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_LRPN, nvl & 0x7f));
}
- else if (a < CTRL_RPN14_OFFSET)
+ //else if (a < CTRL_RPN14_OFFSET)
+ else if (a < CTRL_INTERNAL_OFFSET)
{ // NRPN 7-Bit Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
- queueEvent(museport, MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
- queueEvent(museport, MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
- queueEvent(museport, MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, b));
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
+ queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
+ queueEvent(MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, b));
+
+ t += 3;
+ //sendNullRPNParams(chn, true);
+ if(nvh != 0xff)
+ {
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HNRPN, nvh & 0x7f));
+ t += 1;
+ }
+ if(nvl != 0xff)
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_LNRPN, nvl & 0x7f));
}
else if (a < CTRL_NRPN14_OFFSET)
{ // RPN14 Controller
@@ -780,10 +756,20 @@ void MidiJackDevice::processEvent(int museport, const MidiPlayEvent& event)
int ctrlL = a & 0x7f;
int dataH = (b >> 7) & 0x7f;
int dataL = b & 0x7f;
- queueEvent(museport, MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
- queueEvent(museport, MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL));
- queueEvent(museport, MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, dataH));
- queueEvent(museport, MidiPlayEvent(t+3, port, chn, ME_CONTROLLER, CTRL_LDATA, dataL));
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
+ queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL));
+ queueEvent(MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, dataH));
+ queueEvent(MidiPlayEvent(t+3, port, chn, ME_CONTROLLER, CTRL_LDATA, dataL));
+
+ t += 4;
+ //sendNullRPNParams(chn, false);
+ if(nvh != 0xff)
+ {
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HRPN, nvh & 0x7f));
+ t += 1;
+ }
+ if(nvl != 0xff)
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_LRPN, nvl & 0x7f));
}
else if (a < CTRL_NONE_OFFSET)
{ // NRPN14 Controller
@@ -791,10 +777,20 @@ void MidiJackDevice::processEvent(int museport, const MidiPlayEvent& event)
int ctrlL = a & 0x7f;
int dataH = (b >> 7) & 0x7f;
int dataL = b & 0x7f;
- queueEvent(museport, MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
- queueEvent(museport, MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
- queueEvent(museport, MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, dataH));
- queueEvent(museport, MidiPlayEvent(t+3, port, chn, ME_CONTROLLER, CTRL_LDATA, dataL));
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
+ queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
+ queueEvent(MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, dataH));
+ queueEvent(MidiPlayEvent(t+3, port, chn, ME_CONTROLLER, CTRL_LDATA, dataL));
+
+ t += 4;
+ //sendNullRPNParams(chn, true);
+ if(nvh != 0xff)
+ {
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HNRPN, nvh & 0x7f));
+ t += 1;
+ }
+ if(nvl != 0xff)
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_LNRPN, nvl & 0x7f));
}
else
{
@@ -803,8 +799,8 @@ void MidiJackDevice::processEvent(int museport, const MidiPlayEvent& event)
}
else
{
- queueEvent(museport, event);
- //queueEvent(museport, MidiPlayEvent(t, port, chn, event));
+ queueEvent(event);
+ //queueEvent(MidiPlayEvent(t, port, chn, event));
}
}
@@ -814,18 +810,11 @@ void MidiJackDevice::processEvent(int museport, const MidiPlayEvent& event)
void MidiJackDevice::processMidi()
{
- //
- // NOTICE: Only one MusE port (port 0) is supported for now ! MusE has no mechanism to create
- // or select other MusE ports. MusE ALSA midi only creates one port as well.
- //
- const int museport = 0;
- void* port_buf = jack_port_get_buffer(midi_port_out[museport], segmentSize);
+ if(!_client_jackport)
+ return;
+ void* port_buf = jack_port_get_buffer(_client_jackport, segmentSize);
jack_midi_clear_buffer(port_buf);
- //int frameOffset = audio->getFrameOffset();
- //unsigned pos = audio->pos().frame();
- //MPEventList* el = playEvents();
-
while(!eventFifo.isEmpty())
{
MidiPlayEvent e(eventFifo.get());
@@ -844,146 +833,20 @@ void MidiJackDevice::processMidi()
//el->insert(eventFifo.get());
//el->insert(e);
- processEvent(museport, e);
+ processEvent(e);
}
MPEventList* el = playEvents();
if(el->empty())
return;
- //if(debugMsg)
- // printf("MidiJackDevice::processMidi\n");
-
- //int port = midiPort();
- //MidiPort* mp = port != -1 ? &midiPorts[port] : 0;
iMPEvent i = nextPlayEvent();
- //int tickpos = audio->tickPos();
- //bool extsync = extSyncFlag.value();
-
-
for(; i != el->end(); ++i)
{
- processEvent(museport, *i);
-
- /*
- const MidiPlayEvent& event = *i;
- int chn = event.channel();
- unsigned t = event.time();
-
- // No sub-tick playback resolution yet, with external sync.
- // Just do this for now until we figure out more precise external timings. Tested OK so far !
- if(extSyncFlag.value())
- t = frameOffset + pos;
-
- #ifdef JACK_MIDI_DEBUG
- printf("MidiJackDevice::processMidi time:%d type:%d ch:%d A:%d B:%d\n", event.time(), event.type(), event.channel(), event.dataA(), event.dataB());
- #endif
-
- if(event.type() == ME_CONTROLLER)
- {
- int a = event.dataA();
- int b = event.dataB();
- // Perhaps we can find use for this value later, together with the Jack midi MusE port(s).
- // No big deal if not. Not used for now.
- int port = event.port();
-
- if(a == CTRL_PITCH)
- {
- int v = b + 8192;
- queueEvent(museport, MidiPlayEvent(t, port, chn, ME_PITCHBEND, v & 0x7f, (v >> 7) & 0x7f));
- }
- else if (a == CTRL_PROGRAM)
- {
- // don't output program changes for GM drum channel
- //if (!(song->mtype() == MT_GM && chn == 9)) {
- int hb = (b >> 16) & 0xff;
- int lb = (b >> 8) & 0xff;
- int pr = b & 0x7f;
- if (hb != 0xff)
- queueEvent(museport, MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HBANK, hb));
- if (lb != 0xff)
- queueEvent(museport, MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LBANK, lb));
- queueEvent(museport, MidiPlayEvent(t+2, port, chn, ME_PROGRAM, pr, 0));
- // }
- }
- //else if (a == CTRL_MASTER_VOLUME)
- //{
- // unsigned char sysex[] = {
- // 0x7f, 0x7f, 0x04, 0x01, 0x00, 0x00
- // };
- // sysex[1] = deviceId();
- // sysex[4] = b & 0x7f;
- // sysex[5] = (b >> 7) & 0x7f;
- // queueEvent(museport, MidiPlayEvent(t, port, ME_SYSEX, sysex, 6));
- //}
- else if (a < CTRL_14_OFFSET)
- { // 7 Bit Controller
- queueEvent(museport, event);
- //queueEvent(museport, MidiPlayEvent(t, port, chn, event));
- }
- else if (a < CTRL_RPN_OFFSET)
- { // 14 bit high resolution controller
- int ctrlH = (a >> 8) & 0x7f;
- int ctrlL = a & 0x7f;
- int dataH = (b >> 7) & 0x7f;
- int dataL = b & 0x7f;
- queueEvent(museport, MidiPlayEvent(t, port, chn, ME_CONTROLLER, ctrlH, dataH));
- queueEvent(museport, MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, ctrlL, dataL));
- }
- else if (a < CTRL_NRPN_OFFSET)
- { // RPN 7-Bit Controller
- int ctrlH = (a >> 8) & 0x7f;
- int ctrlL = a & 0x7f;
- queueEvent(museport, MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
- queueEvent(museport, MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL));
- queueEvent(museport, MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, b));
- }
- else if (a < CTRL_RPN14_OFFSET)
- { // NRPN 7-Bit Controller
- int ctrlH = (a >> 8) & 0x7f;
- int ctrlL = a & 0x7f;
- queueEvent(museport, MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
- queueEvent(museport, MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
- queueEvent(museport, MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, b));
- }
- else if (a < CTRL_NRPN14_OFFSET)
- { // RPN14 Controller
- int ctrlH = (a >> 8) & 0x7f;
- int ctrlL = a & 0x7f;
- int dataH = (b >> 7) & 0x7f;
- int dataL = b & 0x7f;
- queueEvent(museport, MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
- queueEvent(museport, MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL));
- queueEvent(museport, MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, dataH));
- queueEvent(museport, MidiPlayEvent(t+3, port, chn, ME_CONTROLLER, CTRL_LDATA, dataL));
- }
- else if (a < CTRL_NONE_OFFSET)
- { // NRPN14 Controller
- int ctrlH = (a >> 8) & 0x7f;
- int ctrlL = a & 0x7f;
- int dataH = (b >> 7) & 0x7f;
- int dataL = b & 0x7f;
- queueEvent(museport, MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
- queueEvent(museport, MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
- queueEvent(museport, MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, dataH));
- queueEvent(museport, MidiPlayEvent(t+3, port, chn, ME_CONTROLLER, CTRL_LDATA, dataL));
- }
- else
- {
- printf("MidiJackDevice::processMidi: unknown controller type 0x%x\n", a);
- }
- }
- else
- {
- queueEvent(museport, event);
- //queueEvent(museport, MidiPlayEvent(t, port, chn, event));
- }
- */
-
+ processEvent(*i);
}
- //md->setNextPlayEvent(i);
- setNextPlayEvent(i);
+ setNextPlayEvent(i);
}
//---------------------------------------------------------
@@ -993,30 +856,28 @@ void MidiJackDevice::processMidi()
bool initMidiJack()
{
+ /*
int adr = 0;
-// Removed p3.3.36
-/// memset(jack_midi_out_data, 0, JACK_MIDI_CHANNELS * sizeof(muse_jack_midi_buffer));
-/// memset(jack_midi_in_data, 0, JACK_MIDI_CHANNELS * sizeof(muse_jack_midi_buffer));
+ memset(jack_midi_out_data, 0, JACK_MIDI_CHANNELS * sizeof(muse_jack_midi_buffer));
+ memset(jack_midi_in_data, 0, JACK_MIDI_CHANNELS * sizeof(muse_jack_midi_buffer));
MidiJackDevice* dev = new MidiJackDevice(adr, QString("jack-midi"));
- dev->setrwFlags(3); /* set read and write flags */
-
-// Removed p3.3.35
-/// if(pipe(jackmidi_pi) < 0){
-/// fprintf(stderr, "cant create midi-jack input pipe\n");
-/// }
-/// if(pipe(jackmidi_po) < 0){
-/// fprintf(stderr, "cant create midi-jack output pipe\n");
-/// }
+ dev->setrwFlags(3); // set read and write flags
+
+ if(pipe(jackmidi_pi) < 0){
+ fprintf(stderr, "cant create midi-jack input pipe\n");
+ }
+ if(pipe(jackmidi_po) < 0){
+ fprintf(stderr, "cant create midi-jack output pipe\n");
+ }
- #ifndef JACK_MIDI_SHOW_MULTIPLE_DEVICES
midiDevices.add(dev);
- #endif
- gmdev = dev; /* proclaim the global jack-midi instance */
+ gmdev = dev; // proclaim the global jack-midi instance
//jackScanMidiPorts();
+ */
return false;
}
diff --git a/muse/muse/driver/jackmidi.h b/muse/muse/driver/jackmidi.h
index 1c65a423..d260163c 100644
--- a/muse/muse/driver/jackmidi.h
+++ b/muse/muse/driver/jackmidi.h
@@ -10,6 +10,7 @@
//#include <config.h>
+#include <jack/jack.h>
#include <jack/midiport.h>
#include "mididev.h"
@@ -21,12 +22,14 @@ class MidiPlayEvent;
// Turn on to show multiple devices, work in progress,
// not working fully yet, can't seem to connect...
-/// #define JACK_MIDI_SHOW_MULTIPLE_DEVICES
+#define JACK_MIDI_SHOW_MULTIPLE_DEVICES
+
+// It appears one client port per remote port will be necessary.
+// Jack doesn't seem to like manipulation of non-local ports buffers.
+#define JACK_MIDI_USE_MULTIPLE_CLIENT_PORTS
/* jack-midi channels */
-// Sorry, only one MusE Jack midi port for now.
//#define JACK_MIDI_CHANNELS 32
-#define JACK_MIDI_CHANNELS 1
/* jack-midi buffer size */
//#define JACK_MIDI_BUFFER_SIZE 32
@@ -54,14 +57,18 @@ class MidiJackDevice : public MidiDevice {
// direct to midi port:
MidiFifo eventFifo;
+ static int _nextOutIdNum;
+ static int _nextInIdNum;
+
+ jack_port_t* _client_jackport;
+
virtual QString open();
virtual void close();
//bool putEvent(int*);
- void processEvent(int /*port*/, const MidiPlayEvent&);
+ void processEvent(const MidiPlayEvent&);
// Port is not midi port, it is the port(s) created for MusE.
- bool queueEvent(int /*port*/, const MidiPlayEvent&);
- //bool queueEvent(const MidiPlayEvent&);
+ bool queueEvent(const MidiPlayEvent&);
virtual bool putMidiEvent(const MidiPlayEvent&);
//bool sendEvent(const MidiPlayEvent&);
@@ -72,7 +79,7 @@ class MidiJackDevice : public MidiDevice {
MidiJackDevice() {}
MidiJackDevice(const int&, const QString& name);
void processMidi();
- virtual ~MidiJackDevice() {}
+ virtual ~MidiJackDevice();
//virtual int selectRfd();
//virtual int selectWfd();
//virtual void processInput();
@@ -80,7 +87,10 @@ class MidiJackDevice : public MidiDevice {
virtual void recordEvent(MidiRecordEvent&);
virtual bool putEvent(const MidiPlayEvent&);
- virtual void collectMidiEvents(int port);
+ virtual void collectMidiEvents();
+
+ //virtual jack_port_t* jackPort() { return _jackport; }
+ virtual jack_port_t* clientJackPort() { return _client_jackport; }
};
extern bool initMidiJack();
diff --git a/muse/muse/exportmidi.cpp b/muse/muse/exportmidi.cpp
index 5a6c889e..c068d719 100644
--- a/muse/muse/exportmidi.cpp
+++ b/muse/muse/exportmidi.cpp
@@ -29,10 +29,13 @@
static void addController(MPEventList* l, int tick, int port, int channel, int a, int b)
{
- if (a < 0x1000) { // 7 Bit Controller
+ // p3.3.37
+ //if (a < 0x1000) { // 7 Bit Controller
+ if (a < CTRL_14_OFFSET) { // 7 Bit Controller
l->add(MidiPlayEvent(tick, port, channel, ME_CONTROLLER, a, b));
}
- else if (a < 0x20000) { // 14 Bit Controller
+ //else if (a < 0x20000) { // 14 Bit Controller
+ else if (a < CTRL_RPN_OFFSET) { // 14 Bit Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
int dataH = (b >> 7) & 0x7f;
@@ -40,14 +43,16 @@ static void addController(MPEventList* l, int tick, int port, int channel, int a
l->add(MidiPlayEvent(tick, port, channel, ME_CONTROLLER, ctrlH, dataH));
l->add(MidiPlayEvent(tick+1, port, channel, ME_CONTROLLER, ctrlL, dataL));
}
- else if (a < 0x30000) { // RPN 7-Bit Controller
+ //else if (a < 0x30000) { // RPN 7-Bit Controller
+ else if (a < CTRL_NRPN_OFFSET) { // RPN 7-Bit Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
l->add(MidiPlayEvent(tick, port, channel, ME_CONTROLLER, CTRL_HRPN, ctrlH));
l->add(MidiPlayEvent(tick+1, port, channel, ME_CONTROLLER, CTRL_LRPN, ctrlL));
l->add(MidiPlayEvent(tick+2, port, channel, ME_CONTROLLER, CTRL_HDATA, b));
}
- else if (a < 0x40000) { // NRPN 7-Bit Controller
+ //else if (a < 0x40000) { // NRPN 7-Bit Controller
+ else if (a < CTRL_INTERNAL_OFFSET) { // NRPN 7-Bit Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
l->add(MidiPlayEvent(tick, port, channel, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
@@ -82,7 +87,8 @@ static void addController(MPEventList* l, int tick, int port, int channel, int a
}
l->add(MidiPlayEvent(tick+tickoffset, port, channel, ME_PROGRAM, pr, 0));
}
- else if (a < 0x60000) { // RPN14 Controller
+ //else if (a < 0x60000) { // RPN14 Controller
+ else if (a < CTRL_NRPN14_OFFSET) { // RPN14 Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
int dataH = (b >> 7) & 0x7f;
@@ -92,7 +98,8 @@ static void addController(MPEventList* l, int tick, int port, int channel, int a
l->add(MidiPlayEvent(tick+2, port, channel, ME_CONTROLLER, CTRL_HDATA, dataH));
l->add(MidiPlayEvent(tick+3, port, channel, ME_CONTROLLER, CTRL_LDATA, dataL));
}
- else if (a < 0x70000) { // NRPN14 Controller
+ //else if (a < 0x70000) { // NRPN14 Controller
+ else if (a < CTRL_NONE_OFFSET) { // NRPN14 Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
int dataH = (b >> 7) & 0x7f;
diff --git a/muse/muse/midi.cpp b/muse/muse/midi.cpp
index 61504a97..04f802be 100644
--- a/muse/muse/midi.cpp
+++ b/muse/muse/midi.cpp
@@ -958,8 +958,7 @@ void Audio::processMidi()
// Is it a Jack midi device?
MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(md);
if(mjd)
- // TODO: Just use MusE port 0 for now. Support for multiple MusE ports maybe will come later.
- mjd->collectMidiEvents(0);
+ mjd->collectMidiEvents();
// Take snapshots of the current sizes of the recording fifos,
// because they may change while here in process, asynchronously.
diff --git a/muse/muse/midictrl.cpp b/muse/muse/midictrl.cpp
index e93d3036..3994fe90 100644
--- a/muse/muse/midictrl.cpp
+++ b/muse/muse/midictrl.cpp
@@ -69,7 +69,8 @@ MidiControllerList defaultMidiController;
MidiController veloCtrl("Velocity", CTRL_VELOCITY, 0, 127, 0);
static MidiController pitchCtrl("PitchBend", CTRL_PITCH, -8192, +8191, 0);
static MidiController programCtrl("Program", CTRL_PROGRAM, 0, 0xffffff, 0);
-static MidiController mastervolCtrl("MasterVolume", CTRL_MASTER_VOLUME, 0, 0x3fff, 0x3000);
+// Removed p3.3.37
+//static MidiController mastervolCtrl("MasterVolume", CTRL_MASTER_VOLUME, 0, 0x3fff, 0x3000);
static MidiController volumeCtrl("MainVolume", CTRL_VOLUME, 0, 127, 100);
static MidiController panCtrl("Pan", CTRL_PANPOT, -64, 63, 0);
@@ -132,7 +133,8 @@ void initMidiController()
defaultMidiController.add(&veloCtrl);
defaultMidiController.add(&pitchCtrl);
defaultMidiController.add(&programCtrl);
- defaultMidiController.add(&mastervolCtrl);
+ // Removed p3.3.37
+ //defaultMidiController.add(&mastervolCtrl);
defaultMidiController.add(&volumeCtrl);
defaultMidiController.add(&panCtrl);
}
@@ -204,13 +206,18 @@ MidiController& MidiController::operator=(const MidiController &mc)
MidiController::ControllerType midiControllerType(int num)
{
- if (num < 0x10000)
+ // p3.3.37
+ //if (num < 0x10000)
+ if (num < CTRL_14_OFFSET)
return MidiController::Controller7;
- if (num < 0x20000)
+ //if (num < 0x20000)
+ if (num < CTRL_RPN_OFFSET)
return MidiController::Controller14;
- if (num < 0x30000)
+ //if (num < 0x30000)
+ if (num < CTRL_NRPN_OFFSET)
return MidiController::RPN;
- if (num < 0x40000)
+ //if (num < 0x40000)
+ if (num < CTRL_INTERNAL_OFFSET)
return MidiController::NRPN;
if (num == CTRL_PITCH)
return MidiController::Pitch;
@@ -218,9 +225,11 @@ MidiController::ControllerType midiControllerType(int num)
return MidiController::Program;
if (num == CTRL_VELOCITY)
return MidiController::Velo;
- if (num < 0x60000)
+ //if (num < 0x60000)
+ if (num < CTRL_NRPN14_OFFSET)
return MidiController::RPN14;
- if (num < 0x70000)
+ //if (num < 0x70000)
+ if (num < CTRL_NONE_OFFSET)
return MidiController::NRPN14;
return MidiController::Controller7;
}
@@ -438,31 +447,37 @@ void MidiController::read(Xml& xml)
case RPN:
if (_maxVal == NOT_SET)
_maxVal = 127;
- _num |= 0x20000;
+ // p3.3.37
+ //_num |= 0x20000;
+ _num |= CTRL_RPN_OFFSET;
break;
case NRPN:
if (_maxVal == NOT_SET)
_maxVal = 127;
- _num |= 0x30000;
+ //_num |= 0x30000;
+ _num |= CTRL_NRPN_OFFSET;
break;
case Controller7:
if (_maxVal == NOT_SET)
_maxVal = 127;
break;
case Controller14:
- _num |= 0x10000;
+ //_num |= 0x10000;
+ _num |= CTRL_14_OFFSET;
if (_maxVal == NOT_SET)
_maxVal = 16383;
break;
case RPN14:
if (_maxVal == NOT_SET)
_maxVal = 16383;
- _num |= 0x50000;
+ //_num |= 0x50000;
+ _num |= CTRL_RPN14_OFFSET;
break;
case NRPN14:
if (_maxVal == NOT_SET)
_maxVal = 16383;
- _num |= 0x60000;
+ //_num |= 0x60000;
+ _num |= CTRL_NRPN14_OFFSET;
break;
case Pitch:
if (_maxVal == NOT_SET)
diff --git a/muse/muse/midictrl.h b/muse/muse/midictrl.h
index 45e4255b..69650a65 100644
--- a/muse/muse/midictrl.h
+++ b/muse/muse/midictrl.h
@@ -57,10 +57,17 @@ const int CTRL_LOCAL_OFF = 0x7a; // 122
// NRPN - non registered parameter numbers 0x30000 -
// internal controller types:
-const int CTRL_PITCH = 0x40000;
-const int CTRL_PROGRAM = 0x40001;
-const int CTRL_VELOCITY = 0x40002;
-const int CTRL_MASTER_VOLUME = 0x40003;
+const int CTRL_INTERNAL_OFFSET = 0x40000;
+
+// p3.3.37
+//const int CTRL_PITCH = 0x40000;
+//const int CTRL_PROGRAM = 0x40001;
+//const int CTRL_VELOCITY = 0x40002;
+//const int CTRL_MASTER_VOLUME = 0x40003;
+const int CTRL_PITCH = CTRL_INTERNAL_OFFSET;
+const int CTRL_PROGRAM = CTRL_INTERNAL_OFFSET + 1;
+const int CTRL_VELOCITY = CTRL_INTERNAL_OFFSET + 2;
+//const int CTRL_MASTER_VOLUME = CTRL_INTERNAL_OFFSET + 3;
const int CTRL_VAL_UNKNOWN = 0x10000000; // used as unknown hwVal
diff --git a/muse/muse/mididev.cpp b/muse/muse/mididev.cpp
index 01eb429e..28acd541 100644
--- a/muse/muse/mididev.cpp
+++ b/muse/muse/mididev.cpp
@@ -435,11 +435,15 @@ bool MidiDevice::putEvent(const MidiPlayEvent& ev)
}
}
#if 1 // if ALSA cannot handle RPN NRPN etc.
- if (a < 0x1000) { // 7 Bit Controller
+
+ // p3.3.37
+ //if (a < 0x1000) { // 7 Bit Controller
+ if (a < CTRL_14_OFFSET) { // 7 Bit Controller
//putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, a, b));
putMidiEvent(ev);
}
- else if (a < 0x20000) { // 14 bit high resolution controller
+ //else if (a < 0x20000) { // 14 bit high resolution controller
+ else if (a < CTRL_RPN_OFFSET) { // 14 bit high resolution controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
int dataH = (b >> 7) & 0x7f;
@@ -447,7 +451,8 @@ bool MidiDevice::putEvent(const MidiPlayEvent& ev)
putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, ctrlH, dataH));
putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, ctrlL, dataL));
}
- else if (a < 0x30000) { // RPN 7-Bit Controller
+ //else if (a < 0x30000) { // RPN 7-Bit Controller
+ else if (a < CTRL_NRPN_OFFSET) { // RPN 7-Bit Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
@@ -458,7 +463,8 @@ bool MidiDevice::putEvent(const MidiPlayEvent& ev)
// events do not upset the last *RPN controller.
sendNullRPNParams(chn, false);
}
- else if (a < 0x40000) { // NRPN 7-Bit Controller
+ //else if (a < 0x40000) { // NRPN 7-Bit Controller
+ else if (a < CTRL_INTERNAL_OFFSET) { // NRPN 7-Bit Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
@@ -467,7 +473,8 @@ bool MidiDevice::putEvent(const MidiPlayEvent& ev)
sendNullRPNParams(chn, true);
}
- else if (a < 0x60000) { // RPN14 Controller
+ //else if (a < 0x60000) { // RPN14 Controller
+ else if (a < CTRL_NRPN14_OFFSET) { // RPN14 Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
int dataH = (b >> 7) & 0x7f;
@@ -479,7 +486,8 @@ bool MidiDevice::putEvent(const MidiPlayEvent& ev)
sendNullRPNParams(chn, false);
}
- else if (a < 0x70000) { // NRPN14 Controller
+ //else if (a < 0x70000) { // NRPN14 Controller
+ else if (a < CTRL_NONE_OFFSET) { // NRPN14 Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
int dataH = (b >> 7) & 0x7f;
diff --git a/muse/muse/midiseq.cpp b/muse/muse/midiseq.cpp
index c597573a..bd079c5a 100644
--- a/muse/muse/midiseq.cpp
+++ b/muse/muse/midiseq.cpp
@@ -386,13 +386,13 @@ void MidiSeq::updatePollFd()
//&& (dev->syncInfo().MCIn()))) {
&& (midiPorts[port].syncInfo().MCIn()))) {
if(dev->selectRfd() < 0){
- fprintf(stderr, "WARNING: read-file-descriptor for {%s} is negative\n", name.latin1());
+ //fprintf(stderr, "WARNING: read-file-descriptor for {%s} is negative\n", name.latin1());
}
addPollFd(dev->selectRfd(), POLLIN, ::midiRead, this, dev);
}
if (dev->bytesToWrite()){
if(dev->selectWfd() < 0){
- fprintf(stderr, "WARNING: write-file-descriptor for {%s} is negative\n", name.latin1());
+ //fprintf(stderr, "WARNING: write-file-descriptor for {%s} is negative\n", name.latin1());
}
addPollFd(dev->selectWfd(), POLLOUT, ::midiWrite, this, dev);
}
diff --git a/muse/muse/node.cpp b/muse/muse/node.cpp
index 38d7d40b..4928420f 100644
--- a/muse/muse/node.cpp
+++ b/muse/muse/node.cpp
@@ -1165,7 +1165,8 @@ void AudioInput::setName(const QString& s)
if (jackPorts[i])
audioDevice->setPortName(jackPorts[i], buffer);
else {
- jackPorts[i] = audioDevice->registerInPort(buffer);
+ //jackPorts[i] = audioDevice->registerInPort(buffer);
+ jackPorts[i] = audioDevice->registerInPort(buffer, false);
}
}
}
@@ -1444,7 +1445,8 @@ void AudioOutput::setName(const QString& s)
audioDevice->setPortName(jackPorts[i], buffer);
}
else {
- jackPorts[i] = audioDevice->registerOutPort(buffer);
+ //jackPorts[i] = audioDevice->registerOutPort(buffer);
+ jackPorts[i] = audioDevice->registerOutPort(buffer, false);
}
}
}
diff --git a/muse/muse/seqmsg.cpp b/muse/muse/seqmsg.cpp
index 7cd8176e..42227305 100644
--- a/muse/muse/seqmsg.cpp
+++ b/muse/muse/seqmsg.cpp
@@ -211,7 +211,8 @@ void Audio::msgSetChannels(AudioTrack* node, int n)
if (i < n && ai->jackPort(i) == 0) {
char buffer[128];
snprintf(buffer, 128, "%s-%d", name.latin1(), i);
- ai->setJackPort(i, audioDevice->registerInPort(buffer));
+ //ai->setJackPort(i, audioDevice->registerInPort(buffer));
+ ai->setJackPort(i, audioDevice->registerInPort(buffer, false));
}
else if ((i >= n) && ai->jackPort(i)) {
RouteList* ir = node->inRoutes();
@@ -235,7 +236,8 @@ void Audio::msgSetChannels(AudioTrack* node, int n)
if (i < n && jp == 0) {
char buffer[128];
snprintf(buffer, 128, "%s-%d", name.latin1(), i);
- ao->setJackPort(i, audioDevice->registerOutPort(buffer));
+ //ao->setJackPort(i, audioDevice->registerOutPort(buffer));
+ ao->setJackPort(i, audioDevice->registerOutPort(buffer, false));
}
else if (i >= n && jp) {
RouteList* ir = node->outRoutes();
diff --git a/muse/muse/song.cpp b/muse/muse/song.cpp
index 3cfb4af7..7b1e46bb 100644
--- a/muse/muse/song.cpp
+++ b/muse/muse/song.cpp
@@ -2140,11 +2140,17 @@ void Song::seqSignal(int fd)
#endif
break;
- case 'C':
+ case 'C': // Graph changed
if (audioDevice)
audioDevice->graphChanged();
break;
+ // p3.3.37
+ case 'R': // Registration changed
+ if (audioDevice)
+ audioDevice->registrationChanged();
+ break;
+
default:
printf("unknown Seq Signal <%c>\n", buffer[i]);
break;