Data returned by scipy.io.wavfile.read

I am trying to get data from a wav file in Python and build it. When I use scipy.io.wavfile.read (), I return an array that looks like this:

[[ -1.49836736e-02  -1.27559584e-02]
 [ -1.84625713e-02  -1.63264061e-02]
 [ -2.17888858e-02  -1.95001373e-02]
 ..., 
 [  6.10332937e-05   6.10332937e-05]
 [ -3.05166468e-05   0.00000000e+00]
 [  3.05166468e-05  -6.10332937e-05]]

Why is it a bunch of arrays of length 2, and not one long array with a value in each sample? What is this data? Thanks in advance.

convert_16_bit = float(2**15)
sr, samples = scipy.io.wavfile.read('singingonenote.wav')
x = np.linspace(0, 2000, 0.01)
samples = samples / (convert_16_bit + 1.0)
y = samples
print samples
plt.plot(x, y)
plt.show()
+4
source share
1 answer

The file you are reading seems to be a stereo file. They contain two-dimensional data - one track for the left and one track for the right speaker.

The general concept is explained here: https://en.wikipedia.org/wiki/Stereophonic_sound

,

y = samples[:,0]

, 0 1.

, , , . , , .

+3

All Articles