Coding 2021-02-03

By Max Woerner Chase

I wanted to get some stuff done tonight, but I let things go too late, and I'm liking this whole "get to bed earlier" thing I've been doing. So, I'll describe what I'm planning to work on.

Basically, I want to try using Trio, Mido, and Helm together. I've proven to myself that Mido and Helm seem to work together pretty much automatically, at least on my laptop. To start with, I want to focus on the compositional side of things, and not tweak Helm's settings much. Where does Trio come in? Well, in western music tradition, you've got the concept of a note that has a specific duration, and that is a higher-level concept than MIDI works at. I need to be sending events to start and stop the notes playing, and I want to be interleaving those somehow. Now, I could try to manually sequence this stuff, or I could lean on an existing concurrency framework. Threading is also an option, but I'd much rather use almost anything else, at least in Python.

I'll just sum up what I already have written, since there's no way I'm getting anything further in the next ten minutes. I've got some Protocol classes that are basically a typed wrapper around Mido classes. I should probably write stubs for Mido and re-evaluate the usefulness of the wrappers. I've got one more class, and it implements the concept of "playing a note" as a context manager. Most urgent question about this code: should that class continue to be a class, or should I rewrite it (pretty trivially) into a top-level context manager with just the play-a-note functionality? Right now, I think that would make sense. My gut feeling is that there isn't enough of a reason for this to be a class. It doesn't offer any potential for polymorphism, and it's not aggregating multiple data structures. I'll make the change while this post publishes, then get ready for bed.

Good night.