Hello list,
I know everyone is deep into testing, but I think one small bonus should
be added for us Jack/ALSA users, which is LED control via MIDI. I
implemented this specifically to enable LED control on my DM2, but
others will surely benefit as well.
Albert and Adam: I am about the farthest from an ALSA API expert you can
imagine, so please check what I did. I believe that the flags are all
right, I think SND_SEQ_PORT_CAP_DUPLEX is unnecessary. I also found that
the constructor does not need to connect the port, because the
subsequent devOpen() call does just that, so I removed that segment.
I hope this is good to commit.
- Ján
Index: mixxx/src/midiobjectalsaseq.h
===================================================================
--- mixxx/src/midiobjectalsaseq.h (revision 1767)
+++ mixxx/src/midiobjectalsaseq.h (working copy)
@@ -32,6 +32,7 @@
int getClientPortsList(void);
void devOpen(QString device);
void devClose();
+ void sendShortMsg(unsigned int word);
protected:
void run();
Index: mixxx/src/midiobjectalsaseq.cpp
===================================================================
--- mixxx/src/midiobjectalsaseq.cpp (revision 1767)
+++ mixxx/src/midiobjectalsaseq.cpp (working copy)
@@ -46,13 +46,14 @@
}
snd_seq_port_info_alloca(&pinfo);
- snd_seq_port_info_set_capability(pinfo, SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE );
+ snd_seq_port_info_set_capability(pinfo, SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE |
+ SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ );
snd_seq_port_info_set_type(pinfo, SND_SEQ_PORT_TYPE_MIDI_GENERIC | SND_SEQ_PORT_TYPE_APPLICATION );
snd_seq_port_info_set_midi_channels(pinfo, 16);
snd_seq_port_info_set_timestamping(pinfo, 1);
snd_seq_port_info_set_timestamp_real(pinfo, 1);
snd_seq_port_info_set_timestamp_queue(pinfo, m_queue);
- snd_seq_port_info_set_name(pinfo, "input");
+ snd_seq_port_info_set_name(pinfo, "Mixxx");
m_input = snd_seq_create_port(m_handle, pinfo);
if (m_input != 0)
@@ -61,13 +62,6 @@
return;
}
- err = snd_seq_connect_from(m_handle, m_input, SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_ANNOUNCE);
- if (err != 0)
- {
- qDebug("snd_seq_connect_from failed" );
- return;
- }
-
// BJW Actually open the requested device (otherwise it won't be opened
// until reconfigured via the Preferences dialog!)
devOpen(device);
@@ -193,10 +187,14 @@
//qDebug("Connecting " + sPortName + " to Mixxx");
snd_seq_connect_from(m_handle, m_input, iAlsaClient, iAlsaPort);
+ snd_seq_connect_to(m_handle, m_input, iAlsaClient, iAlsaPort);
sActivePortName = sPortName;
}
- else //Disconnect Mixxx from any other ports (might be annoying, but let's us be safe.)
+ else {
+ //Disconnect Mixxx from any other ports (might be annoying, but let's us be safe.)
snd_seq_disconnect_from(m_handle, snd_seq_port_info_get_port(pPortInfo), iAlsaClient, iAlsaPort);
+ snd_seq_disconnect_to(m_handle, snd_seq_port_info_get_port(pPortInfo), iAlsaClient, iAlsaPort);
+ }
iDirtyCount++;
}
@@ -293,3 +291,23 @@
}
}
+void MidiObjectALSASeq::sendShortMsg(unsigned int word) {
+ snd_seq_event_t ev;
+ int byte1, byte2, byte3;
+ byte1 = word & 0xff;
+ byte2 = (word>>8) & 0xff;
+ byte3 = (word>>16) & 0xff;
+ // qDebug("MIDI message being implemented on this platform: %02x %02x %02x", byte1, byte2, byte3);
+ snd_seq_ev_set_direct(&ev);
+ snd_seq_ev_set_source(&ev, m_input);
+ snd_seq_ev_set_dest(&ev, SND_SEQ_ADDRESS_SUBSCRIBERS, 0);
+ switch ((byte1 & 0xf0)) {
+ case 0x90:
+ snd_seq_ev_set_noteon(&ev, byte1&0xf, byte2, byte3);
+ break;
+ case 0xb0:
+ snd_seq_ev_set_controller(&ev, byte1&0xf0, byte2, byte3);
+ break;
+ }
+ snd_seq_event_output_direct(m_handle, &ev);
+}
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Mixxx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mixxx-devel