How To Edit Raw Pcm Audio Data Without An Audio Library?
Solution 1:
I read the question and the answers and I feel that I must be missing something completely obvious, because nobody mentioned the following two modules:
Perhaps I come from a parallel universe and Guido's time machine is actually a space-time machine :)
Should you need example code, feel free to ask.
PS Assuming 48kHz sampling rate, a video frame at 24/1.001==23.976023976… fps is 2002 audio samples long, and at 25fps it's 1920 audio samples long.
Solution 2:
I've only written a PCM reader in C++ and Java, but the format itself is fairly simple. A decent description can be found here: http://ccrma.stanford.edu/courses/422/projects/WaveFormat/
Past that you should be able to just read it in (binary file reading, http://www.johnny-lin.com/cdat_tips/tips_fileio/bin_array.html) and just deal with the resulting array. You may need to use some bit shifting to get the alignments correct (https://docs.python.org/reference/expressions.html#shifting-operations) but depending on how you read it in, you might not need to.
All of that said, I'd still lean towards David's approach.
Solution 3:
Is it really important that your solution be pure Python, or would you accept something that can work with native audio libraries on various platforms (so it's effectively cross-platform)? There are several examples of the latter at http://wiki.python.org/moin/PythonInMusic
Solution 4:
Seems like a combination of open(..., "rb"), struct module, and some details about the wav/riff file format (probably better reference out there) will do the job.
Just curious, what do you intend on doing with the raw sample data?
Solution 5:
I was looking this up and I found this: http://www.swharden.com/blog/2009-06-19-reading-pcm-audio-with-python/ It requires Numpy (and matplotlib if you want to graph it)
import numpy
data = numpy.memmap("test.pcm", dtype='h', mode='r')
print "VALUES:",data
Check out the original author's site for more details.
Post a Comment for "How To Edit Raw Pcm Audio Data Without An Audio Library?"