From dd7d23431eae1e4bf3251a19709cff418ff09ae4 Mon Sep 17 00:00:00 2001 From: Karl Linden Date: Thu, 28 Jan 2016 11:20:38 +0100 Subject: example-clients/transport.c: remove trailing spaces --- example-clients/transport.c | 48 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'example-clients') diff --git a/example-clients/transport.c b/example-clients/transport.c index 4847c1b8..cadf1d41 100644 --- a/example-clients/transport.c +++ b/example-clients/transport.c @@ -2,7 +2,7 @@ * transport.c -- JACK transport master example client. * * Copyright (C) 2003 Jack O'Quin. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -53,7 +53,7 @@ volatile int time_reset = 1; /* true when time values change */ * * Runs in the process thread. Realtime, must not wait. */ -static void timebase(jack_transport_state_t state, jack_nframes_t nframes, +static void timebase(jack_transport_state_t state, jack_nframes_t nframes, jack_position_t *pos, int new_pos, void *arg) { double min; /* minutes since frame 0 */ @@ -238,7 +238,7 @@ command_t commands[] = { {"?", com_help, "Synonym for `help'" }, {(char *)NULL, (cmd_function_t *)NULL, (char *)NULL } }; - + static command_t *find_command(char *name) { register int i; @@ -258,7 +258,7 @@ static command_t *find_command(char *name) else return (&commands[i]); } - + return ((command_t *)NULL); } @@ -302,33 +302,33 @@ static void execute_command(char *line) register int i; command_t *command; char *word; - + /* Isolate the command word. */ i = 0; while (line[i] && whitespace(line[i])) i++; word = line + i; - + while (line[i] && !whitespace(line[i])) i++; - + if (line[i]) line[i++] = '\0'; - + command = find_command(word); - + if (!command) { fprintf(stderr, "%s: No such command. There is `help\'.\n", word); return; } - + /* Get argument to command, if any. */ while (whitespace(line[i])) i++; - + word = line + i; - + /* invoke the command function. */ (*command->func)(word); } @@ -345,28 +345,28 @@ static char *stripwhite(char *string) if (*s == '\0') return s; - + t = s + strlen (s) - 1; while (t > s && whitespace(*t)) t--; *++t = '\0'; - + return s; } - + static char *dupstr(char *s) { char *r = malloc(strlen(s) + 1); strcpy(r, s); return r; } - + /* Readline generator function for command completion. */ static char *command_generator (const char *text, int state) { static int list_index, len; char *name; - + /* If this is a new word to complete, initialize now. This includes saving the length of TEXT for efficiency, and initializing the index variable to 0. */ @@ -374,16 +374,16 @@ static char *command_generator (const char *text, int state) list_index = 0; len = strlen (text); } - + /* Return the next name which partially matches from the command list. */ while ((name = commands[list_index].name)) { list_index++; - + if (strncmp(name, text, len) == 0) return dupstr(name); } - + return (char *) NULL; /* No names matched. */ } @@ -397,7 +397,7 @@ static void command_loop() /* Allow conditional parsing of the ~/.inputrc file. */ rl_readline_name = package; - + /* Define a custom completion function. */ rl_completion_entry_function = command_generator; #else @@ -410,7 +410,7 @@ static void command_loop() #ifdef HAVE_READLINE line = readline(prompt); - + if (line == NULL) { /* EOF? */ printf("\n"); /* close out prompt */ done = 1; @@ -421,7 +421,7 @@ static void command_loop() fgets(line, sizeof(line), stdin); line[strlen(line)-1] = '\0'; #endif - + /* Remove leading and trailing whitespace from the line. */ cmd = stripwhite(line); @@ -433,7 +433,7 @@ static void command_loop() #endif execute_command(cmd); } - + #ifdef HAVE_READLINE free(line); /* realine() called malloc() */ #endif -- cgit v1.2.1 From a9079314095031654751c3d247d314dd2568bd1a Mon Sep 17 00:00:00 2001 From: Karl Linden Date: Thu, 28 Jan 2016 11:29:07 +0100 Subject: example-clients/transport.c: replace '#ifdef' with '#if' and '#ifndef x' with '#if !x' --- example-clients/transport.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'example-clients') diff --git a/example-clients/transport.c b/example-clients/transport.c index cadf1d41..fd258d8f 100644 --- a/example-clients/transport.c +++ b/example-clients/transport.c @@ -24,14 +24,14 @@ #include #include #include -#ifdef HAVE_READLINE +#if HAVE_READLINE #include #include #endif #include #include -#ifndef HAVE_READLINE +#if !HAVE_READLINE #define whitespace(c) (((c) == ' ') || ((c) == '\t')) #endif @@ -389,7 +389,7 @@ static char *command_generator (const char *text, int state) static void command_loop() { -#ifdef HAVE_READLINE +#if HAVE_READLINE char *line, *cmd; char prompt[32]; @@ -408,7 +408,7 @@ static void command_loop() /* Read and execute commands until the user quits. */ while (!done) { -#ifdef HAVE_READLINE +#if HAVE_READLINE line = readline(prompt); if (line == NULL) { /* EOF? */ @@ -428,13 +428,13 @@ static void command_loop() /* If anything left, add to history and execute it. */ if (*cmd) { -#ifdef HAVE_READLINE +#if HAVE_READLINE add_history(cmd); #endif execute_command(cmd); } -#ifdef HAVE_READLINE +#if HAVE_READLINE free(line); /* realine() called malloc() */ #endif } @@ -459,7 +459,7 @@ int main(int argc, char *argv[]) return 1; } -#ifndef WIN32 +#if !WIN32 signal(SIGQUIT, signal_handler); signal(SIGHUP, signal_handler); #endif -- cgit v1.2.1 From 123de3614fd2fa83fbea97d499dedecf95c5cbfc Mon Sep 17 00:00:00 2001 From: Stephane Letz Date: Wed, 10 Feb 2016 16:48:44 +0100 Subject: Correct midiseq.c : better use jack_midi_reset_buffer instead of jack_midi_clear_buffer for output port. --- example-clients/midiseq.c | 67 +++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 37 deletions(-) (limited to 'example-clients') diff --git a/example-clients/midiseq.c b/example-clients/midiseq.c index 1fc779e3..7906e0fa 100644 --- a/example-clients/midiseq.c +++ b/example-clients/midiseq.c @@ -50,49 +50,44 @@ static void usage() static int process(jack_nframes_t nframes, void *arg) { - int i,j; - void* port_buf = jack_port_get_buffer(output_port, nframes); - unsigned char* buffer; - jack_midi_clear_buffer(port_buf); - /*memset(buffer, 0, nframes*sizeof(jack_default_audio_sample_t));*/ + int i,j; + void* port_buf = jack_port_get_buffer(output_port, nframes); + unsigned char* buffer; + jack_midi_reset_buffer(port_buf); + /*memset(buffer, 0, nframes*sizeof(jack_default_audio_sample_t));*/ - for(i=0; i= loop_nsamp ? 0 : loop_index+1; - } - return 0; + for (i = 0; i < nframes; i++) { + for (j = 0; j < num_notes; j++) { + if (note_starts[j] == loop_index) { + if ((buffer = jack_midi_event_reserve(port_buf, i, 3))) { + /* printf("wrote a note on, port buffer = 0x%x, event buffer = 0x%x\n", port_buf, buffer); */ + buffer[2] = 64; /* velocity */ + buffer[1] = note_frqs[j]; + buffer[0] = 0x90; /* note on */ + } + } else if (note_starts[j] + note_lengths[j] == loop_index) { + if ((buffer = jack_midi_event_reserve(port_buf, i, 3))) { + /* printf("wrote a note off, port buffer = 0x%x, event buffer = 0x%x\n", port_buf, buffer); */ + buffer[2] = 64; /* velocity */ + buffer[1] = note_frqs[j]; + buffer[0] = 0x80; /* note off */ + } + } + } + loop_index = loop_index+1 >= loop_nsamp ? 0 : loop_index+1; + } + return 0; } int main(int narg, char **args) { int i; jack_nframes_t nframes; - if((narg<6) || ((narg-3)%3 !=0)) - { + if ((narg<6) || ((narg-3)%3 != 0)) { usage(); exit(1); } - if((client = jack_client_open (args[1], JackNullOption, NULL)) == 0) - { + if ((client = jack_client_open (args[1], JackNullOption, NULL)) == 0) { fprintf (stderr, "JACK server not running?\n"); return 1; } @@ -105,15 +100,13 @@ int main(int narg, char **args) note_starts = malloc(num_notes*sizeof(jack_nframes_t)); note_lengths = malloc(num_notes*sizeof(jack_nframes_t)); loop_nsamp = atoi(args[2]); - for(i=0; i Date: Thu, 11 Feb 2016 11:58:01 +0100 Subject: Correct JackDriver::Open : call to fGraphManager->SetBufferSize has to use current fEngineControl->fBufferSize value. --- example-clients/midiseq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'example-clients') diff --git a/example-clients/midiseq.c b/example-clients/midiseq.c index 7906e0fa..45085e80 100644 --- a/example-clients/midiseq.c +++ b/example-clients/midiseq.c @@ -53,7 +53,7 @@ static int process(jack_nframes_t nframes, void *arg) int i,j; void* port_buf = jack_port_get_buffer(output_port, nframes); unsigned char* buffer; - jack_midi_reset_buffer(port_buf); + jack_midi_clear_buffer(port_buf); /*memset(buffer, 0, nframes*sizeof(jack_default_audio_sample_t));*/ for (i = 0; i < nframes; i++) { -- cgit v1.2.1