开发者

File decompression memory footprint

开发者 https://www.devze.com 2023-04-08 02:09 出处:网络
I want to process audio offline on iOS, but have a query regarding memory usage. If I use AVAssetRe开发者_如何学Cader to decompress an MP3 to raw PCM data, the memory footprint would be huge. So how w

I want to process audio offline on iOS, but have a query regarding memory usage. If I use AVAssetRe开发者_如何学Cader to decompress an MP3 to raw PCM data, the memory footprint would be huge. So how would I go about processing (offline FFT) an mp3 file if decompression would lead to the app using too much memory? I assume I have to stream it somehow, but I don't know how to do this in iOS.


AVAssetReader can write to a file using AVAssetWriter.

To get PCM, you can write a WAV file format, and then skip the RIFF header(s) on read. Then you only need to pull in as much data from the WAV file into memory at any one time as your FFT length requires. This should only cause a memory footprint problem if each FFT is well over 1 million samples long.

You can use C/unix posix calls (fgetc, etc.) to read a file stream under iOS. Or read from an NSInputStream into NSData.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号