2spork@informatik.uni-hamburg.de
2005-Oct-09 03:43 UTC
[Vorbis-dev] ov_read_float vs. ov_read
Hello, Am I missing something? float** pcm_channels; int bitstream; int where = ov_pcm_tell(&vf); -> The Result is "0"; ov_read_float(&vf, &pcm_channels, 1, &bitstream); -> pcm_channels[0][0] is "0.000338580" ov_pcm_seek(&vf, 0); char* buffer = new char[2]; ov_read(&vf, buffer, sizeof(buffer), 0, 2, 1, &bitstream); short temp = *((short*)buffer); float test = temp / 32768.0f; -> test is "0.000335693" Why are the values different? Am I doing a wrong calculation? Or is "ov_read_float()" doing an other calculation? Thanx, Micha. ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.
On 10/9/05, 2spork@informatik.uni-hamburg.de <2spork@informatik.uni-hamburg.de> wrote:> Hello, > > Am I missing something?Yes. Integer rounding. You'll find that ov_read_float() returns a value (between -1 and 1), which, when multiplied by 32768, is not exactly an integer. That's perfectly normal, and not a problem. Mike