1-multichannel #1

Merged
boomjacky merged 31 commits from 1-multichannel into multichannel 2026-05-09 15:47:09 -04:00
Showing only changes of commit e7761c4b53 - Show all commits

View File

@@ -10,6 +10,7 @@
#include <jack/jack.h>
#include <jack/midiport.h>
#include <math.h>
#include <time.h>
/* static variables for passthrough test */
static jack_port_t *passthrough_output_port = NULL;
@@ -32,6 +33,13 @@ static jack_client_t *midi_inject_client = NULL;
static unsigned char midi_inject_note = 0;
static unsigned char midi_inject_velocity = 0;
static void safe_usleep(unsigned int usec) {
struct timespec ts;
ts.tv_sec = usec / 1000000;
ts.tv_nsec = (usec % 1000000) * 1000L;
nanosleep(&ts, NULL);
}
static int midi_inject_process(jack_nframes_t nframes, void *arg) {
(void)arg;
if (!midi_inject_port) return 0;
@@ -57,8 +65,8 @@ static int passthrough_process(jack_nframes_t nframes, void *arg) {
(void)arg;
jack_default_audio_sample_t *out =
(jack_default_audio_sample_t *)jack_port_get_buffer(passthrough_output_port, nframes);
jack_default_audio_sample_t *in =
(jack_default_audio_sample_t *)jack_port_get_buffer(passthrough_input_port, nframes);
const jack_default_audio_sample_t *in =
(const jack_default_audio_sample_t *)jack_port_get_buffer(passthrough_input_port, nframes);
if (!out || !in) return 0;
float *outf = out;
const float *inf = in;
@@ -195,7 +203,7 @@ static int test_audio_pass_through(void) {
waitpid(pid, NULL, 0);
return 1;
}
usleep(2200000); /* 2.2 seconds */
safe_usleep(2200000);
int saw_input = passthrough_done;
double rms = passthrough_total_samples > 0 ?
sqrt(passthrough_sum_sq / passthrough_total_samples) : 0.0;
@@ -349,7 +357,7 @@ static int test_looper_looping(void) {
}
/* wait enough time for several loops (4 seconds to be safe) */
usleep(4000000);
safe_usleep(4000000);
jack_deactivate(client);
jack_client_close(client);
@@ -390,7 +398,7 @@ static int test_multiple_channels(void) {
}
/* wait long enough for the looper's main loop to process the add command
(it sleeps for 1 second between checks, so 1.5 s is safe) */
usleep(1500000);
safe_usleep(1500000);
int found = 0;
const char **ports = jack_get_ports(client, NULL, JACK_DEFAULT_AUDIO_TYPE, 0);
@@ -500,7 +508,7 @@ static int test_control_key_modifier(void) {
fprintf(stderr, " FAIL: send note 62 for loop\n");
return 1;
}
usleep(2000000); /* wait for a few loops */
safe_usleep(2000000);
jack_deactivate(client);
jack_client_close(client);
kill(pid, SIGTERM);
@@ -613,7 +621,7 @@ static int test_bind_channel(void) {
fprintf(stderr, " FAIL: toggle for loop\n");
return 1;
}
usleep(2000000);
safe_usleep(2000000);
jack_deactivate(client);
jack_client_close(client);
kill(pid, SIGTERM);
@@ -741,7 +749,7 @@ static int test_bind_unbind(void) {
fprintf(stderr, " FAIL: toggle for loop\n");
return 1;
}
usleep(2000000);
safe_usleep(2000000);
jack_deactivate(client);
jack_client_close(client);
kill(pid, SIGTERM);
@@ -776,7 +784,7 @@ static int test_remove_channel(void) {
fprintf(stderr, " FAIL: send note 60 failed\n");
return 1;
}
usleep(1500000);
safe_usleep(1500000);
/* verify channel1_input exists */
const char **ports = jack_get_ports(client, NULL, JACK_DEFAULT_AUDIO_TYPE, 0);
int found = 0;
@@ -803,7 +811,7 @@ static int test_remove_channel(void) {
fprintf(stderr, " FAIL: send note 61 failed\n");
return 1;
}
usleep(1500000);
safe_usleep(1500000);
/* verify channel1_input has disappeared */
ports = jack_get_ports(client, NULL, JACK_DEFAULT_AUDIO_TYPE, 0);
int still_found = 0;