Skip to content

Commit 249726b

Browse files
committed
CoderBot audio env + Library for music class
1 parent fd8be44 commit 249726b

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

music.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,31 @@
2727
############################################################################
2828

2929
import os
30+
import sox
3031

32+
class Music:
3133

32-
class Musical:
34+
_instance = None
35+
36+
@classmethod
37+
def get_instance(cls):
38+
if cls._instance is None:
39+
cls._instance = Music()
40+
return cls._instance
3341

3442
def __init__(self):
35-
print("We have create a class: MUSICAL")
43+
os.putenv('AUDIODRIVER', 'alsa')
44+
os.putenv('AUDIODEV', 'hw:1,0')
45+
print("We have create a class: MUSICAL")
46+
47+
def test(self):
48+
tfm = sox.Transformer()
49+
tfm.preview('cat.wav')
50+
51+
if __name__ == "__main__":
52+
a = Music()
53+
54+
a.test()
55+
a.test()
56+
a.test()
57+
a.test()

requirements_stub.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ setuptools==42.0.1
4444
smbus2==0.3.0
4545
spidev==3.4
4646
cachetools==3.0.0
47+
48+
sox==1.3.7
49+
pyalsaaudio==0.8.4

0 commit comments

Comments
 (0)