Changeset 8aed26d for src/io/sink_sndfile.c
- Timestamp:
- Jul 15, 2012, 8:18:28 PM (12 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:
- 42e6a5e
- Parents:
- 11a1abe
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/sink_sndfile.c
r11a1abe r8aed26d 34 34 35 35 struct _aubio_sink_sndfile_t { 36 uint_t hop_size;37 36 uint_t samplerate; 38 37 uint_t channels; … … 43 42 }; 44 43 45 aubio_sink_sndfile_t * new_aubio_sink_sndfile(char_t * path, uint_t samplerate , uint_t hop_size) {44 aubio_sink_sndfile_t * new_aubio_sink_sndfile(char_t * path, uint_t samplerate) { 46 45 aubio_sink_sndfile_t * s = AUBIO_NEW(aubio_sink_sndfile_t); 47 46 … … 51 50 } 52 51 53 s->hop_size = hop_size;54 52 s->samplerate = samplerate; 53 s->max_size = MAX_SIZE; 55 54 s->channels = 1; 56 55 s->path = path; … … 72 71 } 73 72 74 s->scratch_size = s-> hop_size*s->channels;73 s->scratch_size = s->max-size*s->channels; 75 74 /* allocate data for de/interleaving reallocated when needed. */ 76 75 if (s->scratch_size >= MAX_SIZE * MAX_CHANNELS) { 77 76 AUBIO_ERR("%d x %d exceeds maximum aubio_sink_sndfile buffer size %d\n", 78 s-> hop_size, s->channels, MAX_CHANNELS * MAX_CHANNELS);77 s->max_size, s->channels, MAX_CHANNELS * MAX_CHANNELS); 79 78 return NULL; 80 79 } … … 84 83 } 85 84 86 void aubio_sink_sndfile_do(aubio_sink_sndfile_t *s, fvec_t * write , uint_t * written){85 void aubio_sink_sndfile_do(aubio_sink_sndfile_t *s, fvec_t * write_data, uint_t write){ 87 86 sf_count_t written_frames = 0; 88 87 int i, j, channels = s->channels; 89 int nsamples = channels* (*written);88 int nsamples = channels*write; 90 89 smpl_t *pwrite; 90 91 if (write > s->max_size) { 92 write = s->max_size; 93 AUBIO_WRN("trying to write %d frames, but only %d can be written at a time", 94 write, s->max_frames); 95 } 91 96 92 97 /* interleaving data */ 93 98 for ( i = 0; i < channels; i++) { 94 pwrite = (smpl_t *)write ->data;95 for (j=0; j < s->hop_size; j++) {99 pwrite = (smpl_t *)write_data->data; 100 for (j=0; j < write; j++) { 96 101 s->scratch_data[channels*j+i] = pwrite[j]; 97 102 } 98 103 } 99 written_frames = sf_write_float (s->handle, s->scratch_data, nsamples); 100 *written = written_frames/channels; 104 105 uint_t written = sf_write_float (s->handle, s->scratch_data, nsamples); 106 if (written/channels != write) { 107 AUBIO_WRN("trying to write %d frames to %s, but only %d could be written", 108 write, s->path, written); 109 } 101 110 return; 102 111 }
Note: See TracChangeset
for help on using the changeset viewer.