|
| 1 | +diff --git a/windows/portaudio/JackPortAudioDriver.cpp b/windows/portaudio/JackPortAudioDriver.cpp |
| 2 | +index 67829aba..0f428cf0 100644 |
| 3 | +--- a/windows/portaudio/JackPortAudioDriver.cpp |
| 4 | ++++ b/windows/portaudio/JackPortAudioDriver.cpp |
| 5 | +@@ -26,6 +26,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 6 | + #include "JackTime.h" |
| 7 | + #include "JackTools.h" |
| 8 | + #include "JackCompilerDeps.h" |
| 9 | ++#include "JackLockedEngine.h" |
| 10 | ++#include "JackMidiPort.h" |
| 11 | + #include <iostream> |
| 12 | + #include <assert.h> |
| 13 | + |
| 14 | +@@ -33,6 +35,31 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 15 | + #include "JackServerGlobals.h" |
| 16 | + #endif |
| 17 | + |
| 18 | ++typedef uint32_t (*jacksym_midi_get_event_count)(void*); |
| 19 | ++typedef int (*jacksym_midi_event_get)(jack_midi_event_t*, void*, uint32_t); |
| 20 | ++typedef int (*jacksym_midi_event_write)(void*, jack_nframes_t, const jack_midi_data_t*, size_t); |
| 21 | ++ |
| 22 | ++extern "C" |
| 23 | ++{ |
| 24 | ++LIB_EXPORT uint32_t jack_midi_get_event_count(void* port_buffer); |
| 25 | ++ |
| 26 | ++LIB_EXPORT int jack_midi_event_get(jack_midi_event_t* event, |
| 27 | ++ void* port_buffer, uint32_t event_index); |
| 28 | ++ |
| 29 | ++LIB_EXPORT int jack_midi_event_write(void* port_buffer, |
| 30 | ++ jack_nframes_t time, const jack_midi_data_t* data, size_t data_size); |
| 31 | ++ |
| 32 | ++void PaJack_SetMidiCallbacks(PaStream* s, |
| 33 | ++ jacksym_midi_get_event_count get_count, |
| 34 | ++ jacksym_midi_event_get get, |
| 35 | ++ jacksym_midi_event_write write); |
| 36 | ++ |
| 37 | ++void PaJack_SetMidiBuffers(PaStream* s, |
| 38 | ++ void* get_ptr, |
| 39 | ++ void* write_ptr); |
| 40 | ++ |
| 41 | ++} |
| 42 | ++ |
| 43 | + using namespace std; |
| 44 | + |
| 45 | + namespace Jack |
| 46 | +@@ -109,6 +136,14 @@ int JackPortAudioDriver::Read() |
| 47 | + for (int i = 0; i < fCaptureChannels; i++) { |
| 48 | + memcpy(GetInputBuffer(i), fInputBuffer[i], sizeof(jack_default_audio_sample_t) * fEngineControl->fBufferSize); |
| 49 | + } |
| 50 | ++ |
| 51 | ++#ifdef __linux__ |
| 52 | ++ JackMidiBuffer* cbuf = (JackMidiBuffer*)fGraphManager->GetBuffer(fCaptureMidiPort, fEngineControl->fBufferSize); |
| 53 | ++ JackMidiBuffer* pbuf = (JackMidiBuffer*)fGraphManager->GetBuffer(fPlaybackMidiPort, fEngineControl->fBufferSize); |
| 54 | ++ pbuf->Reset(fEngineControl->fBufferSize); |
| 55 | ++ PaJack_SetMidiBuffers(fStream, pbuf, cbuf); |
| 56 | ++#endif |
| 57 | ++ |
| 58 | + return 0; |
| 59 | + } |
| 60 | + |
| 61 | +@@ -117,6 +152,12 @@ int JackPortAudioDriver::Write() |
| 62 | + for (int i = 0; i < fPlaybackChannels; i++) { |
| 63 | + memcpy(fOutputBuffer[i], GetOutputBuffer(i), sizeof(jack_default_audio_sample_t) * fEngineControl->fBufferSize); |
| 64 | + } |
| 65 | ++ |
| 66 | ++#ifdef __linux__ |
| 67 | ++ JackMidiBuffer* cbuf = (JackMidiBuffer*)fGraphManager->GetBuffer(fCaptureMidiPort, fEngineControl->fBufferSize); |
| 68 | ++ cbuf->Reset(fEngineControl->fBufferSize); |
| 69 | ++#endif |
| 70 | ++ |
| 71 | + return 0; |
| 72 | + } |
| 73 | + |
| 74 | +@@ -303,6 +344,23 @@ int JackPortAudioDriver::Open(jack_nframes_t buffer_size, |
| 75 | + device_reservation_loop_running = false; |
| 76 | + } |
| 77 | + } |
| 78 | ++ |
| 79 | ++ jack_port_id_t port_index; |
| 80 | ++ JackPort* port; |
| 81 | ++ if (fEngine->PortRegister(fClientControl.fRefNum, "system:midi_capture_1", JACK_DEFAULT_MIDI_TYPE, |
| 82 | ++ CaptureDriverFlags, fEngineControl->fBufferSize, &port_index) < 0) { |
| 83 | ++ goto error; |
| 84 | ++ } |
| 85 | ++ fCaptureMidiPort = port_index; |
| 86 | ++ port = fGraphManager->GetPort(port_index); |
| 87 | ++ port->SetAlias("MOD Desktop MIDI Capture"); |
| 88 | ++ if (fEngine->PortRegister(fClientControl.fRefNum, "system:midi_playback_1", JACK_DEFAULT_MIDI_TYPE, |
| 89 | ++ PlaybackDriverFlags, fEngineControl->fBufferSize, &port_index) < 0) { |
| 90 | ++ goto error; |
| 91 | ++ } |
| 92 | ++ fPlaybackMidiPort = port_index; |
| 93 | ++ port = fGraphManager->GetPort(port_index); |
| 94 | ++ port->SetAlias("MOD Desktop MIDI Playback"); |
| 95 | + #endif |
| 96 | + |
| 97 | + return 0; |
| 98 | +@@ -387,6 +445,12 @@ int JackPortAudioDriver::Start() |
| 99 | + if (JackAudioDriver::Start() == 0) { |
| 100 | + PaError err; |
| 101 | + if ((err = Pa_StartStream(fStream)) == paNoError) { |
| 102 | ++#ifdef __linux__ |
| 103 | ++ PaJack_SetMidiCallbacks(fStream, |
| 104 | ++ jack_midi_get_event_count, |
| 105 | ++ jack_midi_event_get, |
| 106 | ++ jack_midi_event_write); |
| 107 | ++#endif |
| 108 | + return 0; |
| 109 | + } |
| 110 | + jack_error("Pa_StartStream error = %s", Pa_GetErrorText(err)); |
| 111 | +diff --git a/windows/portaudio/JackPortAudioDriver.h b/windows/portaudio/JackPortAudioDriver.h |
| 112 | +index 7b16d6ea..f366189b 100644 |
| 113 | +--- a/windows/portaudio/JackPortAudioDriver.h |
| 114 | ++++ b/windows/portaudio/JackPortAudioDriver.h |
| 115 | +@@ -49,7 +49,11 @@ class JackPortAudioDriver : |
| 116 | + PaDeviceIndex fInputDevice; |
| 117 | + PaDeviceIndex fOutputDevice; |
| 118 | + PortAudioDevices* fPaDevices; |
| 119 | ++#ifdef __linux__ |
| 120 | ++ int fCaptureMidiPort; |
| 121 | ++ int fPlaybackMidiPort; |
| 122 | + jack_native_thread_t fReservationLoopThread; |
| 123 | ++#endif |
| 124 | + |
| 125 | + static int Render(const void* inputBuffer, void* outputBuffer, |
| 126 | + unsigned long framesPerBuffer, |
| 127 | +@@ -69,6 +73,9 @@ class JackPortAudioDriver : |
| 128 | + #endif |
| 129 | + JackAudioDriver(name, alias, engine, table), fStream(NULL), fInputBuffer(NULL), fOutputBuffer(NULL), |
| 130 | + fInputDevice(paNoDevice), fOutputDevice(paNoDevice), fPaDevices(pa_devices) |
| 131 | ++#ifdef __linux__ |
| 132 | ++ , fCaptureMidiPort(0), fPlaybackMidiPort(0) |
| 133 | ++#endif |
| 134 | + {} |
| 135 | + |
| 136 | + virtual ~JackPortAudioDriver() |
0 commit comments