Detect Tempo from Audio Input

I tried some approaches to achieve an “audio tapping”… what finally worked was the use of a free little helper plugin from the “pizMidi collection”, called midiAudioToCC in combination with a short script in GP4. (Most probably won’t work in GP3!)
Here is a thread with links to this plugin-collection for WIN/MAC:

This plugin reacts on incoming audio (you can configure some parameters) and converts them in midi CC messages and you can read the change of its parameters with GP-script (i checked for the “Envelope L” in my script)…
Just connect the inputs of the plugin with your audio-in, set the OSC/Script handle of the plugin block according to the variable name in the script (right click the plugin block in wiring view) and use that code as rackspace script (don’t forget to hit “compile” after you inserted the code!)
In the example-gig i used it in a local rackspace, but it should work in the Global Rackspace as well (probably this would be even the better place).

var
audio2Midi : PluginBlock //script handle of the piz-plugin (can be set in the plugin block/wiring view)

a2mThreshHigh : double = 1.0 //upper threshold value to set an audio tap (1.0 = full level)
a2mThreshLow : double = 0.2 //lower threshold level - only if audio level drops below this, a new tap can be recognized

tapFlag : boolean = false //auxiliary flag to mark an already made "tap" (will be cleared when audio drops below lower Threshold)

//Check for changing paramter conditions from pluginblock
On ParameterValueChanged(parameterNumber : integer, parameterValue : double) from audio2Midi
    If parameterNumber == 7 Then //param# 7 is reacting on incoming audio (=envelope L)
        If parameterValue >= a2mThreshHigh and tapFlag == false then//check if tap-flag is cleared AND audiolevel exceeds upper threshold
            tapFlag = true //set the tap-flag (a tap has been made now)
            Tap() // do a tap
            //Print (parameterValue) //uncomment to display the value in the logging window
        Elsif parameterValue <= a2mThreshLow then //if audio drops below lower Threshold clear the tap-flag
            tapFlag = false
        End
    End
End

Here is a ready made example to try if this works for you:
audio2midi-tap.gig (14.4 KB)

6 Likes