Detect Tempo from Audio Input

I just made an improved version of the above example, where i put everything into the global rackspace and i also placed two knobs on the panel to adjust the threshold levels on the fly, and i placed a small VU-widget besides them which will show wether there is some incoming audio (just as an indicator).

2022-12-05 17_43_29-Window

audio2midi-tap_global.gig (77.0 KB)

The script will then have a few lines more - although it could be optimized, i wanted to keep it how it is because of better understandability for beginners (hopefully :nerd_face: ).

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

knbThrLo, knbThrHi : widget //knob widgets for audio threshold adjustments

a2mThreshHigh : double //variable for upper threshold value to set an audio tap (1.0 = full level)
a2mThreshLow : double //variable for 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)


Initialization
//Get actual widget values on first start and set variables accordingly    
    a2mThreshLow = GetWidgetValue (knbThrLo)
    SetWidgetLabel (knbThrLo, a2mThreshLow)
    a2mThreshHigh = GetWidgetValue (knbThrHi)
    SetWidgetLabel (knbThrHi, a2mThreshHigh)
End

//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

//Use widgets to set the lower threshold variable & update the widget caption
On WidgetValueChanged (kVal : double) from knbThrLo //Lower Threshold widget
    a2mThreshLow = kVal
    SetWidgetLabel (knbThrLo, kVal)
End

//Use widgets to set the higher threshold variable & update the widget caption
On WidgetValueChanged (kVal : double) from knbThrHi//Lower Threshold widget
    a2mThreshHigh = kVal
    SetWidgetLabel (knbThrHi, kVal)
End

may it be useful for you folks… :vulcan_salute: :beers:

Oh… there is also a textbox on the panel with a rough explanation which says:

6 Likes