• 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
How to play 24 bit pcm data using core audio ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to play 24 bit pcm data using core audio ?


  • Subject: How to play 24 bit pcm data using core audio ?
  • From: "Hari Prasad" <email@hidden>
  • Date: Mon, 19 May 2008 17:59:31 +0530

I am trying to play a 48kHz , 24 bit .pcm file using core audio. But I hear only noise.  I am using the PlayFile sample with some modifications,

I do not want to use a FilePlayer unit. 


In MakeSimpleGraph() I only create the output unit and set its format according to the .pcm files ASBD

absd.Print() gives:

format: ABSD:  2 ch,   8000 Hz, 'lpcm' (0x0000000C) 24-bit little-endian signed integer


  //create a default output unit

       ...

  // set the input callback for the output unit here :

renderCallbackStruct.inputProc = RenderProc;

AudioUnitSetProperty(outputUnit, kAudioUnitProperty_SetRenderCallback ... )


//set the output format for the output unit


CAAudioUnit outputAU = CAAudioUnit(outputNode,outputUnit);

XThrowIfError(outputAU.SetFormat(kAudioUnitScope_Input,0,absd),"Set Format");

In my Input Callback RenderProc, i read and copy the file data into the ioData->mBuffers.

This works correctly for a bit depth of 16, but for bit depths of 24,I hear noise.

And for a .pcm file with bit depth of 32, i dont hear anything. How should I copy data for bit depth other than 16 bits ? 


RenderProc(params...)

{

    OSStatus err= noErr;

if(feof(fp))

{

ioData->mBuffers[0].mData = NULL;

ioData->mBuffers[0].mDataByteSize = 0;

}


        // The data is in interleaved format

//read the pcm data into the buffer

fread(ioData->mBuffers[0].mData,ioData->mBuffers[0].mDataByteSize,1,fp);


    return err;

}


I saw some samples casting the iodata->mBuffers[0] to a Float32* and using it, How to do this for 24/32 bits ? 


Thanks 

Hari

 _______________________________________________
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

  • Prev by Date: Re: Built-in audio hardware question
  • Next by Date: Re: Built-in audio hardware question
  • Previous by thread: Re: Built-in audio hardware question
  • Next by thread: ExtAudioFileRead fails after reaching EOF, despite new seek position
  • Index(es):
    • Date
    • Thread