forked from imaoca/RTTY
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtty8k.py
22 lines (21 loc) · 834 Bytes
/
rtty8k.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import wave
import numpy as np
fname='rtty3s.wav' # should be specify the filename.
smp= 8000 # Sampling Rate
FQm= smp/914.0 # Mark Frequency 914Hz
FQs= smp/1086.0 # Space Frequency 1086Hz
wind= 32 # windows size Integer
waveFile = wave.open(fname, 'r')
mq=[];mi=[];sq=[];si=[]
for j in range(waveFile.getnframes()):
buf = waveFile.readframes(1)
mq.append((buf[0]-128)*np.sin(np.pi*2.0/FQm*j))
mi.append((buf[0]-128)*np.cos(np.pi*2.0/FQm*j))
sq.append((buf[0]-128)*np.sin(np.pi*2.0/FQs*j))
si.append((buf[0]-128)*np.cos(np.pi*2.0/FQs*j))
mk = np.sqrt(sum(mq)**2 + sum(mi)**2)
sp = np.sqrt(sum(sq)**2 + sum(si)**2)
print(mk,sp,int(mk>sp),sep=",")
if j>wind:
mq.pop(0);mi.pop(0);sq.pop(0);si.pop(0)
waveFile.close()