Last active
March 2, 2019 01:19
-
-
Save J3698/e9ec85c337ac28846eb657728670865d to your computer and use it in GitHub Desktop.
First Program in Jack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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