API suggestions
Thanks for your library! It's the first Python library I could find that allows to play notes in a simple way.
I intend to use the library with my students. I have some suggestions to extend the API so it would be even more accessible for beginners:
- Default player: It would be nice to have a default player in the package much like with the
turtlepackage so that one does not have to create a player object:
from musicalbeeps import *
play_note("C5", 0.4)
- Play a tune which is either a list of notes or a file name, something like:
class Player:
def play_tune(self, tune):
if type(tune) == str:
with open(tune) as file:
tune = file.readlines()
for note in tune:
if ":" in note:
tone, duration = note.split(":")
self.play_note(tone, float(duration))
player = Player()
player.play_tune(["C4:.45", "C4:.15", "D4:.60", "C4:.60", "F4:.60", "E4:1.2"])
player.play_tune("happy_birthday.txt")
- It would be very nice if the tempo could be changed. The tempo would be multiplied with the duration of each note:
player.set_tempo(2)
- Disable console echo by default.
Thanks for considering my suggestions.
I ingeminate suggestion number four. The console output must be disabled completely or in the very least disable the note and the duration but ignore the frequency. I need this because I made a Simon game based on the library and no one can play the game without seeing the answers. There shall be a disable_console_echo variable with options such as none [as is now], all [disable console echo completely which shall be default], note [disable print of note played], frequency [disable print of frequency of note], and duration [disable print of duration for which note is played].
Moreover, I support changing the player for I do not care for the actual timbre of the tones and semi-tones.