Changeset 4621cd6 for examples/sndfileio.c
- Timestamp:
- Dec 4, 2009, 1:46:40 AM (14 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:
- aea235c
- Parents:
- c17a0ee
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/sndfileio.c
rc17a0ee r4621cd6 96 96 aubio_sndfile_t * f = AUBIO_NEW(aubio_sndfile_t); 97 97 f->samplerate = fmodel->samplerate; 98 f->channels = fmodel->channels;98 f->channels = 1; //fmodel->channels; 99 99 f->format = fmodel->format; 100 100 aubio_sndfile_open_wo(f, outputname); … … 125 125 /* read frames from file in data 126 126 * return the number of frames actually read */ 127 int aubio_sndfile_read(aubio_sndfile_t * f, int frames, fvec_t * read) {127 int aubio_sndfile_read(aubio_sndfile_t * f, int frames, fvec_t ** read) { 128 128 sf_count_t read_frames; 129 129 int i,j, channels = f->channels; … … 150 150 /* de-interleaving data */ 151 151 for (i=0; i<channels; i++) { 152 pread = (smpl_t *)fvec_get_ channel(read,i);152 pread = (smpl_t *)fvec_get_data(read[i]); 153 153 for (j=0; j<aread; j++) { 154 154 pread[j] = (smpl_t)f->tmpdata[channels*j+i]; … … 158 158 } 159 159 160 int 161 aubio_sndfile_read_mono (aubio_sndfile_t * f, int frames, fvec_t * read) 162 { 163 sf_count_t read_frames; 164 int i, j, channels = f->channels; 165 int nsamples = frames * channels; 166 int aread; 167 smpl_t *pread; 168 169 /* allocate data for de/interleaving reallocated when needed. */ 170 if (nsamples >= f->size) { 171 AUBIO_ERR ("Maximum aubio_sndfile_read buffer size exceeded."); 172 return -1; 173 /* 174 AUBIO_FREE(f->tmpdata); 175 f->tmpdata = AUBIO_ARRAY(float,nsamples); 176 */ 177 } 178 //f->size = nsamples; 179 180 /* do actual reading */ 181 read_frames = sf_read_float (f->handle, f->tmpdata, nsamples); 182 183 aread = (int) FLOOR (read_frames / (float) channels); 184 185 /* de-interleaving data */ 186 pread = (smpl_t *) fvec_get_data (read); 187 for (i = 0; i < channels; i++) { 188 for (j = 0; j < aread; j++) { 189 pread[j] += (smpl_t) f->tmpdata[channels * j + i]; 190 } 191 } 192 for (j = 0; j < aread; j++) { 193 pread[j] /= (smpl_t)channels; 194 } 195 196 return aread; 197 } 198 160 199 /* write 'frames' samples to file from data 161 200 * return the number of frames actually written 162 201 */ 163 int aubio_sndfile_write(aubio_sndfile_t * f, int frames, fvec_t * write) {202 int aubio_sndfile_write(aubio_sndfile_t * f, int frames, fvec_t ** write) { 164 203 sf_count_t written_frames = 0; 165 204 int i, j, channels = f->channels; … … 180 219 /* interleaving data */ 181 220 for (i=0; i<channels; i++) { 182 pwrite = (smpl_t *)fvec_get_ channel(write,i);221 pwrite = (smpl_t *)fvec_get_data(write[i]); 183 222 for (j=0; j<frames; j++) { 184 223 f->tmpdata[channels*j+i] = (float)pwrite[j];
Note: See TracChangeset
for help on using the changeset viewer.