Randomizing Plugin Parameters!

I’m not a programmer, tried to get into Basic as a kid and found I’m just not exact enough. :grinning_face_with_smiling_eyes: When I do programming, I’m usually just modifying other people’s scripts.

Started trying to figure out how to randomize plugin parameters with GPscript and started with the example in the manual. What is this error? I literally copied and pasted the example script and modified in a few places to start experimenting. What did I do?

Thank you!

Read the error message. It clearly states that you can’t declare a plugin block in a gig script. It has to be in a rackspace script.

Disregard that last message. I’m sorry, I see now. Apologies

Alright, got this working, sort of. But do have a question.

Var

RplRand1 : Widget

Repl : PluginBlock;

Aa : integer

Bb : integer

On WidgetValueChanged(newValue : double) from RplRand1

Aa = RandomRange(8,12)

Bb = RandomRange(0,1)

SetParameter(Repl, 0, Aa)

SetParameter(Repl, 1, Bb)

Aa is a knob that has, I think, 21 values. Bb is a button, so it has two, on and off, and this one works fine.

I’ve tried several different ranges for Aa, and sometimes it will change but mostly it sits at the maximum value (fully clockwise on the knob).

I was thinking that a range of 8,12 would have varied that knob between the 8th and 12th value, but obviously that’s not the case.

Does anyone have any insight as to how to set “Range” for a plugin knob? I’m hoping I’m making sense :stuck_out_tongue_winking_eye:

You have to scale values. Plugin parameters are always between 0.0 and 1.0

I see, using Scale

Scale(x: Double, xMin: Double, xMax: Double, yMin: Double, yMax: Double ) Autotype Returns Double

Maps a value between xMin and xMax into a value between yMin and yMax. Integers will be converted to doubles. See MidiToParam and ParamToMidi for slightly faster implementations

Parameters

Return type

Double

I will find examples later tonight, try to get it to work and post the successful script, thanks!

Actually, didn’t need to scale at all if I want to use any number between 0 and 1. Just use Random. And it works!

Var

RplRand1 : Widget

Repl : PluginBlock;

Ka : double

Ba : integer

On WidgetValueChanged(newValue : double) from RplRand1

Ka = Random()

Ba = RandomRange(0,1)

SetParameter(Repl, 0, Ka)

SetParameter(Repl, 1, Ba)

End

However, I did want to figure out scale so I could confine the range, if desired. And this works too!

Var

RplRand1 : Widget

Repl : PluginBlock;

Ka : double

KaSc : double

Ba : integer

On WidgetValueChanged(newValue : double) from RplRand1

Ka = RandomRange(0,100)

KaSc = Scale (Ka, 0, 100, 0.25, 0.5)

Ba = RandomRange(0,1)

SetParameter(Repl, 0, KaSc)

SetParameter(Repl, 1, Ba)

End

This is awesome! Thank you for your help dhj. And let me say also, I am loving GP. It’s been exactly what I needed and really really looking forward to getting my templates together and get going.

I have another question. I see there is a way in the Script Editor to add a New Editor Tab. Do I put all scripting in the Main Script (Live) window or if I create New Editor Tabs and put other scripts, will they work too? If I missed this in the manual, I apologize.

Edit: Nevermind, I think I just figured out all scripting needs to go into the main window. This is going to get a little complicated but ok! Actually, any great examples of how to organize this window for lots of scripting would be wonderful to look at, if anyone has any.