SuperCollider’s extensions for physical modeling
Last year I (almost accidently) discovered SuperCollider. This is a kind of advanced mutlipurpose audio software platform, a computer music nerd like me could only dream about. Its server part is
a real-time audio-generationg powerhouse, which responds to OSC protocol commands, and could be programmed using sclang
language.
I’ve installed it and was totally hooked, the moment I executed its helloworld code. Why? Well, it generated a gabber beat on the fly, for f0kks sake!
And then I realized that it also supports physical modeling, I was literally blown away. Also, remember, these are all free and open source tools, they might be not so glossy. do not have that “WOW EFFECT ON” switch, they do not come with sweet marketed advertising s promises of magically making your productions sound “commercial”, “radio-friendly”, “like your fav. band/procducer”. However, if you put effort into learning them, they can really take your creative process to the next level.
So, there are a number of SuperCollider unit generators (uGens), that are based on physical modeling. You’ll have to build those yourself and place into sc extensions directory. Here is a brief instructions on that:
Also, if you are loading synthdefs that use extensions inside any containerized environment (SuperColliderAU), the extension plugins should be reachable from there.
In this article we will concentrate on making a somewhat realistic snare drum sound, using a physical model, that simulates audible vibrations of a simple membraine, as a foundation. On their own, those DWGMembrain SC ugens sound somwhat like a tuned percussive timpani-sh rototoms.
Snare sound. Common approaches
In the world of modern sound-design, the timbre of a snare drum is usually approached by means of FM synthesis, trying to match the resonances, with the ones of an acoustic drum, using a frequency spectrum analyzer.
There are other approaches as well. What unites all of them is the fact, the the sound itself is functionally split into two parts: the top of the snare, and the bottom of it. By doing so, we are capturing the most essential physical part of this kind of percussion, which contribute to the “snare drum” sound: vibration of a plastic film on the top the insturmnet, as well as the noisy metallic ramble/rattle of an actual snare-wires on its bottom.
That also matches the standards of today’s pop and rock drum recordings, where snare drum is picked up by two microphones placed at the top and the bottom of an instrument.
One can also argue, that the is also a suffient component of snare drum tone comes from the drumkit’s overhead and room mics as well. However, the implact of on the overral sound is highly dependent on the genre, the record and producer’s taste. Today’s omnious practice of enchancing live drum recordings with samples, makes it even harder to do a final judgement on this matter.
Our approach
So, we have a sc ugen that imitates a sound of a simple vibrating membrane. Its physical sound-producing model is based on something called Digital Wave Guide (DWG). In short, this method can be condensed, integrating wave equation, using digital delay lines for sampling oscillation across the closed geometry of the vibrating body, and digital filters for calculcating frequency loss, when waves travel through medium aroud it.
So, this is the sample code, which came with the DWG MembraneCircle SC extension:
// Change MembraneCircle to MembraneHexagon for a different shaped
// circular drum head
s.boot;
s.reboot;
(
{ var excitation = EnvGen.kr(Env.perc,
MouseButton.kr(0, 1, 0),
timeScale: 0.1, doneAction: 0
) * PinkNoise.ar(0.4);
var tension = MouseX.kr(0.01, 0.1);
var loss = MouseY.kr(0.999999, 0.999, 1);
MembraneCircle.ar(excitation, tension, loss);
}.play;
)
Note, that this code’s gimmick is that it produces a sound, every time the mouse is clicked, using its screen X an Y coordinates as tension and dissipation parameters of the physical model respectively.
Digital wave guide model also allows us to approximate the effect of a sound virbration moving through a resonator (body), so I modified a code, to pass the membrane sound through DWGBox, which gave me a bit more rich and deep sound.
I then added logging of the parameters and spent about 40 mins clicking on various places of the screen trying to find the sweet spot that would sound somewhat like a snare top.
On a personal note, I’d say that defining the variying parameters and their ranges within sound-producing software is a non-trivial task for a prophan like me. And proper adjustment of those, can really make it or break it in terms of playability of a particular virtual instrument (case study: Steve Duda talks about making Serum).
So, we’ve got our first half of a snare sound. We will then try to augment it with an approximation of . At this point, I
decided to use simple filtered white noise for that purpose.
(
SynthDef(\snare, { |out = 0, tension = 0.02578, loss = 0.999441, decay = 0.3, curve = -4.0, noise = 0.10 |
var excitation = EnvGen.kr(Env.perc(0.01, 1.0, 1.0, curve), 1, timeScale: decay - 0.05, doneAction: 0) * PinkNoise.ar(0.2);
var sound1 = MembraneCircle.ar(excitation, tension, loss);
var sound3 = DelayN.ar(EnvGen.kr(Env.perc, 1, timeScale: decay, doneAction: 2) * PinkNoise.ar(noise), delaytime: 0.05);
var sound2 = DWGSoundBoard.ar(sound1 + sound3, 40, 40);
var ss = sound1 + sound2 + sound3;
Out.ar(out, ss!2);
}).writeDefFile
)
Finally, we can futher mix in a sample of a wooden stick hitting a metallic hoop against the which the membrane is tightened, to achieve a more realistic tone. But that would be the job for our mighty MembrainSC. Other opportunity to go further with our experimentation with this model will be sending the sound through two membraines, which will resonate with each other.