Mercurial > hg > index.fcgi > lsonify > lsonify-1pba
comparison lsonify.c @ 3:3dd48f06493e
add sample rate change callback
author | paulo@localhost |
---|---|
date | Thu, 21 May 2009 00:56:16 -0700 |
parents | ff028323c114 |
children |
comparison
equal
deleted
inserted
replaced
0:5a0318b2d281 | 1:f6fe2232a1d4 |
---|---|
104 process_audio (nframes); | 104 process_audio (nframes); |
105 return 0; | 105 return 0; |
106 } | 106 } |
107 | 107 |
108 int | 108 int |
109 sample_rate_change () { | 109 sample_rate_change (jack_nframes_t nframes, void *arg) { |
110 printf("Sample rate has changed! Exiting...\n"); | 110 if (nframes != sr) { |
111 exit(-1); | 111 printf("Sample rate has changed! Exiting...\n"); |
112 exit(-1); | |
113 } | |
114 return 0; | |
112 } | 115 } |
113 | 116 |
114 int | 117 int |
115 main (int argc, char *argv[]) | 118 main (int argc, char *argv[]) |
116 { | 119 { |
220 } | 223 } |
221 jack_set_process_callback (client, process, 0); | 224 jack_set_process_callback (client, process, 0); |
222 output_port = jack_port_register (client, port_string, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); | 225 output_port = jack_port_register (client, port_string, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); |
223 | 226 |
224 sr = jack_get_sample_rate (client); | 227 sr = jack_get_sample_rate (client); |
228 jack_set_sample_rate_callback (client, sample_rate_change, 0); | |
225 | 229 |
226 /* setup wave table parameters */ | 230 /* setup wave table parameters */ |
227 wave_length = 60 * sr / bpm; | 231 wave_length = 60 * sr / bpm; |
228 tone_length = sr * dur_arg / 1000; | 232 tone_length = sr * dur_arg / 1000; |
229 attack_length = tone_length * attack_percent / 100; | 233 attack_length = tone_length * attack_percent / 100; |