Bug introduced in 11.3 or earlier
CASE:4075745
I have been experimenting with using Audio
and associated functions for data acquisition using an external sound card. I came across a bizarre problem with generated sine waves, where jagged teeth would appear in the waveform.
ListLinePlot[
AudioData[
AudioGenerator[{"Sin", 1000}, 0.1, SampleRate -> 48000]
][[1, ;; 100]]
]
This is a problem in the audio itself and not a display or data extraction error, as verified by looking at the output of the sound card on an oscilloscope. This originally occurred when using AudioGenerator
, but the error persisted when passing an array of Sin
values to Audio
.
The problem appears to be caused by Audio
interpreting high-precision (but not exact) values of 1/2 as 0.25.
a = N[{Sin[(25*Pi)/6], 1/2, 0.5, 0.4999999, 0.49999999, Sin[(25.*Pi)/6]}]
(* {0.5, 0.5, 0.5, 0.5, 0.5, 0.5} *)
First[AudioData[Audio[a]]]
(* {0.5, 0.5, 0.5, 0.5, 0.25, 0.25} *)
This error was observed on 11.3 on macOS, but also occurs on Mathematica Online. The issue has been reported to Wolfram support [CASE:4075745].
Audio
uses 32 bitmaybe try AudioData[Audio[a, "Real"]]
? $\endgroup$First@AudioData@Audio@Table[Sin[x], {x, 0, 10, 0.1}] // ListLinePlot
. $\endgroup$Audio[..., "Real"]
. $\endgroup$