Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API suggestions #4

Open
r0the opened this issue Jan 20, 2021 · 1 comment
Open

API suggestions #4

r0the opened this issue Jan 20, 2021 · 1 comment

Comments

@r0the
Copy link

r0the commented Jan 20, 2021

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:

  1. Default player: It would be nice to have a default player in the package much like with the turtle package so that one does not have to create a player object:
from musicalbeeps import *

play_note("C5", 0.4)
  1. 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")
  1. 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)
  1. Disable console echo by default.

Thanks for considering my suggestions.

@Rogue-Git-Dev
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants