Re: Possible bug in WAV export
- To: mathgroup at smc.vnet.net
- Subject: [mg87644] Re: Possible bug in WAV export
- From: Szabolcs <szhorvat at gmail.com>
- Date: Tue, 15 Apr 2008 05:47:58 -0400 (EDT)
- References: <ftsd0o$ba7$1@smc.vnet.net> <ftv8on$7kv$1@smc.vnet.net>
On Apr 14, 11:39 am, Jerry <Jer75... at yahoo.com> wrote: > The sound in Mathematica and the sound from the exported WAV file > (using some unknown player) seem the same to me. I'm using > V6.02 on a XP box. I experimented some more and it turns out that the problem is not limited to WAV (it is present with FLAC and AIFF too). However, the problem only appears randomly, and not in each evaluation. The following command does not always give the same result: ImportString[ ExportString[ Play[Sum[Sin[2 Pi 440 k t], {k, 1, 4}], {t, 0, 1}, SampleRate -> 44100, SampleDepth -> 16], "WAV"], "WAV"] In about 20 or so evaluations I always get a few incorrect results. It is not even necessary to play the sound---it is possible to see the difference by looking at the spectra: Table[ImportString[ ExportString[ Play[Sum[Sin[2 Pi 440 k t], {k, 1, 4}], {t, 0, 1}, SampleRate -> 44100, SampleDepth -> 16], "WAV"], "WAV"], {20}] Can anyone else reproduce this problem? It is very strange that the result is not deterministic. Any ideas why this might happen? To demonstrate that this unbelievable thing really happens, here's an another example, together with the result. Note that the very same command returns different results in subsequent evaluations: In[1]:= Table[ Total[#[[1, 1, 1]]] &@ ImportString[ ExportString[ Play[Sum[Sin[2 Pi 440 k t], {k, 1, 4}], {t, 0, 1}, SampleRate -> 44100, SampleDepth -> 16], "WAV"], "WAV"], {20}] Out[1]= {0., 268.745, -0.752563, -0.756226, -0.756226, -2.99866, 0., \ 0., -2.98279, 0., 0.756226, 341.993, 0., -0.752563, 0., 268.017, \ -0.752563, 0., -2.2522, 0.} The small fluctuations could be explained by dithering, but any reasonably precise result cannot have a sum of 342! The sound function was constructed in such a way that the sum should be 0.