私の目標は、pyaudio によって提供された文字列を正しく int16 に解凍して変更を加え、再度パックして再生することです。
これは私がこれまでに得たものです(コードは他の投稿からコピーされました):
#data contains my string of interleaved int16 data
#this code should unpack it accordingly
# 1 short out of each 2 chars in data
count = len(data)/2
format = "%dh"%(count) #results in '2048h' as format: 2048 short
shorts = struct.unpack(format, data)
#here some modifications will take place but are left out to test packing
#now i need to pack my short data back to pyaudio compliant string
#i have tried the following with no success. just random noise
struct.pack(str(len(shorts)*2) + "s", str(shorts))
今私の質問:
struct.pack
データをpyaudio文字列に戻すための正しい引数は何ですか?