AudioFileTools
AudioFileTools
- Subject: AudioFileTools
- From: Simon Brée <email@hidden>
- Date: Sun, 1 Jan 2006 19:14:24 +0100
Hi,
I'm working with the example /Developer/Examples/CoreAudio/Services/
AudioFileTools/AudioFileTools.xcodeproj,
which is working fine.
Now, I'm just trying to add to it an interface, but have some
problems: the audio file is well created and his size increase but
when trying in Audacity the file is empty and when opening with
quicktime it says "This file is not reconnize by Quicktime".
The way I did it:
- I declare in the controller of my GUI the recorder :
CAAudioFileRecorder *recorder;
- I Initilize recorder in my controller when pressing the start
button in that way :
// set up defaults
AudioFileTypeID filetype = kAudioFileAIFFType;
CAStreamBasicDescription dataFormat;
dataFormat.mSampleRate = 44100.; // later get this from the hardware
dataFormat.mFormatID = kAudioFormatLinearPCM;
dataFormat.mFormatFlags = kAudioFormatFlagIsBigEndian |
kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
dataFormat.mFramesPerPacket = 1;
dataFormat.mChannelsPerFrame = 2;
dataFormat.mBitsPerChannel = 16;
dataFormat.mBytesPerPacket = dataFormat.mBytesPerFrame = 4;
SInt32 bitrate = -1, quality = -1;
if (dataFormat.IsPCM())
dataFormat.ChangeNumberChannels(2, true);
else
dataFormat.mChannelsPerFrame = 2;
try {
const int kNumberBuffers = 3;
const unsigned kBufferSize = 0x8000;
delete recorder; recorder = NULL;
recorder = new CAAudioFileRecorder (kNumberBuffers, kBufferSize);
NSURL *theNSURLPath = [[NSURL alloc] initFileURLWithPath:
[Preferences objectForKey:SaveDirectory]];
FSRef parentDir;
CFURLRef theCFURLRef = (CFURLRef)theNSURLPath;
CFURLGetFSRef(theCFURLRef, &parentDir);
[theNSURLPath release];
CFStringRef filename = CFStringCreateWithCString(NULL, "Magneto",
kCFStringEncodingUTF8);
recorder->SetFile(parentDir, filename, filetype, dataFormat, NULL);
CAAudioFile &recfile = recorder->GetFile();
if (bitrate >= 0)
recfile.SetConverterProperty(kAudioConverterEncodeBitRate, sizeof
(UInt32), &bitrate);
if (quality >= 0)
recfile.SetConverterProperty(kAudioConverterCodecQuality, sizeof
(UInt32), &quality);
recorder->Start();
}
catch (CAXException &e) {
char buf[256];
fprintf(stderr, "Error: %s (%s)\n", e.mOperation,
CAXException::FormatError(buf, e.mError));
}
catch (...) {
fprintf(stderr, "An unknown error occurred\n");
}
- I stop recording the following way in the same controller file when
pressing an other button with:
recorder->Stop();
Do you see what I'm doing wrong?
Thanks for any help and happy new year to all.
Simon
_______________________________________________
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