aboutsummaryrefslogtreecommitdiff
path: root/beepemu-pysinewave
blob: b74d19751d06c9964851173c4bd47a9a480b4bd1 (plain)
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
27
28
29
30
#!/usr/bin/python

import math
import sys
import time
from pysinewave import SineWave

i = 1
f = 0
l = 0
while i < len(sys.argv):
    if sys.argv[i] == '-f':
        i += 1
        f = float(sys.argv[i])
    elif sys.argv[i] == '-l':
        i += 1
        l = float(sys.argv[i])/1000
    elif sys.argv[i] == '-D':
        i += 1
        time.sleep(float(sys.argv[i])/1000)
    if f != 0 and l != 0:
        print(f, l)
        s = SineWave(pitch_per_second=1000)
        s.set_frequency(f)
        s.play()
        time.sleep(l)
        s.stop()
        f = 0
        l = 0
    i += 1