Re: CAAudioFile writing on Panther
Re: CAAudioFile writing on Panther
- Subject: Re: CAAudioFile writing on Panther
- From: Craig Hopson <email@hidden>
- Date: Mon, 11 Sep 2006 13:46:26 -0600
On Sep 11, 2006, at 12:19 PM, Doug Wyatt wrote:
What are the file and data formats?
CAStreamBasicDescription outputFormat;
outputFormat.mChannelsPerFrame = 2;
outputFormat.mSampleRate = _graphSampleRate; // == 44100
outputFormat.mFormatID = kAudioFormatLinearPCM;
AudioFileTypeID destFileType; // will be kAudioFileAIFFType
CAAudioFileFormats::Instance()->InferFileFormatFromFilename
( outputFilePath, destFileType );
// dataFormat is kAudioFormatLinearPCM
outputFormat.mBytesPerPacket = outputFormat.mChannelsPerFrame * 2;
outputFormat.mFramesPerPacket = 1;
outputFormat.mBytesPerFrame = outputFormat.mBytesPerPacket;
outputFormat.mBitsPerChannel = 16;
// destFileType is kAudioFileAIFFType)
outputFormat.mFormatFlags = kLinearPCMFormatFlagIsBigEndian |
kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
CAAudioFile caOutFile;
FSRef parentDir;
CFStringRef destFileName;
require_noerr( result = PosixPathToParentFSRefAndName
( outputFilePath, parentDir, destFileName ), fail );
caOutFile.CreateNew( parentDir, destFileName, destFileType,
outputFormat );
CFRelease( destFileName );
require_noerr( result, fail );
Just as a sanity check, does the problem persist if you disable one
of the dual G5's processors?
Hmm... hadn't thought of trying that. I'll do that and get back to
you.
In the meantime, here's a little more (helpful?) info...
The audio processing runs on several threads - much like Apple's
DeferredRenderer, but of our own making, since we need it to work on
Panther.
Here is what is going on in heart of the export...
do {
if ([NSApp runModalSession:session] != NSRunContinuesResponse)
break;
outputBuffer.Prepare();
AudioUnitRenderActionFlags actionFlags = 0;
// pause that refreshes - let the processing threads have some
quality time...
usleep( 10000 ); // NOTE: 1,000 (actually much less) works for
dual G5 or 1GHz iBook running Tiger
// will 10,000 be enough for slower machines??
require_noerr( result = AudioUnitRender( outputUnit, &actionFlags,
&tStamp, 0, numFrames/*512*/, outputBuffer.ABL()), fail );
tStamp.mSampleTime += numFrames;
caOutFile.Write( numFrames, outputBuffer.ABL() );
require_noerr( result = MusicPlayerGetTime( player, ¤tTime ),
fail );
[progressIndicator setDoubleValue:(double)currentTime];
} while( currentTime < sequenceLength );
The usleep is there to provide enough time between buffer pulls to
allow the processing to keep current. If we increase that amount by
10X then export will work on the same G5 running Panther.
I'm sure that there is actually a slowdown when running on a single
processor system. However, on a given piece of hardware, the
difference between Tiger & Panther is day & night. I guess I don't
understand why export is so much affected, while playback is not.
With export I realize there is some file system overhead, but at the
same time the UI feedback (very expensive) is not present.
-Craig
Doug
On Sep 8, 2006, at 13:00 , Craig Hopson wrote:
This is a pure export - that is, we are not playing while
writing. On a 500 MHz Ti Powerbook running Tiger, export is
fine. However, on a 2 GHz dual G5 running Panther the export
doesn't work - we get drop outs, buzzing, etc. Audio playback
within the application is fine on all hardware/OS combinations
that we have tested. And, other than pulling for the audio
buffers ourselves (rather than the default output AU) and calling
CAAudioFile::Write() there are no differences between the export
and playback code.
--
Doug Wyatt
Core Audio, Apple
Craig Hopson
Red Rock Software
***************************************************
"If every household in the U.S. replaced one light bulb with an
ENERGY STAR qualified compact fluorescent light bulb (CFL), it would
prevent enough pollution to equal removing one million cars from the
road." http://www.energystar.gov/index.cfm?c=cfls.pr_cfls
_______________________________________________
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