AJ | Pact | logo
PACT
Prism Fission

Prism Fission

9 September 2017

CreativePact (32 posts)

In this CreativePact, following a couple of months in the creative doldrums, I will be working to complete Prism Exhilarated, a unique media music release by ‑otron.

Prism in Python - constructing a side

21/09/17
AJ Pact | Prism Fission | Prism in Python - constructing a side

Following on from constructing a track and constructing an album, today I constructed a side! This is a vital functionality considering Prism Exhilarated is destined for cassette tape.

Having weighed up my CLI command options, I decided against integrating the side selection into --album (which would have made argument parsing much more complex) and went instead for a new CLI command: -s/--side.

Alongside an optional integer to select a specific rendition, --side takes a mandatory string as the side identifier: this could technically be anything, but I expect a simple 'A' or 'B'. That identifier should be present as the value in a 'side' entry for each track in the config file.

In code the implementation was very similar to that which constructs the album, only with the tracks from the chosen side. So similar in fact that it may be beneficial to write one function to handle both cases.

One programming trap with the sides though: because enumerated loop indexes start from 0, initially a construction of side B was using the audio for side A (as the track indexes for side B files start after their side A cohorts). Enumerating through all tracks filtering for side identifier fixed that.

There may be a better way to handle this, especially as sides should be a contiguous range of tracks: there shouldn't be a situation where a track from side B appears between those from side A, and the current config file arrangement allows for that. Perhaps better to design it out?