Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6373439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:21:52+00:00 2026-05-25T01:21:52+00:00

I need to process audio that comes from the iPod library. The only way

  • 0

I need to process audio that comes from the iPod library. The only way to read an asset for the iPod library is AVAssetReader. To process audio with an Audio Unit it needs to be in stereo format so I have values for the left and right channels. But when I use AVAssetReader to read an asset from the iPod library it does not allow me to get it out in stereo format. It comes out in interleaved format which I do not know how to break into left and right audio channels.

To get to where I need to go I would need to do one of the following:

  1. Get AVAssetReader to give me an AudioBufferList in stereo format
  2. Convert the interleaved data to non-interleaved to get the stereo output I need
  3. Send it through Audio Queue Services to get what I need with automatic buffering

I seem to be limited by what the existing public API can do and what AVAssetReader supports when reading an iPod library asset. What would you do? How can I get what I need to process with an Audio Unit?

Another limitation that I have is that I cannot read an entire song at a time as it would fill up memory and crash the app. This is the reason I want to use the Audio Queue Services. If I can treat the asset from the iPod library as a stream in stereo format then all my requirements would be addressed.

Can this even be done? Are there any docs, blogs or articles anywhere that would explain how this could be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:21:53+00:00Added an answer on May 25, 2026 at 1:21 am

    Sounds like you have a couple questions stacked in there.

    When you setups an AVAssetReader you can pass in a dictionary of settings. Here is how I create my AVAssetReaders…

        AVAssetReader* CreateAssetReaderFromSong(AVURLAsset* songURL) {
    
        if([songURL.tracks count] <= 0)
            return NULL;
    
    
        AVAssetTrack* songTrack = [songURL.tracks objectAtIndex:0];
    
        NSDictionary* outputSettingsDict = [[NSDictionary alloc] initWithObjectsAndKeys:
    
                                            [NSNumber numberWithInt:kAudioFormatLinearPCM],AVFormatIDKey,
                                            //     [NSNumber numberWithInt:AUDIO_SAMPLE_RATE],AVSampleRateKey,  /*Not Supported*/
                                            //     [NSNumber numberWithInt: 2],AVNumberOfChannelsKey,   /*Not Supported*/
    
                                            [NSNumber numberWithInt:16],AVLinearPCMBitDepthKey,
                                            [NSNumber numberWithBool:NO],AVLinearPCMIsBigEndianKey,
                                            [NSNumber numberWithBool:NO],AVLinearPCMIsFloatKey,
                                            [NSNumber numberWithBool:NO],AVLinearPCMIsNonInterleaved,
    
                                            nil];
    
        NSError* error = nil;
        AVAssetReader* reader = [[AVAssetReader alloc] initWithAsset:songURL error:&error];
    
        {
            AVAssetReaderTrackOutput* output = [[AVAssetReaderTrackOutput alloc] initWithTrack:songTrack outputSettings:outputSettingsDict];
            [reader addOutput:output];
            [output release];
        }
    
        return reader;
    }
    

    So as far as splitting the Left and Right channel, you can loop over the data based on your ‘AVLinearPCMBitDepthKey’.

    So something like this for 16 bit…

    for (j=0; j<tBufCopy; j++, pAD+=2) {            // Fill the buffers...
        mProcessingBuffer.Left[(tBlockUsed+j)] = ((sint32)pAD[0]);
        mProcessingBuffer.Right[(tBlockUsed+j)] = ((sint32)pAD[1]);
    }
    

    Now I assume you need this for your processing. But having the data in interleaved format is really quite nice. You can generally take the straight interleaved format and pass it right back to the AudioQueue or Remote I/O callback and it will play correctly.

    In order to get the audio playing using the AudioQueue framework the data should follow this flow:

    AVAssetReader -> NSData Buffer -> AudioQueueBuffer

    Then in the AudioQueue callback where it asks for more data simply pass the AudioQueueBuffer. Something like…

    - (void) audioQueueCallback:(AudioQueueRef)aq  buffer:(AudioQueueBufferRef)buffer {
    
        memcpy(buffer->mAudioData, srcData, mBufferByteSize);
        //Setup buffer->mAudioDataSize
    
        //...
    
        AudioQueueEnqueueBuffer(mQueue, buffer, 0 /*CBR*/, 0 /*non compressed*/);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to process the shared library dependencies of a library from a bash
I need a way to extract the audio from some video (in PHP). I
I have a project that needs the fmod library, and I need to have
I need to process the incoming predefined ASN format data(coming from verity of clients
I have the next problem: I need to process only 1 request at a
I have a quite big XML output from an application. I need to process
I'm writing a CMS in ASP.NET/C#, and I need to process things like that,
What's the easiest way to implement lan interprocess communication? I need process on machine
I need to process credit card payments on an app that provides a service
I need to read some large files (from 50k to 100k lines), structured in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.