Tarai
The 「tarai function」 recently came to my attention; the context was music composition, or the art of creating hopefully neither boring nor terrible sounds from the emissions of some algorithm.
Outputs
A first step may be to study the outputs for given inputs; x > y will avoid the obvious filter, and who knows what z will do. Given the subtractions we probably want positive values, and probably not values that are too large given all the recursion. Some experimentation yielded the following, which gets slow, and does not appear to produce anything interesting.
Tools to convert streams of numbers into Lilypond or MIDI might be good to have. Some of these come from my App::MusicTools module: transpose the numbers up by 54 pitches, convert to lilypond, convert lilypond to sheet music and a MIDI file. Other translations would be possible (to chords, a particular scale, a rhythm, etc).
Yeah... if something uses glorious amounts of CPU for not much if any gain, we are probably on the wrong track. Some functions work when fed sequences of integers (see Music::Voss for example) but probably not this one. Maybe you might find something to use here?
Internals
The author of the tarai function posting does not use the output of the function, but rather uses the internal x y z of each of the many recursive function calls.
This gives us 343,073 lines to work with. We might use the numbers as pitch values in some scale, or maybe the first number is the pitch, the second the note velocity, and the third duration? Plenty of things to experiment with here, as all sorts of mappings and modulus are possible.
A statistical look at the numbers may be worthwhile; this shows the numbers mostly stay around one though rarely will get up to 10. They could be mapped directlyl to a 12-note scale, or perhaps extreme values could be ignored, put into the next octave, or modulated into some smaller base scale. The columns have different values, which perhaps points to using only one of the columns, or to utilize a unique mapping for each column.
Converting the first column (x) pitches to Dorian mostly results in a stepwise descent and some leaps. Nothing really too interesting. More experimentation here might turn up something usable. The original post used arpeggio which probably adds interest and may hide a weaker harmonic or melodic line.
By way of:
See Also
Random code I've thrown together to wrangle music or numbers with. Probably needs a rewrite. Proably will not be rewritten.
https://metacpan.org/pod/App::MusicTools
https://metacpan.org/pod/Music::Voss
tags #lisp #music