Changeset 944c7e1


Ignore:
Timestamp:
Feb 10, 2013, 5:12:28 AM (11 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:
87b0c03
Parents:
f8ee337
Message:

src/io/source_apple_audio.c: automagically set samplerate if 0 was requested, add _get_samplerate

Location:
src/io
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/io/source.c

    rf8ee337 r944c7e1  
    7272}
    7373
     74uint_t aubio_source_get_samplerate(aubio_source_t * s) {
     75#ifdef __APPLE__
     76  return aubio_source_apple_audio_get_samplerate((aubio_source_apple_audio_t *)s->source);
     77#else /* __APPLE__ */
     78#if HAVE_SNDFILE
     79  return aubio_source_sndfile_get_samplerate((aubio_source_sndfile_t *)s->source);
     80#endif /* HAVE_SNDFILE */
     81#endif /* __APPLE__ */
     82}
     83
  • src/io/source.h

    rf8ee337 r944c7e1  
    3737void del_aubio_source(aubio_source_t * s);
    3838
     39uint_t aubio_source_get_samplerate(aubio_source_t * s);
     40
    3941#ifdef __cplusplus
    4042}
  • src/io/source_apple_audio.c

    rf8ee337 r944c7e1  
    5555
    5656  s->path = path;
    57   s->samplerate = samplerate;
    5857  s->block_size = block_size;
    5958  s->channels = 1;
     
    6160  OSStatus err = noErr;
    6261  UInt32 propSize;
    63 
    64   AudioStreamBasicDescription clientFormat;
    65   propSize = sizeof(clientFormat);
    66   memset(&clientFormat, 0, sizeof(AudioStreamBasicDescription));
    67   clientFormat.mFormatID         = kAudioFormatLinearPCM;
    68   clientFormat.mSampleRate       = (Float64)(s->samplerate);
    69   clientFormat.mFormatFlags      = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
    70   clientFormat.mChannelsPerFrame = s->channels;
    71   clientFormat.mBitsPerChannel   = sizeof(short) * 8;
    72   clientFormat.mFramesPerPacket  = 1;
    73   clientFormat.mBytesPerFrame    = clientFormat.mBitsPerChannel * clientFormat.mChannelsPerFrame / 8;
    74   clientFormat.mBytesPerPacket   = clientFormat.mFramesPerPacket * clientFormat.mBytesPerFrame;
    75   clientFormat.mReserved         = 0;
    7662
    7763  // open the resource url
     
    8975      kExtAudioFileProperty_FileDataFormat, &propSize, &fileFormat);
    9076  if (err) { AUBIO_ERROR("error in ExtAudioFileGetProperty, %d\n", (int)err); goto beach;}
     77
     78  if (samplerate == 0) {
     79    samplerate = fileFormat.mSampleRate;
     80    AUBIO_WRN("sampling rate set to 0, automagically adjusting to %d", samplerate);
     81  }
     82  s->samplerate = samplerate;
     83
     84  AudioStreamBasicDescription clientFormat;
     85  propSize = sizeof(clientFormat);
     86  memset(&clientFormat, 0, sizeof(AudioStreamBasicDescription));
     87  clientFormat.mFormatID         = kAudioFormatLinearPCM;
     88  clientFormat.mSampleRate       = (Float64)(s->samplerate);
     89  clientFormat.mFormatFlags      = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
     90  clientFormat.mChannelsPerFrame = s->channels;
     91  clientFormat.mBitsPerChannel   = sizeof(short) * 8;
     92  clientFormat.mFramesPerPacket  = 1;
     93  clientFormat.mBytesPerFrame    = clientFormat.mBitsPerChannel * clientFormat.mChannelsPerFrame / 8;
     94  clientFormat.mBytesPerPacket   = clientFormat.mFramesPerPacket * clientFormat.mBytesPerFrame;
     95  clientFormat.mReserved         = 0;
    9196
    9297  // set the client format description
     
    176181}
    177182
     183uint_t aubio_source_apple_audio_get_samplerate(aubio_source_apple_audio_t * s) {
     184  return s->samplerate;
     185}
     186
    178187#endif /* __APPLE__ */
  • src/io/source_apple_audio.h

    rf8ee337 r944c7e1  
    2727void del_aubio_source_apple_audio(aubio_source_apple_audio_t * s);
    2828
     29uint_t aubio_source_apple_audio_get_samplerate(aubio_source_apple_audio_t * s);
     30
    2931#endif /* _AUBIO_SOURCE_APPLE_AUDIO_H */
Note: See TracChangeset for help on using the changeset viewer.