💾 Archived View for thrig.me › blog › 2023 › 06 › 01 › music-of-the-spheres.gmi captured on 2024-07-09 at 01:04:42. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-11-14)
-=-=-=-=-=-=-
An orbital simulator can be put to productive(?) use in the production of music. Perhaps the tau (or (* 2 pi))† has been divided into some number of sectors around something being orbited, maybe 0 to 15 degrees maps to 0, 16 to 30 maps to 1, etc., depending on where the satellite is. depending on where the satellite is. The mapped numbers can then be used to index into a scale, which means you'll need the intervals of the scale--say, pentatonic minor--and a bit of code to get a MIDI pitch number from the mapped orbit numbers. And some bounds checking, because write-it-in-a-hurry art code never has bugs, and ambitus is a thing.
#!/usr/bin/env perl use 5.36.0; sub index_interval_factory_class_factory (@intervals) { my @offsets = (0); for my $i (@intervals) { push @offsets, $offsets[-1] + $i; } return sub ( $index, $start = 60, $max = 84 ) { die "your index is no good" if $index < 0; my $pitch = $start; while ( $index > $#offsets ) { $pitch += $offsets[-1]; $index -= $#offsets; } $pitch += $offsets[$index]; die "too far!!" unless $start <= $pitch <= $max; return $pitch; }; } my $fn = index_interval_factory_class_factory(qw/3 2 2 3 2/); say join ' -> ', $_, $fn->($_) for 0 .. 12;
A not terrible result was the following:
LMMS was used here to get a bit of reverb from some plugin, plus I think it was xylophones in the Lil'Sness soundfont. Fluidsynth allows you to customize the reverb and chorus, but it's easier to fiddle with a GUI dial for something you rarely have to deal with. GUI do often become dreadful when you need to automate things.
Another way to slice up an orbit might be to use the distance, e.g. if the object is close enough start playing the notes of a scale; otherwise, ignore that object. This might work well for highly eccentric orbits, though you may need a lot of comets given how long they tend to stay out there.
This all needs a bunch of fiddling and fine tuning, as most orbits do not make for good music: maybe too regular, maybe too many orders of magnitude difference between things.
tags #music #perl
† the tau that can be told is not the eternal tau