Skip to content

Commit 37efde2

Browse files
MicheleCarboneraMicheleCarbonera
authored andcommitted
add interface for front-end sys for Music-Ext
1 parent cc9177e commit 37efde2

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

music.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ def get_instance(cls,managerPackage):
4848
return cls._instance
4949

5050
def __init__(self,managerPackage):
51-
os.putenv('AUDIODRIVER', 'alsa')
52-
os.putenv('AUDIODEV', 'hw:1,0')
51+
52+
#os.putenv('AUDIODRIVER', 'alsa')
53+
#os.putenv('AUDIODEV', 'hw:1,0')
5354
self.managerPackage = managerPackage
5455
print("We have create a class: MUSICAL")
5556

@@ -68,7 +69,8 @@ def play_pause(self, duration):
6869
# @param note: name of the note in the following format "A2"
6970
# @para alteration: if it is a diesis or a bemolle
7071
# @param time: duration of the note in seconds
71-
def play_note(self, note, alteration='none', time=1.0, instrument='piano'):
72+
def play_note(self, note, instrument='piano', alteration='none', time=1.0):
73+
print(note)
7274
tfm = sox.Transformer()
7375

7476
time = float(time)
@@ -134,17 +136,3 @@ def play_animal(self, instrument, note='G2', alteration='none', time=1.0):
134136
tfm.trim(0.0, end_time=0.5*time)
135137
#tfm.stretch(time, window=20)
136138
tfm.preview('./sounds/notes/' + instrument + '/audio.wav')
137-
138-
139-
140-
if __name__ == "__main__":
141-
b = MusicPackageManager()
142-
a = Music(b)
143-
144-
a.play_note('C2')
145-
a.play_pause(1)
146-
a.play_note('E2')
147-
a.play_note('C2',instrument="piano")
148-
a.play_note('E2',instrument="guitar")
149-
a.play_note('C2')
150-
a.play_animal(instrument='cat')

musicPackages.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ class MusicPackageManager:
9090
def get_instance(cls):
9191
if cls._instance is None:
9292
cls._instance = MusicPackageManager()
93+
print("make MusicPackageManager")
9394
return cls._instance
9495

9596
def __init__(self):
9697
self.packages = dict()
9798
with open('./sounds/notes/music_package.json') as json_file:
99+
print("99 musik pac")
98100
data = json.load(json_file)
99101
for p in data['packages']:
100102

program.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@
3131
import config
3232
import audio
3333
import event
34-
34+
import music
35+
import musicPackages
3536

3637

3738
PROGRAM_PATH = "./data/"
3839
PROGRAM_PREFIX = "program_"
3940
PROGRAM_SUFFIX = ".json"
4041

42+
musicPackageManager = musicPackages.MusicPackageManager.get_instance()
43+
4144
def get_cam():
4245
return camera.Camera.get_instance()
4346

@@ -56,6 +59,9 @@ def get_prog_eng():
5659
def get_event():
5760
return event.EventManager.get_instance()
5861

62+
def get_music():
63+
return music.Music.get_instance(musicPackageManager)
64+
5965
class ProgramEngine:
6066

6167
# pylint: disable=exec-used

0 commit comments

Comments
 (0)