Show HN: Billard – Generate music from ball collisions in 2D space (billard.medusis.com)
Most traditional music composition tools revolve around the idea of a repeatable pattern. Billard is a webapp that never repeats itself. It generates music automatically based on the collisions of balls in a 2D space. Collisions trigger notes (or chords) in a given key. One can add balls or move them (y-position is pitch); the app remembers its state between reloads; or it can be reset with the 'init' button on the top left. Gravity can be adjusted in real time to change the behavior of the balls.
It owes a lot of inspiration to Brian Eno and Erik Satie (inventor of musique d'ameublement, or "furniture music"). Some may think the lack of pattern makes it not musical enough -- but this lets it be listened to —and watched— for a while without boredom.
The webapp is made using plain JavaScript. (All SVG icons were made 'by hand'.) It uses Tone.js only for triggering piano samples. Beyond piano, it's MIDI-enabled and works well at slow speed with haunting, dark synth sounds.
Hope you like it!
75 comments
[ 4.1 ms ] story [ 132 ms ] threadReminds me of the 'polyrhythm' genre of videos on youtube (eg. LucidRhythms)
One fun thing to do is load the canvas up with a bunch of balls really close to each other then click the yin and yang icon which causes them to change state when struck.
Adding some kind of gravity might be fun.
I seem to have triggered "infinite sample playback" when I stuck the ball in a corner and the audio crashed. One experience I've had with this kind of large sample playback (in SuperCollider) is that by dynamically reducing the volume, it creates an interesting textured sound [1].
Of course for every project using Tone.js I would like to mention one of my project glicol.js which is in active development [2]. It has better performance but needs more use case to find what's needed in the API.
[1] https://github.com/chaosprint/Packing
[2] https://github.com/chaosprint/glicol
https://glicol.org/demo#themodel (remember to play with line 14)
Since then, I've been playing around with it a bit and found out that it even has a cli/tui [0], although that one seems to have a few more bugs than the web version It's going to be my main way of using it as I don't want to miss my $EDITOR instead of editing on the web.
[0] https://github.com/glicol/glicol-cli
Any chance you are going to share the source code?
The code is not obfuscated or minified in any way, so it's easy enough to read. But I'm not sure it deserves to be actually published... ;-)
I see some videos which suggest that the developer actually set up the map and the physics such that specific songs get played, although I think there is some trickery to simplify it.
At the moment I'm working on a subproject which is generating the audio sounds for various bumping events, having found musicpy/sf2_loader a quick way to generate samples.
There are other plugins for this, each with its own personality. For example Bitwig's Ricochet is a totally different take on the same idea, where they managed to make it usable for more rhythmic purposes: https://www.youtube.com/watch?v=WFvIYkTGRzA
Didn't know about Ricochet (not a Bitwig user), but it's very impressive!
Also, you're the creator of protoplug? What a fantastic idea!
https://www.youtube.com/watch?v=RdCutpuUrX4
[0] https://www.albinoblacksheep.com/games/boomshine
It'd be hard to trigger the sound before the collision (although possible, in theory)...
Trapping the balls may give you something more approaching 'music'. Changing the root note, also. And the 'mode', too.
It's billiard-like and makes complex patterns over time that might sound coherent and interesting in various audio mappings. Runs best in Edge
https://github.com/mnenoff/society-htm/tree/main