Changeset 5bd806d
- Timestamp:
- Feb 8, 2016, 5:09:47 PM (9 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:
- fa74361
- Parents:
- 9fa9b86
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source_sndfile.c
r9fa9b86 r5bd806d 36 36 #define MAX_SIZE 4096 37 37 #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 */ 38 44 39 45 struct _aubio_source_sndfile_t { … … 59 65 // some temporary memory for sndfile to write at 60 66 uint_t scratch_size; 61 float *scratch_data;67 smpl_t *scratch_data; 62 68 }; 63 69 … … 104 110 s->samplerate = samplerate; 105 111 /* 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; 107 113 s->input_hop_size = (uint_t)FLOOR(s->hop_size / s->ratio + .5); 108 114 … … 139 145 /* allocate data for de/interleaving reallocated when needed. */ 140 146 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); 142 148 143 149 return s; … … 153 159 uint_t i,j, input_channels = s->input_channels; 154 160 /* 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); 156 162 157 163 /* where to store de-interleaved data */ … … 194 200 uint_t i,j, input_channels = s->input_channels; 195 201 /* 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); 197 203 198 204 /* where to store de-interleaved data */ … … 214 220 for (j = 0; j < read_samples / input_channels; j++) { 215 221 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]; 217 223 } 218 224 } … … 222 228 for (j = 0; j < read_samples / input_channels; j++) { 223 229 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]; 225 231 } 226 232 } … … 232 238 for (j = 0; j < read_samples / input_channels; j++) { 233 239 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)]; 235 241 } 236 242 }
Note: See TracChangeset
for help on using the changeset viewer.