Mimba - a karplus-strong synth in Pd
This page contains documentation on a synthesizer that I designed in Pure Data (Pd). It is based on audio algorithms (not samples) that mimick physical processes, for example the sound production by a string, a resonator, etc. These algorithms are suitable to create virtual string sounds (guitar, piano, etc.), [mimba] is not meant to simulate acoustical instruments though, my approach is more experimental. If you want to try this synth, you will have to install Pd (vanilla version).
Starting
Installation: download this zip file (containing 6 Pd files plus 2 text files). Start by opening [main-mimba], the abstractions (additional Pd files) are [mimba], [mba], [vlin~], [reverb] and [presets]. The preset .txt files, loaded in [presets], should be in the folder /presets.
This is version 0.92b (April 2023), tested in Pd vanilla 0.50.2. One of the minor bugs is that (some) GUI parameters are not loaded immediately in the presets. First you have to play 10 notes (...because of the 10-voice polyphony) to produce the correct sound of some presets. The whole patch isn't very 'readable' yet, sorry for the mess... (I don't use sends and receives but wired audio connections to avoid delays in reblocked subpatches). The previous version 0.92 (February 2023) contained optimization improvements to reduce the CPU usage.
Take care when you start playing around with all the knobs and number boxes: there is no safety system to prevent loud sounds and feedback!!!
[mimba] has many adaptable parameters, perhaps it's a good idea to start by opening one of the 22 presets. It's useless to change the (light and dark) red number boxes: they only show values, often of parameters that are influenced by the keytracking.
This synth is quiet heavy on computer resources (on my laptop...). The current version has ten voices. If you want a clean sound, restart Pd, open a preset and don't open [mimba] or other objects to avoid that the GUI is continuously being updated
Presets Sound Examples
The following sound samples give realistic examples of [mimba]. The (post-recording) editing only consists of panning and adjusting the sound level.Ukrainian folk song, played with three guitar presets ('soft-noizy-gtr', 'gitty' and 'dirty-gtr-1'):
The bluesy melody is produced by the preset 'synth-strings-2', the string-like accompaniment is preset 'steamstring-soft':
A preset sounding like a mix of accordion and electric guitar (preset 'soft-fluty-FB-organ'):
Electric guitar example with lots of feedback (preset 'dirty-gtr-1'):
A preset mixing the sound of a metal banjo and a prepared piano (preset 'metalbox-gtr'):
And these are four one-minute improvisations (a bit more experimental, some microtonal tunings) with different presets:
General Design
The general flow of [mimba] is similar to a Karplus-Strong algorithm. Two impulses go through an allpass filter (APF) and feedback delay (DEL). These impulses (or excitation sources) are a noise burst (BRT) and a main impulse (IMP), the latter consisting of a wave and a noise impulse. The wave can be played back once, several times or with variations (see parameter 'read_mode') from a wavetable.
The difference between the main noise impulse (IMP) and the noise burst (BRT):- the noise burst goes through a low pass filter before the APF and has its own amplitude envelope;
- the amplitude of the main wave and main noise impulses are connected, they are inversily related: the level of the noise impulse is subtracted from the (amplitude of the) wave impulse during the duration of the noise impulse. To ensure that the main wave impulse can still be present if the main noise impulse is loud, I also provided a minimum level (parameter 'min-amp-wave') for the main wave impulse (setting the values higher than 1-minus-the-level-of-the-main-noise-impulse makes the main wave impulse audible).
Internally, the APF also consists of a delay line. The amplitude of the input to and the output from this delay (= the APF gain) are inversely related to each other. The design of this APF was made by Mike Moreno in his my-membrane~ instrument. The allpass filter is nested inside the main delay DEL, thus the delay length of this APF is always connected and added to the main delay. If the main pitch (i.e. of the main delay) is the same as the pitch of the APF, the resulting pitch is an octave lower (the length of the two delay lines summed).
When the main delay line is read (DEL), the output can also bypass the APF, this is the WOUT shortcut in the scheme.
Mimba has an extra output for a reverb (RVB). You can cut out the start of a sound (the loudest part with the highest frequencies, due to the Karplus algorithm) with the 'init-delay-reverb' fader, independent from the main output sound. The reverb abstraction itself is mainly based on the [rev3~] abstraction by Miller Puckette.
* * *
Added to this basic scheme, there are 3 extra modules: first, an extra impulse (XTR) triggered by the main impulse IMP. Here the main impulse is band filtered and ring modulated by a sine wave. The output of this extra impulse goes to the allpass filter (APF), to the main sound generation before the entry of the main delay (DEL) or the main sound before the extra gain and output. Second, there is a resonator (RESO) triggered by the impulses. The resonator design is also based on Mike Moreno's work, his EP-MK1 patch (which uses www.musicdsp.org as an inspirational source). Third, a noise generator with filters (AFT) follows the amplitude of the main audio flow, after the amplitude has been analyzed.
* * *
There is also an extra feedback circuitry (SFB) reinforcing the main delay line (bypassing the APF). Because this feedback delay has no lowpass or allpass filters it can grow very fast and become very loud, therefore I built an anti-feedback subpatch into this straigth, harsh feedback.
* * *
There are also about 30 'keytrack' faders to adapt the influence that the pitch has on several parameters. These are important to finetune new preset instruments.
* * *
There are many details and about 175 changeable parameters influencing the sound production. Have a look in the Pd files ([mimba] and [mba] abstractions) to see all the details...
Tuning
The tuning system for [mimba] is only in a first phase. The tuning can be adapted based on four parameters that detune the synth. First, there is a correction of the pitch shift caused by the delay lines. The numberbox 'T1-delay' lets you choose from several tuning corrections, you can also bypass this tuning correction by choosing value 0. Second, the crossfade between the APF input and the circuitry bypassing this APF also detunes the pitch ('T2-xfade'). Third, the gain in the APF creates a feedback within this delay line ('T3-APF-gain') which detunes the pitch ('T3-APFgain'). Fourth, the duration of the main impulses also changes the pitch ('T4-dur').
The detuning by these four parameters was hard to systematize into algorithms, I mainly created adhoc solutions (with lookup arrays, very nonlinear algorithms, etc.). If you are more experienced in tuning correction algorithms of karplus-strong synths I'd be happy to hear from you!
Additional Remarks
I made an abstraction based on [line~] imitating [vline~] called [vlin~] because I had some strange audible artefacts and the vline~ help file mentioned a bug of vline~ inside reblocked subpatches.
One trigger (based on the velocity) sets the sound production of a tone and the sound processing in motion in the abstraction [mba] inside [mimba]. Most of the approx. 175 parameters arrive before this trigger and can't be changed once the sound production has started (similar to the acoustic phenomenon of hitting a string). Compared to usual synthesizers there aren't many general parameters that change simultaneously in all the synthesizer voices. This one-trigger design means that each note can have a different mix of (most of the 175) parameters and that changes of the [mimba] parameters only effect future notes.