I would like to use this script to automatically start the midi file player on the next 1 of the next bar. Automatic start of a midi file. Also pasted below.
However, it is using a widget input to trigger the script. I have midi learned in the global midi settings my pedals to the NEXT and PREV song parts. I would like that to trigger the same script. In other words, when I press NEXT or PREV on my pedal, I would like it to switch on the next bar’s 1. How do I write the script to capture that incoming midi CC? Sorry, my scripting knowledge is still very limited. It is not a widget, nor a midi block so I didn’t how to declare variable. Thanks!
Var
NPART : Widget
SwitchPart : Boolean
initialization
SwitchPart = false
end
// Called when a single widget value has changed
On WidgetValueChanged(newValue : double) from NPART
if newValue == 1.0 then
SwitchPart = true
end
End
// Called when beat changes
// Only beat number is valid for now
On BeatChanged(bar : integer, beat : integer)
if beat == 1 and SwitchPart == true then
SongNextPart()
SwitchPart = false
end
end
Bad news: I haven’t solved it yet
Good news: I finally realized I should not waste more time thinking about how to declare it, because it probably doesn’t need to be declared. It is already assigned in the global settings, so a part change is going to happen upon pressing the pedal, so the question is how to delay that change to take place at the next bar 1? If of course what I’m trying to delay has already happened, its useless. Is it possible to have that global midi assignment for part change AND listen for that CC and not allow the part change to take place until the next bar’s 1??? Or would that require un-assigning the global midi setting to change parts (which I don’t want to do since I use that is my normal operation, I only want this delay to the downbeat when using midi file player).
This is what I got so far which does nothing:
var
SwitchPart : Boolean
initialization
SwitchPart = false
end
On BeatChanged(bar : integer, beat : integer)
if beat == 1 and SwitchPart == true then
SongNextPart()
SwitchPart = false
end
end
So my brain is running around in circles, need help! Where is everyone today? Responses are usually very quick in this forum… LOL
When you have things defined in Global Midi options then those messages are not available elsewhere in GP. So you’ll likely need to manage everything via scripts and possibly widgets in the global rackspace.
So if I put a midi in block to be used in script variable in the global rackspace to send CC’s to switch song parts, don’t I put this script in the setlist script editor? If so, where do I declare the midi in block variable, since that’s not allowed in the setlist script editor?
var
SwitchPart : Boolean
initialization
SwitchPart = false
end
On BeatChanged(bar : integer, beat : integer)
if beat == 1 and SwitchPart == true then
SongNextPart()
SwitchPart = false
end
end
Where is your MFP? Global Rackspace?
The other thing to consider is do you really want both the song part change and MFP start to be quantized to beat 1? It may be better to keep the song part change manual so you can trigger it just before the beat, so that your new song part/variation is ‘ready’.
Yes. Right now that’s being triggered to play with CC in the song part switching itself.
The first line choses the song, the second line turns widget on that starts the PLAY function. I had to do it this way b/c when it was just relying on the widget state in the variation, it was getting the widget PLAY message first and song part second. Never started to play. Once I put them both here, works fine.
var
MyMidiBlock : MidiInBlock // rename MyMidiBlock to the handle you've given to the block
SwitchPart : Boolean
initialization
SwitchPart = false
end
On BeatChanged(bar : integer, beat : integer)
if beat == 1 and SwitchPart == true then
SongNextPart()
SwitchPart = false
end
end
// CC to move to the next song part
On ControlChangeEvent(m : ControlChangeMessage) Matching 51 from MyMidiBlock // Change 51 to the CC number from your controller
if GetCCValue(m) == 127 then
SwitchPart = true
end
End
Just to clarify, you are talking about the song part change in the MFP right? Not the song part change in the setlist… If so, you are right, the MFP song change has to happen before the PLAY command, but that’s all taken care of with the current setlist song part change that I just screen shotted. I’m not sure if that’s the best way to handle it, but it works flawlessly, I just would like the entire setlist song part change to happen on the next bar 1.
I owe you (another) beer!!! It works! You know it was bound to since we both picked CC51 for next (before I even got your message). LOL
Now how do I go backwards to PREV song part (w/o creating a copy/separate message with SongPrevPart)? I’m guessing there is a more elegant way of doing an IF 50 PREV if 51 NEXT?
Var
MyMidiBlock : MidiInBlock
SwitchNextPart, SwitchPrevPart : Boolean = false
On BeatChanged(bar : integer, beat : integer)
if beat == 1 and (SwitchNextPart or SwitchPrevPart) then
if SwitchNextPart then
SongNextPart()
else
SongPrevPart()
end
SwitchNextPart = false
SwitchPrevPart = false
end
end
// CC to move to the next song part
On ControlChangeEvent(m : ControlChangeMessage) Matching 51 from MyMidiBlock // Change 51 to the CC number from your controller
if GetCCValue(m) == 127 then
SwitchNextPart = true
end
End
// CC to move to the previous song part
On ControlChangeEvent(m : ControlChangeMessage) Matching 50 from MyMidiBlock // Change 50 to the CC number from your controller
if GetCCValue(m) == 127 then
SwitchPrevPart = true
end
End
Thanks so much! I’m glad you sent it b/c it was not letting my copy the “on BeatChanged” as it was defined already. I was messing up the If / else … Works great!
I’m very happy with this already, but … is it possible to press two or three times to bypass parts? If so, how difficult is it to accomplish that? If it is not easy, I’ll just use touch for those extra rare times. I’m pretty sure that won’t be needed much.
I’m sure it’s possible. But you’d have to manage a counter that increments/decrements with each press, and also a widget to communicate this to you so you know which one you’re about to switch too.