Bonk~ is an external object that was originally created in PureData and then later ported (using the same code but changing a few things) to Max/MSP.
So what does bonk~ do? Well….BONK!
Bonk~ puts out a bang or message whenever it receives an audio signal above a certain threshold. Programmers usually use bonk~ in one way and one way only; to detect an attack.
But there is a lot more that you can do with bonk~, which is what will we talk about in this article.
First things first, here are the links to download the bonk~ external
After you download the external, place the folder in your search path. If you’ve never done this, here is where you go:
then choose the file folder, wherever it is on your machine. I usually like to create an “externals” folder somewhere so that I don’t forget where my externals are.
This is just your microphone input going into a volume control (the *~ object) and then into bonk~. Even just using the default arguments, you can do some cool things with this!
I’ll get into the arguments that we can use later, but for now let’s go onto the messages that bonk~ can receive (or at least the one’s that I think are valuable and important).
Minvel stands for “minimum velocity” and we can somewhat equate this to the velocity parameter for MIDI. It basically says at what loudness should I tell you I received an attack? You can see at what level you’re at by hooking up a message box to the second outlet of bonk~. The second number in the list that comes out is the velocity.
Spew is just an on/off that allows: (0) a message to be sent just when an attack over the minvel is received or to just spew (1) out the information all the time as fast as it can. This could be useful if we wanted to track the amplitude….but there’s another object for that.
The interesting thing about this message is that, for some reason, people just stopped documenting this aspect of the object and I’m not exactly sure why…..because it’s awesome! When you really look into how bonk~ works underneath the hood, it is comparing different amplitudes of frequency bands. So when a certain change happens in between the frequency bands (this is called spectral tilt) then it says “YES THAT WAS AN ATTACK”. Another thing that you can do with these amplitudes is predict something else….timbre.
Roughly speaking, timbre is the way the energy in a sound is distributed over the frequency spectrum. Essentially, that means the various frequency bands of different timbres will have different amplitudes. With the bonk learn function we can tell bonk~ “okay I’m going to hit 5 different objects and record their timbres. When I play these objects again, use this data to tell me which object I hit.” Pretty cool huh?
So obviously bonk~ will have a harder time distinguishing instruments that are closer in timbre/pitch just like you would. A good rule of thumb is: if you have a hard time making a clear distinction between two objects then a computer is going to do a LOT worse.
That being said, I did manage to get bonk~ to recognize not only what instrument I was hitting but also what mallet I was using! (I’m a percussionist by the way). Although it wasn’t 100% reliable, after playing with it for a while I adapted my strokes so that it had more success.
I should also say that this point that your success rate with the bonk~ learn function will depend on:
- The quality of your microphone and equipment (using the built-in mic isn’t a good idea).
- The consistency in microphone placement and levels.
- The consistency of performance (if you botch an attack, bonk~ is not going to understand that that was botched attack).
Read and Write Files
So once who have gotten some things that work well, you can save the data to external files and read from them later. You can do this by using the “write” message followed by the path to a file (or a new one if it doesn’t exist) and then the “read” message followed by the file path. Now I don’t recommend this all of the time because if you change your environment (practice room to stage) then the microphones might react differently for a variety of reasons. Once you get into a new space, reinitialize all of those learned instruments….it’s the best way to ensure the best possible accuracy.
In Part 2 I will explain some abstractions that I created to work with bonk~ to do things such as pattern recognition.