views:

104

answers:

1

Hi

I am trying to write some data to the beginning of an audio file. But the file is getting overwritten. If I write data worth 20 seconds to the beginning of the audio file using AudioFileWritePackets, the initial 20 seconds of data is overwritten in the original audio file.

This is what I use

AudioFileOpenURL((CFURLRef)flUrl, kAudioFileReadWritePermission, 0, &audioId);
//initialize my 20 sec data into a buffer
AudioFileWritePackets(audioId, FALSE, numBytesToWrite, NULL, 0, &packetsToWrite, packBuffer);

Can someone please tell me how I can achieve this (prepend the 20 sec worth of audio to the original audio file)

Thanks.

A: 

You're going to need to open a new file, write your new data to it, and then copy the old audio from the old file to the end of the new file.

David Maymudes
Thanks thats what I ended up with! Couldn't find any other way to prepend data to an audio file.
lostInTransit