def play_note(self,note_name,note_duration):
"""Plays a single note by creating a 1 note song in song 0
"""
current_song = 0
play_list=[]
noError = True
if noError:
#Need to map ascii to numbers from the dict.
if note_name in self.config.data['midi table']:
play_list.append(self.config.data['midi table'][note_name])
play_list.append(note_duration)
else:
# That note doesn't exist. Plays nothing
# Raise an error so the software knows that the input was bad
play_list.append(self.config.data['midi table'][0])
warnings.formatwarning = custom_format_warning
warnings.warn("Warning: Note '" + note_name + "' was not found in midi table")
#create a song from play_list and play it
self.create_song(current_song,play_list)
self.play(current_song)
评论列表
文章目录