0

I was reading this StackOverflow post:

How is audio represented with numbers?

According to the answer the digital signal will have one +ve component and one negative component. So i'm trying to relate this with a very basic wav audio file.

I'm reading all frames of one WAV audio file using python. I using below code:

import wave
import sys
ip = wave.open(sys.argv[1], 'r')
print ip.getparams()
for i in range(ip.getnframes()):
    iframe = ip.readframes(1)
    print iframe.encode('hex') , ' >>> ',int(iframe.encode('hex'), 16)
ip.close()

'''
Output :
C:\>python readframe.py test.wav
(1, 2, 44100, 176400, 'NONE', 'not compressed')
0000  >>>  0
0204  >>>  516
0008  >>>  8
f70b  >>>  63243
e10f  >>>  57615
bb13  >>>  47891
8217  >>>  33303
311b  >>>  12571
c41e  >>>  50206
3922  >>>  14626
8b25  >>>  35621
b728  >>>  46888
bb2b  >>>  47915
922e  >>>  37422
3b31  >>>  15153
b233  >>>  45619
f535  >>>  62773

'''

My question is how can I get the positive and negative component of the wav audio from each frame data ..??

Thanks in Advance,

Community
  • 1
  • 1
Dev.K.
  • 2,428
  • 5
  • 35
  • 49
  • Possible duplicate: [How to read *.wav file in Python?](http://stackoverflow.com/questions/2060628/how-to-read-wav-file-in-python) – David K Apr 01 '14 at 12:35

1 Answers1

1

Values larger than 32767 need to be subtracted from 2^16 to get their negative value converted from a 16-bit 2-complement signed representation.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153