| 1 |
#!/usr/bin/env python3 |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# Fenrir TTY screen reader |
| 5 |
# By Chrys, Storm Dragon, and contributors. |
| 6 |
|
| 7 |
from fenrirscreenreader.core import debug |
| 8 |
from fenrirscreenreader.core.soundDriver import sound_driver |
| 9 |
|
| 10 |
|
| 11 |
class driver(sound_driver): |
| 12 |
def __init__(self): |
| 13 |
sound_driver.__init__(self) |
| 14 |
|
| 15 |
def initialize(self, environment): |
| 16 |
self.env = environment |
| 17 |
self._initialized = True |
| 18 |
print("Sound Debug Driver: Initialized") |
| 19 |
|
| 20 |
def shutdown(self): |
| 21 |
if not self._initialized: |
| 22 |
return |
| 23 |
self.cancel() |
| 24 |
self._initialized = False |
| 25 |
print("Sound Debug Driver: Shutdown") |
| 26 |
|
| 27 |
def play_frequence( |
| 28 |
self, frequence, duration, adjust_volume=0.0, interrupt=True |
| 29 |
): |
| 30 |
if not self._initialized: |
| 31 |
return |
| 32 |
if interrupt: |
| 33 |
self.cancel() |
| 34 |
print( |
| 35 |
"Sound Debug Driver: play_frequence:" |
| 36 |
+ " freq:" |
| 37 |
+ str(frequence) |
| 38 |
+ " duration:" |
| 39 |
+ str(duration) |
| 40 |
+ " adjust_volume:" |
| 41 |
+ str(adjust_volume) |
| 42 |
) |
| 43 |
print("Sound Debug Driver: -----------------------------------") |
| 44 |
|
| 45 |
def play_sound_file(self, file_path, interrupt=True): |
| 46 |
if not self._initialized: |
| 47 |
return |
| 48 |
if interrupt: |
| 49 |
self.cancel() |
| 50 |
print("Sound Debug Driver: play_sound_file:" + str(file_path)) |
| 51 |
print("Sound Debug Driver: -----------------------------------") |
| 52 |
|
| 53 |
def cancel(self): |
| 54 |
if not self._initialized: |
| 55 |
return |
| 56 |
print("Sound Debug Driver: Cancel") |
| 57 |
|
| 58 |
def set_callback(self, callback): |
| 59 |
if not self._initialized: |
| 60 |
return |
| 61 |
print("Sound Debug Driver: set_callback") |
| 62 |
|
| 63 |
def set_volume(self, volume): |
| 64 |
if not self._initialized: |
| 65 |
return |
| 66 |
self.volume = volume |
| 67 |
print("Sound Debug Driver: set_volume:" + str(self.volume)) |