Re: Using AudioConverterFillComplexBuffer to Decompress Audio File Dynamically
Re: Using AudioConverterFillComplexBuffer to Decompress Audio File Dynamically
- Subject: Re: Using AudioConverterFillComplexBuffer to Decompress Audio File Dynamically
- From: Kevin Dixon <email@hidden>
- Date: Mon, 19 Aug 2013 13:58:00 -0700
Once you have your AVAssetReaderAudioMixOutput, you can simply call
copyNextSampleBuffer on that object. If you have configured the
AVAssetReader with the proper client format, then it will be in plain
16 bit PCM, or whatever you asked for.
For example
_audioDecodeSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber
numberWithInt:kAudioFormatLinearPCM], AVFormatIDKey,
[NSNumber numberWithFloat:samplingRate],
AVSampleRateKey,
[NSNumber numberWithInt: numCh],
AVNumberOfChannelsKey,
[NSData dataWithBytes: &layout length:
sizeof(AudioChannelLayout)], AVChannelLayoutKey,
[NSNumber numberWithInt:16], AVLinearPCMBitDepthKey,
[NSNumber numberWithBool:NO],
AVLinearPCMIsNonInterleaved,
[NSNumber numberWithBool:NO], AVLinearPCMIsFloatKey,
[NSNumber numberWithBool:NO],
AVLinearPCMIsBigEndianKey,
nil];
//get audioTracks from the AVAsset tracksWithMediaType:AVMediaTypeAudio
AVAssetReaderAudioMixOutput * newReaderOutput =
[AVAssetReaderAudioMixOutput
assetReaderAudioMixOutputWithAudioTracks:audioTracks
audioSettings:
_audioDecodeSettings];
//add output to AVAssetReader instance
//AVAssetReader startReading
then copyNextSampleBuffer. You must do some CF incantations to get
this data into the properly "retained" format and all that.
HTH
-Kevin
On Mon, Aug 19, 2013 at 1:46 PM, Richard Oths <email@hidden> wrote:
> Hello,
>
> Trying to convert compressed audio file dynamically and populating array
> with PCM sample integer amplitudes for further evaluation. Following the
> steps in http://www.subfurther.com/blog/category/ipod/ - I am good up to the
> point of writing to file via assetWriterInput object. But why can't i grab
> the decompressed sample data before they are written into file? My hunch is
> that there is more going on behind the scenes with the assetWriter in terms
> of conversion.
>
> Is AudioConverterFillComplexBuffer the correct approach to capture
> decompressed audio dynamically? Any examples are greatly appreciated.
>
> ~Mickey
>
> _______________________________________________
> 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