Two How to Do Questions

  1. How can I access the individual notes played within an “On Notevent callback”? I want to treat “m” as an array such that I can discern the chord, address the individual notes and expand the chord. EG: I have a basic C7 chord (C4-E4-G4-Bb4) coming in from a digital accordion and I want to rearrange it to an open piano chord (C3-C73-.G4-Bb4-D5-G5).

  2. In the “On NoteEvent” or “On NoteoffEvent” I want to turn off/on the boolean for “MIDI Block noteon” in the midi block. … if not, can I turn on/off the note block filter boolean in the MIDI Filter? I just can’t find the GPscript function to do this.

In the “On NoteEvent” or “On NoteoffEvent” I want to turn off/on the boolean for “MIDI Block noteon” in the midi block. … if not, can I turn on/off the note block filter boolean in the MIDI Filter? I just can’t find the GPscript function to do this.

For my understanding: You want to enable/disable the option in the MIDI In Block by pressing a note on your controller?

Try this as an example, a Widget controls the Note On property
In your case youw would do that in the on NoteOnEvent or on NoteOffEvent

BypassNoteOn.gig (4.4 KB)

//$<AutoDeclare>
// DO NOT EDIT THIS SECTION MANUALLY
Var
   MIN : MidiInBlock
   KNOB : Widget
//$</AutoDeclare>


// Called when a widget value has changed
On WidgetValueChanged(newValue : double) from KNOB
  SetParameter(MIN, 288, newValue)
End
1 Like

How can I access the individual notes played within an “On Notevent callback”? I want to treat “m” as an array such that I can discern the chord, address the individual notes and expand the chord. EG: I have a basic C7 chord (C4-E4-G4-Bb4) coming in from a digital accordion and I want to rearrange it to an open piano chord (C3-C73-.G4-Bb4-D5-G5).

With this script you can build an array where all played Note Numbers are marked.
Now you can manipulate this array and at the end send Note Messages,
BUT: As the callback is executed for each played note - when is the right time to manipulate the array?

var nn  : Integer [127]
    MIN : MidiInBlock
    
on NoteOnEvent (m : NoteMessage) from MIN
 nn[GetNoteNumber(m)] = 1
 SendNow(MIN, m)
end

on NoteOffEvent (m : NoteMessage) from MIN
 nn[GetNoteNumber(m)] = 0
 SendNow(MIN, m)
end
1 Like

Thanks, this (SetParameter(MIN, 288, newValue)) is great! However, where do I find the menaing of “288”. Also, I think the “New/Value” I send should be a boolean?

Take a look at the screenshot,

when you click on a gui element you see the parameter number in the top of the window.

the newValue is a number, the properties accept only numbers as I know.

The parameter values of any plugin are float (double in GPScript) ranging from 0.0 to 1.0. So, the typical off/on values are respectively 0.0 and 1.0.

2 Likes

Thanks, Paul. I will play with this code this evening … this should do the trick :slight_smile:

Your solution : "SetParameter(MIN, 288, newValue): works great! However, where does it say in the GP documentation the “288” is the “Note On property”?

If I say, “SetParameter(MIN, 1, newValue)”, it turns on channel 2 and sets its output channel to 16. … but where is the reference to this? :slight_smile:

The documentation does not say that 288 is note on, it says where you can see what parameter number a property has.
Each parameter goes from 0.0 to 1.0
So you have to calculate the right value to set a properties to the desired value.
It you should think about using widgets mapped to such properties and use variations.

1 Like

Upper left corner :wink:
All Blocks (plugins included) “reveal” their parameters there, when you edit/manipulate them

4 Likes

Can you tell me why this script doesn’t work? I am trying to set the MaxNote value to 60. It is my understanding that the Maxnote parameter in the MIDIBlock has a value of 17.

Var
M1 : MidiInBlock
nMaxNote : Integer
nMaxNoteValue : Integer

On Activate

nMaxNote = 17
nMaxNoteValue = 60
Print ("Activate - Setting MAX Note to 60")
SetParameter(M1, nMaxNote, nMaxNotevalue)

End

on NoteEvent(m : NoteMessage) from M1

Print ("NoteEvent - setting Max note to 15")
SetParameter(M1, nMaxNote, 15)

end

Parameter values must always be between 0.0 and 1.0 so a value of 15 makes no sense.

For MIDI note 15, you need the value 0.1181102

Now before you panic and wonder where the hell that number came from, there is a function called MidiToParam that converts MIDI values (i.e, integers between 0 and 127) into the appropriate parameter value between 0.0 and 1.0

So the following will work for you

SetParameter(M1, nMaxNote, MidiToParam(15))

will do the job

1 Like

By the way, if your goal is to set keyboard splits, it’s useful to define a function to make it easier to use those parameters. For example

Var
   Foo : MidiInBlock

Function DefineSplit(keyboard : MidiInBlock, lowerNote : integer, upperNote : integer)
   SetParameter(keyboard, 16, MidiToParam(lowerNote)) // 16 is parameter index for lower note
   SetParameter(keyboard, 17, MidiToParam(upperNote)) // 17 is parameter index for upper note
End


Initialization
   DefineSplit(Foo, C2, C3) // Create a split between C2 and C3
End

To declare a MidiInBlock , I would say for example "var M1 : MidiInBlock " where “M1” is the handle of the MidiInBlock. My question is: How do I declare a source block?

What do you mean by “source block”?

image

the handle is “Source2” and I want to do this: “SetPluginBypassed(Source2,1.0)”

I am getting this error: “Semantic error: Line 67, Col 27: Identifier not declared: Source2”

Ok, you miss this

var Source2 : PluginBlock

You have to declare this block

And then this should work:

SetPluginBypassed(Source2,true)

The 2nd parameter is a boolean and not a double.

1 Like

Thank you. I didn’t know the type “PluginBlock” as it doesn’t seem to be defined in the online documentation!

However, now this statement “SetPluginBypassed(Source2,1.0)” is getting the following error:
“Semantic error: Line 68, Col 35: Types are not compatible”

See my refreshed answer :wink:

And with the code helper button you get help

Yes, that works using “true” … but isn’t the value “1.0” the same as true and “0.00” the same as “false”?