Midi Notes

Ahh, truly just note patterns and not chords. I have a similar thing in one of my songs and that is a script unique to that song and matches three 2 note patterns. I had a think about making a generic version that would work for me. I think this does 1/7th of your script, so you would need to add 7 scriptlets, but the patterns can be added without editing code, so can be set in variations via widgets so may reduce the number you require. Also It distributes the loops into the notes arriving so the activation is as fast as possible.


const DEFAULT_CHANNEL : Integer = 1
const DEFAULT_NOTE : String = "C-2"
const DEFAULT_VELOCITY : Integer = 127

Var note3 : Parameter AsNoteNames C-2..G8 = DEFAULT_NOTE
    note2 : Parameter AsNoteNames C-2..G8 = DEFAULT_NOTE 
    note1 : Parameter AsNoteNames C-2..G8 = DEFAULT_NOTE 
    output : Parameter AsNoteNames C-2..G8 = DEFAULT_NOTE

Var noteOut : NoteMessage
    count : Integer = 0
    match : Integer Array = [0,0,0]
    sent : boolean = false

// Handle note On/Off events
On NoteOnEvent(m : NoteMessage)
    var i : Integer = 0
    If count < Size(match) Then
        for i=0; i<Size(match); i=i+1 Do
            If match[i] == GetNoteNumber(m) Then
                count = count + 1
            End
        End
    End
    
    // Send trigger
    If sent == false And count == Size(match) Then
        SendNow(noteOut)
        sent = true
    End
End

On NoteOffEvent(m : NoteMessage)
    var i : Integer = 0
    If count > 0 Then
        for i=0; i<Size(match); i=i+1 Do
            If match[i] == GetNoteNumber(m) Then
                count = count - 1
            End
        End
    End
    
    If sent == true And count != Size(match)Then
        SendNow(WithVelocity(noteOut,0))
        sent = false
    End
End

// Set up paramters for detector and output
On ParameterValueChanged matching note3
    match[2] = NoteNameToNoteNumber(note3)
End

On ParameterValueChanged matching note2
    note3 = note2
    match[1] = NoteNameToNoteNumber(note2)
End

On ParameterValueChanged matching note1
    note2 = note1
    match[0] = NoteNameToNoteNumber(note1)
End

On ParameterValueChanged matching output
    noteOut = noteOut.WithNoteNumber(NoteNameToNoteNumber(output))
End

Initialization
    noteOut = MakeNoteMessageEx(NoteNameToNoteNumber(output),DEFAULT_VELOCITY,DEFAULT_CHANNEL)
End

1 Like

I use the SAFP for playbacks and for controlling several keyboards/plugins (syncron) and don’t want to overload my laptop

Unfortunately, I’m not yet very familiar with Script. Perhaps it would be better to attach a GP file?

Yes, note patterns, not chords… sorry, english is my third language, so… :see_no_evil: :hear_no_evil: :speak_no_evil:
This scriptlet is custom hardcoded for this song. Otherwise, I use a generic scriptlet with sliders to create combinations on the fly, supporting up to 20 combos with different MIDI channels. Unfortunately, I can’t use it effectively because Gig Performer’s User Preset function only supports one combination at a time. So, I use the generic scriptlet to test note patterns, then have Grok hardcode them. This is why I’d love a built-in MIDI chord maker—scriptlets are a clunky, time-consuming workaround. For now, I guess I’ll have to manage with this approach.