Changeset 466dff3 for examples/jackio.c
- Timestamp:
- Dec 7, 2013, 4:09:00 AM (11 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 3da8187
- Parents:
- 44e94f3c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/jackio.c
r44e94f3c r466dff3 1 1 /* 2 Copyright (C) 2003-20 09Paul Brossier <piem@aubio.org>2 Copyright (C) 2003-2013 Paul Brossier <piem@aubio.org> 3 3 4 4 This file is part of aubio. … … 36 36 37 37 /** 38 * jack device structure 38 * jack device structure 39 39 */ 40 40 struct _aubio_jack_t … … 70 70 /** jack processing function */ 71 71 aubio_process_func_t callback; 72 /** internal fvec */ 73 fvec_t *ibuf; 74 fvec_t *obuf; 75 uint_t hop_size; 76 int pos; 72 77 }; 73 78 … … 75 80 static aubio_jack_t *aubio_jack_alloc (uint_t ichan, uint_t ochan, 76 81 uint_t imidichan, uint_t omidichan); 77 static uint_t aubio_jack_free (aubio_jack_t * jack_setup);78 82 /* jack callback functions */ 79 83 static int aubio_jack_process (jack_nframes_t nframes, void *arg); … … 81 85 82 86 aubio_jack_t * 83 new_aubio_jack (uint_t ichan, uint_t ochan,84 uint_t imidichan, uint_t omidichan , aubio_process_func_t callback)87 new_aubio_jack (uint_t hop_size, uint_t ichan, uint_t ochan, 88 uint_t imidichan, uint_t omidichan) 85 89 { 86 90 aubio_jack_t *jack_setup = aubio_jack_alloc (ichan, ochan, … … 149 153 } 150 154 151 /* set processing callback */ 152 jack_setup->callback = callback; 155 /* get sample rate */ 156 jack_setup->samplerate = jack_get_sample_rate (jack_setup->client); 157 158 jack_setup->hop_size = hop_size; 159 jack_setup->ibuf = new_fvec(hop_size); 160 jack_setup->obuf = new_fvec(hop_size); 161 jack_setup->pos = 0; 153 162 return jack_setup; 154 163 … … 160 169 161 170 uint_t 162 aubio_jack_activate (aubio_jack_t * jack_setup) 163 { 164 /* get sample rate */ 165 jack_setup->samplerate = jack_get_sample_rate (jack_setup->client); 171 aubio_jack_get_samplerate (aubio_jack_t * jack_setup) { 172 return jack_setup->samplerate; 173 } 174 175 uint_t 176 aubio_jack_activate (aubio_jack_t * jack_setup, aubio_process_func_t callback) 177 { 178 /* set processing callback */ 179 jack_setup->callback = callback; 166 180 /* actual jack process activation */ 167 181 if (jack_activate (jack_setup->client)) { … … 177 191 /* bug : should disconnect all ports first */ 178 192 jack_client_close (jack_setup->client); 179 aubio_jack_free (jack_setup);180 193 } 181 194 … … 209 222 } 210 223 211 static uint_t 212 aubio_jack_free(aubio_jack_t * jack_setup)224 void 225 del_aubio_jack (aubio_jack_t * jack_setup) 213 226 { 214 227 if (jack_setup->omidichan && jack_setup->midi_out_ring) { 215 228 jack_ringbuffer_free (jack_setup->midi_out_ring); 216 229 } 230 del_fvec (jack_setup->ibuf); 231 del_fvec (jack_setup->obuf); 217 232 AUBIO_FREE (jack_setup->oports); 218 233 AUBIO_FREE (jack_setup->iports); … … 220 235 AUBIO_FREE (jack_setup->obufs); 221 236 AUBIO_FREE (jack_setup); 222 return AUBIO_OK;223 237 } 224 238 … … 232 246 233 247 static void process_midi_output (aubio_jack_t * dev, jack_nframes_t nframes); 248 249 static int block_process(aubio_jack_t *dev, 250 smpl_t **input, smpl_t **output, int nframes) { 251 unsigned int j; /*frames*/ 252 for (j=0;j<(unsigned)nframes;j++) { 253 /* put synthnew in output */ 254 output[0][j] = fvec_read_sample(dev->obuf, dev->pos); 255 /* write input to datanew */ 256 fvec_write_sample(dev->ibuf, input[0][j], dev->pos); 257 /*time for fft*/ 258 if (dev->pos == (int)(dev->hop_size) - 1) { 259 /* block loop */ 260 dev->callback(dev->ibuf, dev->obuf); 261 /* end of block loop */ 262 dev->pos = -1; /* so it will be zero next j loop */ 263 } 264 dev->pos++; 265 } 266 return 1; 267 } 234 268 235 269 static int … … 249 283 } 250 284 #ifndef AUBIO_JACK_NEEDS_CONVERSION 251 dev->callback (dev->ibufs, dev->obufs, nframes);285 block_process(dev, dev->ibufs, dev->obufs, nframes); 252 286 #else 253 287 uint_t j; … … 257 291 } 258 292 } 259 dev->callback (dev->sibufs, dev->sobufs, nframes);293 block_process(dev, dev->sibufs, dev->sobufs, nframes); 260 294 for (j = 0; j < MIN (nframes, AUBIO_JACK_MAX_FRAMES); j++) { 261 295 for (i = 0; i < dev->ochan; i++) {
Note: See TracChangeset
for help on using the changeset viewer.