3 # Simple script to convert pm3 traces to something audible
4 sampleRate
= 16000.0 # hertz, so we're scaling the 125kHz to 16kHz
12 with
open(sys
.argv
[1]) as pm3
:
13 data
= np
.fromfile(pm3
, dtype
=int, sep
="\n")
16 repeat
= int(sys
.argv
[2], 10)
18 repeat
= default_repeat
20 ofile
= sys
.argv
[1].replace('pm3', 'wav')
21 if ofile
== sys
.argv
[1]:
22 ofile
= sys
.argv
[1]+'.wav'
23 obj
= wave
.open(ofile
,'w')
24 obj
.setnchannels(1) # mono
26 obj
.setframerate(sampleRate
)
28 for i
in range(repeat
):
31 obj
.writeframesraw( struct
.pack('<h', d
*factor
) )
33 print("B:" , d
, d
*factor
)