Changes in / [db120ac:54a2ca2]


Ignore:
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • src/io/source.h

    rdb120ac r54a2ca2  
    2626  Media source to read blocks of consecutive audio samples from file
    2727
    28   To write to file, use ::aubio_sink_t.
    29 
    3028  \example io/test-source.c
    31   \example io/test-source_multi.c
    3229
    3330*/
  • src/io/source_apple_audio.c

    rdb120ac r54a2ca2  
    5252extern CFURLRef getURLFromPath(const char * path);
    5353
    54 uint_t aubio_source_apple_audio_open (aubio_source_apple_audio_t *s, char_t * path);
    55 
    5654aubio_source_apple_audio_t * new_aubio_source_apple_audio(char_t * path, uint_t samplerate, uint_t block_size)
    5755{
    5856  aubio_source_apple_audio_t * s = AUBIO_NEW(aubio_source_apple_audio_t);
    5957
     58  s->path = path;
    6059  s->block_size = block_size;
    61   s->samplerate = samplerate;
    62 
    63   if ( aubio_source_apple_audio_open ( s, path ) ) {
    64     goto beach;
    65   }
    66   return s;
    67 
    68 beach:
    69   AUBIO_FREE(s);
    70   return NULL;
    71 }
    72 
    73 uint_t aubio_source_apple_audio_open (aubio_source_apple_audio_t *s, char_t * path)
    74 {
     60
    7561  OSStatus err = noErr;
    7662  UInt32 propSize;
    77   s->path = path;
    7863
    7964  // open the resource url
     
    9277  if (err) { AUBIO_ERROR("error in ExtAudioFileGetProperty, %d\n", (int)err); goto beach;}
    9378
    94   if (s->samplerate == 0) {
    95     s->samplerate = fileFormat.mSampleRate;
     79  if (samplerate == 0) {
     80    samplerate = fileFormat.mSampleRate;
    9681    //AUBIO_DBG("sampling rate set to 0, automagically adjusting to %d\n", samplerate);
    9782  }
    98 
     83  s->samplerate = samplerate;
    9984  s->source_samplerate = fileFormat.mSampleRate;
    10085  s->channels = fileFormat.mChannelsPerFrame;
     
    139124
    140125  // compute the size of the segments needed to read the input file
    141   UInt32 samples = s->block_size * s->channels;
    142   Float64 rateRatio = s->samplerate / s->source_samplerate;
     126  UInt32 samples = s->block_size * clientFormat.mChannelsPerFrame;
     127  Float64 rateRatio = clientFormat.mSampleRate / fileFormat.mSampleRate;
    143128  uint_t segmentSize= (uint_t)(samples * rateRatio + .5);
    144129  if (rateRatio < 1.) {
    145130    segmentSize = (uint_t)(samples / rateRatio + .5);
    146131  } else if (rateRatio > 1.) {
    147     AUBIO_WRN("up-sampling %s from %0dHz to %0dHz\n", s->path, s->source_samplerate, s->samplerate);
     132    AUBIO_WRN("up-sampling %s from %0.2fHz to %0.2fHz\n", s->path, fileFormat.mSampleRate, clientFormat.mSampleRate);
    148133  } else {
    149134    assert ( segmentSize == samples );
     
    152137
    153138  // allocate the AudioBufferList
    154   if (createAubioBufferList(&s->bufferList, s->channels, segmentSize)) {
    155     AUBIO_ERR("source_apple_audio: failed creating bufferList\n");
    156     goto beach;
    157   }
    158 
     139  if (createAubioBufferList(&s->bufferList, s->channels, segmentSize)) err = -1;
     140
     141  return s;
     142 
    159143beach:
    160   return err;
     144  AUBIO_FREE(s);
     145  return NULL;
    161146}
    162147
     
    220205}
    221206
    222 uint_t aubio_source_apple_audio_close (aubio_source_apple_audio_t *s)
    223 {
     207void del_aubio_source_apple_audio(aubio_source_apple_audio_t * s){
    224208  OSStatus err = noErr;
    225   if (!s || !s->audioFile) { return 1; }
     209  if (!s || !s->audioFile) { return; }
    226210  err = ExtAudioFileDispose(s->audioFile);
    227211  if (err) AUBIO_ERROR("error in ExtAudioFileDispose, %d\n", (int)err);
    228212  s->audioFile = NULL;
    229   return err;
    230 }
    231 
    232 void del_aubio_source_apple_audio(aubio_source_apple_audio_t * s){
    233   aubio_source_apple_audio_close (s);
    234213  freeAudioBufferList(&s->bufferList);
    235214  AUBIO_FREE(s);
Note: See TracChangeset for help on using the changeset viewer.