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

  • SEARCH
  • Home
  • 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 7634323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:08:32+00:00 2026-05-31T07:08:32+00:00

I’m trying to convert a PCM 32-bit float audio stream to ALAC. I found

  • 0

I’m trying to convert a PCM 32-bit float audio stream to ALAC. I found some working examples to build from, but my own code keeps getting a -50 (paramErr) from AudioConverterFillComplexBuffer. My eyes are crossing from looking at this code; I can’t see what’s different from my examples.

I set up my input and output formats and create the converter:

UInt32 numChannels = 2;

// Describe the input stream
AudioStreamBasicDescription inputFormat;
memset(&inputFormat, 0, sizeof(AudioStreamBasicDescription));
inputFormat.mSampleRate = 44100;
inputFormat.mFormatID = kAudioFormatLinearPCM;
inputFormat.mFramesPerPacket = 1; 
inputFormat.mChannelsPerFrame = numChannels;  
inputFormat.mFormatFlags = kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsPacked;
inputFormat.mBitsPerChannel = sizeof(Float32) * 8;
inputFormat.mBytesPerPacket = numChannels * (inputFormat.mBitsPerChannel / 8);
inputFormat.mBytesPerFrame = inputFormat.mBytesPerPacket * inputFormat.mFramesPerPacket;

// Describe the output stream
AudioStreamBasicDescription outputFormat;
memset(&outputFormat, 0, sizeof(AudioStreamBasicDescription));
outputFormat.mSampleRate = 44100;
outputFormat.mFormatID = kAudioFormatAppleLossless;
outputFormat.mFramesPerPacket = 4096;

OSStatus err = AudioConverterNew(&inputFormat, &outputFormat, &_alacConverter);

Then I get the maximum output packet size and allocate a buffer to hold the converted data:

size = sizeof(UInt32);
UInt32 maxOutputSize;
AudioConverterGetProperty(_alacConverter, 
                          kAudioConverterPropertyMaximumOutputPacketSize, 
                          &size, 
                          &maxOutputSize);

_outputBuffer = [[NSMutableData dataWithCapacity:maxOutputSize] retain];

Finally, I call AudioConverterFillComplexBuffer to get some data:

AudioBufferList bufferList; 
memset(&bufferList, 0, sizeof(AudioBufferList));
memset(&bufferList.mBuffers[0], 0, sizeof(AudioBuffer));

bufferList.mNumberBuffers = 1;
bufferList.mBuffers[0].mNumberChannels = numChannels;
bufferList.mBuffers[0].mDataByteSize = [_outputBuffer length];
bufferList.mBuffers[0].mData = [_outputBuffer mutableBytes];

AudioStreamPacketDescription streamDesc = {0};

UInt32 numPackets = 1;

err = AudioConverterFillComplexBuffer(_alacConverter, 
                                      _encoderDataProc, 
                                      self, 
                                      &numPackets, 
                                      &bufferList, 
                                      &streamDesc);

…where I always get the -50 error. Can anyone give me a clue where I’m going wrong? Many (many) thanks!

Update: I’m just using a stub function as the data source, which is never called:

OSStatus _encoderDataProc(AudioConverterRef inAudioConverter, 
                          UInt32* ioNumberDataPackets, 
                          AudioBufferList* ioData, 
                          AudioStreamPacketDescription** outDataPacketDescription,
                          void* inUserData)
{
    TraceDebug(@"_encoderDataProc has been called");
    return -1;
}

The maxOutputSize comes back as 32776. And for good measure, here’s what I get from CAShow(_alacConverter):

AudioConverter 0xa8404e (0x101c449f0):
  PCMConverter2 0x101c34370
    Input:   2 ch,  44100 Hz, 'lpcm' (0x00000009) 32-bit little-endian float
    Output:  2 ch,  44100 Hz, 'lpcm' (0x0000000C) 32-bit little-endian signed integer
  CodecConverter 0x101c44b90
    Input:   2 ch,  44100 Hz, 'lpcm' (0x0000000C) 32-bit little-endian signed integer
    Output:  2 ch,  44100 Hz, 'alac' (0x00000004) from 32-bit source, 4096 frames/packet
    codec: 'aenc'/'alac'/'appl'
    Input layout tag: 0x650002
    Output layout tag: 0x650002

As ever, any help is greatly appreciated. I’ve made no headway on this since the original post.

  • 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-31T07:08:34+00:00Added an answer on May 31, 2026 at 7:08 am

    I was stuck in the same situation (basically after using your code as a template). Solution seems to be in allocation of memory for the AudioBufferList. Implementing this answer did the trick for me (although my objective-C is not good enough to see the exact difference :))

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.