Count-In with GP Metronome

Hi.

Is it possible to arrange for a count-in with GP’s built-in metronome?

IOW, when I press the arrowhead here:

Snag_83ca19

I would like GP to count-in 4 beats with the metronome before actually starting the transport (and thus the MIDI File Player, etc.)

Not at this time

1 Like

What is the use case?

I possess a large collection of MIDI files which do not have count-ins prepared in the files (and really should not, because of the nature of their usage).

Thus, it would be very good to be able to get the count-in from GP, ala the way I would from any of my DAWs.

Ok, so you need a count in for the band or drummer?

Yes, that’s right.

You could do that with scripting.
Do not sync the midi file player with the global play.
In the on timeline callback you could start the midi file player with beat 5

Interesting approach …

So I did this in the Global Rackspace script:

/*
    Script for Count-In with Metronome
*/

// Called at specfied bar:beats
On Timeline(bar : integer, beat : integer)  // EveryBeat
   
   1:1 
      EnableMetronome(true)
      
   1:4       
      EnableMetronome(false) // Useful if you turned it on before starting
      
End

and the result was a count of: 2 3 4.

Is there a way I can get a count of: 1 2 3 4 ?

You lost me, what do you want to achieve?

In the example above, just to get a click-count of: 1 2 3 4 when I press the playhead.

Once that is accomplished, I can get on to starting the MFP where I want it to start.

Use this callback to enable the metronome
on SystemEvent(x : double) Matching PlayheadStateChanged
Check if x == 1.0 and enable the metronome

That works. Thanks!

So this gives a nice 4 beat count in:


/*
    Script for Count-In with Metronome
*/

// Called on attempt to change playhead status - (Rackspace and GigScript only)
On SystemEvent( SysEvent : double) Matching PlayheadStateChanged

    if (SysEvent == 1.0) then 
            EnableMetronome(true) 
    end
End

// Called at specfied bar:beats
On Timeline(bar : integer, beat : integer)  // EveryBeat
      
   1:4       
      EnableMetronome(false) // Useful if you turned it on before starting
      
End

Now I’m having a hard time finding how to start the MIDI File Player.

Do I have to go thru a widget for that?

Assuming “yes”, I looked for something like “Start” in the MFP plugin parameter list but could not find it.

P.S. How can I get a “code block” into a Forum post so that code is set off visually?

Take a look at the function SetParameter

OK, I see that SetParameter() will let a script talk directly to a plugin.

Trying to work with that, I created a runtime error.

Snag_f27c1c

How can I clear this condition so that I can again attempt to run my code?

mFP exists now, I think:

Snag_f3db2f

Without the code …
Where is the midi file player located?

My question is: Do I have a way to re-enable scripting other than exiting and reopening GP?

This code will produce the error and shut off scripting.

/*
    Script for Count-In with Metronome

*/

var
    mFP : PluginBlock

// Called on attempt to change playhead status - (Rackspace and GigScript only)
On SystemEvent( SysEvent : double) Matching PlayheadStateChanged

    if (SysEvent == 1.0) then 
            EnableMetronome(true) 
    end
End

// Called at specfied bar:beats
On Timeline(bar : integer, beat : integer)  // EveryBeat
      
   1:4       
      EnableMetronome(false) // Useful if you turned it on before starting
      
End

I thought setting a GPScript Handle like this would make the name “mFP” visible to and usable by my code.

Snag_111ea7f

So far I’ve tried nothing more than declaring the var. There must be something wrong there, but what?

The problem was that the script was in the Global Rackspace and the MIDI FIle player was in a local rackspace. Duh!

Here is code that does the job:

/*
    Script:   MFP Start with CountIn 01
    
    Script for Count-In with Metronome
    and Start of MIDI File Player
    
    Make this script the 'Rackspace Script' in a rackspace containing a 
    MIDI FIle Player with Handle: "mFP"
    
*/

    var
        //  mFP  - MIDI File Player
        //  Set this handle for the MIDI File Player in the Wiring view.
        mFP : PluginBlock   

// Called on attempt to change playhead status - (Rackspace and GigScript only)
On SystemEvent( SysEvent : double) Matching PlayheadStateChanged

    //  When the playhead state goes to 1.0 (On), turn on the metronome
    if (SysEvent == 1.0) then 
            EnableMetronome(true) 
    end

   //  When the playhead state goes to 0.0 (off), turn off the MIDI File Player
    if (SysEvent == 0.0) then 
            //  Param 3 is 'Start' for the MIDI File Player, zero it to turn off MFP.
            //  You must do this here in the script, else the MFP will not stop!
            SetParameter(mFP, 3, 0.0)      
    end

End

// Called at specfied bar:beats
On Timeline(bar : integer, beat : integer)  // EveryBeat

    // the locations below may be set differently if desired

   1:4       // turn off metronome after the first bar
      EnableMetronome(false) // Useful if you turned it on before starting
            
   2:1      //  Start MIDI FIle Player at beginning of 2nd bar
       SetParameter(mFP, 3, 1.0)      //    Param 3 is 'Start' for the MIDI File Player
      
End
1 Like