Acoustic drums, one phone microphone, and the part I got wrong
The question that started this was a boring one about mapping. In Bashery, hitting a tom tells the sequencer to roll out a new pattern, and somebody wanted to know whether they had to map their rack tom, floor tom and low tom separately for that to work.
They didn't, as it happens. There's only one tom role and all six standard tom notes already point at it, so mapping one is the same as mapping all of them. But answering the easy half made me look at the hard half, which is that if you play an acoustic kit into the phone's microphone, none of it works, because the microphone had never been able to hear a tom at all. Every tom you hit was going in as a snare.
I already knew that. There was a comment in the source saying so, which I had written myself and then stopped thinking about:
Which was fair enough at the time. The acoustic mode exists so that a drummer with a wooden kit can drive the band without a MIDI trigger on every drum, and to do that you only really need to know where the pulse is. Kick and snare give you that. Toms were a luxury. Then toms stopped being a luxury, because I hung a feature off them, and the comment quietly turned into a bug.
The existing detector is not clever and I don't want to oversell it. It leans entirely on an accident of the instrument, which is that the three drums you need for tempo happen to sit in different parts of the spectrum and mostly stay out of each other's way. A kick is nearly all sub-100 Hz. A hi-hat is nearly all top end, 6 kHz and up. A snare is stuck in the middle, but its crack covers roughly 300 Hz to 3 kHz and it is louder there than anything else on the kit.
So there are three filters, an envelope follower on each, and a threshold that slowly adapts to whatever the room is already doing, so that a fan or a hum or a bit of PA bleed gets absorbed into the noise floor instead of firing the band every two seconds. A rising edge well clear of that floor counts as a hit, and then a short refractory window stops one strike being counted twice. That's the whole thing. It works because the drums cooperate, not because I was smart.
Toms don't cooperate. A tom's fundamental sits somewhere around 80 to 200 Hz depending which one it is, which is not a gap in the spectrum, it's the bit of fence between the kick and the snare with both of them leaning on it. My first instinct was to do the thing that had worked three times already and give the tom its own band, and it took about ten minutes of thinking about where that band would go to realise it fires on kicks and it fires on snares and I would have swapped one wrong answer for two.
A snare drum is a shallow drum with a set of wires stretched across the underside of the bottom head. That's the whole difference. Take the wires off and what's left, acoustically, is a shallow tom. The wires are also why a snare sprays broadband hiss well past 5 kHz, long after the shell itself has stopped contributing anything, and a tom does not do that, because it hasn't got any.
So the detector doesn't need a new band, it needs a different question, asked about a strike that the snare detector has already caught. Measure the low-mid body, call it 100 to 250 Hz, which is the shell. Then measure the top, 2 to 5 kHz, which is where the wires live. Then look at the ratio between the two rather than at either number on its own.
I like the ratio more than I like most of my ideas, and the reason is not elegance, it's that ratios survive the real world. The absolute level of a drum through a phone microphone depends on how hard you hit it, how far away the phone is, whether you're in a carpeted room or a kitchen, and which phone it is. Trying to reason about any of that from my desk is hopeless. The proportion between two parts of the same strike doesn't care about any of it, because all of those things scale both halves at once.
Snare on 2 and 4 with a kick underneath is possibly the most common thing a drummer has ever done, and it broke this immediately.
When a kick and a snare land on the same beat, the microphone hears both, and the kick dumps a large amount of low energy into precisely the range I had decided to call "body". So the body number goes up, the ratio goes down, and the detector concludes, with total confidence, that the backbeat of every rock song ever recorded is a tom.
The fix is a guard rather than anything sophisticated: if the kick is loud enough to account for the low energy by itself, then that low energy isn't evidence of anything. Only treat body as tom-shaped when it can't be explained by the kick. The snare detector already needed a related trick, because a kick's beater click leaks into the snare band too and would otherwise read as a ghost snare on every kick.
This is the part I'd want to read, so it's the part I should write down.
A 120 Hz shell hasn't finished a single cycle in the first eight milliseconds of its life. You cannot ask how much body a strike has four milliseconds after it starts, because at that point there isn't any body yet to measure. The filters haven't even settled. So I widened the window the snare band waits before it commits, from about four milliseconds out to twelve, so that the shell would have time to say something.
That broke the backbeat, and not in the new tom code. It broke the snare detection that had been sitting there working perfectly well for a year.
That four-millisecond wait was not arbitrary. It was there so the kick veto could work: the kick's low-pass filters rise more slowly than the snare band sees a beater click, so the veto needs a head start before it can judge whether a snare-band onset is a real snare or just kick bleed. By twelve milliseconds the picture is completely different. The snare's envelope has already begun to fall away while the kick's is still sitting up there, so the comparison that was correct at four milliseconds now looked at a fading snare next to a loud kick and threw the snare away. Every snare that shared a beat with a kick simply stopped existing.
An existing test caught it, which is the only reason you're reading this in a blog post rather than in a tester's bug report. But I don't think the takeaway is "write more tests". I'd already written that test, a year ago, for a completely different reason. The takeaway is that I had two separate questions here, one being whether a mid-band onset is a real snare or just kick bleed, the other being whether it's a snare or a tom, and I had quietly let both of them share a window. So tuning one of them retuned the other without asking me first.
Once they're pulled apart it's fine. The veto still commits at four milliseconds, exactly as it always did, untouched. Only the tom-or-snare question waits, out to about fifteen milliseconds. And that wait costs nothing downstream, because the onset gets stamped with the time of the strike, not the time I made my mind up about it. The tempo tracker never finds out that I dithered. I'd already used the same trick for cymbals, where the detector watches a hit ring for a fifth of a second to decide whether it was a crash or a hat, and still reports it at the moment the stick landed.
I should be plain about this: everything above has been tested against drums I synthesised in a unit test. It has never been in a room with a real kit.
And of all the calls this thing makes, tom-versus-snare is the one I'd bet against myself on. A 16-inch floor tom and a rack tom are not the same instrument. Somebody's going to back the wires off their snare, which is a thing drummers do, and hand me an instrument that is deliberately halfway between the two categories I've just invented. A cheap phone mic in a small tiled kitchen is doing things to the top end that I can't predict from here, and the top end is exactly where I've decided the answer lives.
So the threshold is exposed rather than baked in, and every decision it makes writes down what it saw before it made it:
It's in the diagnostics export. If it calls your floor tom a snare, that line tells me whether it heard too much crack, or not enough body, or whether your kick was sitting on top of it. Those are three different bugs with three different fixes. Getting told "it doesn't work" is nearly useless to me. Getting told "it doesn't work, here's what it thought" means I can fix it on a kit I've never heard, in a room I'll never stand in, which is the only way any of this ever gets fixed.
If you drum on wood and you fancy being the person who tells me my ratio is wrong, the acoustic mode is in the current build.
Bashery is a generated band that follows your drumming - tempo, dynamics, fills, and now, on an acoustic kit, your toms. Try it.
© 2026 Sashyo & Petty Vendetta. All rights reserved. · bashery.app · more posts