28 lines
785 B
Python
28 lines
785 B
Python
|
from pysine import pysine
|
||
|
import winsound
|
||
|
import threading
|
||
|
|
||
|
MODE = 'pysine'
|
||
|
|
||
|
global __beeper__
|
||
|
|
||
|
def __beeper_therad__(frequency: float, duration: float):
|
||
|
if MODE == 'winsound':
|
||
|
winsound.Beep(frequency=int(frequency), duration=int(duration*1000))
|
||
|
elif MODE == 'pysine':
|
||
|
pysine.sine(frequency=frequency,duration=duration)
|
||
|
|
||
|
__beeper__ = threading.Thread(target=__beeper_therad__,
|
||
|
kwargs={'frequency': 0, 'duration': 0}
|
||
|
)
|
||
|
|
||
|
def beep(frequency: float, duration: float):
|
||
|
global __beeper__
|
||
|
if not __beeper__.is_alive():
|
||
|
__beeper__ = threading.Thread(target=__beeper_therad__,
|
||
|
kwargs={'frequency': frequency, 'duration': duration}
|
||
|
)
|
||
|
__beeper__.start()
|
||
|
|
||
|
|