Re: File format conversion
Re: File format conversion
- Subject: Re: File format conversion
- From: William Stewart <email@hidden>
- Date: Tue, 3 Feb 2009 15:43:27 -0800
you probably need to set the IsPacked bit in the format flags - if I
do afinfo on an aiff file:
File: /System/Library/Sounds/Submarine.aiff
File type ID: AIFF
Data format: 2 ch, 44100 Hz, 'lpcm' (0x0000000E) 16-bit big-
endian signed integer
no channel layout.
estimated duration: 0.975 sec
audio bytes: 171992
audio packets: 42998
bit rate: 1411200 bits per second
packet size upper bound: 4
audio data file offset: 54
optimized
----
So, your format flags aren't complete. You need:
kAudioFormatFlagIsBigEndian
kAudioFormatFlagIsSignedInteger
kAudioFormatFlagIsPacked
Are you checking result codes from your AudioFile... calls - I could
imagine you have an error being returned somewhere
The third arg to AudioFileWriteBytes is the byte offset to put the
data at - you would need to increment it as you write (it doesn't work
like a stream)
Also, yes, you'll need an audio converter to convert the little endian
wav data to the big endian AIFF data
Bill
On Feb 3, 2009, at 3:29 PM, Fredrik wrote:
Hi,
I´m trying to make a format converter that converts from two
uncompressed formats, in this case wav to aif.
I have managed to create the new file (aif) with the correct header
but some of the fields in the header doesn´t reflect
the actual size of the data but only an empty header. So in this
case the FORM chunk size is 4088 bytes, number of sample frames is 0
and the SSND chunk size is 8.
I don´t get where the problem could be, I have looked over the
AudioStreamBascDescription struct that I have filled in like this:
AudioStreamBasicDescription OutFormat;
OutFormat.mSampleRate = 44100;
OutFormat.mFormatID = kAudioFormatLinearPCM;
OutFormat.mFormatFlags = kAudioFormatFlagIsBigEndian;
OutFormat.mBytesPerPacket = 2;
OutFormat.mFramesPerPacket = 1;
OutFormat.mBytesPerFrame = 2;
OutFormat.mChannelsPerFrame = 1;
OutFormat.mBitsPerChannel = 16;
The file is mono, 16 bit 44.1
I then write the file like this, I have checked the size of
propertyData and it´s correct.
AudioFileWriteBytes(convertedFile,
false,
0,
&propertyData,
&buf.mData);
I guess that I also need a AudioConverter to perform endian
conversion on the data but is that the reason that the size
fields of the header is missed?
_______________________________________________
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