Compare commits
1 Commits
3-integrat
...
0612f423d1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0612f423d1 |
@@ -95,18 +95,18 @@ void channel_remove_scene(jack_client_t *client, int idx) {
|
|||||||
/* shift remaining scenes down (atomic copy of fields) */
|
/* shift remaining scenes down (atomic copy of fields) */
|
||||||
for (int i = cs; i < sc - 1; i++) {
|
for (int i = cs; i < sc - 1; i++) {
|
||||||
atomic_store(&cur[idx].scenes[i].loop_count,
|
atomic_store(&cur[idx].scenes[i].loop_count,
|
||||||
atomic_load(&cur[idx].scenes[i + 1].loop_count));
|
atomic_load(&cur[idx].scenes[i+1].loop_count));
|
||||||
atomic_store(&cur[idx].scenes[i].record_pos,
|
atomic_store(&cur[idx].scenes[i].record_pos,
|
||||||
atomic_load(&cur[idx].scenes[i + 1].record_pos));
|
atomic_load(&cur[idx].scenes[i+1].record_pos));
|
||||||
atomic_store(&cur[idx].scenes[i].playback_pos,
|
atomic_store(&cur[idx].scenes[i].playback_pos,
|
||||||
atomic_load(&cur[idx].scenes[i + 1].playback_pos));
|
atomic_load(&cur[idx].scenes[i+1].playback_pos));
|
||||||
atomic_store(&cur[idx].scenes[i].state,
|
atomic_store(&cur[idx].scenes[i].state,
|
||||||
atomic_load(&cur[idx].scenes[i + 1].state));
|
atomic_load(&cur[idx].scenes[i+1].state));
|
||||||
atomic_store(&cur[idx].scenes[i].prev_state,
|
atomic_store(&cur[idx].scenes[i].prev_state,
|
||||||
atomic_load(&cur[idx].scenes[i + 1].prev_state));
|
atomic_load(&cur[idx].scenes[i+1].prev_state));
|
||||||
/* copy loop data (may race with RT thread; acceptable for this release) */
|
/* copy loop data (may race with RT thread; acceptable for this release) */
|
||||||
memcpy(cur[idx].scenes[i].loop.audio_buffer,
|
memcpy(cur[idx].scenes[i].loop.audio_buffer,
|
||||||
cur[idx].scenes[i + 1].loop.audio_buffer,
|
cur[idx].scenes[i+1].loop.audio_buffer,
|
||||||
LOOP_BUF_SIZE * sizeof(float));
|
LOOP_BUF_SIZE * sizeof(float));
|
||||||
}
|
}
|
||||||
atomic_fetch_sub(&cur[idx].scene_count, 1);
|
atomic_fetch_sub(&cur[idx].scene_count, 1);
|
||||||
|
|||||||
@@ -4,16 +4,16 @@
|
|||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "midi.h"
|
#include "midi.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include <fcntl.h>
|
|
||||||
#include <jack/jack.h>
|
#include <jack/jack.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <jack/midiport.h>
|
#include <jack/midiport.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdatomic.h>
|
#include <stdatomic.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#define STATUS_FIFO "/tmp/looper_status"
|
#define STATUS_FIFO "/tmp/looper_status"
|
||||||
|
|
||||||
@@ -31,23 +31,15 @@ static void looper_write_status(void) {
|
|||||||
int state = atomic_load(&cur[ch].scenes[sc_idx].state);
|
int state = atomic_load(&cur[ch].scenes[sc_idx].state);
|
||||||
const char *state_str;
|
const char *state_str;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case STATE_IDLE:
|
case STATE_IDLE: state_str = "IDLE"; break;
|
||||||
state_str = "IDLE";
|
case STATE_RECORD: state_str = "RECORD"; break;
|
||||||
break;
|
case STATE_LOOPING: state_str = "LOOPING"; break;
|
||||||
case STATE_RECORD:
|
case STATE_PAUSED: state_str = "PAUSED"; break;
|
||||||
state_str = "RECORD";
|
default: state_str = "UNKNOWN";
|
||||||
break;
|
|
||||||
case STATE_LOOPING:
|
|
||||||
state_str = "LOOPING";
|
|
||||||
break;
|
|
||||||
case STATE_PAUSED:
|
|
||||||
state_str = "PAUSED";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
state_str = "UNKNOWN";
|
|
||||||
}
|
}
|
||||||
int n = snprintf(buf, sizeof(buf), "CH=%d SC=%d STATE=%s\n", ch, sc_idx,
|
int n = snprintf(buf, sizeof(buf),
|
||||||
state_str);
|
"CH=%d SC=%d STATE=%s\n",
|
||||||
|
ch, sc_idx, state_str);
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
int ret = write(fd, buf, n);
|
int ret = write(fd, buf, n);
|
||||||
(void)ret;
|
(void)ret;
|
||||||
@@ -260,7 +252,8 @@ int process_callback(jack_nframes_t nframes, void *arg) {
|
|||||||
if (rp < MAX_MIDI_EVENTS) {
|
if (rp < MAX_MIDI_EVENTS) {
|
||||||
sc->loop.midi_events[rp].timestamp = ev.time;
|
sc->loop.midi_events[rp].timestamp = ev.time;
|
||||||
sc->loop.midi_events[rp].status = ev.buffer[0];
|
sc->loop.midi_events[rp].status = ev.buffer[0];
|
||||||
sc->loop.midi_events[rp].note = (ev.size > 1) ? ev.buffer[1] : 0;
|
sc->loop.midi_events[rp].note =
|
||||||
|
(ev.size > 1) ? ev.buffer[1] : 0;
|
||||||
sc->loop.midi_events[rp].velocity =
|
sc->loop.midi_events[rp].velocity =
|
||||||
(ev.size > 2) ? ev.buffer[2] : 0;
|
(ev.size > 2) ? ev.buffer[2] : 0;
|
||||||
atomic_store(&sc->record_pos, rp + 1);
|
atomic_store(&sc->record_pos, rp + 1);
|
||||||
@@ -317,7 +310,8 @@ int process_callback(jack_nframes_t nframes, void *arg) {
|
|||||||
jack_midi_event_write(midi_out_buf, ev.time, ev.buffer, ev.size);
|
jack_midi_event_write(midi_out_buf, ev.time, ev.buffer, ev.size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (state == STATE_LOOPING) {
|
if (state == STATE_LOOPING) {
|
||||||
atomic_store(&sc->loop_count, atomic_load(&sc->record_pos));
|
atomic_store(&sc->loop_count, atomic_load(&sc->record_pos));
|
||||||
|
|||||||
@@ -82,7 +82,8 @@ void midi_handle_events(void *port_buffer, jack_nframes_t nframes) {
|
|||||||
queue_push(&cmd_queue_main_midi, cmd);
|
queue_push(&cmd_queue_main_midi, cmd);
|
||||||
} break;
|
} break;
|
||||||
case 69: {
|
case 69: {
|
||||||
command_t cmd = {.type = CMD_ADD_SCENE, .channel = -1, .data = 0};
|
command_t cmd = {
|
||||||
|
.type = CMD_ADD_SCENE, .channel = -1, .data = 0};
|
||||||
queue_push(&cmd_queue_main_midi, cmd);
|
queue_push(&cmd_queue_main_midi, cmd);
|
||||||
} break;
|
} break;
|
||||||
case 70: {
|
case 70: {
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define FIFO_PATH "/tmp/looper_cmd"
|
#define FIFO_PATH "/tmp/looper_cmd"
|
||||||
@@ -39,8 +39,7 @@ static void *pipe_thread_func(void *arg) {
|
|||||||
command_t cmd = {.type = CMD_ADD_CHANNEL, .channel = -1, .data = 0};
|
command_t cmd = {.type = CMD_ADD_CHANNEL, .channel = -1, .data = 0};
|
||||||
queue_push(&cmd_queue_main_fifo, cmd);
|
queue_push(&cmd_queue_main_fifo, cmd);
|
||||||
} else if (strcmp(line, "add_midi") == 0) {
|
} else if (strcmp(line, "add_midi") == 0) {
|
||||||
command_t cmd = {
|
command_t cmd = {.type = CMD_ADD_MIDI_CHANNEL, .channel = -1, .data = 0};
|
||||||
.type = CMD_ADD_MIDI_CHANNEL, .channel = -1, .data = 0};
|
|
||||||
queue_push(&cmd_queue_main_fifo, cmd);
|
queue_push(&cmd_queue_main_fifo, cmd);
|
||||||
} else if (strcmp(line, "remove") == 0) {
|
} else if (strcmp(line, "remove") == 0) {
|
||||||
command_t cmd = {.type = CMD_REMOVE_CHANNEL, .channel = -1, .data = 0};
|
command_t cmd = {.type = CMD_REMOVE_CHANNEL, .channel = -1, .data = 0};
|
||||||
|
|||||||
Reference in New Issue
Block a user