Coding 2026-04-09

Tags:
By Max Woerner Chase

Okay, let's see what I can plan out, with a little more time. On the audio synthesis side of things, I have a function to produce an unscaled and unshifted sine wave, which is intended to be passed an array of samples. These samples are interpreted as fractions of a period. I wish to have more sophisticated means of sampling and processing later, but first, let's see what's required to produce a 440 Hz tone for two seconds.

...

Okay, I've got a function to convert an interval of time into samples. Next, I need to look into writing the big array that this represents to a wav file. Looking at SciPy's options, I see that I need to actually make some kind of decision about lots of things. I think for now, I'll clamp the sampled values to the range from -1 to 1, and then convert to signed 16 bit integers for the output. I'm less sure about the proper data types to use for intermediate steps. I think for now, I'll go with "maybe too big, but almost certainly big enough".

...

All right, everything (eventually) worked the way I wanted and expected it to. Thinking about relative utility, I think next I'm going to work on starting notes at different times, then basic envelopes, then scales. At that point, I can work on as much additive synthesis as I feel like messing with.


For now, though, I think I'll ponder the other project I was thinking about, making calendar stuff extensible so that it can handle funky made-up calendars. For that, I'm right now thinking about the equivalent of Python date objects, which are (probably) going to involve a year, a year and a month, or a year, month, and day. The trick is, different calendars will assign different days to a given month (and different days to a given year), give a month a different number of days, or use a different set of months entirely. (And when you get into times, different years could involve days of different lengths; in exotic enough orbital configurations, this could, technically, happen within a single calendar.)

Anyway, if we ignore anything within or comparing days, then the equivalent of timedelta can be used with any calendar. And one way of encoding a datetime equivalent would be "days since some common epoch" combined with "means of representation". Because the "means of representation" has different fields with potentially different types, I conclude that it is a class, with an instance attribute of the days since epoch, and computed attributes of year, month, day, etc. Then, there are constructors for specifying the desired values of those computed attributes, and perhaps constructors for returning the date of a given holiday in a particular year.

All right, that makes significantly more difference than my prototypes ever did, so I'm feeling good about implementing this. Later. Because it's super late again. I just got really excited to be doing stuff with tangible results again.

But seriously, let's wrap things up.

Good night.