私はDSP関連のiOSアプリに取り組んでいます。作業の一部は、データ処理のためにoutBuffer->mAudioDataからユーザー指定の配列にオーディオデータをコピーすることです。readメソッドは次のようになります。
OSStatus result = AudioFileReadPackets(myInfo->mAudioFile, // The audio file from which packets of audio data are to be read.
false, // Set to true to cache the data. Otherwise, set to false.
&numBytes, // On output, a pointer to the number of bytes actually returned.
myInfo->mPacketDescs, // A pointer to an array of packet descriptions that have been allocated.
myInfo->mCurrentPacket, // The packet index of the first packet you want to be returned.
&nPackets, // On input, a pointer to the number of packets to read. On output, the number of packets actually read.
outBuffer->mAudioData); // A pointer to user-allocated memory.
このプロセスは成功しています。しかし、outBuffer-> mAudioDataからデータを読み取ろうとすると、「void*const」から「SInt16*」への無効な変換を示すエラーが常に発生します。
outBuffer->mAudioDataByteSize = numBytes;
SInt16 *testBuffer = outBuffer->mAudioData; //Read data from buffer... Error!
for (int i=0; i<numBytes; i++)
{
UInt16 currentData = testBuffer[i];
printf("Current data in testbuffer is %d", currentData);
}
THISやTHISのようないくつかの関連する質問を経験しましたが、それらは機能しているようです... AudioFileReadPackets()でoutBuffer-> mAudioDataをtestBufferに置き換えようとしましたが、testBufferは空の配列であることがわかりました。
それで、それは正しいアプローチですか?生データをint/float配列に読み取る他の方法はありますか?
または、より一般的には、void定数ポインターにアクセスして読み取り/書き込み操作を実行する方法は?(ええ、私のC ++はそれほど強力ではありません...)
どんな助けでもありがたいです:-)
乾杯、マンカ