Changeset 74c1fb9
- Timestamp:
- Dec 19, 2018, 5:50:42 PM (6 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/timestretch, fix/ffmpeg5, master
- Children:
- 0045668
- Parents:
- c1ba75b (diff), fda3394 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 2 added
- 7 deleted
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
MANIFEST.in
rc1ba75b r74c1fb9 11 11 include src/*/*.c src/*/*.h 12 12 include examples/*.c examples/*.h 13 include tests/*.h tests/*/*.c tests/*/*/*.c 13 recursive-include tests *.h *.c *.py 14 14 include python/ext/*.h 15 15 recursive-include python *.py -
python/README.md
rc1ba75b r74c1fb9 28 28 ----- 29 29 30 Some examples are available in the [`python/demos` ][demos_dir] folder. Each30 Some examples are available in the [`python/demos` folder][demos_dir]. Each 31 31 script is a command line program which accepts one ore more argument. 32 32 -
python/ext/aubiomodule.c
rc1ba75b r74c1fb9 224 224 225 225 // compute the function 226 result = Py _BuildValue (AUBIO_NPY_SMPL_CHR,fvec_alpha_norm (&vec, alpha));226 result = PyFloat_FromDouble(fvec_alpha_norm (&vec, alpha)); 227 227 if (result == NULL) { 228 228 return NULL; … … 320 320 321 321 // compute the function 322 result = Py _BuildValue (AUBIO_NPY_SMPL_CHR,aubio_zero_crossing_rate (&vec));322 result = PyFloat_FromDouble(aubio_zero_crossing_rate (&vec)); 323 323 if (result == NULL) { 324 324 return NULL; -
python/ext/py-cvec.c
rc1ba75b r74c1fb9 137 137 } 138 138 139 args = Py _BuildValue ("I",self->length);139 args = PyLong_FromLong(self->length); 140 140 if (args == NULL) { 141 141 goto fail; -
python/ext/py-musicutils.c
rc1ba75b r74c1fb9 40 40 } 41 41 42 level_lin = Py _BuildValue(AUBIO_NPY_SMPL_CHR,aubio_level_lin(&vec));42 level_lin = PyFloat_FromDouble(aubio_level_lin(&vec)); 43 43 if (level_lin == NULL) { 44 44 PyErr_SetString (PyExc_ValueError, "failed computing level_lin"); … … 68 68 } 69 69 70 db_spl = Py _BuildValue(AUBIO_NPY_SMPL_CHR,aubio_db_spl(&vec));70 db_spl = PyFloat_FromDouble(aubio_db_spl(&vec)); 71 71 if (db_spl == NULL) { 72 72 PyErr_SetString (PyExc_ValueError, "failed computing db_spl"); … … 97 97 } 98 98 99 silence_detection = Py _BuildValue("I",aubio_silence_detection(&vec, threshold));99 silence_detection = PyLong_FromLong(aubio_silence_detection(&vec, threshold)); 100 100 if (silence_detection == NULL) { 101 101 PyErr_SetString (PyExc_ValueError, "failed computing silence_detection"); … … 126 126 } 127 127 128 level_detection = Py _BuildValue(AUBIO_NPY_SMPL_CHR,aubio_level_detection(&vec, threshold));128 level_detection = PyFloat_FromDouble(aubio_level_detection(&vec, threshold)); 129 129 if (level_detection == NULL) { 130 130 PyErr_SetString (PyExc_ValueError, "failed computing level_detection"); … … 195 195 } 196 196 if (htk != NULL && PyObject_IsTrue(htk) == 1) 197 return Py _BuildValue(AUBIO_NPY_SMPL_CHR,aubio_hztomel_htk(v));197 return PyFloat_FromDouble(aubio_hztomel_htk(v)); 198 198 else 199 return Py _BuildValue(AUBIO_NPY_SMPL_CHR,aubio_hztomel(v));199 return PyFloat_FromDouble(aubio_hztomel(v)); 200 200 } 201 201 … … 212 212 } 213 213 if (htk != NULL && PyObject_IsTrue(htk) == 1) 214 return Py _BuildValue(AUBIO_NPY_SMPL_CHR,aubio_meltohz_htk(v));214 return PyFloat_FromDouble(aubio_meltohz_htk(v)); 215 215 else 216 return Py _BuildValue(AUBIO_NPY_SMPL_CHR,aubio_meltohz(v));216 return PyFloat_FromDouble(aubio_meltohz(v)); 217 217 } 218 218 … … 224 224 return NULL; 225 225 } 226 return Py _BuildValue(AUBIO_NPY_SMPL_CHR,aubio_hztomel_htk(v));226 return PyFloat_FromDouble(aubio_hztomel_htk(v)); 227 227 } 228 228 … … 234 234 return NULL; 235 235 } 236 return Py _BuildValue(AUBIO_NPY_SMPL_CHR,aubio_meltohz_htk(v));237 } 236 return PyFloat_FromDouble(aubio_meltohz_htk(v)); 237 } -
src/aubio_priv.h
rc1ba75b r74c1fb9 368 368 #endif /* __STRICT_ANSI__ */ 369 369 370 #if defined(DEBUG) 371 #include <assert.h> 372 #define AUBIO_ASSERT(x) assert(x) 373 #else 374 #define AUBIO_ASSERT(x) 375 #endif /* DEBUG */ 376 370 377 #endif /* AUBIO_PRIV_H */ -
src/io/ioutils.c
rc1ba75b r74c1fb9 52 52 return AUBIO_OK; 53 53 } 54 55 uint_t 56 aubio_sink_validate_input_length(const char_t *kind, const char_t *path, 57 uint_t max_size, uint_t write_data_length, uint_t write) 58 { 59 uint_t can_write = write; 60 61 if (write > max_size) { 62 AUBIO_WRN("%s: partial write to %s, trying to write %d frames," 63 " at most %d can be written at once\n", kind, path, write, max_size); 64 can_write = max_size; 65 } 66 67 if (can_write > write_data_length) { 68 AUBIO_WRN("%s: partial write to %s, trying to write %d frames," 69 " but found input of length %d\n", kind, path, write, 70 write_data_length); 71 can_write = write_data_length; 72 } 73 74 return can_write; 75 } 76 77 uint_t 78 aubio_sink_validate_input_channels(const char_t *kind, const char_t *path, 79 uint_t sink_channels, uint_t write_data_height) 80 { 81 uint_t channels = sink_channels; 82 if (write_data_height < sink_channels) { 83 AUBIO_WRN("%s: partial write to %s, trying to write %d channels," 84 " but found input of height %d\n", kind, path, sink_channels, 85 write_data_height); 86 channels = write_data_height; 87 } 88 return channels; 89 } -
src/io/ioutils.h
rc1ba75b r74c1fb9 54 54 uint_t channels); 55 55 56 /** validate length of input 57 58 \param kind the object kind to report on 59 \param path the path to report on 60 \param max_size maximum number of frames that can be written 61 \param write_data_length actual length of input vector/matrix 62 \param write number of samples asked 63 64 \return write or the maximum number of frames that can be written 65 */ 66 uint_t 67 aubio_sink_validate_input_length(const char_t *kind, const char_t *path, 68 uint_t max_size, uint_t write_data_length, uint_t write); 69 70 /** validate height of input 71 72 \param kind the object kind to report on 73 \param path the path to report on 74 \param max_size maximum number of channels that can be written 75 \param write_data_height actual height of input matrix 76 77 \return write_data_height or the maximum number of channels 78 */ 79 uint_t 80 aubio_sink_validate_input_channels(const char_t *kind, const char_t *path, 81 uint_t sink_channels, uint_t write_data_height); 82 56 83 #ifdef __cplusplus 57 84 } -
src/io/sink.c
rc1ba75b r74c1fb9 103 103 AUBIO_ERROR("sink: failed creating '%s' at %dHz (no sink built-in)\n", uri, samplerate); 104 104 #endif 105 AUBIO_FREE(s);105 del_aubio_sink(s); 106 106 return NULL; 107 107 } … … 136 136 137 137 void del_aubio_sink(aubio_sink_t * s) { 138 if (!s) return; 139 s->s_del((void *)s->sink); 138 AUBIO_ASSERT(s); 139 if (s->s_del && s->sink) 140 s->s_del((void *)s->sink); 140 141 AUBIO_FREE(s); 141 return;142 142 } -
src/io/sink_apple_audio.c
rc1ba75b r74c1fb9 32 32 #include <AudioToolbox/AudioToolbox.h> 33 33 34 #define FLOAT_TO_SHORT(x) (short)(x * 32768) 35 36 extern int createAubioBufferList(AudioBufferList *bufferList, int channels, int segmentSize); 34 extern int createAudioBufferList(AudioBufferList *bufferList, int channels, int segmentSize); 37 35 extern void freeAudioBufferList(AudioBufferList *bufferList); 38 36 extern CFURLRef createURLFromPath(const char * path); … … 62 60 s->async = false; 63 61 64 if ( (uri == NULL) || (str len(uri) < 1) ) {62 if ( (uri == NULL) || (strnlen(uri, PATH_MAX) < 1) ) { 65 63 AUBIO_ERROR("sink_apple_audio: Aborted opening null path\n"); 66 64 goto beach; 67 65 } 68 if (s->path != NULL) AUBIO_FREE(s->path); 66 69 67 s->path = AUBIO_ARRAY(char_t, strnlen(uri, PATH_MAX) + 1); 70 68 strncpy(s->path, uri, strnlen(uri, PATH_MAX) + 1); … … 77 75 return s; 78 76 } 77 79 78 // invalid samplerate given, abort 80 79 if (aubio_io_validate_samplerate("sink_apple_audio", s->path, samplerate)) { … … 92 91 return s; 93 92 beach: 94 AUBIO_FREE(s);93 del_aubio_sink_apple_audio(s); 95 94 return NULL; 96 95 } … … 103 102 s->samplerate = samplerate; 104 103 // automatically open when both samplerate and channels have been set 105 if ( s->samplerate != 0 &&s->channels != 0) {104 if (/* s->samplerate != 0 && */ s->channels != 0) { 106 105 return aubio_sink_apple_audio_open(s); 107 106 } … … 116 115 s->channels = channels; 117 116 // automatically open when both samplerate and channels have been set 118 if (s->samplerate != 0 && s->channels != 0) {117 if (s->samplerate != 0 /* && s->channels != 0 */) { 119 118 return aubio_sink_apple_audio_open(s); 120 119 } … … 151 150 CFURLRef fileURL = createURLFromPath(s->path); 152 151 bool overwrite = true; 152 153 // set the in-memory format 154 AudioStreamBasicDescription inputFormat; 155 memset(&inputFormat, 0, sizeof(AudioStreamBasicDescription)); 156 inputFormat.mFormatID = kAudioFormatLinearPCM; 157 inputFormat.mSampleRate = (Float64)(s->samplerate); 158 inputFormat.mFormatFlags = kAudioFormatFlagIsFloat | kAudioFormatFlagIsPacked; 159 inputFormat.mChannelsPerFrame = s->channels; 160 inputFormat.mBitsPerChannel = sizeof(smpl_t) * 8; 161 inputFormat.mFramesPerPacket = 1; 162 inputFormat.mBytesPerFrame = inputFormat.mBitsPerChannel * inputFormat.mChannelsPerFrame / 8; 163 inputFormat.mBytesPerPacket = inputFormat.mFramesPerPacket * inputFormat.mBytesPerFrame; 153 164 OSStatus err = noErr; 154 165 err = ExtAudioFileCreateWithURL(fileURL, fileType, &clientFormat, NULL, … … 162 173 goto beach; 163 174 } 164 if (createAubioBufferList(&s->bufferList, s->channels, s->max_frames * s->channels)) { 175 176 err = ExtAudioFileSetProperty(s->audioFile, 177 kExtAudioFileProperty_ClientDataFormat, 178 sizeof(AudioStreamBasicDescription), &inputFormat); 179 if (err) { 180 char_t errorstr[20]; 181 AUBIO_ERR("sink_apple_audio: error when trying to set output format on %s " 182 "(%s)\n", s->path, getPrintableOSStatusError(errorstr, err)); 183 goto beach; 184 } 185 186 if (createAudioBufferList(&s->bufferList, s->channels, s->max_frames * s->channels)) { 165 187 AUBIO_ERR("sink_apple_audio: error when creating buffer list for %s, " 166 188 "out of memory? \n", s->path); … … 175 197 void aubio_sink_apple_audio_do(aubio_sink_apple_audio_t * s, fvec_t * write_data, uint_t write) { 176 198 UInt32 c, v; 177 short *data = (short*)s->bufferList.mBuffers[0].mData; 178 if (write > s->max_frames) { 179 AUBIO_WRN("sink_apple_audio: trying to write %d frames, max %d\n", write, s->max_frames); 180 write = s->max_frames; 181 } 182 smpl_t *buf = write_data->data; 183 184 if (buf) { 185 for (c = 0; c < s->channels; c++) { 186 for (v = 0; v < write; v++) { 187 data[v * s->channels + c] = 188 FLOAT_TO_SHORT(buf[ v * s->channels + c]); 189 } 190 } 191 } 192 aubio_sink_apple_audio_write(s, write); 199 smpl_t *data = (smpl_t*)s->bufferList.mBuffers[0].mData; 200 uint_t length = aubio_sink_validate_input_length("sink_apple_audio", s->path, 201 s->max_frames, write_data->length, write); 202 203 for (c = 0; c < s->channels; c++) { 204 for (v = 0; v < length; v++) { 205 data[v * s->channels + c] = write_data->data[v]; 206 } 207 } 208 209 aubio_sink_apple_audio_write(s, length); 193 210 } 194 211 195 212 void aubio_sink_apple_audio_do_multi(aubio_sink_apple_audio_t * s, fmat_t * write_data, uint_t write) { 196 213 UInt32 c, v; 197 short *data = (short*)s->bufferList.mBuffers[0].mData; 198 if (write > s->max_frames) { 199 AUBIO_WRN("sink_apple_audio: trying to write %d frames, max %d\n", write, s->max_frames); 200 write = s->max_frames; 201 } 202 smpl_t **buf = write_data->data; 203 204 if (buf) { 205 for (c = 0; c < s->channels; c++) { 206 for (v = 0; v < write; v++) { 207 data[v * s->channels + c] = 208 FLOAT_TO_SHORT(buf[c][v]); 209 } 210 } 211 } 212 aubio_sink_apple_audio_write(s, write); 214 smpl_t *data = (smpl_t*)s->bufferList.mBuffers[0].mData; 215 uint_t channels = aubio_sink_validate_input_channels("sink_apple_audio", 216 s->path, s->channels, write_data->height); 217 uint_t length = aubio_sink_validate_input_length("sink_apple_audio", s->path, 218 s->max_frames, write_data->length, write); 219 220 for (c = 0; c < channels; c++) { 221 for (v = 0; v < length; v++) { 222 data[v * s->channels + c] = write_data->data[c][v]; 223 } 224 } 225 226 aubio_sink_apple_audio_write(s, length); 213 227 } 214 228 215 229 void aubio_sink_apple_audio_write(aubio_sink_apple_audio_t *s, uint_t write) { 216 230 OSStatus err = noErr; 231 // set mDataByteSize to match the number of frames to be written 232 // see https://www.mail-archive.com/coreaudio-api@lists.apple.com/msg01109.html 233 s->bufferList.mBuffers[0].mDataByteSize = write * s->channels 234 * sizeof(smpl_t); 217 235 if (s->async) { 218 236 err = ExtAudioFileWriteAsync(s->audioFile, write, &s->bufferList); … … 258 276 259 277 void del_aubio_sink_apple_audio(aubio_sink_apple_audio_t * s) { 260 if (s->audioFile) aubio_sink_apple_audio_close (s); 261 if (s->path) AUBIO_FREE(s->path); 278 AUBIO_ASSERT(s); 279 if (s->audioFile) 280 aubio_sink_apple_audio_close (s); 281 if (s->path) 282 AUBIO_FREE(s->path); 262 283 freeAudioBufferList(&s->bufferList); 263 284 AUBIO_FREE(s); 264 return;265 285 } 266 286 -
src/io/sink_sndfile.c
rc1ba75b r74c1fb9 59 59 if (path == NULL) { 60 60 AUBIO_ERR("sink_sndfile: Aborted opening null path\n"); 61 return NULL; 62 } 63 64 if (s->path) AUBIO_FREE(s->path); 61 goto beach; 62 } 63 65 64 s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1); 66 65 strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); … … 98 97 s->samplerate = samplerate; 99 98 // automatically open when both samplerate and channels have been set 100 if ( s->samplerate != 0 &&s->channels != 0) {99 if (/* s->samplerate != 0 && */ s->channels != 0) { 101 100 return aubio_sink_sndfile_open(s); 102 101 } … … 111 110 s->channels = channels; 112 111 // automatically open when both samplerate and channels have been set 113 if (s->samplerate != 0 && s->channels != 0) {112 if (s->samplerate != 0 /* && s->channels != 0 */) { 114 113 return aubio_sink_sndfile_open(s); 115 114 } … … 148 147 /* allocate data for de/interleaving reallocated when needed. */ 149 148 if (s->scratch_size >= MAX_SIZE * AUBIO_MAX_CHANNELS) { 150 abort(); 151 AUBIO_ERR("sink_sndfile: %d x %d exceeds maximum aubio_sink_sndfile buffer size %d\n", 149 AUBIO_ERR("sink_sndfile: %d x %d exceeds maximum buffer size %d\n", 152 150 s->max_size, s->channels, MAX_SIZE * AUBIO_MAX_CHANNELS); 153 151 return AUBIO_FAIL; … … 159 157 160 158 void aubio_sink_sndfile_do(aubio_sink_sndfile_t *s, fvec_t * write_data, uint_t write){ 161 uint_t i, j, channels = s->channels; 162 int nsamples = 0; 163 smpl_t *pwrite; 159 uint_t i, j; 164 160 sf_count_t written_frames; 165 166 if (write > s->max_size) { 167 AUBIO_WRN("sink_sndfile: trying to write %d frames, but only %d can be written at a time\n", 168 write, s->max_size); 169 write = s->max_size; 170 } 171 172 nsamples = channels * write; 161 uint_t channels = s->channels; 162 uint_t length = aubio_sink_validate_input_length("sink_sndfile", s->path, 163 s->max_size, write_data->length, write); 164 int nsamples = channels * length; 173 165 174 166 /* interleaving data */ 175 167 for ( i = 0; i < channels; i++) { 176 pwrite = (smpl_t *)write_data->data; 177 for (j = 0; j < write; j++) { 178 s->scratch_data[channels*j+i] = pwrite[j]; 168 for (j = 0; j < length; j++) { 169 s->scratch_data[channels*j+i] = write_data->data[j]; 179 170 } 180 171 } … … 189 180 190 181 void aubio_sink_sndfile_do_multi(aubio_sink_sndfile_t *s, fmat_t * write_data, uint_t write){ 191 uint_t i, j, channels = s->channels; 192 int nsamples = 0; 193 smpl_t *pwrite; 182 uint_t i, j; 194 183 sf_count_t written_frames; 195 196 if (write > s->max_size) { 197 AUBIO_WRN("sink_sndfile: trying to write %d frames, but only %d can be written at a time\n", 198 write, s->max_size); 199 write = s->max_size; 200 } 201 202 nsamples = channels * write; 184 uint_t channels = aubio_sink_validate_input_channels("sink_sndfile", s->path, 185 s->channels, write_data->height); 186 uint_t length = aubio_sink_validate_input_length("sink_sndfile", s->path, 187 s->max_size, write_data->length, write); 188 int nsamples = channels * length; 203 189 204 190 /* interleaving data */ 205 for ( i = 0; i < write_data->height; i++) { 206 pwrite = (smpl_t *)write_data->data[i]; 207 for (j = 0; j < write; j++) { 208 s->scratch_data[channels*j+i] = pwrite[j]; 191 for ( i = 0; i < channels; i++) { 192 for (j = 0; j < length; j++) { 193 s->scratch_data[channels*j+i] = write_data->data[i][j]; 209 194 } 210 195 } … … 231 216 232 217 void del_aubio_sink_sndfile(aubio_sink_sndfile_t * s){ 233 if (!s) return; 234 if (s->path) AUBIO_FREE(s->path); 235 aubio_sink_sndfile_close(s); 236 AUBIO_FREE(s->scratch_data); 218 AUBIO_ASSERT(s); 219 if (s->handle) 220 aubio_sink_sndfile_close(s); 221 if (s->path) 222 AUBIO_FREE(s->path); 223 if (s->scratch_data) 224 AUBIO_FREE(s->scratch_data); 237 225 AUBIO_FREE(s); 238 226 } -
src/io/sink_wavwrite.c
rc1ba75b r74c1fb9 88 88 goto beach; 89 89 } 90 if ((sint_t)samplerate < 0) { 91 AUBIO_ERR("sink_wavwrite: Can not create %s with samplerate %d\n", path, samplerate); 92 goto beach; 93 } 94 95 if (s->path) AUBIO_FREE(s->path); 90 96 91 s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1); 97 92 strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); … … 136 131 s->samplerate = samplerate; 137 132 // automatically open when both samplerate and channels have been set 138 if ( s->samplerate != 0 &&s->channels != 0) {133 if (/* s->samplerate != 0 && */ s->channels != 0) { 139 134 return aubio_sink_wavwrite_open(s); 140 135 } … … 149 144 s->channels = channels; 150 145 // automatically open when both samplerate and channels have been set 151 if (s->samplerate != 0 && s->channels != 0) {146 if (s->samplerate != 0 /* && s->channels != 0 */) { 152 147 return aubio_sink_wavwrite_open(s); 153 148 } … … 234 229 235 230 void aubio_sink_wavwrite_do(aubio_sink_wavwrite_t *s, fvec_t * write_data, uint_t write){ 236 uint_t i = 0, written_frames = 0; 237 238 if (write > s->max_size) { 239 AUBIO_WRN("sink_wavwrite: trying to write %d frames to %s, " 240 "but only %d can be written at a time\n", write, s->path, s->max_size); 241 write = s->max_size; 242 } 243 244 for (i = 0; i < write; i++) { 245 s->scratch_data[i] = HTOLES(FLOAT_TO_SHORT(write_data->data[i])); 246 } 247 written_frames = fwrite(s->scratch_data, 2, write, s->fid); 231 uint_t c = 0, i = 0, written_frames = 0; 232 uint_t length = aubio_sink_validate_input_length("sink_wavwrite", s->path, 233 s->max_size, write_data->length, write); 234 235 for (c = 0; c < s->channels; c++) { 236 for (i = 0; i < length; i++) { 237 s->scratch_data[i * s->channels + c] = HTOLES(FLOAT_TO_SHORT(write_data->data[i])); 238 } 239 } 240 written_frames = fwrite(s->scratch_data, 2, length * s->channels, s->fid); 248 241 249 242 if (written_frames != write) { … … 258 251 uint_t c = 0, i = 0, written_frames = 0; 259 252 260 if (write > s->max_size) { 261 AUBIO_WRN("sink_wavwrite: trying to write %d frames to %s, " 262 "but only %d can be written at a time\n", write, s->path, s->max_size); 263 write = s->max_size; 264 } 265 266 for (c = 0; c < s->channels; c++) { 267 for (i = 0; i < write; i++) { 253 uint_t channels = aubio_sink_validate_input_channels("sink_wavwrite", s->path, 254 s->channels, write_data->height); 255 uint_t length = aubio_sink_validate_input_length("sink_wavwrite", s->path, 256 s->max_size, write_data->length, write); 257 258 for (c = 0; c < channels; c++) { 259 for (i = 0; i < length; i++) { 268 260 s->scratch_data[i * s->channels + c] = HTOLES(FLOAT_TO_SHORT(write_data->data[c][i])); 269 261 } 270 262 } 271 written_frames = fwrite(s->scratch_data, 2, write* s->channels, s->fid);263 written_frames = fwrite(s->scratch_data, 2, length * s->channels, s->fid); 272 264 273 265 if (written_frames != write * s->channels) { … … 298 290 299 291 void del_aubio_sink_wavwrite(aubio_sink_wavwrite_t * s){ 300 if (!s) return; 301 aubio_sink_wavwrite_close(s); 302 if (s->path) AUBIO_FREE(s->path); 303 AUBIO_FREE(s->scratch_data); 292 AUBIO_ASSERT(s); 293 if (s->fid) 294 aubio_sink_wavwrite_close(s); 295 if (s->path) 296 AUBIO_FREE(s->path); 297 if (s->scratch_data) 298 AUBIO_FREE(s->scratch_data); 304 299 AUBIO_FREE(s); 305 300 } -
src/io/source.c
rc1ba75b r74c1fb9 122 122 " (no source built-in)\n", uri, samplerate, hop_size); 123 123 #endif 124 AUBIO_FREE(s);124 del_aubio_source(s); 125 125 return NULL; 126 126 } … … 139 139 140 140 void del_aubio_source(aubio_source_t * s) { 141 if (!s) return; 142 s->s_del((void *)s->source); 141 AUBIO_ASSERT(s); 142 if (s->s_del && s->source) 143 s->s_del((void *)s->source); 143 144 AUBIO_FREE(s); 144 145 } -
src/io/source.h
rc1ba75b r74c1fb9 60 60 61 61 \example io/test-source.c 62 \example io/test-source_multi.c63 62 64 63 */ -
src/io/source_apple_audio.c
rc1ba75b r74c1fb9 34 34 #define RT_BYTE3( a ) ( ((a) >> 16) & 0xff ) 35 35 #define RT_BYTE4( a ) ( ((a) >> 24) & 0xff ) 36 37 #define SHORT_TO_FLOAT(x) (smpl_t)(x * 3.0517578125e-05)38 36 39 37 struct _aubio_source_apple_audio_t { … … 49 47 }; 50 48 51 extern int createAu bioBufferList(AudioBufferList *bufferList, int channels, int max_source_samples);49 extern int createAudioBufferList(AudioBufferList *bufferList, int channels, int max_source_samples); 52 50 extern void freeAudioBufferList(AudioBufferList *bufferList); 53 51 extern CFURLRef createURLFromPath(const char * path); … … 60 58 aubio_source_apple_audio_t * s = AUBIO_NEW(aubio_source_apple_audio_t); 61 59 62 if (path == NULL ) {60 if (path == NULL || strnlen(path, PATH_MAX) < 1) { 63 61 AUBIO_ERROR("source_apple_audio: Aborted opening null path\n"); 64 62 goto beach; … … 86 84 87 85 beach: 88 AUBIO_FREE(s);86 del_aubio_source_apple_audio(s); 89 87 return NULL; 90 88 } … … 95 93 UInt32 propSize; 96 94 97 if (s->path) AUBIO_FREE(s->path);98 95 s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1); 99 96 strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); … … 140 137 141 138 AudioStreamBasicDescription clientFormat; 142 propSize = sizeof( clientFormat);139 propSize = sizeof(AudioStreamBasicDescription); 143 140 memset(&clientFormat, 0, sizeof(AudioStreamBasicDescription)); 144 141 clientFormat.mFormatID = kAudioFormatLinearPCM; 145 142 clientFormat.mSampleRate = (Float64)(s->samplerate); 146 clientFormat.mFormatFlags = kAudioFormatFlagIs SignedInteger | kAudioFormatFlagIsPacked;143 clientFormat.mFormatFlags = kAudioFormatFlagIsFloat; 147 144 clientFormat.mChannelsPerFrame = s->channels; 148 clientFormat.mBitsPerChannel = sizeof(s hort) * 8;145 clientFormat.mBitsPerChannel = sizeof(smpl_t) * 8; 149 146 clientFormat.mFramesPerPacket = 1; 150 147 clientFormat.mBytesPerFrame = clientFormat.mBitsPerChannel * clientFormat.mChannelsPerFrame / 8; 151 148 clientFormat.mBytesPerPacket = clientFormat.mFramesPerPacket * clientFormat.mBytesPerFrame; 152 clientFormat.mReserved = 0;153 149 154 150 // set the client format description … … 188 184 // allocate the AudioBufferList 189 185 freeAudioBufferList(&s->bufferList); 190 if (createAu bioBufferList(&s->bufferList, s->channels, s->block_size * s->channels)) {186 if (createAudioBufferList(&s->bufferList, s->channels, s->block_size * s->channels)) { 191 187 AUBIO_ERR("source_apple_audio: failed creating bufferList\n"); 192 188 goto beach; … … 197 193 } 198 194 199 void aubio_source_apple_audio_do(aubio_source_apple_audio_t *s, fvec_t * read_to, uint_t * read) { 200 UInt32 c, v, loadedPackets = s->block_size; 195 static UInt32 aubio_source_apple_audio_read_frame(aubio_source_apple_audio_t *s) 196 { 197 UInt32 loadedPackets = s->block_size; 201 198 OSStatus err = ExtAudioFileRead(s->audioFile, &loadedPackets, &s->bufferList); 202 199 if (err) { … … 205 202 "with ExtAudioFileRead (%s)\n", s->path, 206 203 getPrintableOSStatusError(errorstr, err)); 207 goto beach; 208 } 209 210 short *data = (short*)s->bufferList.mBuffers[0].mData; 211 212 smpl_t *buf = read_to->data; 204 } 205 return loadedPackets; 206 } 207 208 void aubio_source_apple_audio_do(aubio_source_apple_audio_t *s, fvec_t * read_to, 209 uint_t * read) { 210 uint_t c, v; 211 UInt32 loadedPackets = aubio_source_apple_audio_read_frame(s); 212 smpl_t *data = (smpl_t*)s->bufferList.mBuffers[0].mData; 213 213 214 214 for (v = 0; v < loadedPackets; v++) { 215 buf[v] = 0.;215 read_to->data[v] = 0.; 216 216 for (c = 0; c < s->channels; c++) { 217 buf[v] += SHORT_TO_FLOAT(data[ v * s->channels + c]);218 } 219 buf[v] /= (smpl_t)s->channels;217 read_to->data[v] += data[ v * s->channels + c]; 218 } 219 read_to->data[v] /= (smpl_t)s->channels; 220 220 } 221 221 // short read, fill with zeros 222 222 if (loadedPackets < s->block_size) { 223 223 for (v = loadedPackets; v < s->block_size; v++) { 224 buf[v] = 0.;224 read_to->data[v] = 0.; 225 225 } 226 226 } … … 228 228 *read = (uint_t)loadedPackets; 229 229 return; 230 beach:231 *read = 0;232 return;233 230 } 234 231 235 232 void aubio_source_apple_audio_do_multi(aubio_source_apple_audio_t *s, fmat_t * read_to, uint_t * read) { 236 UInt32 c, v, loadedPackets = s->block_size; 237 OSStatus err = ExtAudioFileRead(s->audioFile, &loadedPackets, &s->bufferList); 238 if (err) { 239 char_t errorstr[20]; 240 AUBIO_ERROR("source_apple_audio: error while reading %s " 241 "with ExtAudioFileRead (%s)\n", s->path, 242 getPrintableOSStatusError(errorstr, err)); 243 goto beach; 244 } 245 246 short *data = (short*)s->bufferList.mBuffers[0].mData; 247 248 smpl_t **buf = read_to->data; 233 uint_t c, v; 234 UInt32 loadedPackets = aubio_source_apple_audio_read_frame(s); 235 smpl_t *data = (smpl_t*)s->bufferList.mBuffers[0].mData; 249 236 250 237 for (v = 0; v < loadedPackets; v++) { 251 238 for (c = 0; c < read_to->height; c++) { 252 buf[c][v] = SHORT_TO_FLOAT(data[ v * s->channels + c]);239 read_to->data[c][v] = data[ v * s->channels + c]; 253 240 } 254 241 } … … 258 245 for (v = 0; v < loadedPackets; v++) { 259 246 for (c = s->channels; c < read_to->height; c++) { 260 buf[c][v] = SHORT_TO_FLOAT(data[ v * s->channels + (s->channels - 1)]);247 read_to->data[c][v] = data[ v * s->channels + (s->channels - 1)]; 261 248 } 262 249 } … … 266 253 for (v = loadedPackets; v < s->block_size; v++) { 267 254 for (c = 0; c < read_to->height; c++) { 268 buf[c][v] = 0.;255 read_to->data[c][v] = 0.; 269 256 } 270 257 } 271 258 } 259 272 260 *read = (uint_t)loadedPackets; 273 return;274 beach:275 *read = 0;276 261 return; 277 262 } … … 294 279 295 280 void del_aubio_source_apple_audio(aubio_source_apple_audio_t * s){ 281 AUBIO_ASSERT(s); 296 282 aubio_source_apple_audio_close (s); 297 283 if (s->path) AUBIO_FREE(s->path); 298 284 freeAudioBufferList(&s->bufferList); 299 285 AUBIO_FREE(s); 300 return;301 286 } 302 287 … … 324 309 // after a short read, the bufferList size needs to resetted to prepare for a full read 325 310 AudioBufferList *bufferList = &s->bufferList; 326 bufferList->mBuffers[0].mDataByteSize = s->block_size * s->channels * sizeof (s hort);311 bufferList->mBuffers[0].mDataByteSize = s->block_size * s->channels * sizeof (smpl_t); 327 312 // do the actual seek 328 313 err = ExtAudioFileSeek(s->audioFile, resampled_pos); -
src/io/source_avcodec.c
rc1ba75b r74c1fb9 45 45 #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57,0,0) 46 46 #define HAVE_AUBIO_LIBAVCODEC_DEPRECATED 1 47 #endif 48 49 #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,3,102) 50 #define HAVE_AUBIO_LIBAVCODEC_TIMEBASE_FIX 1 47 51 #endif 48 52 … … 144 148 s->channels = 1; 145 149 146 if (s->path) AUBIO_FREE(s->path);147 150 s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1); 148 151 strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); … … 240 243 goto beach; 241 244 } 245 #if HAVE_AUBIO_LIBAVCODEC_TIMEBASE_FIX 246 // avoids 'skipped frames warning' with avecodec < 58, deprecated after 247 av_codec_set_pkt_timebase(avCodecCtx, 248 avFormatCtx->streams[selected_stream]->time_base); 249 #endif 242 250 #endif 243 251 … … 631 639 632 640 void del_aubio_source_avcodec(aubio_source_avcodec_t * s){ 633 if (!s) return;641 AUBIO_ASSERT(s); 634 642 aubio_source_avcodec_close(s); 635 643 if (s->output != NULL) { -
src/io/source_sndfile.c
rc1ba75b r74c1fb9 87 87 s->channels = 1; 88 88 89 if (s->path) AUBIO_FREE(s->path);90 89 s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1); 91 90 strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); … … 332 331 333 332 void del_aubio_source_sndfile(aubio_source_sndfile_t * s){ 334 if (!s) return;333 AUBIO_ASSERT(s); 335 334 aubio_source_sndfile_close(s); 336 335 #ifdef HAVE_SAMPLERATE -
src/io/source_wavread.c
rc1ba75b r74c1fb9 92 92 } 93 93 94 if (s->path) AUBIO_FREE(s->path);95 94 s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1); 96 95 strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); … … 472 471 473 472 void del_aubio_source_wavread(aubio_source_wavread_t * s) { 474 if (!s) return;473 AUBIO_ASSERT(s); 475 474 aubio_source_wavread_close(s); 476 475 if (s->short_output) AUBIO_FREE(s->short_output); -
src/io/utils_apple_audio.c
rc1ba75b r74c1fb9 13 13 char_t *getPrintableOSStatusError(char_t *str, OSStatus error); 14 14 15 int createAubioBufferList(AudioBufferList * bufferList, int channels, int max_source_samples) { 15 int createAudioBufferList(AudioBufferList * bufferList, int channels, 16 int max_source_samples) { 16 17 bufferList->mNumberBuffers = 1; 17 18 bufferList->mBuffers[0].mNumberChannels = channels; 18 bufferList->mBuffers[0].mData = AUBIO_ARRAY(s hort, max_source_samples);19 bufferList->mBuffers[0].mDataByteSize = max_source_samples * sizeof(s hort);19 bufferList->mBuffers[0].mData = AUBIO_ARRAY(smpl_t, max_source_samples); 20 bufferList->mBuffers[0].mDataByteSize = max_source_samples * sizeof(smpl_t); 20 21 return 0; 21 22 } -
tests/src/io/test-sink.c
rc1ba75b r74c1fb9 2 2 #include "utils_tests.h" 3 3 4 int main (int argc, char **argv) 4 int test_wrong_params(void); 5 6 int main(int argc, char **argv) 5 7 { 6 sint_t err = 0;7 8 if (argc < 3) {9 PRINT_ERR("not enough arguments, running tests\n");10 err = run_on_default_source_and_sink(main);11 PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n",argv[0]);8 uint_t err = 0; 9 if (argc < 3 || argc >= 6) { 10 PRINT_ERR("wrong number of arguments, running tests\n"); 11 err = test_wrong_params(); 12 PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", 13 argv[0]); 12 14 return err; 13 15 } … … 20 22 char_t *sink_path = argv[2]; 21 23 24 aubio_source_t *src = NULL; 25 aubio_sink_t *snk = NULL; 26 22 27 if ( argc >= 4 ) samplerate = atoi(argv[3]); 23 28 if ( argc >= 5 ) hop_size = atoi(argv[4]); 24 if ( argc >= 6 ) {25 err = 2;26 PRINT_ERR("too many arguments\n");27 return err;28 }29 29 30 30 fvec_t *vec = new_fvec(hop_size); 31 if (!vec) { err = 1; goto beach_fvec; }31 if (!vec) { err = 1; goto failure; } 32 32 33 aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size); 34 if (!i) { err = 1; goto beach_source; } 33 src = new_aubio_source(source_path, samplerate, hop_size); 34 if (!src) { err = 1; goto failure; } 35 if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(src); 35 36 36 if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i); 37 38 aubio_sink_t *o = new_aubio_sink(sink_path, samplerate); 39 if (!o) { err = 1; goto beach_sink; } 37 snk = new_aubio_sink(sink_path, samplerate); 38 if (!snk) { err = 1; goto failure; } 40 39 41 40 do { 42 aubio_source_do( i, vec, &read);43 aubio_sink_do( o, vec, read);41 aubio_source_do(src, vec, &read); 42 aubio_sink_do(snk, vec, read); 44 43 n_frames += read; 45 44 } while ( read == hop_size ); 46 45 47 PRINT_MSG(" read %d frames at %dHz (%d blocks) from %swritten to %s\n",46 PRINT_MSG("%d frames read at %dHz (%d blocks) from %s and written to %s\n", 48 47 n_frames, samplerate, n_frames / hop_size, 49 48 source_path, sink_path); 50 49 51 del_aubio_sink(o); 52 beach_sink: 53 del_aubio_source(i); 54 beach_source: 55 del_fvec(vec); 56 beach_fvec: 50 // close sink now (optional) 51 aubio_sink_close(snk); 52 53 failure: 54 if (snk) 55 del_aubio_sink(snk); 56 if (src) 57 del_aubio_source(src); 58 if (vec) 59 del_fvec(vec); 60 57 61 return err; 58 62 } 63 64 int test_wrong_params(void) 65 { 66 fvec_t *vec; 67 fmat_t *mat; 68 aubio_sink_t *s; 69 char_t sink_path[PATH_MAX] = "tmp_aubio_XXXXXX"; 70 uint_t samplerate = 44100; 71 uint_t hop_size = 256; 72 uint_t oversized_hop_size = 4097; 73 uint_t oversized_samplerate = 192000 * 8 + 1; 74 uint_t channels = 3; 75 uint_t oversized_channels = 1025; 76 // create temp file 77 int fd = create_temp_sink(sink_path); 78 79 if (!fd) return 1; 80 81 if (new_aubio_sink( 0, samplerate)) return 1; 82 if (new_aubio_sink("\0", samplerate)) return 1; 83 if (new_aubio_sink(sink_path, -1)) return 1; 84 85 s = new_aubio_sink(sink_path, 0); 86 87 // check setting wrong parameters fails 88 if (!aubio_sink_preset_samplerate(s, oversized_samplerate)) return 1; 89 if (!aubio_sink_preset_channels(s, oversized_channels)) return 1; 90 if (!aubio_sink_preset_channels(s, -1)) return 1; 91 92 // check setting valid parameters passes 93 if (aubio_sink_preset_samplerate(s, samplerate)) return 1; 94 if (aubio_sink_preset_channels(s, 1)) return 1; 95 96 // check writing a vector with valid length 97 vec = new_fvec(hop_size); 98 aubio_sink_do(s, vec, hop_size); 99 // check writing more than in the input 100 aubio_sink_do(s, vec, hop_size+1); 101 // check write 0 frames 102 aubio_sink_do(s, vec, 0); 103 del_fvec(vec); 104 105 // check writing an oversized vector 106 vec = new_fvec(oversized_hop_size); 107 aubio_sink_do(s, vec, oversized_hop_size); 108 del_fvec(vec); 109 110 // test delete without closing 111 del_aubio_sink(s); 112 113 s = new_aubio_sink(sink_path, 0); 114 115 // preset channels first 116 if (aubio_sink_preset_channels(s, channels)) return 1; 117 if (aubio_sink_preset_samplerate(s, samplerate)) return 1; 118 119 if (aubio_sink_get_samplerate(s) != samplerate) return 1; 120 if (aubio_sink_get_channels(s) != channels) return 1; 121 122 mat = new_fmat(channels, hop_size); 123 // check writing a vector with valid length 124 aubio_sink_do_multi(s, mat, hop_size); 125 // check writing 0 frames 126 aubio_sink_do_multi(s, mat, 0); 127 // check writing more than in the input 128 aubio_sink_do_multi(s, mat, hop_size+1); 129 del_fmat(mat); 130 131 // check writing oversized input 132 mat = new_fmat(channels, oversized_hop_size); 133 aubio_sink_do_multi(s, mat, oversized_hop_size); 134 del_fmat(mat); 135 136 // check writing undersized input 137 mat = new_fmat(channels - 1, hop_size); 138 aubio_sink_do_multi(s, mat, hop_size); 139 del_fmat(mat); 140 141 aubio_sink_close(s); 142 // test closing twice 143 aubio_sink_close(s); 144 145 del_aubio_sink(s); 146 147 // delete temp file 148 close_temp_sink(sink_path, fd); 149 150 return run_on_default_source_and_sink(main); 151 } -
tests/src/io/test-sink_apple_audio.c
rc1ba75b r74c1fb9 2 2 #include <aubio.h> 3 3 #include "utils_tests.h" 4 5 #define aubio_sink_custom "apple_audio" 6 7 #ifdef HAVE_SINK_APPLE_AUDIO 8 #define HAVE_AUBIO_SINK_CUSTOM 9 #define aubio_sink_custom_t aubio_sink_apple_audio_t 10 #define new_aubio_sink_custom new_aubio_sink_apple_audio 11 #define del_aubio_sink_custom del_aubio_sink_apple_audio 12 #define aubio_sink_custom_do aubio_sink_apple_audio_do 13 #define aubio_sink_custom_do_multi aubio_sink_apple_audio_do_multi 14 #define aubio_sink_custom_close aubio_sink_apple_audio_close 15 #define aubio_sink_custom_preset_samplerate aubio_sink_apple_audio_preset_samplerate 16 #define aubio_sink_custom_preset_channels aubio_sink_apple_audio_preset_channels 17 #define aubio_sink_custom_get_samplerate aubio_sink_apple_audio_get_samplerate 18 #define aubio_sink_custom_get_channels aubio_sink_apple_audio_get_channels 19 #endif /* HAVE_SINK_APPLE_AUDIO */ 20 21 #include "base-sink_custom.h" 4 22 5 23 // this file uses the unstable aubio api, please use aubio_sink instead … … 8 26 int main (int argc, char **argv) 9 27 { 10 sint_t err = 0; 11 12 if (argc < 3) { 13 PRINT_ERR("not enough arguments, running tests\n"); 14 err = run_on_default_source_and_sink(main); 15 PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]); 16 return err; 17 } 18 19 #ifdef HAVE_SINK_APPLE_AUDIO 20 uint_t samplerate = 0; 21 uint_t hop_size = 512; 22 uint_t n_frames = 0, read = 0; 23 24 char_t *source_path = argv[1]; 25 char_t *sink_path = argv[2]; 26 27 if ( argc >= 4 ) samplerate = atoi(argv[3]); 28 if ( argc >= 5 ) hop_size = atoi(argv[4]); 29 if ( argc >= 6 ) { 30 err = 2; 31 PRINT_ERR("too many arguments\n"); 32 return err; 33 } 34 35 fvec_t *vec = new_fvec(hop_size); 36 if (!vec) { err = 1; goto beach_fvec; } 37 38 aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size); 39 if (!i) { err = 1; goto beach_source; } 40 41 if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i); 42 43 aubio_sink_apple_audio_t *o = new_aubio_sink_apple_audio(sink_path, samplerate); 44 if (!o) { err = 1; goto beach_sink; } 45 46 do { 47 aubio_source_do(i, vec, &read); 48 aubio_sink_apple_audio_do(o, vec, read); 49 n_frames += read; 50 } while ( read == hop_size ); 51 52 PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n", 53 n_frames, samplerate, n_frames / hop_size, 54 source_path, sink_path); 55 56 del_aubio_sink_apple_audio(o); 57 beach_sink: 58 del_aubio_source(i); 59 beach_source: 60 del_fvec(vec); 61 beach_fvec: 62 #else /* HAVE_SINK_APPLE_AUDIO */ 63 err = 0; 64 PRINT_ERR("aubio was not compiled with aubio_source_apple_audio\n"); 65 #endif /* HAVE_SINK_APPLE_AUDIO */ 66 return err; 28 return base_main(argc, argv); 67 29 } -
tests/src/io/test-sink_sndfile.c
rc1ba75b r74c1fb9 2 2 #include <aubio.h> 3 3 #include "utils_tests.h" 4 5 #define aubio_sink_custom "sndfile" 6 7 #ifdef HAVE_SNDFILE 8 #define HAVE_AUBIO_SINK_CUSTOM 9 #define aubio_sink_custom_t aubio_sink_sndfile_t 10 #define new_aubio_sink_custom new_aubio_sink_sndfile 11 #define del_aubio_sink_custom del_aubio_sink_sndfile 12 #define aubio_sink_custom_do aubio_sink_sndfile_do 13 #define aubio_sink_custom_do_multi aubio_sink_sndfile_do_multi 14 #define aubio_sink_custom_close aubio_sink_sndfile_close 15 #define aubio_sink_custom_preset_samplerate aubio_sink_sndfile_preset_samplerate 16 #define aubio_sink_custom_preset_channels aubio_sink_sndfile_preset_channels 17 #define aubio_sink_custom_get_samplerate aubio_sink_sndfile_get_samplerate 18 #define aubio_sink_custom_get_channels aubio_sink_sndfile_get_channels 19 #endif /* HAVE_SNDFILE */ 20 21 #include "base-sink_custom.h" 4 22 5 23 // this file uses the unstable aubio api, please use aubio_sink instead … … 8 26 int main (int argc, char **argv) 9 27 { 10 sint_t err = 0; 11 12 if (argc < 3) { 13 PRINT_ERR("not enough arguments, running tests\n"); 14 err = run_on_default_source_and_sink(main); 15 PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]); 16 return err; 17 } 18 19 #ifdef HAVE_SNDFILE 20 uint_t samplerate = 0; 21 uint_t hop_size = 512; 22 uint_t n_frames = 0, read = 0; 23 24 char_t *source_path = argv[1]; 25 char_t *sink_path = argv[2]; 26 27 if ( argc >= 4 ) samplerate = atoi(argv[3]); 28 if ( argc >= 5 ) hop_size = atoi(argv[4]); 29 if ( argc >= 6 ) { 30 err = 2; 31 PRINT_ERR("too many arguments\n"); 32 return err; 33 } 34 35 fvec_t *vec = new_fvec(hop_size); 36 if (!vec) { err = 1; goto beach_fvec; } 37 38 aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size); 39 if (!i) { err = 1; goto beach_source; } 40 41 if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i); 42 43 aubio_sink_sndfile_t *o = new_aubio_sink_sndfile(sink_path, samplerate); 44 if (!o) { err = 1; goto beach_sink; } 45 46 do { 47 aubio_source_do(i, vec, &read); 48 aubio_sink_sndfile_do(o, vec, read); 49 n_frames += read; 50 } while ( read == hop_size ); 51 52 PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n", 53 n_frames, samplerate, n_frames / hop_size, 54 source_path, sink_path); 55 56 del_aubio_sink_sndfile(o); 57 beach_sink: 58 del_aubio_source(i); 59 beach_source: 60 del_fvec(vec); 61 beach_fvec: 62 #else 63 err = 0; 64 PRINT_ERR("aubio was not compiled with aubio_source_sndfile\n"); 65 #endif /* HAVE_SNDFILE */ 66 return err; 28 return base_main(argc, argv); 67 29 } -
tests/src/io/test-sink_wavwrite.c
rc1ba75b r74c1fb9 2 2 #include <aubio.h> 3 3 #include "utils_tests.h" 4 5 #define aubio_sink_custom "wavwrite" 6 7 #ifdef HAVE_WAVWRITE 8 #define HAVE_AUBIO_SINK_CUSTOM 9 #define aubio_sink_custom_t aubio_sink_wavwrite_t 10 #define new_aubio_sink_custom new_aubio_sink_wavwrite 11 #define del_aubio_sink_custom del_aubio_sink_wavwrite 12 #define aubio_sink_custom_do aubio_sink_wavwrite_do 13 #define aubio_sink_custom_do_multi aubio_sink_wavwrite_do_multi 14 #define aubio_sink_custom_close aubio_sink_wavwrite_close 15 #define aubio_sink_custom_preset_samplerate aubio_sink_wavwrite_preset_samplerate 16 #define aubio_sink_custom_preset_channels aubio_sink_wavwrite_preset_channels 17 #define aubio_sink_custom_get_samplerate aubio_sink_wavwrite_get_samplerate 18 #define aubio_sink_custom_get_channels aubio_sink_wavwrite_get_channels 19 #endif /* HAVE_WAVWRITE */ 20 21 #include "base-sink_custom.h" 4 22 5 23 // this file uses the unstable aubio api, please use aubio_sink instead … … 8 26 int main (int argc, char **argv) 9 27 { 10 sint_t err = 0; 11 12 if (argc < 3) { 13 PRINT_ERR("not enough arguments, running tests\n"); 14 err = run_on_default_source_and_sink(main); 15 PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]); 16 return err; 17 } 18 19 #ifdef HAVE_WAVWRITE 20 uint_t samplerate = 0; 21 uint_t hop_size = 512; 22 uint_t n_frames = 0, read = 0; 23 24 char_t *source_path = argv[1]; 25 char_t *sink_path = argv[2]; 26 27 if ( argc >= 4 ) samplerate = atoi(argv[3]); 28 if ( argc >= 5 ) hop_size = atoi(argv[4]); 29 if ( argc >= 6 ) { 30 err = 2; 31 PRINT_ERR("too many arguments\n"); 32 return err; 33 } 34 35 fvec_t *vec = new_fvec(hop_size); 36 if (!vec) { err = 1; goto beach_fvec; } 37 38 aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size); 39 if (!i) { err = 1; goto beach_source; } 40 41 if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i); 42 43 aubio_sink_wavwrite_t *o = new_aubio_sink_wavwrite(sink_path, samplerate); 44 if (!o) { err = 1; goto beach_sink; } 45 46 do { 47 aubio_source_do(i, vec, &read); 48 aubio_sink_wavwrite_do(o, vec, read); 49 n_frames += read; 50 } while ( read == hop_size ); 51 52 PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n", 53 n_frames, samplerate, n_frames / hop_size, 54 source_path, sink_path); 55 56 del_aubio_sink_wavwrite(o); 57 beach_sink: 58 del_aubio_source(i); 59 beach_source: 60 del_fvec(vec); 61 beach_fvec: 62 #else 63 err = 0; 64 PRINT_ERR("aubio was not compiled with aubio_sink_wavwrite\n"); 65 #endif /* HAVE_WAVWRITE */ 66 return err; 28 return base_main(argc, argv); 67 29 } -
tests/src/io/test-source.c
rc1ba75b r74c1fb9 2 2 #include "utils_tests.h" 3 3 4 int main (int argc, char **argv) 4 int test_wrong_params(void); 5 6 int main(int argc, char **argv) 5 7 { 6 8 uint_t err = 0; 7 9 if (argc < 2) { 8 10 PRINT_ERR("not enough arguments, running tests\n"); 9 err = run_on_default_source(main);11 err = test_wrong_params(); 10 12 PRINT_MSG("read a wave file as a mono vector\n"); 11 13 PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]); … … 28 30 char_t *source_path = argv[1]; 29 31 30 31 32 aubio_source_t* s = 32 33 new_aubio_source(source_path, samplerate, hop_size); 33 if (!s) { err = 1; goto beach; }34 34 fvec_t *vec = new_fvec(hop_size); 35 if (!s || !vec) { err = 1; goto beach; } 35 36 36 37 uint_t n_frames_expected = aubio_source_get_duration(s); … … 50 51 // close the file (optional) 51 52 aubio_source_close(s); 53 54 beach: 55 if (vec) 56 del_fvec(vec); 57 if (s) 58 del_aubio_source(s); 59 return err; 60 } 61 62 int test_wrong_params(void) 63 { 64 char_t *uri = DEFINEDSTRING(AUBIO_TESTS_SOURCE); 65 uint_t samplerate = 44100; 66 uint_t hop_size = 512; 67 uint_t channels, read = 0; 68 fvec_t *vec; 69 fmat_t *mat; 70 aubio_source_t *s; 71 72 if (new_aubio_source(0, samplerate, hop_size)) return 1; 73 if (new_aubio_source("\0", samplerate, hop_size)) return 1; 74 if (new_aubio_source(uri, -1, hop_size)) return 1; 75 if (new_aubio_source(uri, 0, 0)) return 1; 76 77 s = new_aubio_source(uri, samplerate, hop_size); 78 if (!s) return 1; 79 channels = aubio_source_get_channels(s); 80 81 // vector to read downmixed samples 82 vec = new_fvec(hop_size); 83 // matrix to read individual channels 84 mat = new_fmat(channels, hop_size); 85 86 if (aubio_source_get_samplerate(s) != samplerate) return 1; 87 88 // read first hop_size frames 89 aubio_source_do(s, vec, &read); 90 if (read != hop_size) return 1; 91 92 // seek to 0 93 if(aubio_source_seek(s, 0)) return 1; 94 95 // read again as multiple channels 96 aubio_source_do_multi(s, mat, &read); 97 if (read != hop_size) return 1; 98 99 // close the file (optional) 100 aubio_source_close(s); 52 101 // test closing the file a second time 53 102 aubio_source_close(s); 54 103 55 del_fvec (vec); 56 del_aubio_source (s); 57 beach: 58 return err; 104 del_aubio_source(s); 105 del_fmat(mat); 106 del_fvec(vec); 107 108 return run_on_default_source(main); 59 109 } -
tests/src/io/test-source_apple_audio.c
rc1ba75b r74c1fb9 2 2 #include <aubio.h> 3 3 #include "utils_tests.h" 4 5 #define aubio_source_custom "apple_audio" 6 7 #ifdef HAVE_SOURCE_APPLE_AUDIO 8 #define HAVE_AUBIO_SOURCE_CUSTOM 9 #define aubio_source_custom_t aubio_source_apple_audio_t 10 #define new_aubio_source_custom new_aubio_source_apple_audio 11 #define del_aubio_source_custom del_aubio_source_apple_audio 12 #define aubio_source_custom_get_samplerate aubio_source_apple_audio_get_samplerate 13 #define aubio_source_custom_get_duration aubio_source_apple_audio_get_duration 14 #define aubio_source_custom_do aubio_source_apple_audio_do 15 #define aubio_source_custom_do_multi aubio_source_apple_audio_do_multi 16 #define aubio_source_custom_seek aubio_source_apple_audio_seek 17 #define aubio_source_custom_close aubio_source_apple_audio_close 18 #define aubio_source_custom_get_channels aubio_source_apple_audio_get_channels 19 #define aubio_source_custom_get_samplerate aubio_source_apple_audio_get_samplerate 20 #endif /* HAVE_SOURCE_APPLE_AUDIO */ 21 22 #include "base-source_custom.h" 4 23 5 24 // this file uses the unstable aubio api, please use aubio_source instead … … 8 27 int main (int argc, char **argv) 9 28 { 10 uint_t err = 0; 11 if (argc < 2) { 12 PRINT_ERR("not enough arguments, running tests\n"); 13 err = run_on_default_source(main); 14 PRINT_MSG("read a wave file as a mono vector\n"); 15 PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]); 16 PRINT_MSG("examples:\n"); 17 PRINT_MSG(" - read file.wav at original samplerate\n"); 18 PRINT_MSG(" %s file.wav\n", argv[0]); 19 PRINT_MSG(" - read file.aif at 32000Hz\n"); 20 PRINT_MSG(" %s file.aif 32000\n", argv[0]); 21 PRINT_MSG(" - read file.mp3 at original samplerate with 4096 blocks\n"); 22 PRINT_MSG(" %s file.mp3 0 4096 \n", argv[0]); 23 return err; 24 } 25 26 #if HAVE_SOURCE_APPLE_AUDIO 27 uint_t samplerate = 0; 28 uint_t hop_size = 256; 29 uint_t n_frames = 0, read = 0; 30 if ( argc >= 3 ) samplerate = atoi(argv[2]); 31 if ( argc >= 4 ) hop_size = atoi(argv[3]); 32 33 char_t *source_path = argv[1]; 34 35 36 aubio_source_apple_audio_t * s = 37 new_aubio_source_apple_audio(source_path, samplerate, hop_size); 38 if (!s) { err = 1; goto beach; } 39 fvec_t *vec = new_fvec(hop_size); 40 41 uint_t n_frames_expected = aubio_source_apple_audio_get_duration(s); 42 43 samplerate = aubio_source_apple_audio_get_samplerate(s); 44 45 do { 46 aubio_source_apple_audio_do(s, vec, &read); 47 fvec_print (vec); 48 n_frames += read; 49 } while ( read == hop_size ); 50 51 PRINT_MSG("read %d frames (expected %d) at %dHz (%d blocks) from %s\n", 52 n_frames, n_frames_expected, samplerate, n_frames / hop_size, 53 source_path); 54 55 del_fvec (vec); 56 del_aubio_source_apple_audio (s); 57 beach: 58 #else /* HAVE_SOURCE_APPLE_AUDIO */ 59 err = 0; 60 PRINT_ERR("aubio was not compiled with aubio_source_apple_audio\n"); 61 #endif /* HAVE_SOURCE_APPLE_AUDIO */ 62 return err; 29 return base_main(argc, argv); 63 30 } -
tests/src/io/test-source_avcodec.c
rc1ba75b r74c1fb9 2 2 #include <aubio.h> 3 3 #include "utils_tests.h" 4 5 #define aubio_source_custom "avcodec" 6 7 #ifdef HAVE_LIBAV 8 #define HAVE_AUBIO_SOURCE_CUSTOM 9 #define aubio_source_custom_t aubio_source_avcodec_t 10 #define new_aubio_source_custom new_aubio_source_avcodec 11 #define del_aubio_source_custom del_aubio_source_avcodec 12 #define aubio_source_custom_get_samplerate aubio_source_avcodec_get_samplerate 13 #define aubio_source_custom_get_duration aubio_source_avcodec_get_duration 14 #define aubio_source_custom_do aubio_source_avcodec_do 15 #define aubio_source_custom_do_multi aubio_source_avcodec_do_multi 16 #define aubio_source_custom_seek aubio_source_avcodec_seek 17 #define aubio_source_custom_close aubio_source_avcodec_close 18 #define aubio_source_custom_get_channels aubio_source_avcodec_get_channels 19 #define aubio_source_custom_get_samplerate aubio_source_avcodec_get_samplerate 20 #endif /* HAVE_LIBAV */ 21 22 #include "base-source_custom.h" 4 23 5 24 // this file uses the unstable aubio api, please use aubio_source instead … … 8 27 int main (int argc, char **argv) 9 28 { 10 uint_t err = 0; 11 if (argc < 2) { 12 PRINT_ERR("not enough arguments, running tests\n"); 13 err = run_on_default_source(main); 14 PRINT_MSG("read a wave file as a mono vector\n"); 15 PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]); 16 PRINT_MSG("examples:\n"); 17 PRINT_MSG(" - read file.wav at original samplerate\n"); 18 PRINT_MSG(" %s file.wav\n", argv[0]); 19 PRINT_MSG(" - read file.wav at 32000Hz\n"); 20 PRINT_MSG(" %s file.aif 32000\n", argv[0]); 21 PRINT_MSG(" - read file.wav at original samplerate with 4096 blocks\n"); 22 PRINT_MSG(" %s file.wav 0 4096 \n", argv[0]); 23 return err; 24 } 25 26 #ifdef HAVE_LIBAV 27 uint_t samplerate = 0; 28 uint_t hop_size = 256; 29 uint_t n_frames = 0, read = 0; 30 if ( argc >= 3 ) samplerate = atoi(argv[2]); 31 if ( argc >= 4 ) hop_size = atoi(argv[3]); 32 33 char_t *source_path = argv[1]; 34 35 36 aubio_source_avcodec_t * s = 37 new_aubio_source_avcodec(source_path, samplerate, hop_size); 38 if (!s) { err = 1; goto beach; } 39 fvec_t *vec = new_fvec(hop_size); 40 41 uint_t n_frames_expected = aubio_source_avcodec_get_duration(s); 42 43 samplerate = aubio_source_avcodec_get_samplerate(s); 44 45 do { 46 aubio_source_avcodec_do(s, vec, &read); 47 fvec_print (vec); 48 n_frames += read; 49 } while ( read == hop_size ); 50 51 PRINT_MSG("read %d frames (expected %d) at %dHz (%d blocks) from %s\n", 52 n_frames, n_frames_expected, samplerate, n_frames / hop_size, 53 source_path); 54 55 del_fvec (vec); 56 del_aubio_source_avcodec (s); 57 beach: 58 #else /* HAVE_LIBAV */ 59 err = 0; 60 PRINT_ERR("aubio was not compiled with aubio_source_avcodec\n"); 61 #endif /* HAVE_LIBAV */ 62 return err; 29 return base_main(argc, argv); 63 30 } -
tests/src/io/test-source_sndfile.c
rc1ba75b r74c1fb9 2 2 #include <aubio.h> 3 3 #include "utils_tests.h" 4 5 #define aubio_source_custom "sndfile" 6 7 #ifdef HAVE_SNDFILE 8 #define HAVE_AUBIO_SOURCE_CUSTOM 9 #define aubio_source_custom_t aubio_source_sndfile_t 10 #define new_aubio_source_custom new_aubio_source_sndfile 11 #define del_aubio_source_custom del_aubio_source_sndfile 12 #define aubio_source_custom_get_samplerate aubio_source_sndfile_get_samplerate 13 #define aubio_source_custom_get_duration aubio_source_sndfile_get_duration 14 #define aubio_source_custom_do aubio_source_sndfile_do 15 #define aubio_source_custom_do_multi aubio_source_sndfile_do_multi 16 #define aubio_source_custom_seek aubio_source_sndfile_seek 17 #define aubio_source_custom_close aubio_source_sndfile_close 18 #define aubio_source_custom_get_channels aubio_source_sndfile_get_channels 19 #define aubio_source_custom_get_samplerate aubio_source_sndfile_get_samplerate 20 #endif /* HAVE_LIBAV */ 21 22 #include "base-source_custom.h" 4 23 5 24 // this file uses the unstable aubio api, please use aubio_source instead … … 8 27 int main (int argc, char **argv) 9 28 { 10 uint_t err = 0; 11 if (argc < 2) { 12 PRINT_ERR("not enough arguments, running tests\n"); 13 err = run_on_default_source(main); 14 PRINT_MSG("read a wave file as a mono vector\n"); 15 PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]); 16 PRINT_MSG("examples:\n"); 17 PRINT_MSG(" - read file.wav at original samplerate\n"); 18 PRINT_MSG(" %s file.wav\n", argv[0]); 19 PRINT_MSG(" - read file.wav at 32000Hz\n"); 20 PRINT_MSG(" %s file.aif 32000\n", argv[0]); 21 PRINT_MSG(" - read file.wav at original samplerate with 4096 blocks\n"); 22 PRINT_MSG(" %s file.wav 0 4096 \n", argv[0]); 23 return err; 24 } 25 26 #ifdef HAVE_SNDFILE 27 uint_t samplerate = 0; 28 uint_t hop_size = 256; 29 uint_t n_frames = 0, read = 0; 30 if ( argc >= 3 ) samplerate = atoi(argv[2]); 31 if ( argc >= 4 ) hop_size = atoi(argv[3]); 32 33 char_t *source_path = argv[1]; 34 35 36 aubio_source_sndfile_t * s = 37 new_aubio_source_sndfile(source_path, samplerate, hop_size); 38 if (!s) { err = 1; goto beach; } 39 fvec_t *vec = new_fvec(hop_size); 40 41 uint_t n_frames_expected = aubio_source_sndfile_get_duration(s); 42 43 samplerate = aubio_source_sndfile_get_samplerate(s); 44 45 do { 46 aubio_source_sndfile_do(s, vec, &read); 47 fvec_print (vec); 48 n_frames += read; 49 } while ( read == hop_size ); 50 51 PRINT_MSG("read %d frames (expected %d) at %dHz (%d blocks) from %s\n", 52 n_frames, n_frames_expected, samplerate, n_frames / hop_size, 53 source_path); 54 55 del_fvec (vec); 56 del_aubio_source_sndfile (s); 57 beach: 58 #else 59 err = 0; 60 PRINT_ERR("aubio was not compiled with aubio_source_sndfile\n"); 61 #endif /* HAVE_SNDFILE */ 62 return err; 29 return base_main(argc, argv); 63 30 } -
tests/src/io/test-source_wavread.c
rc1ba75b r74c1fb9 2 2 #include <aubio.h> 3 3 #include "utils_tests.h" 4 5 #define aubio_source_custom "wavread" 6 7 #ifdef HAVE_WAVREAD 8 #define HAVE_AUBIO_SOURCE_CUSTOM 9 #define aubio_source_custom_t aubio_source_wavread_t 10 #define new_aubio_source_custom new_aubio_source_wavread 11 #define del_aubio_source_custom del_aubio_source_wavread 12 #define aubio_source_custom_get_samplerate aubio_source_wavread_get_samplerate 13 #define aubio_source_custom_get_duration aubio_source_wavread_get_duration 14 #define aubio_source_custom_do aubio_source_wavread_do 15 #define aubio_source_custom_do_multi aubio_source_wavread_do_multi 16 #define aubio_source_custom_seek aubio_source_wavread_seek 17 #define aubio_source_custom_close aubio_source_wavread_close 18 #define aubio_source_custom_get_channels aubio_source_wavread_get_channels 19 #define aubio_source_custom_get_samplerate aubio_source_wavread_get_samplerate 20 #endif /* HAVE_WAVREAD */ 21 22 #include "base-source_custom.h" 4 23 5 24 // this file uses the unstable aubio api, please use aubio_source instead … … 8 27 int main (int argc, char **argv) 9 28 { 10 uint_t err = 0; 11 if (argc < 2) { 12 PRINT_ERR("not enough arguments, running tests\n"); 13 err = run_on_default_source(main); 14 PRINT_MSG("read a wave file as a mono vector\n"); 15 PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]); 16 PRINT_MSG("examples:\n"); 17 PRINT_MSG(" - read file.wav at original samplerate\n"); 18 PRINT_MSG(" %s file.wav\n", argv[0]); 19 PRINT_MSG(" - read file.wav at 32000Hz\n"); 20 PRINT_MSG(" %s file.aif 32000\n", argv[0]); 21 PRINT_MSG(" - read file.wav at original samplerate with 4096 blocks\n"); 22 PRINT_MSG(" %s file.wav 0 4096 \n", argv[0]); 23 return err; 24 } 25 26 #ifdef HAVE_WAVREAD 27 uint_t samplerate = 0; 28 uint_t hop_size = 256; 29 uint_t n_frames = 0, read = 0; 30 if ( argc >= 3 ) samplerate = atoi(argv[2]); 31 if ( argc >= 4 ) hop_size = atoi(argv[3]); 32 33 char_t *source_path = argv[1]; 34 35 36 aubio_source_wavread_t * s = 37 new_aubio_source_wavread(source_path, samplerate, hop_size); 38 if (!s) { err = 1; goto beach; } 39 fvec_t *vec = new_fvec(hop_size); 40 41 uint_t n_frames_expected = aubio_source_wavread_get_duration(s); 42 43 samplerate = aubio_source_wavread_get_samplerate(s); 44 45 do { 46 aubio_source_wavread_do(s, vec, &read); 47 fvec_print (vec); 48 n_frames += read; 49 } while ( read == hop_size ); 50 51 PRINT_MSG("read %d frames (expected %d) at %dHz (%d blocks) from %s\n", 52 n_frames, n_frames_expected, samplerate, n_frames / hop_size, 53 source_path); 54 55 del_fvec (vec); 56 del_aubio_source_wavread (s); 57 beach: 58 #else 59 err = 0; 60 PRINT_ERR("aubio was not compiled with aubio_source_wavread\n"); 61 #endif /* HAVE_WAVREAD */ 62 return err; 29 return base_main(argc, argv); 63 30 } -
tests/src/onset/test-onset.c
rc1ba75b r74c1fb9 70 70 uint_t samplerate = 44100; 71 71 // hop_size < 1 72 if (new_aubio_onset("default", 5, 0, samplerate)) 73 return 1; 72 if (new_aubio_onset("default", 5, 0, samplerate)) return 1; 73 74 74 // buf_size < 2 75 if (new_aubio_onset("default", 1, 1, samplerate)) 76 return 1; 75 if (new_aubio_onset("default", 1, 1, samplerate)) return 1; 76 77 77 // buf_size < hop_size 78 if (new_aubio_onset("default", hop_size, win_size, samplerate)) 79 return 1; 78 if (new_aubio_onset("default", hop_size, win_size, samplerate)) return 1; 79 80 80 // samplerate < 1 81 if (new_aubio_onset("default", 1024, 512, 0)) 82 return 1; 81 if (new_aubio_onset("default", 1024, 512, 0)) return 1; 83 82 84 83 // specdesc creation failed 85 if (new_aubio_onset("abcd", win_size, win_size/2, samplerate)) 86 return 1; 84 if (new_aubio_onset("abcd", win_size, win_size/2, samplerate)) return 1; 87 85 88 86 aubio_onset_t *o; … … 93 91 94 92 o = new_aubio_onset("default", win_size, hop_size, samplerate); 95 if (!aubio_onset_set_default_parameters(o, "wrong_type")) 96 return 1; 93 if (!aubio_onset_set_default_parameters(o, "wrong_type")) return 1; 97 94 del_aubio_onset(o); 98 95 -
tests/src/tempo/test-tempo.c
rc1ba75b r74c1fb9 82 82 83 83 // test wrong method fails 84 if (new_aubio_tempo("unexisting_method", win_size, hop_size, samplerate)) 85 return 1; 84 if (new_aubio_tempo("undefined", win_size, hop_size, samplerate)) return 1; 86 85 87 86 // test hop > win fails 88 if (new_aubio_tempo("default", hop_size, win_size, samplerate)) 89 return 1; 87 if (new_aubio_tempo("default", hop_size, win_size, samplerate)) return 1; 90 88 91 89 // test null hop_size fails 92 if (new_aubio_tempo("default", win_size, 0, samplerate)) 93 return 1; 90 if (new_aubio_tempo("default", win_size, 0, samplerate)) return 1; 94 91 95 92 // test 1 buf_size fails 96 if (new_aubio_tempo("default", 1, 1, samplerate)) 97 return 1; 93 if (new_aubio_tempo("default", 1, 1, samplerate)) return 1; 98 94 99 95 // test null samplerate fails 100 if (new_aubio_tempo("default", win_size, hop_size, 0)) 101 return 1; 96 if (new_aubio_tempo("default", win_size, hop_size, 0)) return 1; 102 97 103 98 // test short sizes workaround 104 99 t = new_aubio_tempo("default", 2048, 2048, 500); 105 if (!t) 106 return 1; 100 if (!t) return 1; 107 101 108 102 del_aubio_tempo(t); 109 103 110 104 t = new_aubio_tempo("default", win_size, hop_size, samplerate); 111 if (!t) 112 return 1; 105 if (!t) return 1; 113 106 114 107 in = new_fvec(hop_size); -
tests/src/temporal/test-filter.c
rc1ba75b r74c1fb9 10 10 aubio_filter_t *o = new_aubio_filter_c_weighting (44100); 11 11 12 if (new_aubio_filter(0)) 13 return 1; 12 if (new_aubio_filter(0)) return 1; 14 13 15 if (aubio_filter_get_samplerate(o) != 44100) 16 return 1; 14 if (aubio_filter_get_samplerate(o) != 44100) return 1; 17 15 18 if (aubio_filter_set_c_weighting (o, -1) == 0) 19 return 1; 16 if (aubio_filter_set_c_weighting (o, -1) == 0) return 1; 20 17 21 if (aubio_filter_set_c_weighting (0, 32000) == 0) 22 return 1; 18 if (aubio_filter_set_c_weighting (0, 32000) == 0) return 1; 23 19 24 20 in->data[impulse_at] = 0.5; … … 30 26 o = new_aubio_filter_a_weighting (32000); 31 27 32 if (aubio_filter_set_a_weighting (o, -1) == 0) 33 return 1; 34 if (aubio_filter_set_a_weighting (0, 32000) == 0) 35 return 1; 28 if (aubio_filter_set_a_weighting (o, -1) == 0) return 1; 29 30 if (aubio_filter_set_a_weighting (0, 32000) == 0) return 1; 36 31 37 32 in->data[impulse_at] = 0.5; -
tests/utils_tests.h
rc1ba75b r74c1fb9 56 56 #endif 57 57 58 // are we on windows ? or are we using -std=c99 ? 59 #if defined(HAVE_WIN_HACKS) || defined(__STRICT_ANSI__) 60 // http://en.wikipedia.org/wiki/Linear_congruential_generator 61 // no srandom/random on win32 58 #if defined(HAVE_WIN_HACKS) 62 59 63 uint_t srandom_seed = 1029; 60 // use srand/rand on windows 61 #define srandom srand 62 #define random rand 64 63 65 void srandom(uint_t new_seed) { 66 srandom_seed = new_seed; 67 } 64 #elif defined(__STRICT_ANSI__) 68 65 69 uint_t random(void) { 70 srandom_seed = 1664525 * srandom_seed + 1013904223; 71 return srandom_seed; 72 } 66 // workaround to build with -std=c99 (for instance with older cygwin), 67 // assuming libbc is recent enough to supports these functions. 68 extern void srandom(unsigned); 69 extern int random(void); 70 extern char mkstemp(const char *pat); 71 73 72 #endif 74 73 -
wscript
rc1ba75b r74c1fb9 556 556 target = bld.path.find_or_declare('api/index.html'), 557 557 cwd = bld.path.find_dir('doc')) 558 # evaluate nodes lazily to prevent build directory traversal warnings 558 559 bld.install_files('${DATAROOTDIR}/doc/libaubio-doc/api', 559 bld.path.find_or_declare('api').ant_glob('**/*' ),560 cwd=bld.path.find_or_declare('api'),560 bld.path.find_or_declare('api').ant_glob('**/*', 561 generator=True), cwd=bld.path.find_or_declare('api'), 561 562 relative_trick=True) 562 563 … … 580 581 source = bld.path.find_dir('doc').ant_glob('*.rst'), 581 582 target = bld.path.find_or_declare('manual/index.html')) 583 # evaluate nodes lazily to prevent build directory traversal warnings 582 584 bld.install_files('${DATAROOTDIR}/doc/libaubio-doc/manual', 583 bld.path.find_or_declare('manual').ant_glob('**/*' ),584 cwd=bld.path.find_or_declare('manual'),585 bld.path.find_or_declare('manual').ant_glob('**/*', 586 generator=True), cwd=bld.path.find_or_declare('manual'), 585 587 relative_trick=True) 586 588
Note: See TracChangeset
for help on using the changeset viewer.