source: tests/src/io/test-source_sndfile.c @ 18c6b20

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 18c6b20 was ab7d100, checked in by Paul Brossier <piem@piem.org>, 12 years ago

tests/src/io/test-source_sndfile.c: avoid memory leak

  • Property mode set to 100644
File size: 856 bytes
RevLine 
[afbd7e7]1#include <stdio.h>
2#include <aubio.h>
3#include "config.h"
4
[ab7d100]5char_t *path = "/home/piem/archives/samples/loops/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav";
[afbd7e7]6
7int main(){
[ab7d100]8  int err = 0;
[afbd7e7]9#ifdef HAVE_SNDFILE
[ab7d100]10  uint_t samplerate = 192000;
[afbd7e7]11  uint_t hop_size = 512;
12  uint_t read = hop_size;
13  fvec_t *vec = new_fvec(hop_size);
14  aubio_source_sndfile_t * s = new_aubio_source_sndfile(path, samplerate, hop_size);
15
[ab7d100]16  if (!s) { err = 1; goto beach; }
[afbd7e7]17
18  while ( read == hop_size ) {
19    aubio_source_sndfile_do(s, vec, &read);
20    if (read == 0) break;
21    fprintf(stdout, "%d [%f, %f, ..., %f]\n", read, vec->data[0], vec->data[1], vec->data[read - 1]);
22  }
23
[ab7d100]24beach:
[afbd7e7]25  del_aubio_source_sndfile(s);
[ab7d100]26  del_fvec(vec);
[afbd7e7]27#else
28  fprintf(stderr, "ERR: aubio was not compiled with aubio_source_sndfile\n");
[ab7d100]29  err = 2;
[afbd7e7]30#endif /* HAVE_SNDFILE */
[ab7d100]31  return err;
[afbd7e7]32}
33
Note: See TracBrowser for help on using the repository browser.