I need somewhere to save and then to retrieve Sint16 (2 bytes).
I get:
SInt16* frames = (SInt16*)inBuffer->mAudioData;
and want to save &frames[i]
somewhere (NSMutableData?) that could later easily retrieve. I tried to save like this (in cycle):
[recordedData appendBytes:&frames[i] length:1];
and retrieve:
SInt16* framesRetrieve ;
//sets up mybytes buffer and reads in data from myData
framesRetrieve = (SInt16*)malloc([mutableData framesRetrieve]);
[mutableData getBytes:framesRetrieve];
But this return not the same as i put into.
So what could be a solution ?
thanks.
You need to know the length of the data and then you can store the whole buffer in an
NSMutableData
object:To store:
To retrieve: