The Landau Sampler
The Landau function g(n) returns the largest Lowest Common Multiple (LCM) of partitions of n.
The Landau Sampler takes an audio clip of n seconds, partitions it into smaller clips so that when stacked and looped, the resulting audio only loops every g(n) seconds. g(n) gets very big very fast.
For example, a 5 second clip is split into a 2 second and 3 second clip, and those are looped and stacked, with the resulting clip only repeating every 6 seconds. You can hopefully see for yourself by trying other partitions that this is maximal.
5 = (2 + 3) -> lcm(2, 3) = 6
A 12 second clip, when Landaued, results in a 60 second output!
12 = (3 + 4 + 5) -> lcm(3, 4, 5) = 60
A 60 second clip, after the process of Landauification, results in an output almost 12 days long!!!
60 = (3 + 4 + 5 + 7 + 11 + 13 + 17) -> lcm(those) = 1,021,020
You may have noticed that the optimal strategy is to pack in as many coprime prime powers as you can that sum to n, but whether your did or not is immaterial as the code will do it for you either way!
Example
The following is the first 12 seconds of "Fly Me to the Moon", then the Landau Sampled 60 second version. Have a good listen and see if you can feel the difference in how the elements are landing relative to one another. Apologies about it having to be blank videos, Github Markdown files don't have a nice audio player.
| INPUT | OUTPUT |
|---|---|
INPUT_fly_me_to_the_moon_12s.mp4 |
OUTPUT_fly_me_to_the_moon_60s.mp4 |
Visual
Here's a visualisation of the 12 second case:
The Landau Sampled 12 seconds is now a cycle of 60 seconds
To see the lack of repetition, pay attention to the patterns made by the darkest segments from each colour. This is a 3:4:5 polyrhythm! They're all polytrhythms! And not just any polyrhytms, but maximally coprime. Note: The current default would actually split it up like 5|4|3 rather than 3|4|5, but I plan to make that configurable (and randomizable)
Setup
Clone this repo by running
git clone https://github.com/OisinMoran/landau_sampler.git
or just hit "Download ZIP"
Install the required dependencies
pip install numpy soundfile
Usage
python3 landau_sampler.py input.wav output.wav
As simple as that! You can also use MP3s as the input. Please have fun with this, try lots of different types of sounds and lengths (but remember: the output from a 60 second input clip will be almost 12 days long!), and let me know if you find anything cool!
Feel free to leave any nice comments or cool findings as an issue on this repo, or on:
Ideas for future additions
- Options to reorder and randomise partitions (defaults to descending length)
- Better normalization
- Advanced cut point selection (use/set zero crossings)
- Unit selection (no need for it to be whole seconds)
- Make a plugin version
If you like this you may also like
- Steve Reich
- Jacob Collier (if you like music at all, see this man live if you get the chance)
- Some of my other projects
License
CC BY-NC-SA 4.0
TL;DR: Feel free to use and modify the source code, original must be credited, cannot use commercially, derivatives must use the same license.
