29#if defined(H2CORE_HAVE_JACK) || _DOXYGEN_
39#ifdef H2CORE_HAVE_LASH
49 pthread_mutex_lock(&
mtx);
55 pthread_mutex_unlock(&
mtx);
65 jack_midi_event_t event;
72 buf = jack_port_get_buffer(
input_port, nframes);
77#ifdef JACK_MIDI_NEEDS_NFRAMES
78 events = jack_midi_get_event_count(buf, nframes);
80 events = jack_midi_get_event_count(buf);
83 for (i = 0; i < events; i++) {
86#ifdef JACK_MIDI_NEEDS_NFRAMES
87 error = jack_midi_event_get(&event, buf, i, nframes);
89 error = jack_midi_event_get(&event, buf, i);
100 if (error > (
int)
sizeof(buffer)) {
101 error = (int)
sizeof(buffer);
104 memset(buffer, 0,
sizeof(buffer));
105 memcpy(buffer, event.buffer, error);
109 if ( buffer[ 3 ] == 06 ){
110 for (
int i = 0; i <
sizeof(buffer) && i<6; i++ ) {
115 for (
int i = 0; i <
sizeof(buffer); i++ ) {
134 if (channel < 0 || channel > 15) {
138 if (param < 0 || param > 127) {
142 if (value < 0 || value > 127) {
146 buffer[0] = 0xB0 | channel;
168 if (buf ==
nullptr) {
172#ifdef JACK_MIDI_NEEDS_NFRAMES
173 jack_midi_clear_buffer(buf, nframes);
175 jack_midi_clear_buffer(buf);
180 while ((t < nframes) &&
192#ifdef JACK_MIDI_NEEDS_NFRAMES
193 buffer = jack_midi_event_reserve(buf, t, len, nframes);
195 buffer = jack_midi_event_reserve(buf, t, len);
197 if (buffer ==
nullptr) {
267 pthread_mutex_init(&
mtx,
nullptr);
275 QString jackMidiClientId =
"Hydrogen";
277#ifdef H2CORE_HAVE_OSC
281 if(!nsmClientId.isEmpty()){
282 jackMidiClientId = nsmClientId;
286 jackMidiClientId.append(
"-midi");
288 jack_client = jack_client_open(jackMidiClientId.toLocal8Bit(),
289 JackNoStartServer,
nullptr);
303 JackPortIsOutput, 0);
318 ERRORLOG(
"Failed to unregister jack midi input out");
322 ERRORLOG(
"Failed to unregister jack midi input out");
327 ERRORLOG(
"Failed to unregister jack midi input out");
331 ERRORLOG(
"Failed close jack midi client");
334 pthread_mutex_destroy(&
mtx);
353 std::vector<QString> inputList;
355 inputList.push_back(
"Default");
363 std::vector<QString> outputList;
365 outputList.push_back(
"Default");
392 if (channel < 0 || channel > 15) {
397 if (key < 0 || key > 127) {
402 if (vel < 0 || vel > 127) {
406 buffer[0] = 0x80 | channel;
413 buffer[0] = 0x90 | channel;
426 if (channel < 0 || channel > 15) {
430 if (key < 0 || key > 127) {
434 if (vel < 0 || vel > 127) {
438 buffer[0] = 0x80 | channel;
449 std::shared_ptr<Instrument> pCurInstr;
450 unsigned int numInstruments = pInstrList->size();
455 for (i = 0; i < numInstruments; i++) {
456 pCurInstr = pInstrList->get(i);
458 channel = pCurInstr->get_midi_out_channel();
459 if (channel < 0 || channel > 15) {
463 key = pCurInstr->get_midi_out_note();
464 if (key < 0 || key > 127) {
#define JACK_MIDI_BUFFER_MAX
std::shared_ptr< Song > getSong() const
Get the current song.
static Hydrogen * get_instance()
Returns the current Hydrogen instance __instance.
void raiseError(unsigned nErrorCode)
virtual ~JackMidiDriver()
void JackMidiOutEvent(uint8_t *buf, uint8_t len)
jack_port_t * output_port
void getPortInfo(const QString &sPortName, int &nClient, int &nPort)
virtual void open() override
void JackMidiWrite(jack_nframes_t nframes)
void JackMidiRead(jack_nframes_t nframes)
uint8_t jack_buffer[JACK_MIDI_BUFFER_MAX *4]
virtual std::vector< QString > getInputPortList() override
virtual void close() override
virtual void handleQueueNoteOff(int channel, int key, int velocity) override
virtual std::vector< QString > getOutputPortList() override
virtual void handleQueueAllNoteOff() override
virtual void handleOutgoingControlChange(int param, int value, int channel) override
jack_client_t * jack_client
virtual void handleQueueNote(Note *pNote) override
void setType(int nStatusByte)
Derives and set m_type (and if applicable m_nChannel) using the statusByte of an incoming MIDI messag...
std::vector< unsigned char > m_sysexData
A note plays an associated instrument with a velocity left and right pan.
std::shared_ptr< Instrument > get_instrument()
__instrument accessor
int get_midi_key() const
return scaled key for midi output, !
int get_midi_velocity() const
midi velocity accessor
Manager for User Preferences File (singleton)
static Preferences * get_instance()
Returns a pointer to the current Preferences singleton stored in __instance.
QString getNsmClientId(void)
static QString getNullMidiPort()
Choice of m_sMidiPortName and m_sMidiOutputPortName in case no port/device was selected.
static void JackMidiShutdown(void *arg)
static int JackMidiProcessCallback(jack_nframes_t nframes, void *arg)