COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > Other Software Discussion > WDL users forum

Reply
 
Thread Tools Display Modes
Old 10-30-2019, 01:11 PM   #1
Gubbles
Human being with feelings
 
Gubbles's Avatar
 
Join Date: Jul 2018
Posts: 4
Default Trigger Effect + GUI Element via MIDI

Heyy, so I've got some buttons (IContactControl) in my GUI that currently trigger effects when clicked, and deactivate upon release. The basic code for the parameter change looks like this:

Code:
void GubGlitch::OnParamChange(int paramIdx) {
  IMutexLock lock(this);

  switch (paramIdx) {
  case kChop_2nd:
      if (GetParam(kChop_2nd)->Value()) chopper.setChopper(2.0);
      else chopper.setActive(false);
      break;
  // other parameters etc etc
  }
}
Thing is, I'm having a hell of a time trying to get these effects triggered-- and the buttons to appear pressed-- using MIDI input.

Was able to find that calling SetParameterfromGUI(kChop_2nd) does trigger the effect... but if I just throw it in ProcessDoubleReplacing() it gets called every frame and thus doesn't work as intended (since it's a rhythmic effect). Additionally, the button itself doesn't appear pressed when I trigger the parameter directly like this, so I'm not sure what to do in that regard.

To make matters more complex, I have a separate .h/.cpp file for handling MIDI. I'd like to trigger the effect from there, but I can't call either SetParameterFromGUI() or the direct effect, chopper.setChopper() since they're part of the main cpp file. Optimally I'd like to be able to call it from the NoteOn/NoteOff messages I'm processing in my MIDI queue, since those are only fired once per key press as opposed to every frame it's held down, but for the life of me I cannot figure out how.

Last edited by Gubbles; 10-31-2019 at 11:07 AM.
Gubbles is offline   Reply With Quote
Old 10-31-2019, 10:19 AM   #2
earlevel
Human being with feelings
 
Join Date: Dec 2015
Posts: 331
Default

First, I'd start with the part about having problems getting the buttons pressed from the UI. If they are working, you'll have a parameter change when you press, another when you release, as the parameter associated with the button changes value. Don't try to debug that parameter changes first
earlevel is offline   Reply With Quote
Old 10-31-2019, 11:20 AM   #3
Gubbles
Human being with feelings
 
Gubbles's Avatar
 
Join Date: Jul 2018
Posts: 4
Default

Ah, perhaps I didn't communicate this very clearly; the buttons on the GUI work as intended! I'm struggling to figure out how to essentially "press" the button and trigger the associated effect when a MIDI key is pressed. Edited the post above to hopefully be a bit clearer.

My two points of contention are as follows: I'm not sure what function I'm supposed to use to accomplish this, as SetParameterFromGUI() only seems to do half of what I need (it triggers the effect but doesn't update the UI). Additionally, I'm not sure how or where I'm supposed to call it. Seems like it must be called from somewhere in the main .cpp file, but I'm trying to figure out if there's a way I can remotely call the function whenever certain conditions are met in the MIDI handling .cpp. I also need to ensure that it only gets called once when a MIDI key is pressed, and aside from making the function call directly in that file (which I can't seem to do), I'm unsure of how to accomplish this.
Gubbles is offline   Reply With Quote
Old 11-01-2019, 10:53 AM   #4
earlevel
Human being with feelings
 
Join Date: Dec 2015
Posts: 331
Default

Sorry, I don't have time to check, and it's always confusing, but check SetParameterFromPlug, I think that might be what you want...(also note, for sanity's sake, that SetParameterFromGUI is a method of both IGraphics and IPlugBase—I assume you're using the former).
earlevel is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:39 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.