• 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: Convert an in-memory AAC file to LPCM
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Convert an in-memory AAC file to LPCM


  • Subject: Re: Convert an in-memory AAC file to LPCM
  • From: Chris Adamson <email@hidden>
  • Date: Wed, 24 Sep 2014 18:11:31 -0400

Is this streaming? Audio File Stream services would be a nice way to parse the format for you. We don't cover it in the book, but I do show it in my CocoaConf class (I can send you the web radio player sample code) or that "live lessons" video thing I did for Pearson.

Only thing is, once you start using Audio File Stream, you're kind of locked into it: you feed raw blocks of NSData to it, and it calls you back with metadata and parsed packets. Maybe that'll work for you, maybe not.

-Chris

Sent from my iPad

On Sep 24, 2014, at 5:25 PM, Richard <email@hidden> wrote:

Chris,

Yes, I can change the callback function as you suggest. However, my app does not 
know in advance how the AAC file was encoded ( e.g. the  sampling rate). 

My understanding that the AAC file starts with a header that describes the format of
the rest of the audio data and this header needs to be parsed and mapped into an
ASBD. I know that the Audio File services API does this - is there any other API that 
can do the same thing but from an NSData object rather than by reading an actual file? 
I would like to avoid having to write code to parse the header of the AAC file myself.

Also, I guess the audio bytes start after this header, So I need to know the size of this
header so that I can skip past it to get to the audio data.

Once those two problems (getting the ASBD and figuring out how many bytes to skip 
over), are out of the way, I can do as you say and read out the rest of the audio bytes 
in my callback function.

Also, you mentioned using Audio Queue for conversions - I haven't used Audio Queue
myself, but I can go and look it up. However, I presume that the Audio Queue APIs also
need an ASBD so wouldn't I run into the same problem - how to generate an ASBD and 
how to know how many bytes of header to skip over.

Richard


On Wed, Sep 24, 2014 at 3:45 PM, Chris Adamson <email@hidden> wrote:
Should work a lot like that example, except that in your case the callback function that provides the data to convert (MyAudioConverterCallback() in that example) would just be advancing a pointer through your NSData, rather than calling AudioFileReadPackets().

FWIW, I freaking hate Audio Converter Services, and when I've had to do this myself, I sometimes will just use an offline AudioQueue to do format conversions. It simplifies buffering and is more streaming-friendly.

Hope this helps.

—Chris

On Sep 24, 2014, at 3:33 PM, Richard <email@hidden> wrote:

I have an iOS app that receives an AAC file over the network into an NSData buffer, and I would like to convert the received file to LPCM.

I saw the example in chapter 6 of the Core audio book using the Audio File services API.  This does what I want except for one thing; it expects the AAC file data to be in a file.

I could possibly save the received AAC bytes that from the NSData object into a file and then use the example from the CoreAudio book. However, I would like to avoid that step as I really have no use for that file apart from that conversion. It seems like a waste and it would also increase the latency for the AAC to LPCM conversion.

When I looked at the Audio File Services document,

https://developer.apple.com/library/ios/documentation/MusicAudio/Reference/AudioFileConvertRef/index.html

I saw this line:

This document describes Audio File Services, a C programming interface that enables you to read or write a wide variety of audio data to or from disk or a memory buffer.

But when I looked at the documentation, the functions seems to require a file id. They appear to be memory to file or file to memory conversions, and not memory to memory (I know that you can do memory to memory conversions from one LPCM format to another, but that is not what I need).

Is there any way to do this conversion without using a file as a staging area?

Richard

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
  • Follow-Ups:
    • Re: Convert an in-memory AAC file to LPCM
      • From: Richard <email@hidden>
References: 
 >Convert an in-memory AAC file to LPCM (From: Richard <email@hidden>)
 >Re: Convert an in-memory AAC file to LPCM (From: Chris Adamson <email@hidden>)
 >Re: Convert an in-memory AAC file to LPCM (From: Richard <email@hidden>)

  • Prev by Date: Re: Convert an in-memory AAC file to LPCM
  • Next by Date: Re: Convert an in-memory AAC file to LPCM
  • Previous by thread: Re: Convert an in-memory AAC file to LPCM
  • Next by thread: Re: Convert an in-memory AAC file to LPCM
  • Index(es):
    • Date
    • Thread