Mercurial > hg > index.fcgi > lsonify > lsonify-1pba
changeset 1:46d4c88917a2
add Makefile; rename string to refer to "lsonify" instead of jack_metro; connect to physical input ports on startup
author | paulo@localhost |
---|---|
date | Sun, 17 May 2009 02:32:01 -0700 |
parents | 047192fef940 |
children | ff028323c114 |
files | Makefile metro.c |
diffstat | 2 files changed, 57 insertions(+), 11 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/Makefile Sun May 17 02:32:01 2009 -0700 1.3 @@ -0,0 +1,35 @@ 1.4 +JACK_CFLAGS := $(shell pkg-config --cflags jack) 1.5 +JACK_LDFLAGS := $(shell pkg-config --libs jack) 1.6 + 1.7 +CFLAGS = -g -Wall ${JACK_CFLAGS} 1.8 +LDFLAGS = ${JACK_LDFLAGS} 1.9 + 1.10 +CC = gcc 1.11 + 1.12 +SRC = metro.c 1.13 +OBJ = ${SRC:.c=.o} 1.14 + 1.15 +TARGET := lsonify 1.16 + 1.17 +.PHONY: all clean options 1.18 + 1.19 +all: options ${TARGET} 1.20 + 1.21 +options: 1.22 + @echo build options: 1.23 + @echo "CFLAGS = ${CFLAGS}" 1.24 + @echo "LDFLAGS = ${LDFLAGS}" 1.25 + @echo "CC = ${CC}" 1.26 + 1.27 +%.o: %.c 1.28 + @echo CC $< 1.29 + @${CC} -c ${CFLAGS} $< 1.30 + 1.31 +clean: 1.32 + @echo rm ${OBJ} ${TARGET} 1.33 + @rm ${OBJ} ${TARGET} 1.34 + 1.35 +${TARGET}: ${OBJ} 1.36 + @echo CC -o $@ 1.37 + @${CC} -o $@ ${OBJ} ${LDFLAGS} 1.38 +
2.1 --- a/metro.c Sat May 16 23:03:46 2009 -0700 2.2 +++ b/metro.c Sun May 17 02:32:01 2009 -0700 2.3 @@ -49,7 +49,7 @@ 2.4 2.5 { 2.6 fprintf (stderr, "\n" 2.7 -"usage: jack_metro \n" 2.8 +"usage: lsonify \n" 2.9 " [ --frequency OR -f frequency (in Hz) ]\n" 2.10 " [ --amplitude OR -A maximum amplitude (between 0 and 1) ]\n" 2.11 " [ --duration OR -D duration (in ms) ]\n" 2.12 @@ -57,6 +57,7 @@ 2.13 " [ --decay OR -d decay (in percent of duration) ]\n" 2.14 " [ --name OR -n jack name for metronome client ]\n" 2.15 " [ --transport OR -t transport aware ]\n" 2.16 +" [ --nophysical OR -p to prevent auto-connect to all physical ports]\n" 2.17 " --bpm OR -b beats per minute\n" 2.18 ); 2.19 } 2.20 @@ -118,16 +119,16 @@ 2.21 int i, attack_length, decay_length; 2.22 double *amp; 2.23 double max_amp = 0.5; 2.24 - int option_index; 2.25 int opt; 2.26 int got_bpm = 0; 2.27 int attack_percent = 1, decay_percent = 10, dur_arg = 100; 2.28 char *client_name = 0; 2.29 - char *bpm_string = "bpm"; 2.30 + char *port_string = "out"; 2.31 int verbose = 0; 2.32 + int connect_physical_ports = 1; 2.33 jack_status_t status; 2.34 2.35 - const char *options = "f:A:D:a:d:b:n:thv"; 2.36 + const char *options = "f:A:D:a:d:b:n:tphv"; 2.37 struct option long_options[] = 2.38 { 2.39 {"frequency", 1, 0, 'f'}, 2.40 @@ -138,12 +139,13 @@ 2.41 {"bpm", 1, 0, 'b'}, 2.42 {"name", 1, 0, 'n'}, 2.43 {"transport", 0, 0, 't'}, 2.44 + {"nophysical", 0, 0, 'p'}, 2.45 {"help", 0, 0, 'h'}, 2.46 {"verbose", 0, 0, 'v'}, 2.47 {0, 0, 0, 0} 2.48 }; 2.49 2.50 - while ((opt = getopt_long (argc, argv, options, long_options, &option_index)) != EOF) { 2.51 + while ((opt = getopt_long (argc, argv, options, long_options, NULL)) != EOF) { 2.52 switch (opt) { 2.53 case 'f': 2.54 if ((freq = atoi (optarg)) <= 0) { 2.55 @@ -179,9 +181,6 @@ 2.56 fprintf (stderr, "invalid bpm\n"); 2.57 return -1; 2.58 } 2.59 - bpm_string = (char *) malloc ((strlen (optarg) + 4) * sizeof (char)); 2.60 - strcpy (bpm_string, optarg); 2.61 - strcat (bpm_string, "_bpm"); 2.62 break; 2.63 case 'n': 2.64 client_name = (char *) malloc (strlen (optarg) * sizeof (char)); 2.65 @@ -193,6 +192,9 @@ 2.66 case 't': 2.67 transport_aware = 1; 2.68 break; 2.69 + case 'p': 2.70 + connect_physical_ports = 0; 2.71 + break; 2.72 default: 2.73 fprintf (stderr, "unknown option %c\n", opt); 2.74 case 'h': 2.75 @@ -208,15 +210,16 @@ 2.76 2.77 /* Initial Jack setup, get sample rate */ 2.78 if (!client_name) { 2.79 - client_name = (char *) malloc (9 * sizeof (char)); 2.80 - strcpy (client_name, "metro"); 2.81 + pid_t pid = getpid(); 2.82 + client_name = (char *) malloc (32 * sizeof (char)); 2.83 + snprintf (client_name, 32, "metro_%d", pid); 2.84 } 2.85 if ((client = jack_client_open (client_name, JackNoStartServer, &status)) == 0) { 2.86 fprintf (stderr, "jack server not running?\n"); 2.87 return 1; 2.88 } 2.89 jack_set_process_callback (client, process, 0); 2.90 - output_port = jack_port_register (client, bpm_string, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); 2.91 + output_port = jack_port_register (client, port_string, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); 2.92 2.93 sr = jack_get_sample_rate (client); 2.94 2.95 @@ -263,6 +266,14 @@ 2.96 return 1; 2.97 } 2.98 2.99 + /* connect to physical ports */ 2.100 + if (connect_physical_ports) { 2.101 + const char **ports = jack_get_ports (client, NULL, NULL, JackPortIsPhysical | JackPortIsInput); 2.102 + const char **c; 2.103 + for (c = ports; c && *c; c++) 2.104 + jack_connect (client, jack_port_name(output_port), *c); 2.105 + } 2.106 + 2.107 while (1) { 2.108 sleep(1); 2.109 };