Changeset 5bd806d for src


Ignore:
Timestamp:
Feb 8, 2016, 5:09:47 PM (9 years ago)
Author:
Paul Brossier <piem@piem.org>
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:
fa74361
Parents:
9fa9b86
Message:

src/io/source_sndfile.c: use sf_read_double when compiling with AUBIO_DOUBLE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/source_sndfile.c

    r9fa9b86 r5bd806d  
    3636#define MAX_SIZE 4096
    3737#define MAX_SAMPLES MAX_CHANNELS * MAX_SIZE
     38
     39#if !HAVE_AUBIO_DOUBLE
     40#define aubio_sf_read_smpl sf_read_float
     41#else /* HAVE_AUBIO_DOUBLE */
     42#define aubio_sf_read_smpl sf_read_double
     43#endif /* HAVE_AUBIO_DOUBLE */
    3844
    3945struct _aubio_source_sndfile_t {
     
    5965  // some temporary memory for sndfile to write at
    6066  uint_t scratch_size;
    61   float *scratch_data;
     67  smpl_t *scratch_data;
    6268};
    6369
     
    104110  s->samplerate = samplerate;
    105111  /* compute input block size required before resampling */
    106   s->ratio = s->samplerate/(float)s->input_samplerate;
     112  s->ratio = s->samplerate/(smpl_t)s->input_samplerate;
    107113  s->input_hop_size = (uint_t)FLOOR(s->hop_size / s->ratio + .5);
    108114
     
    139145  /* allocate data for de/interleaving reallocated when needed. */
    140146  s->scratch_size = s->input_hop_size * s->input_channels;
    141   s->scratch_data = AUBIO_ARRAY(float,s->scratch_size);
     147  s->scratch_data = AUBIO_ARRAY(smpl_t, s->scratch_size);
    142148
    143149  return s;
     
    153159  uint_t i,j, input_channels = s->input_channels;
    154160  /* read from file into scratch_data */
    155   sf_count_t read_samples = sf_read_float (s->handle, s->scratch_data, s->scratch_size);
     161  sf_count_t read_samples = aubio_sf_read_smpl (s->handle, s->scratch_data, s->scratch_size);
    156162
    157163  /* where to store de-interleaved data */
     
    194200  uint_t i,j, input_channels = s->input_channels;
    195201  /* do actual reading */
    196   sf_count_t read_samples = sf_read_float (s->handle, s->scratch_data, s->scratch_size);
     202  sf_count_t read_samples = aubio_sf_read_smpl (s->handle, s->scratch_data, s->scratch_size);
    197203
    198204  /* where to store de-interleaved data */
     
    214220    for (j = 0; j < read_samples / input_channels; j++) {
    215221      for (i = 0; i < read_data->height; i++) {
    216         ptr_data[i][j] = (smpl_t)s->scratch_data[j * input_channels + i];
     222        ptr_data[i][j] = s->scratch_data[j * input_channels + i];
    217223      }
    218224    }
     
    222228    for (j = 0; j < read_samples / input_channels; j++) {
    223229      for (i = 0; i < input_channels; i++) {
    224         ptr_data[i][j] = (smpl_t)s->scratch_data[j * input_channels + i];
     230        ptr_data[i][j] = s->scratch_data[j * input_channels + i];
    225231      }
    226232    }
     
    232238    for (j = 0; j < read_samples / input_channels; j++) {
    233239      for (i = input_channels; i < read_data->height; i++) {
    234         ptr_data[i][j] = (smpl_t)s->scratch_data[j * input_channels + (input_channels - 1)];
     240        ptr_data[i][j] = s->scratch_data[j * input_channels + (input_channels - 1)];
    235241      }
    236242    }
Note: See TracChangeset for help on using the changeset viewer.