Readit News logoReadit News
Posted by u/chr15m 3 months ago
Show HN: I made a generative online drum machine with ClojureScriptdopeloop.ai/beat-maker/...
After two years of development, I'm super excited to release Beat Maker! This is my take on what I hope is the best free, web-based drum machine.

My goal was to build something that was not only fun and easy to use for beginners but also powerful enough for serious producers. I did extensive research on existing drum machines, analyzed their UX, and tried to build something that adds something new.

It's a nearly 100% client-side app, written in ClojureScript, and is a PWA so you can install it to your home screen for an app-like experience.

Besides the standard grid editor, Beat Maker has some unique features that I think HN readers might find interesting:

- Procedural sample generation. One annoying thing about writing beats is searching through folders full of samples. I wanted to improve this and so I added the ability to generate new samples with a single click, giving you an infinite supply of unique drum samples. * Generative beat creation. If you're looking for inspiration, Beat Maker can generate entire patterns for you as a starting point. You can then edit and tweak the beat to your liking. Great for solving the "blank canvas" problem and giving you something good to start from. * Advanced export options. This is where it really shines for producers. You can export your work as: * A standard WAV loop * Individual stems (ZIP) * A MIDI file * A ZIP file of all your samples as WAVs * A SoundFont (.sf2) drum kit from your generated samples * An Impulse Tracker (.it) file for use in trackers like Renoise, OpenMPT or a Polyend * Pocket Operator/Volca sync. It can output a sync signal on the left audio channel to sync with these hardware devices for perfect timing. * Per-Note FX. You can add effects like volume slides, repeats, and start volume changes to individual notes for more complex drum phrases incorporating flam and roll.

As an old school tracker guy, I'm particularly excited about the Impulse Tracker export mode. I was surprised to discover how many DAWs (including hardware like Polyend) can import this format. Of course, you can also pull up Impulse Tracker on DOSBox, or the more modern re-implementation, Schismtracker for that retro experience.

By the way, the beat generator feature is not trained on any artists or anything like that. It's an algorithm I built from scratch myself.

The audio engine is built on a declarative audio graph (using `virtual-audio-graph`), inspired by React's virtual DOM, which makes managing the Web Audio API much cleaner. If you're building web based audio apps I highly recommend checking out this library.

I'd love for you to try it out and let me know what you think. Feedback (and the inevitable bug reports) most welcome! Thank you!

P.S. Also, here's a video summary: https://youtu.be/qVmEn9z3H24

chaosprint · 3 months ago
> "The audio engine is built on a declarative audio graph (using `virtual-audio-graph`), inspired by React's virtual DOM, which makes managing the Web Audio API much cleaner. If you're building web based audio apps I highly recommend checking out this library. "

when you have more and more interactions on the gui web audio api will become a problem, check out audioworklet.

I am developing https://glicol.org/ and it has a js port on https://glicol.js.org/ a typical usecase is drum machine with very high time accuracy

chr15m · 3 months ago
I don't like creating a lot of audio nodes on the fly for that reason. Beat Maker re-renders the audio to a buffer any time a value is changed. The audio engine is very efficient, literally playing one static buffer on loop. For the browser/OS this is basically memcpy, which is cheap, and does not take place on the GUI thread.
anonymous344 · 3 months ago
does this solve the stupid problem with chrome mobile (samsung) that if you make javascript timer for example 4 seconds, and then play() the audio is already deleted by garbage-collection.. ?
chr15m · 3 months ago
The algorithm in Beat Maker bypasses that issue completely by rendering the webaudio graph to a static buffer on every change.
iamben · 3 months ago
This is great fun, congrats!

2 small requests that (I think) would help with the UX: consider moving (or duplicating) the play button - maybe directly in the middle below the editor, or on that panel itself. It took me a few confusing seconds to realise where it was. Also, could you consider making each fourth (or first) column a very slightly lighter grey? So if I want my kick on 1, 3, 10 and 11 it's really easy to see where to click without counting?

chr15m · 3 months ago
I've duplicated the play button and also made every 4th column brighter. It's live now, thanks so much for your suggestions!
mockingloris · 3 months ago
> Also, could you consider making each fourth (or first) column a very slightly lighter grey

This could be a component logic; a row of drop downs for customizing the UI and a good examples are color and grid count. This could even be a toml/json config file that can be imported/exported.

My own addition is ability to import samples from my own device.

chr15m · 3 months ago
Importing samples is on my TODO list. Thank you for the feedback!
chr15m · 3 months ago
Great ideas, thank you. I will triage these suggestions into the issue tracker. Many thanks!
dpoljak · 3 months ago
Really cool! How come you've chosen ClojureScript, and did you regret that choice in the 2 years you've been working on this?

To be clear, this is pure curiosity on my part as I love Clojure(Script) and am consistently missing it during my day job.

chr15m · 3 months ago
No regrets. As a solo dev I can use whatever I want and I use ClojureScript for almost all projects. I've been writing code for decades, used dozens of languages, and nothing comes even close to the DX affordances of cljs. It's an absolute joy.
raspasov · 3 months ago
I think the question is for other projects: How come you've not chosen ClojureScript? ;)
h4ch1 · 3 months ago
This takes me back to 2019 when me and my team won HackInOut, a hackathon held in Bangalore, India by building Rosaline, a generative drum machine, that took in lead melodies (guitar tracks, piano samples, etc) and generated a full fledged drum track.

Used GANs & a lot of weird hacky optimizations, can't even find the code for it anymore, but it was a great time :)

https://devfolio.co/projects/rosaline

This is all that's left of it

chr15m · 3 months ago
Looks cool! It's a much more difficult problem than it looks - great that you got something working.
gabriel666smith · 3 months ago
Love this!

One thing I'd find frustrating if using this when working on music: "When beat is playing, get new sample for drum plays as soon as it generates".

If "this sample is programmed to play in playing beat", then it'd be good to do a silent replace, or have the option to, so that you don't get a weird unquantized snare sound, for example. I'm finding it puts me off the generated sound more if I initially hear it in a context where it doesn't fit.

chr15m · 3 months ago
That's a good point. Will fix, thanks.
gabriel666smith · 3 months ago
No - thank you. Really fun drum machine.
marksholms · 3 months ago
Thanks for building this. Really inspiring and great work.

ClojureScript is such an awesome secret weapon for building web apps. I started building a similar web audio looping app using borkdude's scittle version of ClojureScript. Only once the app had grown substantially, did I move on to proper ClojureScript. The cljs development experience is just awesome.

chr15m · 3 months ago
Sounds like a fun project! I also love that you can start out lightweight in Scittle and then switch to compiled cljs fairly seamlessly if your idea takes off. Such a nice dev experience!
WesleyJohnson · 3 months ago
Very cool and quite fun. I love that you used Clojurescript. I played with it years ago and have been meaning to get back to it.

One piece of feedback; I'd love an option to toggle background color of everything nth note. Makes it easier to place on beat.

chr15m · 3 months ago
I've highlighted every 4th column now. Thanks for the suggestion!
chr15m · 3 months ago
Will add this, thanks for the suggestion!
spapas82 · 3 months ago
I had also build a similar (non polished) app using js: https://boombox-agw.pages.dev/

It also includes a bunch of greek rhythms; try tsifteteli!

chr15m · 3 months ago
Very cool! Love greek music, ancient and new.