Script doesn't run first time

hi - i have a script that’s a modified version of one Paul kindly helped me with. this script fades 2 parameters in eventide’s BlackHole plugin, when i press a button on my FC-300 foot controller.

my problem is, the script doesn’t run the first time i press the button (the generator appears to function, but the values of the parameters don’t change). i have to toggle the button on and then off again, then it works the next time i turn it on.

is this a problem with the script, somehow, or is it maybe the plugin?

thanks,

tony

var myRamp : Ramp
 FADE : Widget  // Widget that starts the ramp
 BH : PluginBlock
 v_feedback : Double // Variable to get the current FEEDBACK level
 v_size : Double //Variable to get current SIZE level


 initialization
  SetGeneratorOneShot(myRamp, true)
 end

 on WidgetValueChanged(newValue : double) from FADE
  if newValue > 0.5 then
   v_feedback = GetParameter(BH, 8)
   v_size = GetParameter(BH, 2)
   
   myRamp.SetGeneratorLength(10000)  // 10 sec
   SetTimersRunning(true)
   myRamp.EnableGenerator(true)
   
  end
  
   if newValue < 0.5 then
   SetParameter (BH, 8, 0.9)
   SetParameter (BH, 2, 1)
  end 
 end

 on TimePassing(timeX : integer, amplitudeY : double) from myRamp
  SetParameter(BH, 8, v_feedback*(1.0-amplitudeY))
  SetParameter(BH, 2, v_size*(1.0-amplitudeY))
end

Try swapping the two lines below – let me know

yup. that fixed it, many thanks.

tony

i’ve modified the statement for when i toggle the button off to reset everything:

     if newValue < 0.5 then
     myRamp.EnableGenerator(false)
     SetTimersRunning(false)
     SetParameter (BH, 8, 0.9)
     SetParameter (BH, 2, 1)
     SetParameter (BH, 14, 1)

the last line turns on the “Kill” switch, which clears the plugin’s buffer. how do i then - after a few milliseconds, maybe - turn the Kill switch back off, i.e. send a “SetParameter (BH, 14, 0)” command to the plugin just a moment later? is there something like “SendLater” for a plugin block?

You can do a Trick and schedule a midievent to a osc Midi in Plugin.
In the on noteevent you can react on that.

ugh, but i’ll try it, thanks

At some point, I’ll probably add a more seamless mechanism for this. But the ScheduleMidiEvent function (see https://www.gigperformer.com/downloads/GPScript/SystemFunctionList.html) along with a MIDI In block that’s not used for anything physical (hence the use of an OSC MIDI In block) makes it quite easy to use a made up MIDI event to represent some desired function and then implement that functionality in a callback.

the “ugh” was more for me having to learn how to do what paul suggested, but i am making progress…is there a canonical list of types somewhere? i’m having a little trouble getting my head around that idea, for example, if i declare a variable as a midiMessage, what is a midiMessage? (if you need to send me elsewhere to learn these concepts, i’ll understand).

In the forum I pasted an example script to visualize the metronome.
Maybe that helps you to understand.

ok, this is compiling, but not working - the kill switch engages properly, but does not reset

var myRamp : Ramp
     FADE : Widget  // Widget that starts the ramp
     BH : PluginBlock
     v_feedback : Double // Variable to get the current FEEDBACK level
     v_size : Double //Variable to get current SIZE level
     unkill : MidiInBlock
     unkillarray : Integer Array



 initialization
  SetGeneratorOneShot(myRamp, true)
  unkillarray = [60]
 end

 on WidgetValueChanged(newValue : double) from FADE
  if newValue > 0.5 then
   v_feedback = GetParameter(BH, 8)
   v_size = GetParameter(BH, 2)
   
   myRamp.SetGeneratorLength(10000)  // 10 sec
   myRamp.EnableGenerator(true)
   SetTimersRunning(true)
   
  end
  
   if newValue < 0.5 then
   myRamp.EnableGenerator(false)
   SetTimersRunning(false)
   SetParameter (BH, 8, 0.9)
   SetParameter (BH, 2, 1)
   SetParameter (BH, 14, 1)
   SendNoteMessagesLater(unkill, unkillarray, 100, 1, 15)

  end 
 end
 
on NoteEvent(m : NoteMessage) from unkill
  SetParameter (BH, 14, 0)
end

 on TimePassing(timeX : integer, amplitudeY : double) from myRamp
  SetParameter(BH, 8, v_feedback*(1.0-amplitudeY))
  SetParameter(BH, 2, v_size*(1.0-amplitudeY))
end

the new bit is toward the end, i added an OSC MidiIn block called “unkill”, i send a note message to it 15 milliseconds after the button is pressed, and when it gets the note message it sends the new parameter value to the plugin. except it doesn’t. i think i’m misunderstanding something about the behavior of the note message and the unkill block.

thanks, paul, i think i’m getting some ideas form your metronome script

new script = WORKS!!! thank you so much, paul (and david)
i leave the kill switch engaged for 1 second in this example, just so i can see it work - i will change it to 15ms so that it will be very quick.

var myRamp : Ramp
     FADE : Widget  // Widget that starts the ramp
     BH : PluginBlock
     v_feedback : Double // Variable to get the current FEEDBACK level
     v_size : Double //Variable to get current SIZE level
     unkill : MidiInBlock
     m: MidiMessage



 initialization
  SetGeneratorOneShot(myRamp, true)
  m = MakeNoteMessage(C3, 100)
 end

 on WidgetValueChanged(newValue : double) from FADE
  if newValue > 0.5 then
   v_feedback = GetParameter(BH, 8)
   v_size = GetParameter(BH, 2)
   
   myRamp.SetGeneratorLength(10000)  // 10 sec
   myRamp.EnableGenerator(true)
   SetTimersRunning(true)
   
  end
  
   if newValue < 0.5 then
   myRamp.EnableGenerator(false)
   SetTimersRunning(false)
   SetParameter (BH, 8, 0.9)
   SetParameter (BH, 2, 1)
   SetParameter (BH, 14, 1)
   ScheduleMidiEvent(unkill, m, 1000.0)

  end 
 end
 
on NoteEvent(m : NoteMessage) from unkill
  SetParameter (BH, 14, 0)
end

 on TimePassing(timeX : integer, amplitudeY : double) from myRamp
  SetParameter(BH, 8, v_feedback*(1.0-amplitudeY))
  SetParameter(BH, 2, v_size*(1.0-amplitudeY))
end

Welcome to the club !

getting there…i have to say, it’s going to be hard not to spend all my time writing cool scripts instead of working on the music i’m supposed to finish…

1 Like

I’m sorry that I can’t help with scripting but unfortunately that would end up being an all-consuming black hole and we’d never get any GP code written!

However, if I may add a suggestion – I strongly urge you to liberally comment the code you’ve written. Otherwise, you’ll come back to it in a few months and forget completely what you did and why.

yup, i’ve been thinking about that. i’ve heard plenty of stories about what happens when you don’t do that. thanks for the reminder. a good habit to get into early.