shithub: aubio

Download patch

ref: d69e37d91c59ca538a17455ea6b5733de3ef300c
parent: bd54912abfaddbf74af68cbd31c51e294f3d88dd
author: Paul Brossier <piem@piem.org>
date: Thu Sep 24 23:54:05 EDT 2009

ext/sndfileio.c: convert data from and to float if smpl_t != float

--- a/ext/sndfileio.c
+++ b/ext/sndfileio.c
@@ -128,7 +128,7 @@
         int i,j, channels = f->channels;
         int nsamples = frames*channels;
         int aread;
-        float *pread;	
+        smpl_t *pread;	
 
         /* allocate data for de/interleaving reallocated when needed. */
         if (nsamples >= f->size) {
@@ -148,9 +148,9 @@
 
         /* de-interleaving data  */
         for (i=0; i<channels; i++) {
-                pread = (float *)fvec_get_channel(read,i);
+                pread = (smpl_t *)fvec_get_channel(read,i);
                 for (j=0; j<aread; j++) {
-                        pread[j] = f->tmpdata[channels*j+i];
+                        pread[j] = (smpl_t)f->tmpdata[channels*j+i];
                 }
         }
         return aread;
@@ -163,7 +163,7 @@
         sf_count_t written_frames = 0;
         int i, j,	channels = f->channels;
         int nsamples = channels*frames;
-        float *pwrite;
+        smpl_t *pwrite;
 
         /* allocate data for de/interleaving reallocated when needed. */
         if (nsamples >= f->size) {
@@ -178,9 +178,9 @@
 
         /* interleaving data  */
         for (i=0; i<channels; i++) {
-                pwrite = (float *)fvec_get_channel(write,i);
+                pwrite = (smpl_t *)fvec_get_channel(write,i);
                 for (j=0; j<frames; j++) {
-                        f->tmpdata[channels*j+i] = pwrite[j];
+                        f->tmpdata[channels*j+i] = (float)pwrite[j];
                 }
         }
         written_frames = sf_write_float (f->handle, f->tmpdata, nsamples);