Send MIDI click notes to drum plugin (or Record MIDI Beats During Count-In)

With an alias ‘LGP’ setup in the Rig Manager

Snag_1d3a9dc

I declare that in the gig script

var
LGP : MidiInDeviceAlias // alias LGP is defined in Rig Manager

and then inject like so:

InjectMidiEventViaRigManager( LGP, MakeNoteMessageEx( Click_NoteNum, 127, Click_Chan ) )

and I send that count-in MIDI to a drum plugin so I can hear the count:

I wonder, as a matter of understanding, is there another function I could use in the gig script that would send the count-in MIDI directly into the drum plugin.

IOW, can I address a plugin block by name or handle directly from the gig script?

I don’t think I see a function that offers this, but I would like to confirm. Thanks.

Use a rackspace script or use OSC to send MIDI via OSC to the MIDI in plugin connected to the drum VST.

That’s how I did it

Since I don’t understand these answers, I probably didn’t put my question across clearly.

Let me try again …

The green plugin block in the above picture has the caption/name of “Jamstix4 (1)”, and it has the handle of “ClickOut”.

Is there a line of code (i.e. a function call) that I can use in a script that will send a specified MIDI message from the script directly into the MIDI input of that green box?

IOW, not thru a wire or some other intermediate entity.

(If available, I would use such in the On Timeline() callback in a manner similar to the discussions already above.)

If such exists, and there are limitations on which kind of script I could use it in, then OK, important to note that. But the essence of my question is does the function exist, and if so, what is it? Thanks.

No, there is not.

OK, thanks.

It’s an interesting idea though –

To send MIDI Data to an Handle directly?

Maybe - not sure - but I can (sort of ) see the benefit of not having to require a MIDI In block for such things — but I’m not sure how many would benefit from it

1 Like

I am not sure how to check in the wiring view what signal paths are used when MIDI can directly be sent to a plugin.

And that would be one problem, though I suppose we could make the MIDI input port of the plugin flash by itself :slight_smile:
But the real question is whether it would be worth doing this at all - how many would use such a feature?
That said, forget about GPScript for a minute – it might be very convenient to be able to send MIDI messages directly to a plugin from actions.

Just to point out:

You do not need the timeline callback to generate a countdown. Even from a scriptlet, you could query the current BPM, convert to milliseconds and then use SendNow and SendLater in a single call to generate MIDI note messages that would be sent out over time.

That is true, but when I want to start with the global play the time line is ideal.

Right - but you mightn’t need a timeline – you might just want to provide a countdown to your band without the drummer doing it

OK, that is a valid use case :wink:

Sorry late to the party.

OP you did not specifically say that you need the play head running. As @dhj points out, if all you are looking for is a count in for your band/recording this simple solution is not locked to the Beats/Bars, but is a simple countoff at the BPM (mS intervals). As it generates Audio from the drum plugin so it can be recorded.

A number of parameters are exposed to allow configuration without changing the code. This scriptlet will also obey the BPM overrides provided in the Rackspace or Song parameters.

To trigger the count, the Start Countoff parameter can be mapped to a widget as below. This widget can then be mapped to a physical control, via the Rig Manager.

Here is the scriptlet that should output MIDI for the Drum Plugin. The defaults can be changed in the const DEFAULT_ section of the script, if external control is not needed.

// Count in scriptlet
// The BPM value is taken from the Global BPM
// Rackspace and Song overides temporarily set the Global BPM so these are collected at the moment the trigger fires

const DEFAULT_CHANNEL : Integer = 10
const DEFAULT_NOTE : String = "C3"
const DEFAULT_VELOCITY : Integer = 100
const DEFAULT_mS : Integer = 100
const DEFAULT_COUNT : Integer = 4

var
    start ("Start Countoff") : Subrange Parameter 0..1 = 0
    note ("MIDI Note Number") : Parameter AsNoteNames C-2..G8 = DEFAULT_NOTE
    duration ("Note ON mS") : Subrange Parameter 100..200 = DEFAULT_mS
    clicks ("Number of clicks") : Subrange Parameter 1..8 = DEFAULT_COUNT

var clickNote : NoteMessage

// --------------------------------------------------
// Called when a parameter value has changed
On ParameterValueChanged matching start
    var n : Integer
    var r : Integer = 0
    Var i : Double = 60000.0 / GetBPM()   // Calculate the interval in mS from the BPM 

    If start <> 0 Then
        SendNow(clickNote)
        SendLater(clickNote.WithVelocity(0),duration)
        For n=1; n<clicks; n=n+1 Do
            r = Round(i*n)
            SendLater(clickNote,r)
            SendLater(clickNote.WithVelocity(0),r+duration)
        End
    End
End

// --------------------------------------------------
// Called when a parameter value has changed
On ParameterValueChanged matching note
    clickNote = MakeNoteMessageEx(NoteNameToNoteNumber(note),DEFAULT_VELOCITY,DEFAULT_CHANNEL)    
End

// --------------------------------------------------
// Called automatically after script is loaded
Initialization
    clickNote = MakeNoteMessageEx(NoteNameToNoteNumber(note),DEFAULT_VELOCITY,DEFAULT_CHANNEL)    
End

This is the output trace from the default settings using 120BPM

2 Likes

@Spav That is a very nice solution for an independent widget-triggered count-in. Thanks for posting it with your excellent explanation!

I wonder, could this scriptlet approach itself be tied to the playhead, if that were desired (as an alternative, or in addition)?

IOW, is there a way to kick-start this scriptlet’s action from inside of:

On SystemEvent( SysEvent : double) Matching PlayheadStateChanged

End

in a gig or rackspace script? (or similar)

A scriptlet does not know about the system.
It reacts on incoming MIDI or Parameter Changes.

Here is is clearly shown what callbacks are implemented.

1 Like

Very good. Thanks!

Create a gig script

// Called on attempt to change playhead status - (Rackspace and GigScript only)
On SystemEvent(newValue : double) Matching PlayheadStateChanged
    OSC_SendDoubleSpecific("/Start/SetValue", newValue, "127.0.0.1", 9000)
End

Adjust the port number 9000 to your OSC listening port.

Create a widget and give it the OSC/GSScript Handle Start
Enable OSC

Map a scriptlet Parameter to that widget
and in your scriptlet react on Parameter changes.

This way you trigger the scriptlet by pressing the global play button.

Playhead.gig (26.5 KB)

There are so many feature implemented in Gig Performer, you do not need new functions.
Just be creative :wink:

1 Like