Visualize the metronome?


#1

Does someone see a way to visualize the metronome? Maybe we can do that with a timer callback? On the first beat a red widget LED, on 2, 3, 4 a green one?


#2

That is possible, i will post a script


#3

Here is a script, just create 4 LED’s and give then the corresponding script name,
quick and dirty but it should work

//$<AutoDeclare>
// DO NOT EDIT THIS SECTION MANUALLY
Var
   RED : Widget
   GREEN2 : Widget
   GREEN3 : Widget
   GREEN4 : Widget
//$</AutoDeclare>




on BeatChanged(bar : integer, beat : integer, subbeat : integer)
 Print(beat % 4)
 if beat%4   == 0 then
    SetWidgetValue(RED, 1.0)
    SetWidgetValue(GREEN2, 0.0)
    SetWidgetValue(GREEN3, 0.0)
    SetWidgetValue(GREEN4, 0.0)
 elsif beat%4 == 1 then
    SetWidgetValue(RED, 0.0)
    SetWidgetValue(GREEN2, 1.0)
    SetWidgetValue(GREEN3, 0.0)
    SetWidgetValue(GREEN4, 0.0)
 elsif beat%4 == 2 then
    SetWidgetValue(RED, 0.0)
    SetWidgetValue(GREEN2, 0.0)
    SetWidgetValue(GREEN3, 1.0)
    SetWidgetValue(GREEN4, 0.0)
 elsif beat%4 == 3 then
    SetWidgetValue(RED, 0.0)
    SetWidgetValue(GREEN2, 0.0)
    SetWidgetValue(GREEN3, 0.0)
    SetWidgetValue(GREEN4, 1.0) 
 end   
  
end

#4

A another possibility with just 2 LED’s, 1 red and 1 green.
But you have to include another MIDI in Block (OSC Midi in is fine):

//$<AutoDeclare>
// DO NOT EDIT THIS SECTION MANUALLY
Var
   TRIGGER : MidiInBlock
   RED : Widget
   GREEN : Widget
//$</AutoDeclare>


m :MidiMessage
   
initialization
 m = MakeNoteMessage(C3, 100)
end 


on BeatChanged(bar : integer, beat : integer, subbeat : integer)
 
 if beat%4 == 0 then
    SetWidgetValue(RED, 1.0)
 else
    SetWidgetValue(RED, 0.0)
    SetWidgetValue(GREEN, 1.0)
 end 

 ScheduleMidiEvent(TRIGGER, m, 100.0)

 end
 
 on NoteEvent(m : NoteMessage) from TRIGGER
  SetWidgetValue(RED,0.0)
  SetWidgetValue(GREEN,0.0)
 end

#5

Wow! Thank you for your quick answer, and also for the excellent idea to use an OSC MidiInBlock to trigger something. I can use this more often in my script.
:+1: :wave: