Raw audio packets to WAV/GSM_MS compliant file on Android
I'm looking for the logic/code-snippet which can convert my raw audio p开发者_StackOverflow社区ackets to WAV/GSM_MS complaint audio file. I'm able to capture data from android device mic and store it in buffer or file.
Assuming your raw data is already in interleaved, All you need is to prepend wave header in the beginning. The wave header format is given here https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
When you create a new wave file always write the header (with data length field set to zero as you dont know the entire size of data you wish to write at the at beginning of recording) then start writing your data immediately after the header, once you are done writing the data to it seek to the beginning and update the data length field. here http://www.codeproject.com/Articles/129173/Writing-a-Proper-Wave-File is a code for the same.
精彩评论