I have a knob connected to a scriptlet parameter that changes the tempo of a BeatBuddy. It works fine for changing the tempo but it can not restore the tempo from the saved widget value on initialization.
It seems like functions like GetParameter is not available in scriptlets but is available in scripts. Do I have to use scripts for this ? If so can I send tempo changes to BeatBuddy via ordinary script ?
Hi @kjetilge. What messages are being sent in order to change the tempo in the BeatBuddy?
And is it when you’re switching rackspaces that it’s not sending out a message to the BeatBuddy, or when you first load the gig file, or some other situation?
Is the scriptlet in each local rackspace or in the global rackspace?
I’m glad you got it working.
I wouldn’t have thought that the ‘PreviousValue’ function would be required, but I haven’t tried to test your code.
As you start to use scripts more, anytime you find yourself repeating the same lines of code, you could create your own Function. It’s mentioned here in the Language Manual:
My other comment would be about where you’re sending directly to a midi out device. Because scriptlets exist as a plugin in Wiring view, you can instead just use the general SendNow function, and then connect the scriptlet midi out port to your beat buddy midi out port. This gives you the benefit of a more visual indicator of where the messages are being sent to, and one less thing to have to edit in the script code if you ever need to change the routing.
That doesn’t appear until the system has decided you have posted enough legitimate items so that you’re not a spammer However, you have been manually incremented to the next trust level so that pencil should be available now
Hi @kjetilge, welcome to the GP community forum. Glad to have one more GPScripter!
GetParameter is necessary to get the parameter value of a plugin, not to get the parameter value within a Scriptlet. Scriptlet parameters are directly available using their variable name within the Scriptlet code. You cannot access directly a plugin parameter from a Scriptlet, as Scriptlet are plugins and are therefore not aware of other plugins.
Having said that, a Scriptlet is perfectly adapted to what you want to do here:
a widget mapped to a bmp parameter of your Scriptlet to adjust the tempo
if the Scriptlet bmp parameter is changed the Scriptlet sends the proper MIDI messages to its output (using SendNow as mentioned by @rank13 and not by sending directly to a MIDI port)
when you switch to a rackspace the tempo widget will initialize the bmp parameter of your Scriptlet which is equivalent to changing the bmp parameter manually (On ParameterValueChanged patching bmp will than send the MIDI message)
So indeed, I agree with @rank13, use SendNow and connect the MIDI output of your Scriptlet to the BeaatBudd MIDI out port. Use perhaps your own custom SendBMPNow(bmp) function. And possibly don’t use GetSubRangePreviousValue (bmp), but bmp directly (or perhaps I missed something).