RE: ExtAudioFileWrite, error -1031???
RE: ExtAudioFileWrite, error -1031???
- Subject: RE: ExtAudioFileWrite, error -1031???
- From: "Edwards, Waverly" <email@hidden>
- Date: Wed, 15 May 2013 17:19:03 -0500
- Acceptlanguage: en-US
- Thread-topic: ExtAudioFileWrite, error -1031???
>> Can't tell you about the -1031 (you sure you're logging it correctly?)
Yes, as soon as I perform the write process, I check for the error and that is the error that comes up every time
>> Try writing your Apple Lossless to a CAF file
I think I tried that earlier today but I will revisit it
I do appreciate the help. I'm just stumped. I have an error number that I can reproduce but cant find anywhere.
I checked the docs and I can create the file with the type that I want without issue but I cant write content from a buffer.
I'm using the same function, I'm only changing the ASBD.
Based on the docs, unless I'm reading them wrong I should be able to write a number of different file types
Any ideas are very much welcome,
W.
Creates a new audio file and associates it with a new extended audio file object.
OSStatus ExtAudioFileCreateWithURL (
CFURLRef inURL,
AudioFileTypeID inFileType,
const AudioStreamBasicDescription *inStreamDesc,
const AudioChannelLayout *inChannelLayout,
UInt32 inFlags,
ExtAudioFileRef *outExtAudioFile
);
Parameters
inURL
The URL of the new audio file.
inFileType
The type of file to create, specified as a constant from the Built-In Audio File Types enumeration.
Built-In Audio File Types
Operating system constants that indicate the type of file to be written or a hint about what type of file to expect from data provided.
enum {
kAudioFileAIFFType = 'AIFF',
kAudioFileAIFCType = 'AIFC',
kAudioFileWAVEType = 'WAVE',
kAudioFileSoundDesigner2Type = 'Sd2f',
kAudioFileNextType = 'NeXT',
kAudioFileMP3Type = 'MPG3',
kAudioFileMP2Type = 'MPG2',
kAudioFileMP1Type = 'MPG1',
kAudioFileAC3Type = 'ac-3',
kAudioFileAAC_ADTSType = 'adts',
kAudioFileMPEG4Type = 'mp4f',
kAudioFileM4AType = 'm4af',
kAudioFileCAFType = 'caff',
kAudioFile3GPType = '3gpp',
kAudioFile3GP2Type = '3gp2',
kAudioFileAMRType = 'amrf'
};
________________________________________
From: Chris Adamson [email@hidden]
Sent: Wednesday, May 15, 2013 1:46 PM
To: Edwards, Waverly
Cc: email@hidden
Subject: Re: ExtAudioFileWrite, error -1031???
Can't tell you about the -1031 (you sure you're logging it correctly?), but the root of your problem is probably that Core Audio only supports a handful of codecs in WAV files: little-endian PCM, maybe a-law and u-law, but that's about it.
Try writing your Apple Lossless to a CAF file, which is a content-agnostic format.
--Chris
On May 15, 2013, at 11:50 AM, "Edwards, Waverly" <email@hidden> wrote:
>
> I'm hoping someone can help me.
> I am attempting to write the contents of a buffer to a file using ExtAudioFileWrite.
> If I use an ASBD designed for 'WAVE' format everything works, the file is written to disk.
> If I use an ASBD designed for Apple Lossless ExtAudioFileWrite fails with error -1031.
>
> I have searched through the headers, the docs and Googled it but I cant find that error number anywhere.
> Below is a skeleton of what is going on in my program.
>
> Any ideas on what I'm doing wrong and what does error -1031 mean?
>
>
> Thanks,
>
>
> W.
>
>
> OSStatus CreateAudioOutputFile()
> {
> OSErr err;
> UInt8 numChannels;
> UInt32 numFrames;
> ABuffList aBuffList;
> CFURLRef outPathUrl;
> ASBDType outFileFormat;
> CFStringRef suffix;
> ExtAudioFileRef outAudioFile;
> AudioFileTypeID fileType;
>
> memset( &outFileFormat, 0, sizeof( ASBDType ) );
>
> if ( 1 ==1 )
> {
> fileType = kAudioFileM4AType;
> suffix = CFSTR( "m4a" );
>
> // this ASBD does NOT work with ExtAudioFileWrite
> outFileFormat.mSampleRate = 44100.0;
> outFileFormat.mFormatID = kAudioFormatAppleLossless;
> outFileFormat.mFormatFlags = kAppleLosslessFormatFlag_16BitSourceData;
> outFileFormat.mFramesPerPacket = 4096;
> outFileFormat.mChannelsPerFrame = 2;
> }
> else
> {
>
> numChannels = kChannelStereo;
> fileType = kAudioFileWAVEType;
> fileSuffix = CFSTR( "wav" );
>
> // this ASBD works with ExtAudioFileWrite
>
> outFileFormat.mSampleRate = 44100.0;
> outFileFormat.mFormatID = kAudioFormatLinearPCM;
> outFileFormat.mFormatFlags = (kAudioFormatFlagsNativeEndian) | ((kAudioFormatFlagIsPacked) | (kAudioFormatFlagIsSignedInteger));
> outFileFormat.mBytesPerPacket = 2 * numChannels;
> outFileFormat.mFramesPerPacket = 1;
> outFileFormat.mBytesPerFrame = 2 * numChannels;
> outFileFormat.mChannelsPerFrame = numChannels;
> outFileFormat.mBitsPerChannel = 16;
> outFileFormat.mReserved = 0;
> }
>
> outPathUrl = CreateFilePathInAppDirectory( kFinalOutFileName, suffix );
>
> // no problems here, handle errors
> err = ExtAudioFileCreateWithURL( outPathUrl, fileType, &outFileFormat, NULL, kAudioFileFlags_EraseFile, &outAudioFile );
>
>
> /* fill the buffer */
>
> // error (-1031) ??? when attempting to write apple lossless
> err = ExtAudioFileWrite( outAudioFile, numFrames, &aBuffList );
> return err;
> }
>
> _______________________________________________
> 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
_______________________________________________
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