iphone - How to use Audio File Services to get the raw data of an audio file? -
i'm trying use audio file services audiotoolbox framework raw data wav file. specifically, i'm using audiofilereadbytes() call bytes. here relevant code have:
nsstring *audiofilepath = [[nsstring stringwithcstring:argv[1] encoding:nsutf8stringencoding] stringbyexpandingtildeinpath]; nsurl *audiourl = [nsurl fileurlwithpath:audiofilepath]; audiofileid audiofile; osstatus theerr = noerr; uint64 filedatasize = 0; audiostreambasicdescription thefileformat; uint32 thepropertysize = sizeof(thefileformat); theerr = audiofileopenurl((cfurlref)audiourl, kaudiofilereadpermission, 0, &audiofile); thepropertysize = sizeof(filedatasize); theerr = audiofilegetproperty(audiofile, kaudiofilepropertyaudiodatabytecount, &thepropertysize, &filedatasize); //read data buffer uint32 datasize = filedatasize; void* thedata = malloc(datasize); if (thedata) { audiofilereadbytes(audiofile, false, 0, &datasize, thedata); // create nsdata object hold buffer data nsdata* nsdata = [nsdata datawithbytesnocopy:thedata length:datasize]; //? }
now question is: after create nsdata object (nsdata), how numbered values (like if 'wavread' in matlab give me array of floats) can manipulate values(e.g. pass through filter)?
any input appreciated!
i'm not sure why need nsdata object @ all.
using audiofilegetproperty kaudiofilepropertydataformat, should able determine type of audio data (e.g. array of floats) etc, , therefore how interpret "thedata".
Comments
Post a Comment