Question

I have an android application that records AUDIO in raw format how can i extract a sample of the recording? for example if the raw file has 3 minutes of audio recorded, i would like to extract 20 seconds of the contents from an arbitrary start position is this possible?

Was it helpful?

Solution

If the file contains interleaved PCM data with no header and you know the properties of the audio data (sample rate, number of channels, etc) the problem can be solved with basic math:

The number of bytes of audio data per second is sampleRate * bytesPerSample * numChannels.

The starting offset in bytes would be then be bytesPerSecond * offsetInSeconds, and the size of the chunk to read (in bytes) would be bytesPerSecond * lengthInSeconds.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top