Accessing an Audio stream ???
Accessing an Audio stream ???
- Subject: Accessing an Audio stream ???
- From: "Asher Vander Heiden" <email@hidden>
- Date: Sun, 18 Apr 2004 15:49:41 +1000
Hey, I've been trying to use the AudioToolbox to access an Audio stream
from an audio file.I want to open a file, manipulate the stream and then
save this as a new file.I've managed everything but manipulate the
stream. In the sample below I have saved the stream gEntireFileBuffer
and cannot view what is inside it!!!(I realise that there are other
things to consider when looking at the stream, like the offset and sample
size etc, but first I just want to be able to get to the file info). I'm
not too sure whether I'm on the right track here. Is it possible that I
need to use AUDIO CODEC or an AUDIO UNIT to access the stream ? void
*gEntireFileBuffer;
AudioFileID *gSourceAudioFileID;
UInt64 gTotalPacketCount=0;
UInt64 gFileByteCount =0;// my global vars
FSRef inParentRef;
FSRef inNewFileRef;
Boolean isDirectory;
CFStringRef inFileName;
FSRef outNewFileRef;
AudioFileID outAudioFile2;
UInt64 gSample;
int main (int argc, const char * argv[])
{
OSStatus err = noErr;
UInt32 size;
AudioStreamBasicDescription fileASBD;
AudioFileID musicFileID;
FSRef fileRef;
char *fileName ="/System/Library/Sounds/Blow.aiff";
UInt32 bytesReturned = 0;
UInt32 packets =gTotalPacketCount; //Obtain filesystem reference
to the file using the file path
FSPathMakeRef ((const UInt8 *)fileName, fileRef, 0);
//Open an AudioFile and obtain AudioFileID using the file system ref
err = AudioFileOpen(fileRef, fsRdPerm,0,gSourceAudioFileID );
//Get AudioFilePropertyDataFormat
size = sizeof(AudioStreamBasicDescription);
memset(fileASBD, 0, size);
err = AudioFileGetProperty(*gSourceAudioFileID,
kAudioFilePropertyDataFormat,
&size, fileASBD);
checkStatus(err); // Creating outfile
FSPathMakeRef ("/Developer/", &inParentRef, &isDirectory);
inFileName = CFSTR("NewAudioFile.aiff");
err = AudioFileCreate(&inParentRef,
inFileName,
'AIFF',
fileASBD,
0,
&outNewFileRef,
&outAudioFile2);
checkStatus(err); //alloc a buffer of memory to hold the data
read from disk.
gEntireFileBuffer = malloc(gFileByteCount);
memset(gEntireFileBuffer, 0, gFileByteCount); //Read in the ENTIRE
file into a memory buffer
err = AudioFileReadPackets (*gSourceAudioFileID,
false,
&bytesReturned,
NULL,
0,
&packets,
gEntireFileBuffer);
for(x=0;x<bytesReturned;x++)
{********** THIS IS WHERE I WANT TO ACCESS THE BUFFER
gEntireFileBuffer ********
********** TO DO MY MANIPULATION ..... HOW ??????????????
******************* }
err = AudioFileWritePackets(outAudioFile2,
false,
bytesReturned,
NULL,
0,
&packets,
gEntireFileBuffer);
checkStatus(err); //Cleaning anything allocated.
AudioFileClose(*gSourceAudioFileID); //Closes the audio files
AudioFileClose(outAudioFile2); if(gEntireFileBuffer !=NULL){
free(gEntireFileBuffer);
gEntireFileBuffer = NULL;
} return 0;
}
------------------------------------------------------------------------
Get Extra Storage in 10MB, 25MB, 50MB and 100MB options now! Upgrade
here!
http://ninemsn.com.au/share/redir/adTrack.asp?mode=click&clientID=265&referral=Hotmail_tagline_external_html&URL=http://join.msn.com/?pgmarket=en-au&page=hotmail/es2
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.