Reputation: 1053
when I am using the wave_read.readframes()
I am getting the result in binary data such as /x00/x00/x00:/x16#/x05"
etc a very long string
when asked for single frame it gives @/x00
or \xe3\xff
or so
I want this individual frame data in integer how can I convert them into integer to store them into array.
Upvotes: 2
Views: 6159
Reputation: 4690
If you want each byte in its own int, then I'd go with map:
b = '\xde\xad\xbe\xef'
d = map(ord, b)
print d
[222, 173, 190, 239]
If, however, you are interested in more than 1 byte per int (or word, dword, etc), reduce could do you well (big-endian example):
reduce(lambda x, r: (x << 8) + r, d[1:3])
44478
Upvotes: 1