ExtendedAudioFile problems
ExtendedAudioFile problems
- Subject: ExtendedAudioFile problems
- From: patrick machielse <email@hidden>
- Date: Sun, 1 Jul 2007 23:24:10 +0200
Hi,
I'm trying to use the convenient ExtendedAudioFile API, but I'm
running into some basic problems.
This is my test program:
===
#import <Foundation/Foundation.h>
#import <CoreAudio/CoreAudio.h>
#import <AudioToolbox/AudioToolbox.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// create FSRef for output directory
NSString *desktop = [@"~/Desktop" stringByExpandingTildeInPath];
NSURL *desktopURL = [NSURL fileURLWithPath:desktop];
FSRef desktopRef;
if ( !CFURLGetFSRef((CFURLRef)desktopURL, &desktopRef) ) {
NSLog(@"could not create FSRef for desktop folder\n");
return 1;
}
// some standard stream description
AudioStreamBasicDescription asbd;
asbd.mSampleRate = 44100;
asbd.mFormatID = kAudioFormatLinearPCM;
asbd.mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
asbd.mBytesPerPacket = 2 * sizeof (float);
asbd.mFramesPerPacket = 1;
asbd.mBytesPerFrame = 2 * sizeof (float);
asbd.mChannelsPerFrame = 2;
asbd.mBitsPerChannel = 8 * sizeof (float);
// create audio file
ExtAudioFileRef audiofile = NULL;
OSStatus error = noErr;
error = ExtAudioFileCreateNew(&desktopRef,
(CFStringRef)@"test",
kAudioFileCAFType,
&asbd,
NULL,
&audiofile);
if ( error ) {
NSLog(@"could not create new file (%ld)\n", error);
return 1;
}
// close file (should remove it)
error = ExtAudioFileDispose(audiofile);
if ( error ) {
NSLog(@"could not dispose of file (%ld)\n", error);
}
[pool release];
return 0;
}
===
This program exits with status 0, but the created file isn't removed,
which is what according to the documentation should happen.
The documentation also stipulates that async file writing using
ExtAudioFileWriteAsync can be primed as follows: "You can call this
with 0 frames and null buffer in a non-time-critical context to
initialize the asynchronous mechanism". However when I try to do so
using this code:
ExtAudioFileWriteAsync(audiofile, 0, NULL);
or this code, looking for a solution:
AudioBufferList ioData;
ioData.mNumberBuffers = 1;
ioData.mBuffers[0].mData = NULL;
error = ExtAudioFileWriteAsync(audiofile, 0, ioData);
I drop right into the debugger... :-(
I suppose this is easy to fix. Can anyone help me?
patrick
_______________________________________________
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