Why this error?


#1

i am trying to block midi notes from reaching a VI when my volume pedal is at “0”. there is a midi filter block in the rackspace, but i can’t figure out how to tell it to switch cc7 from blocked to unblocked and back…so, i thought i’d intercept the notes and send a note with volume 0 instead - is there a way to just intercept the notes, i.e. have an “On NoteEvent” callback with no action specified, that just stops the notes? anyway, here’s what i am trying (the pitch bend stuff is just to make sure there are no lingering string bending/pitch issues, my controller is a guitar…):

var cm : PitchBendMessage
M  : MidiInBlock
Slider1 : Widget
null : MidiMessage

initialization
null = MakeNoteMessage(C3, 0)
end

on NoteOffEvent(m : NoteMessage) from M 
 cm := MakePitchBendMessage(8192)
 SendNow(M, cm) 
 SendNow(M, m) // send Note Off
end

On WidgetValueChanged(newValue : double) from Slider1
    if newValue = 0 then     
      on NoteEvent(m : NoteMessage) from M
      SendNow (M, null)
      end
    end
end

i am getting a syntax error after the OnWidgetValueChanged callback, it says

Unexpected or unrecognized token: ‘if’
Mismatched input ‘if’ expecting End

i don’t understand this. this kind of construction complies in other scripts.


#2

You have two end keywords but only one if statement


#3

Oh – wait, you actually have another problem — you have defined an on NoteEvent inside your On WidgetValueChanged callback. That’s the real problem


#4

And when you compare you have to use ==


#5

ok, thanks…i deleted the on NoteEvent and changed “=” to “==” and now it compiles…but, how do i block notes from getting to the VI?

and, i gather you can’t nest callbacks in the way i did? have it look for NoteEvents only when the value of the widget is zero?


#6

i have a midi filter block in the rackspace too, is there a way to tell it to block note messages? are its parameters changeable by scripting? if i could tell it to block note messages when newValue==0, that would work, right?

WAIT - i think i found it…results shortly


#7

so easy:

var cm : PitchBendMessage
    M  : MidiInBlock
    Slider1 : Widget //footcontroller vol pedal sending cc7 to VI
    filter : PluginBlock //MIDI filter
    


on NoteOffEvent(m : NoteMessage) from M 
 cm := MakePitchBendMessage(8192)
 SendNow(M, cm) 
 SendNow(M, m) // send Note Off
end

On WidgetValueChanged(newValue : double) from Slider1
        if newValue == 0 then     
           SetParameter (filter, 4, 1)
          else SetParameter (filter, 4, 0)
        end
end

thanks, paul and david!

however, on getting this working, i found a problem in my concept…need to rethink what i want to do.


#8

You could have your NoteOff callback query the widget value to determine what you want to do when you receive a NoteOff message :wink:


#9

that was part of the problem, i fixed that by just blocking note on events instead of all note events…

the other thing was that i wanted i some cases to prepare notes with the volume off, so it didn’t work to always block notes with the volume at 0. fixed that by having a switch on my pedalboard to turn notes off, instead of the volume widget at 0.


#10

I don’t quite understand but glad you got whatever you needed working :slight_smile: