1-multichannel #1
@@ -23,7 +23,7 @@ void channel_add(jack_client_t *client, int idx)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
channels[idx].active = 1;
|
atomic_store(&channels[idx].active, 1);
|
||||||
atomic_store(&channels[idx].state, STATE_IDLE);
|
atomic_store(&channels[idx].state, STATE_IDLE);
|
||||||
channels[idx].prev_state = -1;
|
channels[idx].prev_state = -1;
|
||||||
channels[idx].loop_count = 0;
|
channels[idx].loop_count = 0;
|
||||||
@@ -38,6 +38,6 @@ void channel_remove(jack_client_t *client, int idx)
|
|||||||
{
|
{
|
||||||
jack_port_unregister(client, channels[idx].audio_in);
|
jack_port_unregister(client, channels[idx].audio_in);
|
||||||
jack_port_unregister(client, channels[idx].audio_out);
|
jack_port_unregister(client, channels[idx].audio_out);
|
||||||
channels[idx].active = 0;
|
atomic_store(&channels[idx].active, 0);
|
||||||
channel_count--;
|
channel_count--;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ struct channel_t {
|
|||||||
int loop_count;
|
int loop_count;
|
||||||
int record_pos;
|
int record_pos;
|
||||||
int playback_pos;
|
int playback_pos;
|
||||||
int active;
|
atomic_int active;
|
||||||
jack_port_t *audio_in;
|
jack_port_t *audio_in;
|
||||||
jack_port_t *audio_out;
|
jack_port_t *audio_out;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,14 +26,16 @@ int process_callback(jack_nframes_t nframes, void *arg)
|
|||||||
{
|
{
|
||||||
(void)arg;
|
(void)arg;
|
||||||
|
|
||||||
|
if (midi_control_port) {
|
||||||
void *midi_ctrl_buf = jack_port_get_buffer(midi_control_port, nframes);
|
void *midi_ctrl_buf = jack_port_get_buffer(midi_control_port, nframes);
|
||||||
if (midi_ctrl_buf) {
|
if (midi_ctrl_buf) {
|
||||||
midi_handle_events(midi_ctrl_buf, nframes);
|
midi_handle_events(midi_ctrl_buf, nframes);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* process each active channel */
|
/* process each active channel */
|
||||||
for (int c = 0; c < MAX_CHANNELS; c++) {
|
for (int c = 0; c < MAX_CHANNELS; c++) {
|
||||||
if (!channels[c].active) continue;
|
if (!atomic_load(&channels[c].active)) continue;
|
||||||
|
|
||||||
/* Guard against NULL ports (e.g. if port registration failed) */
|
/* Guard against NULL ports (e.g. if port registration failed) */
|
||||||
if (!channels[c].audio_in || !channels[c].audio_out) {
|
if (!channels[c].audio_in || !channels[c].audio_out) {
|
||||||
@@ -108,6 +110,7 @@ int process_callback(jack_nframes_t nframes, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* MIDI clock events – affect channel 0 only */
|
/* MIDI clock events – affect channel 0 only */
|
||||||
|
if (midi_clock_port) {
|
||||||
void *midi_clock_buf = jack_port_get_buffer(midi_clock_port, nframes);
|
void *midi_clock_buf = jack_port_get_buffer(midi_clock_port, nframes);
|
||||||
if (midi_clock_buf) {
|
if (midi_clock_buf) {
|
||||||
jack_nframes_t n_clock_events = jack_midi_get_event_count(midi_clock_buf);
|
jack_nframes_t n_clock_events = jack_midi_get_event_count(midi_clock_buf);
|
||||||
@@ -136,6 +139,7 @@ int process_callback(jack_nframes_t nframes, void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ static unsigned char midi_inject_velocity = 0;
|
|||||||
|
|
||||||
static int midi_inject_process(jack_nframes_t nframes, void *arg) {
|
static int midi_inject_process(jack_nframes_t nframes, void *arg) {
|
||||||
(void)arg;
|
(void)arg;
|
||||||
|
if (!midi_inject_port) return 0;
|
||||||
void *port_buf = jack_port_get_buffer(midi_inject_port, nframes);
|
void *port_buf = jack_port_get_buffer(midi_inject_port, nframes);
|
||||||
if (!port_buf) return 0;
|
if (!port_buf) return 0;
|
||||||
jack_midi_clear_buffer(port_buf);
|
jack_midi_clear_buffer(port_buf);
|
||||||
|
|||||||
Reference in New Issue
Block a user