[xiph-commits] r14520 -
experimental/ribamar/etheora/examples/encode_vorbis
ribamar at svn.xiph.org
ribamar at svn.xiph.org
Sat Feb 16 21:16:18 PST 2008
Author: ribamar
Date: 2008-02-16 21:16:18 -0800 (Sat, 16 Feb 2008)
New Revision: 14520
Modified:
experimental/ribamar/etheora/examples/encode_vorbis/README.txt
Log:
understanding how to read wav files and how to set the buffer from vorbis_ananlysis_buffer()
Modified: experimental/ribamar/etheora/examples/encode_vorbis/README.txt
===================================================================
--- experimental/ribamar/etheora/examples/encode_vorbis/README.txt 2008-02-16 23:50:45 UTC (rev 14519)
+++ experimental/ribamar/etheora/examples/encode_vorbis/README.txt 2008-02-17 05:16:18 UTC (rev 14520)
@@ -53,7 +53,7 @@
buffer = vorbis_analysis_buffer()
/* this buffer is a matrix where data read from the WAV file must be
-put. */
+put. see below in reading data from WAV how to fill this buffer. */
/* tell the library how much we actually submitted */
@@ -84,3 +84,39 @@
vorbis_info_clear(&vi);
+
+reading an wave file:
+http://ccrma.stanford.edu/courses/422/projects/WaveFormat/
+
+the fields we're interested in are (for configuring
+vorbis_encode_init...()):
+
+- SampleRate (little endian) 24th byte (starting from zero). 4 bytes of
+data. (eg 44100 Hz)
+
+- NumChannels 22nd byte (sf0). little endian. 2 bytes of data. (eg Stereo = 2)
+
+- BitsPerSample 34th byte (sf0). little. 2 bytes of data. (eg 16 bits)
+
+- BlockAlign: can be calculated ( NumChannels * BitsPerSample/8 ) or
+ read: 32nd byte (sf0). little endian. 2 bytes of data.
+
+
+understanding the
+ float **buffer = vorbis_analysis_buffer()
+
+buffer[0..(numChannels -1)][0..(i-1)] where i is the
+second parameter (buffer size) of vorbis_analysis_buffer(), which is
+an arbitrarily set value.
+
+see numChannels below, when we learn to read the wav files.
+
+the number 4 used several times in the code for the vorbis encode_example.c
+is the wav parameter BlockAlign.
+
+everything now needed to get the correct buffer value (for each
+channel) now is to convert from little to big endian and, finally,
+divide the result by 2^(BitsPerSample - 1).
+
+
+
More information about the commits
mailing list