Ignore:
Timestamp:
Jul 15, 2012, 8:02:27 PM (12 years ago)
Author:
Paul Brossier <piem@piem.org>
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:
11a1abe
Parents:
32df658
Message:

src/io/sink_apple_audio.c: added apple_audio sink, merge apple stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/source_apple_audio.c

    r32df658 r1223979  
    2525#include "io/source_apple_audio.h"
    2626
    27 // CFURLRef, CFURLCreateWithFileSystemPath, ...
    28 #include <CoreFoundation/CoreFoundation.h>
    2927// ExtAudioFileRef, AudioStreamBasicDescription, AudioBufferList, ...
    3028#include <AudioToolbox/AudioToolbox.h>
     
    4543
    4644  ExtAudioFileRef audioFile;
    47   AudioStreamBasicDescription fileFormat;
    4845  AudioBufferList bufferList;
    4946};
    5047
    51 static int createAubioBufferList(AudioBufferList *bufferList, int channels, int segmentSize);
    52 static void freeAudioBufferList(AudioBufferList *bufferList);
    53 static CFURLRef getURLFromPath(const char * path);
     48extern int createAubioBufferList(AudioBufferList *bufferList, int channels, int segmentSize);
     49extern void freeAudioBufferList(AudioBufferList *bufferList);
     50extern CFURLRef getURLFromPath(const char * path);
    5451
    5552aubio_source_apple_audio_t * new_aubio_source_apple_audio(char_t * path, uint_t samplerate, uint_t block_size)
     
    9693  err = ExtAudioFileSetProperty(s->audioFile, kExtAudioFileProperty_ClientDataFormat,
    9794      propSize, &clientFormat);
    98   if (err) { fprintf(stderr, "error in ExtAudioFileSetProperty, %d\n", (int)err); goto beach;}
     95  if (err) { AUBIO_ERROR("error in ExtAudioFileSetProperty, %d\n", (int)err); goto beach;}
    9996
     97#if 0
    10098  // print client and format descriptions
    10199  AUBIO_DBG("Opened %s\n", s->path);
     
    113111  AUBIO_DBG("file/client Format.mBytesPerPacket   : %6d / %d\n",    (int)fileFormat.mBytesPerPacket  , (int)clientFormat.mBytesPerPacket);
    114112  AUBIO_DBG("file/client Format.mReserved         : %6d / %d\n",    (int)fileFormat.mReserved        , (int)clientFormat.mReserved);
     113#endif
    115114
    116115  // compute the size of the segments needed to read the input file
     
    166165}
    167166
    168 static int createAubioBufferList(AudioBufferList * bufferList, int channels, int segmentSize) {
    169   bufferList->mNumberBuffers = 1;
    170   bufferList->mBuffers[0].mNumberChannels = channels;
    171   bufferList->mBuffers[0].mData = (short *)malloc(segmentSize * sizeof(short));
    172   bufferList->mBuffers[0].mDataByteSize = segmentSize * sizeof(short);
    173   return 0;
    174 }
    175 
    176 static void freeAudioBufferList(AudioBufferList *bufferList) {
    177   UInt32 i = 0;
    178   if (!bufferList) return;
    179   for (i = 0; i < bufferList->mNumberBuffers; i++) {
    180     if (bufferList->mBuffers[i].mData) {
    181       free (bufferList->mBuffers[i].mData);
    182       bufferList->mBuffers[i].mData = NULL;
    183     }
    184   }
    185   bufferList = NULL;
    186 }
    187 
    188 static CFURLRef getURLFromPath(const char * path) {
    189   CFStringRef cfTotalPath = CFStringCreateWithCString (kCFAllocatorDefault,
    190       path, kCFStringEncodingUTF8);
    191 
    192   return CFURLCreateWithFileSystemPath(kCFAllocatorDefault, cfTotalPath,
    193       kCFURLPOSIXPathStyle, false);
    194 }
    195 
    196 
    197167void del_aubio_source_apple_audio(aubio_source_apple_audio_t * s){
    198168  OSStatus err = noErr;
Note: See TracChangeset for help on using the changeset viewer.