Fakin’ It : Güira Style

One of the great things about an electric drum kit is the ability to access many sounds without having to haul around a huge collection of percussion instruments. The downside is that electronic triggers limit the playing techniques you can apply and make it difficult to recreate some of the nuances of the real instruments.

This fact became an issue for me while preparing for In The Heights. The score calls for various techniques on a Güira (a metal Guiro used in Dominican Meringue music), including the seemingly simple pattern below:

GuiroPattern

The obvious solution is to use a velocity threshold to access the two samples. However, a simple threshold can be tricky – hit slightly too hard or soft and you trigger the wrong sample, wrecking the groove. My solution was to use the new scripting feature in MainStage 3 to create an adaptive velocity threshold that floats based on my playing, helping me lock in the groove. Read on for the details…

Static versus Adaptive

I had set up my güira patch to play the long brush sound at high velocity and the tapping sounds with low velocity. However, I noticed that I would occasionally re-trigger the brush sound in the wrong place.  Adjusting the velocity threshold helped some, but mostly just moved the problem around.

StaticThresholdMy solution was to create an adaptive threshold that started at the value of the last hard strike and decayed slowly down to a base value. This prevented a second loud-ish strike from re-triggering the brush sound. This worked for me since none of the rhythms in the score called for two consecutive brush sounds.

DynamicThreshold

Other Solutions

Another solution to the problem described above would be to use separate triggers for each desired sound, however, this poses a couple of problems. First, it is difficult to move between triggers when playing quick passages. Second, as you’ll see in a future Rig Rundown for In The Heights, I needed every available trigger and couldn’t spare two for this instrument.

Metal Guiro

The TD-30 lacks a metal guiro sample so my first step was to acquire some high-quality samples of this instrument. I looked at the Native Instruments Cuba library but ultimately settled on the Vir2 World Impact : Global Percussion library as it had a number of other samples I wanted. Both of these libraries are driven by the Native Instruments Kontakt sample engine. You can download the free version of the Kontakt engine here.

I used the Guiro (Dominican) patch which has round-robin samples in three different groups. The lowest range (C2-B2) has a number of short attack sounds and the upper range (C4-B4) has a medium duration scrapes. The middle range (C3-B3) range has long duration scrapes that didn’t fit the timing of the score, so they weren’t used.

Scripting

MainStage 3 and Logic Pro X introduced a set of new MIDI FX plugins including the new Scripter plugin. This module allows you to write JavaScript programs to modify incoming MIDI messages and read values from the user interface. You can read more about the scripting functionality in the MainStage 3 Effects documentation.

The basic flow of the adaptive velocity script is to:

  1. watch for incoming notes at C2
  2. compare velocity with the current threshold
  3. if louder than the threshold, change the note value to C4
  4. update threshold to new value

There are some additional details, but that is the basic flow.

You can see a detailed breakdown of the HandleMIDI() function below, or just grab the script and try it out.

Nuts and Bolts

The first part of the function checks the incoming event to see if it is a NoteOn and for the note number we care about. If so, let’s record the current time and recompute the exponential fall-off from our last detected peak, never going below the baseline threshold:

if ( event instanceof NoteOn && event.pitch == lowVelocityPitch ) {

    // record current time and time since last peak
    var time = (new Date()).getTime();
    var delta = time - lastPeakTime;

    // compute exponential fall-off from 'lastPeakValue'
    currentThreshold = lastPeakValue * Math.exp(-delta / decayTime);

    // but, never go below 'baselineThreshold'
    currentThreshold = Math.max(currentThreshold, baselineThreshold);

Next, we compare the velocity of the incoming note to the current threshold and set up to emit the alternate sound if we have a new peak:

    if ( event.velocity > currentThreshold ) {

        // we've found a new peak, record it
        lastPeakTime = time;
        lastPeakValue = event.velocity;
        currentThreshold = event.velocity;

        // change incoming event to the alternate note number
        event.pitch = highVelocityPitch;

        // record the fact that we did the remapping

        didRemap = true;
    }
}

Since we’re changing the note number of the NoteOn, we’ll need to do the same for the NoteOff or these will play indefinitely, consuming voices and eventually locking up MainStage. We set the flag didRemap above and we’ll check it if we have an incoming NoteOff event next:

if ( event instanceof NoteOff && didRemap ) {
    // remap the NoteOff event
    event.pitch = highVelocityPitch;

    // clear the remap flag
    didRemap = false;
}

With all the processing done, our final step is to send the event:

    event.send();
}

This technique worked for my TD-30 setup except for one problem. The TD-30 sends an immediate NoteOff with every trigger hit and cuts off the long scrape sound. If you look in the attached script you will see some additional handling for this, but the overall logic is the same.

You will also see some code to setup connections to the UI which allowed me to create knobs to tweak the baseline threshold and decay time along with other parameters:

GüiraUI

The full script can be found here. If you find it useful, or have questions or comments, let me know in the comments section below.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s