April

double densed uncounthest hour of allbleakest age with a bad of wind and a barrel of rain

double densed uncounthest hour of allbleakest age with a bad of wind and a barrel of rain is an in-progress piece for resonators and brass. I’m keeping a composition log here as I work on it.

There are sure to be many detours. Getting it in shape might involve:

Friday April 5th

It’s been a week of spring cleaning in the astrid world. Lots of unremarkable cleanup, though I ended up getting bit by garbage-collected cython strings when I realized that I was passing the instrument name to astrid_instrument_start as pointer to a garbage-collected string. Moving the instrument initiation into the main thread and passing the wrapped cython Instrument to the message thread let me simplify things a bit too, the python and C instruments both call the same astrid_instrument_tick function in the main thread now, which reads a line from the console, relays parsed commands as messages on the instrument queues, and cleans up spent buffers in shared memory.

Some remaining plumbing tasks that come to mind:

Other stuff, I’m sure!

Monday April 1st

Hey, it’s April!

In astrid-land, I’m still debugging issues with the new lpsampler interfaces and working on getting the ADC sampling interface working in the python instruments. The (mostly stupid, as usual) issues with the shared memory backing are mostly sorted and libpippi buffers are now using flexible array members as their last elements.

At the moment I’m trying to avoid more copies and allocations when reading from the sampler in cython. Pippi’s SoundBuffers are still numpy-backed Note 0 and I don’t think there’s any safe way to avoid all copies until they’re libpippi-backed…

I’m trying out creating the numpy array that will be used to back the output buffer from the sampler first, then (hopefully) giving C a pointer to the underlying memory there to fill the buffer, and just wrapping it back into a SoundBuffer at the end. In other words copying once into a new array whose memory is managed by numpy.

The fiddly bits in the middle are where I’m stuck this morning.

The cython docs show this way of getting a pointer to a memoryview:


the_memoryview: cython.double[::1] = numpy_array # this must already be C contiguous / typed as a double

some_c_function_that_wants_a_pointer(cython.address(the_memoryview[0]))

Pippi uses numpy ndarrays typed as double[:,:] at the moment. It makes working with arbitrary numbers of channels easier since you can slice across dimensions and just operate on one channel at a time without an extra copy for example… but I’m stumbling over the reshaping here, it might not be possible to get the pointer directly without another copy?

Allocating a temporary array in the right shape, copying the samples into it through the C call, and then copying it back into the double[:,:]-shaped numpy array is the best idea I have right now.

It’s fine! I don’t care much about the extra copies I guess, but getting rid of them is probably a project for another time. Once the sampler works the fun stuff can begin: pushing brass tones through astrid into resonators.

Note 0: There are a lot of places where pippi assumes that SoundBuffers have a frames param which is the numpy array, and that gets used to do things with the python buffer API interfaces. The new buffers are backed by libpippi lpbuffer_t structs and expose the buffer API directly on the object – that’s probably the last big pippi project before I take it out of beta, whatever that means.


Log March 2024

Log February 2024

Log January 2024

Log December 2023