I am writing a program for me to better understand the PyAudio module, in trying to understand how best to manipulate the audio stream, I convert the last 10 values of the first chunk into integers and compare it with the corresponding original bytes data, but the format and style of the byte stream don't make sense to me.
import pyaudio
p = pyaudio.PyAudio()
stream = p.open(44100,1,pyaudio.paInt16,True,frames_per_buffer=1024)
frames = []
arrNum = []
try:
while True:
data = stream.read(1024)
frames.append(data)
except KeyboardInterrupt:
pass
stream.stop_stream()
stream.close()
p.terminate()
for i in range (len(frames[0])-10,len(frames[0])):
arrNum.append(frames[0][i])
print(frames[0][-10:])
print(arrNum)
I ran this code for 2 different sounds and got these outputs
b'y\x0b\xdc\x0b\xaf\x0b.\n"\t'
[121, 11, 220, 11, 175, 11, 46, 10, 34, 9]
b'\xfe\xff\r\x00\x0c\x00\x00\x00\xfe\xff'
[254, 255, 13, 0, 12, 0, 0, 0, 254, 255]
firstly, how does \r\ convert to 13 or \x0b.\ convert to 11 ect, this doesn't seem to be hex is it something else? secondly, the first byte output doesn't contain the tail end of numbers that the array contains, why is this ?