Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jack2 latent_client.c #14

Merged
merged 5 commits into from
Dec 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions example-clients/latent_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,36 @@ jack_default_audio_sample_t *delay_line;
jack_nframes_t delay_index;
jack_nframes_t latency = 1024;

#ifdef WIN32
#define jack_sleep(val) Sleep((val))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this macro is only used once, so I dont really think it makes sense. plus the -1*1000 for !win32 case makes it be very weird..

will remove this part to be more in line with the other examples, which do not use a macro

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a ticket for this?

#else
#define jack_sleep(val) usleep((val) * 1000)
#endif

/**
* The process callback for this JACK application is called in a
* special realtime thread once for each audio cycle.
*
* This client does nothing more than copy data from its input
* port to its output port. It will exit when stopped by
* port to its output port. It will exit when stopped by
* the user (e.g. using Ctrl-C on a unix-ish operating system)
*/
int
process (jack_nframes_t nframes, void *arg)
{
jack_default_audio_sample_t *in, *out;
int k;

in = jack_port_get_buffer (input_port, nframes);
out = jack_port_get_buffer (output_port, nframes);

for (k=0; k<nframes; k++) {
out[k] = delay_line[delay_index];
delay_line[delay_index] = in[k];
delay_index = (delay_index + 1) % latency;
}
}

return 0;
return 0;
}

void
Expand All @@ -71,7 +77,7 @@ latency_cb (jack_latency_callback_mode_t mode, void *arg)
void
jack_shutdown (void *arg)
{
fprintf(stderr, "JACK shut down, exiting ...\n");
fprintf(stderr, "JACK shut down, exiting ...\n");
exit (1);
}

Expand All @@ -83,7 +89,7 @@ main (int argc, char *argv[])
const char *server_name = NULL;
jack_options_t options = JackNullOption;
jack_status_t status;


if (argc == 2)
latency = atoi(argv[1]);
Expand Down Expand Up @@ -134,7 +140,7 @@ main (int argc, char *argv[])

jack_on_shutdown (client, jack_shutdown, 0);

/* display the current sample rate.
/* display the current sample rate.
*/

printf ("engine sample rate: %" PRIu32 "\n",
Expand Down Expand Up @@ -182,7 +188,7 @@ main (int argc, char *argv[])
}

free (ports);

ports = jack_get_ports (client, NULL, NULL,
JackPortIsPhysical|JackPortIsInput);
if (ports == NULL) {
Expand All @@ -198,11 +204,7 @@ main (int argc, char *argv[])

/* keep running until stopped by the user */

#ifdef WIN32
Sleep (-1);
#else
sleep (-1);
#endif
jack_sleep (-1);

/* this is never reached but if the program
had some other way to exit besides being killed,
Expand Down