• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: SampleRate Conversion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SampleRate Conversion


  • Subject: Re: SampleRate Conversion
  • From: Frederic De Jaeger <email@hidden>
  • Date: Fri, 20 Jun 2014 10:22:45 +0200

I've never used those API so I might be wrong.  I'm not sure that format conversions cover the going from stereo to mono since this implies a severe data loss.  You have to decide how this is to be done and  there is no universal answer for this problem (taking the average of the left and right channel can lead to phase cancellation issues and this API would probably not do such a job). 
Did you have a look at kAudioConverterChannelMap ?
By the way, from the description, it looks the converter should work even if the channel map is not set.  It will just throw out one of the input channel (which is probably not a good way to do stereo -> mono).

And one more things:
// from AudioConverter.h

    kAudioConverterErr_InvalidInputSize         = 'insz',








2014-06-19 10:49 GMT+02:00 Anthony Myatt <email@hidden>:
Hi,

I am trying to do a conversion using AudioConverterFillComplexBuffer but am getting ‘insz’ errors.
Integer -> Float
Stereo -> Mono
44100 -> 16000

The code worked with everything except for sample rate conversion, as soon as I added that I began getting the errors.

Below is my two format descriptions:

———————
/* Setup input format */
    size_t bytesPerSample = sizeof (AudioUnitSampleType);
    inputStreamFormat.mFormatID          = kAudioFormatLinearPCM;
    inputStreamFormat.mFormatFlags       = kAudioFormatFlagsAudioUnitCanonical;
    inputStreamFormat.mBytesPerPacket    = bytesPerSample;
    inputStreamFormat.mFramesPerPacket   = 1;
    inputStreamFormat.mBytesPerFrame     = bytesPerSample;
    inputStreamFormat.mChannelsPerFrame  = 2;
    inputStreamFormat.mBitsPerChannel    = 8 * bytesPerSample;
    inputStreamFormat.mSampleRate        = 44100;

    

    /* Setup float format */
    floatAudioDescription.mFormatID          = kAudioFormatLinearPCM;
    floatAudioDescription.mFormatFlags       = kAudioFormatFlagIsFloat | kAudioFormatFlagIsPacked | kAudioFormatFlagIsNonInterleaved;
    floatAudioDescription.mChannelsPerFrame  = stereo() ? 2 : 1;
    floatAudioDescription.mBytesPerPacket    = sizeof(float);
    floatAudioDescription.mFramesPerPacket   = 1;
    floatAudioDescription.mBytesPerFrame     = sizeof(float);
    floatAudioDescription.mBitsPerChannel    = 8 * sizeof(float);
    floatAudioDescription.mSampleRate        = samplerate();
———————

Can anyone see what I am doing wrong?


Regards,

Anthony

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >SampleRate Conversion (From: Anthony Myatt <email@hidden>)
 >Re: SampleRate Conversion (From: Anthony Myatt <email@hidden>)

  • Prev by Date: Generating a rising sine tone with sinf() (Adam Bellard)
  • Next by Date: Re: SampleRate Conversion
  • Previous by thread: Re: SampleRate Conversion
  • Next by thread: Re: SampleRate Conversion
  • Index(es):
    • Date
    • Thread