-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathafsk.py
26 lines (23 loc) · 814 Bytes
/
afsk.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from audioroutines import *
def generateAFSKpcmData(markF, spaceF, bitrate, sampRate, sampWidth, peakLevel, numCh,
stringData):
"Generate a string of binary data of AFSK audio"
pcm_data = ''
bitstream = ''
bitduration = 1.0 / bitrate
print stringData
for byte in stringData:
bytebits = "{0:08b}".format( ord(byte))
bitstream += bytebits[::-1]
#bitstream += bytebits
#print bitstream
one_bit = generateSimplePCMToneData(markF, markF, sampRate, bitduration, sampWidth,
peakLevel, numCh)
zero_bit = generateSimplePCMToneData(spaceF, spaceF, sampRate, bitduration, sampWidth,
peakLevel, numCh)
for bit in bitstream:
if bit == '1':
pcm_data += one_bit
else:
pcm_data += zero_bit
return pcm_data