Open ntoll opened 3 years ago
I think the problem for this is that pyfxr is not a player and it can't really be, across all use case. Pygame doesn't have a built in event loop - it isn't a game engine - so you can't just schedule notes to play at a moment in time. The user has to be involved in playing notes at the relevant moment; the best we could do is provide the timing data and SoundBuffer objects in a way where it can be integrated with a couple of lines of code.
As a standalone library, pyfxr could mix a sequence of notes and produce a longer sound sequence - but that would be quite expensive, and not really appropriate in the context of a game.
However, playing melodies would be easily achievable as a feature of Pygame Zero, because that is a game engine, and does have a clock that would let you schedule notes for a moment in time.
Hmm... I'm not sure I quite get the subtle difference between PyGame not being a game engine and PyGameZero actually being one. Something for us to discuss in future I guess, in terms of implementation details.
Putting that aside, if folks want to define a melody, I think my suggestion still stands for a melody DSL.
As a musician, I want to be able to create melodic parts as collections of notes. May I suggest the music DSL we made for the micro:bit as a starting point..? https://microbit-micropython.readthedocs.io/en/v1.0.1/music.html
In addition to the named notes (e.g.
"c1:4"
) I want to be able to perhaps describe specific pitches by cycles, e.g."440:4"
for a concert A (440) for a "crotchet's" value of duration. Obviously, I'm using a string based representation for those latter values, and these could just be a tuple like this:(440, 4)
.