- Timestamp:
- Jul 15, 2012, 8:18:28 PM (12 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:
- 42e6a5e
- Parents:
- 11a1abe
- Location:
- src/io
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/sink.c
r11a1abe r8aed26d 23 23 #include "fvec.h" 24 24 #include "io/sink.h" 25 #ifdef __APPLE__ 26 #include "io/sink_apple_audio.h" 27 #endif /* __APPLE__ */ 28 #ifdef HAVE_SNDFILE 29 #include "io/sink_sndfile.h" 30 #endif 25 31 26 32 struct _aubio_sink_t { 27 uint_t hopsize; 28 uint_t samplerate; 33 void *sink; 29 34 }; 30 35 31 aubio_sink_t * new_aubio_sink(char_t * uri, uint_t hop_size, uint_tsamplerate) {36 aubio_sink_t * new_aubio_sink(char_t * uri, uint_t samplerate) { 32 37 aubio_sink_t * s = AUBIO_NEW(aubio_sink_t); 33 return s; 38 #ifdef __APPLE__ 39 s->sink = (void *)new_aubio_sink_apple_audio(uri, samplerate); 40 if (s->sink) return s; 41 #else /* __APPLE__ */ 42 #if HAVE_SNDFILE 43 s->sink = (void *)new_aubio_sink_sndfile(uri, samplerate); 44 if (s->sink) return s; 45 #endif /* HAVE_SNDFILE */ 46 #endif /* __APPLE__ */ 47 if (s->sink == NULL) { AUBIO_FREE(s); return NULL; } 34 48 } 35 49 36 void aubio_sink_do(aubio_sink_t * s, fvec_t * write_data, uint_t * written) {50 void aubio_sink_do(aubio_sink_t * s, fvec_t * write_data, uint_t write) { 37 51 } 38 52 -
src/io/sink.h
r11a1abe r8aed26d 33 33 34 34 typedef struct _aubio_sink_t aubio_sink_t; 35 aubio_sink_t * new_aubio_sink(char_t * method, uint_t hop_size, uint_tsamplerate);36 void aubio_sink_do(aubio_sink_t * s, fvec_t * write_data, uint_t *written);35 aubio_sink_t * new_aubio_sink(char_t * method, uint_t samplerate); 36 void aubio_sink_do(aubio_sink_t * s, fvec_t * write_data, uint_t written); 37 37 void del_aubio_sink(aubio_sink_t * s); 38 38 -
src/io/sink_sndfile.c
r11a1abe r8aed26d 34 34 35 35 struct _aubio_sink_sndfile_t { 36 uint_t hop_size;37 36 uint_t samplerate; 38 37 uint_t channels; … … 43 42 }; 44 43 45 aubio_sink_sndfile_t * new_aubio_sink_sndfile(char_t * path, uint_t samplerate , uint_t hop_size) {44 aubio_sink_sndfile_t * new_aubio_sink_sndfile(char_t * path, uint_t samplerate) { 46 45 aubio_sink_sndfile_t * s = AUBIO_NEW(aubio_sink_sndfile_t); 47 46 … … 51 50 } 52 51 53 s->hop_size = hop_size;54 52 s->samplerate = samplerate; 53 s->max_size = MAX_SIZE; 55 54 s->channels = 1; 56 55 s->path = path; … … 72 71 } 73 72 74 s->scratch_size = s-> hop_size*s->channels;73 s->scratch_size = s->max-size*s->channels; 75 74 /* allocate data for de/interleaving reallocated when needed. */ 76 75 if (s->scratch_size >= MAX_SIZE * MAX_CHANNELS) { 77 76 AUBIO_ERR("%d x %d exceeds maximum aubio_sink_sndfile buffer size %d\n", 78 s-> hop_size, s->channels, MAX_CHANNELS * MAX_CHANNELS);77 s->max_size, s->channels, MAX_CHANNELS * MAX_CHANNELS); 79 78 return NULL; 80 79 } … … 84 83 } 85 84 86 void aubio_sink_sndfile_do(aubio_sink_sndfile_t *s, fvec_t * write , uint_t * written){85 void aubio_sink_sndfile_do(aubio_sink_sndfile_t *s, fvec_t * write_data, uint_t write){ 87 86 sf_count_t written_frames = 0; 88 87 int i, j, channels = s->channels; 89 int nsamples = channels* (*written);88 int nsamples = channels*write; 90 89 smpl_t *pwrite; 90 91 if (write > s->max_size) { 92 write = s->max_size; 93 AUBIO_WRN("trying to write %d frames, but only %d can be written at a time", 94 write, s->max_frames); 95 } 91 96 92 97 /* interleaving data */ 93 98 for ( i = 0; i < channels; i++) { 94 pwrite = (smpl_t *)write ->data;95 for (j=0; j < s->hop_size; j++) {99 pwrite = (smpl_t *)write_data->data; 100 for (j=0; j < write; j++) { 96 101 s->scratch_data[channels*j+i] = pwrite[j]; 97 102 } 98 103 } 99 written_frames = sf_write_float (s->handle, s->scratch_data, nsamples); 100 *written = written_frames/channels; 104 105 uint_t written = sf_write_float (s->handle, s->scratch_data, nsamples); 106 if (written/channels != write) { 107 AUBIO_WRN("trying to write %d frames to %s, but only %d could be written", 108 write, s->path, written); 109 } 101 110 return; 102 111 } -
src/io/sink_sndfile.h
r11a1abe r8aed26d 33 33 34 34 typedef struct _aubio_sink_sndfile_t aubio_sink_sndfile_t; 35 aubio_sink_sndfile_t * new_aubio_sink_sndfile(char_t * method, uint_t hop_size, uint_tsamplerate);36 void aubio_sink_sndfile_do(aubio_sink_sndfile_t * s, fvec_t * write_data, uint_t * written);35 aubio_sink_sndfile_t * new_aubio_sink_sndfile(char_t * method, uint_t samplerate); 36 void aubio_sink_sndfile_do(aubio_sink_sndfile_t * s, fvec_t * write_data, uint_t write); 37 37 void del_aubio_sink_sndfile(aubio_sink_sndfile_t * s); 38 38
Note: See TracChangeset
for help on using the changeset viewer.