• 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: AudioConverter fails on SRC when formats are float -> float
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AudioConverter fails on SRC when formats are float -> float


  • Subject: Re: AudioConverter fails on SRC when formats are float -> float
  • From: James McCartney <email@hidden>
  • Date: Tue, 14 Oct 2003 17:55:08 -0700

> Although it provided 2048 samples to the converter and gets called
> every 512 samples

> RENDERER: Action Flags 0, Time Stamp 512.000000 (valid 1)
> DECODER: Bytes: 2976; Fs 32000; BytesPerFrame 8
> DECODER: Input format: Fs 32000, ID 1819304813, Fl 0xb, BpP 8, FpP 1,
> BpF 8, CpF 2, bpC 32, Res 0
> DECODER: Bytes: 16384 written

I get the behaviour I would expect from the program below. One input
proc call of 2048 frames@32khz yields 5 or 6 outputs of 512 frames
@44.1khz.

const int kInputBufFrames = 2048;
const int kChannelsPerFrame = 2;
float gInputBuffer[kInputBufFrames * kChannelsPerFrame];
double gPhase = 0.f;
double gFreq = 800. / 32000. * 2. * 3.14159265358979;

OSStatus testInputProc( AudioConverterRef inAudioConverter,
UInt32* ioNumberDataPackets,
AudioBufferList* ioData,
AudioStreamPacketDescription** outDataPacketDescription,
void* inUserData)
{
for (int i=0, k=0; i<kInputBufFrames; ++i)
{
gInputBuffer[k++] = sin(gPhase);
gInputBuffer[k++] = sin(1.2 * gPhase);
gPhase += gFreq;
}
ioData->mBuffers[0].mData = (void*)gInputBuffer;
ioData->mBuffers[0].mDataByteSize = kInputBufFrames *
kChannelsPerFrame * sizeof(float);
ioData->mBuffers[0].mNumberChannels = 1;
*ioNumberDataPackets = kInputBufFrames;
printf("<-testInputProc bytes %d frames %d\n",
ioData->mBuffers[0].mDataByteSize, *ioNumberDataPackets);
return noErr;
}


void testConverter()
{
AudioStreamBasicDescription a, b;
a.mSampleRate = 32000.;
a.mFormatID = 'lpcm';
a.mFormatFlags = kAudioFormatFlagIsFloat| kAudioFormatFlagIsBigEndian
| kLinearPCMFormatFlagIsPacked;
a.mFramesPerPacket = 1;
a.mBytesPerPacket = sizeof(float) * kChannelsPerFrame;
a.mBytesPerFrame = sizeof(float) * kChannelsPerFrame;
a.mChannelsPerFrame = kChannelsPerFrame;
a.mBitsPerChannel = sizeof(float) * 8;

b.mSampleRate = 44100.;
b.mFormatID = 'lpcm';
b.mFormatFlags = kAudioFormatFlagIsFloat| kAudioFormatFlagIsBigEndian
| kLinearPCMFormatFlagIsPacked;
b.mFramesPerPacket = 1;
b.mBytesPerPacket = sizeof(float) * kChannelsPerFrame;
b.mBytesPerFrame = sizeof(float) * kChannelsPerFrame;
b.mChannelsPerFrame = kChannelsPerFrame;
b.mBitsPerChannel = sizeof(float) * 8;

OSStatus err;
AudioConverterRef ref;
err = AudioConverterNew(&a, &b, &ref);
printf("AudioConverterNew err %d\n", err);

AudioBufferList outputBufferList;
const int kNumOutputFrames = 512;
float outputBuffer[kNumOutputFrames * kChannelsPerFrame];
outputBufferList.mNumberBuffers = 1;
outputBufferList.mBuffers[0].mData = (void*)outputBuffer;
outputBufferList.mBuffers[0].mDataByteSize = kNumOutputFrames *
kChannelsPerFrame * sizeof(float);

for (int i=0; i<20; ++i)
{
UInt32 numPackets = kNumOutputFrames;
err = AudioConverterFillComplexBuffer(ref, testInputProc, NULL,
&numPackets, &outputBufferList, NULL);
printf("<-AudioConverterFillComplexBuffer X frames %d\n", err,
numPackets);
}

AudioConverterDispose(ref);

}

-
james mccartney
apple coreaudio
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: magic cookies
  • Next by Date: Signaling the end of audio conversion
  • Previous by thread: Re: magic cookies
  • Next by thread: Signaling the end of audio conversion
  • Index(es):
    • Date
    • Thread