Skip to content

Instantly share code, notes, and snippets.

@J3698
Last active March 2, 2019 01:19
Show Gist options
  • Save J3698/e9ec85c337ac28846eb657728670865d to your computer and use it in GitHub Desktop.
Save J3698/e9ec85c337ac28846eb657728670865d to your computer and use it in GitHub Desktop.
First Program in Jack
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <jack/jack.h>
#include <jack/transport.h>
typedef jack_default_audio_sample_t sample_t;
char *client_name;
jack_client_t *client;
int process(jack_nframes_t nframes, void *arg) {
return 0;
}
bool startClient() {
jack_status_t status;
while ((client = jack_client_open(client_name, 0, &status)) == 0) {
fprintf(stderr, "jack server not running?\n");
return false;
}
printf("Client started\n");
return true;
}
int main(int argc, char *argv[]) {
// start jack
client_name = "Visualizer";
if (!startClient()) {
return -1;
}
jack_set_process_callback(client, process, 0);
// activate jack
if (jack_activate(client)) {
fprintf(stderr, "cannot activate client");
return 1;
}
printf("Jack activated\n");
// get and print port names
const char **port_names = jack_get_ports(client, NULL, NULL, 0);
for (int j = 0; port_names[j] != NULL; j++) {
printf("%s\n", port_names[j]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment