Index: src/io/source_apple_audio.c
===================================================================
--- src/io/source_apple_audio.c	(revision 12e5d8969f8d1e62ca1c7c0fdf311b7d27d18bde)
+++ src/io/source_apple_audio.c	(revision ff6d1b6e931ea03c7056f081ea7427f040460fc5)
@@ -34,6 +34,4 @@
 #define RT_BYTE3( a )      ( ((a) >> 16) & 0xff )
 #define RT_BYTE4( a )      ( ((a) >> 24) & 0xff )
-
-#define SHORT_TO_FLOAT(x) (smpl_t)(x * 3.0517578125e-05)
 
 struct _aubio_source_apple_audio_t {
@@ -49,5 +47,5 @@
 };
 
-extern int createAubioBufferList(AudioBufferList *bufferList, int channels, int max_source_samples);
+extern int createAudioBufferList(AudioBufferList *bufferList, int channels, int max_source_samples);
 extern void freeAudioBufferList(AudioBufferList *bufferList);
 extern CFURLRef createURLFromPath(const char * path);
@@ -139,15 +137,14 @@
 
   AudioStreamBasicDescription clientFormat;
-  propSize = sizeof(clientFormat);
+  propSize = sizeof(AudioStreamBasicDescription);
   memset(&clientFormat, 0, sizeof(AudioStreamBasicDescription));
   clientFormat.mFormatID         = kAudioFormatLinearPCM;
   clientFormat.mSampleRate       = (Float64)(s->samplerate);
-  clientFormat.mFormatFlags      = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
+  clientFormat.mFormatFlags      = kAudioFormatFlagIsFloat;
   clientFormat.mChannelsPerFrame = s->channels;
-  clientFormat.mBitsPerChannel   = sizeof(short) * 8;
+  clientFormat.mBitsPerChannel   = sizeof(smpl_t) * 8;
   clientFormat.mFramesPerPacket  = 1;
   clientFormat.mBytesPerFrame    = clientFormat.mBitsPerChannel * clientFormat.mChannelsPerFrame / 8;
   clientFormat.mBytesPerPacket   = clientFormat.mFramesPerPacket * clientFormat.mBytesPerFrame;
-  clientFormat.mReserved         = 0;
 
   // set the client format description
@@ -187,5 +184,5 @@
   // allocate the AudioBufferList
   freeAudioBufferList(&s->bufferList);
-  if (createAubioBufferList(&s->bufferList, s->channels, s->block_size * s->channels)) {
+  if (createAudioBufferList(&s->bufferList, s->channels, s->block_size * s->channels)) {
     AUBIO_ERR("source_apple_audio: failed creating bufferList\n");
     goto beach;
@@ -196,6 +193,7 @@
 }
 
-void aubio_source_apple_audio_do(aubio_source_apple_audio_t *s, fvec_t * read_to, uint_t * read) {
-  UInt32 c, v, loadedPackets = s->block_size;
+static UInt32 aubio_source_apple_audio_read_frame(aubio_source_apple_audio_t *s)
+{
+  UInt32 loadedPackets = s->block_size;
   OSStatus err = ExtAudioFileRead(s->audioFile, &loadedPackets, &s->bufferList);
   if (err) {
@@ -204,22 +202,25 @@
         "with ExtAudioFileRead (%s)\n", s->path,
         getPrintableOSStatusError(errorstr, err));
-    goto beach;
-  }
-
-  short *data = (short*)s->bufferList.mBuffers[0].mData;
-
-  smpl_t *buf = read_to->data;
+  }
+  return loadedPackets;
+}
+
+void aubio_source_apple_audio_do(aubio_source_apple_audio_t *s, fvec_t * read_to,
+    uint_t * read) {
+  uint_t c, v;
+  UInt32 loadedPackets = aubio_source_apple_audio_read_frame(s);
+  smpl_t *data = (smpl_t*)s->bufferList.mBuffers[0].mData;
 
   for (v = 0; v < loadedPackets; v++) {
-    buf[v] = 0.;
+    read_to->data[v] = 0.;
     for (c = 0; c < s->channels; c++) {
-      buf[v] += SHORT_TO_FLOAT(data[ v * s->channels + c]);
-    }
-    buf[v] /= (smpl_t)s->channels;
+      read_to->data[v] += data[ v * s->channels + c];
+    }
+    read_to->data[v] /= (smpl_t)s->channels;
   }
   // short read, fill with zeros
   if (loadedPackets < s->block_size) {
     for (v = loadedPackets; v < s->block_size; v++) {
-      buf[v] = 0.;
+      read_to->data[v] = 0.;
     }
   }
@@ -227,27 +228,14 @@
   *read = (uint_t)loadedPackets;
   return;
-beach:
-  *read = 0;
-  return;
 }
 
 void aubio_source_apple_audio_do_multi(aubio_source_apple_audio_t *s, fmat_t * read_to, uint_t * read) {
-  UInt32 c, v, loadedPackets = s->block_size;
-  OSStatus err = ExtAudioFileRead(s->audioFile, &loadedPackets, &s->bufferList);
-  if (err) {
-    char_t errorstr[20];
-    AUBIO_ERROR("source_apple_audio: error while reading %s "
-        "with ExtAudioFileRead (%s)\n", s->path,
-        getPrintableOSStatusError(errorstr, err));
-    goto beach;
-  }
-
-  short *data = (short*)s->bufferList.mBuffers[0].mData;
-
-  smpl_t **buf = read_to->data;
+  uint_t c, v;
+  UInt32 loadedPackets = aubio_source_apple_audio_read_frame(s);
+  smpl_t *data = (smpl_t*)s->bufferList.mBuffers[0].mData;
 
   for (v = 0; v < loadedPackets; v++) {
     for (c = 0; c < read_to->height; c++) {
-      buf[c][v] = SHORT_TO_FLOAT(data[ v * s->channels + c]);
+      read_to->data[c][v] = data[ v * s->channels + c];
     }
   }
@@ -257,5 +245,5 @@
     for (v = 0; v < loadedPackets; v++) {
       for (c = s->channels; c < read_to->height; c++) {
-        buf[c][v] = SHORT_TO_FLOAT(data[ v * s->channels + (s->channels - 1)]);
+        read_to->data[c][v] = data[ v * s->channels + (s->channels - 1)];
       }
     }
@@ -265,12 +253,10 @@
     for (v = loadedPackets; v < s->block_size; v++) {
       for (c = 0; c < read_to->height; c++) {
-        buf[c][v] = 0.;
+        read_to->data[c][v] = 0.;
       }
     }
   }
+
   *read = (uint_t)loadedPackets;
-  return;
-beach:
-  *read = 0;
   return;
 }
@@ -323,5 +309,5 @@
   // after a short read, the bufferList size needs to resetted to prepare for a full read
   AudioBufferList *bufferList = &s->bufferList;
-  bufferList->mBuffers[0].mDataByteSize = s->block_size * s->channels * sizeof (short);
+  bufferList->mBuffers[0].mDataByteSize = s->block_size * s->channels * sizeof (smpl_t);
   // do the actual seek
   err = ExtAudioFileSeek(s->audioFile, resampled_pos);
