How can I display a note value in widget caption

I have two knob widgets that send values 0-100 to a plugin.
image

I want to convert that widget values (0-100) to a note name EG: C3 and place it on the widget’s label in place of the widget value. Any help would be appreciated. :slight_smile:

Here is the script I have so far:

Var

   Sax_LowNote  : Widget
   Sax_HighNote : Widget

   CCH_Brass, CCH_Sax, CCH_Wind : PluginBlock;

On WidgetValueChanged(newValue : double) from Sax_LowNote
   SetParameter(CCH_Sax, 161, newValue)
   SetParameter(CCH_Sax, 162, newValue)
   SetParameter(CCH_Sax, 163, newValue)
   SetParameter(CCH_Sax, 164, newValue)
   SetParameter(CCH_Sax, 165, newValue)
   SetParameter(CCH_Sax, 166, newValue)
   SetParameter(CCH_Sax, 167, newValue)
   SetParameter(CCH_Sax, 168, newValue)
   
   SetWidgetLabel(Sax_LowNote, newValue * 100)
 
End


On WidgetValueChanged(newValue : double) from Sax_HighNote
   SetParameter(CCH_Sax, 171, newValue)
   SetParameter(CCH_Sax, 172, newValue)
   SetParameter(CCH_Sax, 173, newValue)
   SetParameter(CCH_Sax, 174, newValue)
   SetParameter(CCH_Sax, 175, newValue)
   SetParameter(CCH_Sax, 176, newValue)
   SetParameter(CCH_Sax, 177, newValue)
   SetParameter(CCH_Sax, 178, newValue)
   
   SetWidgetLabel(Sax_HighNote, newValue * 100)

End

Hi Phil,

if you should have bound the two knobs to the min-note and max-note parameters of a midi-in block (which i don’t know, because you didn’t tell!), there would be the very easy option to just use the “[value]” tag as a customized caption of the widget - but this only works if the widget is actually bound to a parameter!

If you have to / want to use GP-Script, there are those two functions that will do the job, when combined:

NoteNumberToNoteName(<i : integer>)
// converts an integer 0-127 to a note name C-2 to G8

and

ParamToMidi(<m : Double>)
// converts a double value 0.0-1.0 to a MIDI-value 0-127

So the single “SetWidgetLabel()” line in this small script will do the job as wanted:

var
knb_maxnote : widget

On WidgetValueChanged (newval : double) from knb_maxnote
    SetWidgetLabel (knb_maxnote, NoteNumberToNoteName (ParamToMidi(newval)))
End
2 Likes