Skip to content

Commit ba4bd65

Browse files
author
Antonino Tramontana
committed
added control for note and verse in play_animal
1 parent 887fa11 commit ba4bd65

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

music.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def play_note(self, note, instrument='piano', alteration='none', duration=1.0):
8686
shift = self.noteDict[note]+ alt
8787
else:
8888
print('note not exist')
89+
return
8990

9091
tfm.pitch(shift, quick=False)
9192
tfm.trim(0.0, end_time=0.5*duration)
@@ -133,6 +134,18 @@ def play_animal(self, instrument, note='G2', alteration='none', duration=1.0):
133134
shift = 10.0 + alt
134135
elif note == 'G3':
135136
shift = 12.0 + alt
137+
138+
if note in self.noteDict :
139+
shift = self.noteDict[note]+ alt
140+
else:
141+
print('note not exist')
142+
return
143+
144+
if self.managerPackage.isPackageAvailable(instrument):
145+
tfm.preview('./sounds/notes/' + instrument + '/audio.wav')
146+
else:
147+
print("no animal verse:"+str(instrument)+" present in this coderbot!")
148+
return
136149
tfm.pitch(shift, quick=False)
137150
tfm.trim(0.0, end_time=0.5*duration)
138151
#tfm.stretch(time, window=20)

0 commit comments

Comments
 (0)