Hi everyone 👋 I need help with writing a CAL script which moves all the notes in one MIDI track to 6 other MIDI tracks. I need all C's and C#'s to be moved to track 2, all D's and D#'s to be moved to track 3, all E's and B's to be moved to track 4, all F's and F#'s to be moved to track 5, all G's and G#'s to be moved to track 6, and all A's and A#'s to be moved to track 7. I'm trying to create a rainbow color theme for MIDI files in Synthesia to enhance the user's sightreading ability. I asked ChatGPT to write the CAL script but it failed over and over again. It kept getting errors like "CAL Error 004: Unknown Procedure and" and "CAL Error 003: Wrong number of arguments if". Is there a way to do this with CAL?
Here's the first script it gave me:
(do
(include "need20.cal") ; Ensure we're running in CAL 2.0 or later.
(int i) ; Counter for iteration
; Iterate over all selected events in track 1.
(forEachEvent
(if (and (== Event.Kind NOTE)
(or (== Event.Track 1))) ; Only consider notes from track 1
(begin
; Move C notes (MIDI note numbers 0, 12, 24, ...) to track 2
(if (== (mod Event.Note 12) 0)
(setEvent Track 2)
)
; Move C# notes (MIDI note numbers 1, 13, 25, ...) to track 2
(if (== (mod Event.Note 12) 1)
(setEvent Track 2)
)
; Move D notes (MIDI note numbers 2, 14, 26, ...) to track 3
(if (== (mod Event.Note 12) 2)
(setEvent Track 3)
)
; Move D# notes (MIDI note numbers 3, 15, 27, ...) to track 3
(if (== (mod Event.Note 12) 3)
(setEvent Track 3)
)
; Move E notes (MIDI note numbers 4, 16, 28, ...) to track 4
(if (== (mod Event.Note 12) 4)
(setEvent Track 4)
)
; Move B notes (MIDI note numbers 11, 23, 35, ...) to track 4
(if (== (mod Event.Note 12) 11)
(setEvent Track 4)
)
; Move F notes (MIDI note numbers 5, 17, 29, ...) to track 5
(if (== (mod Event.Note 12) 5)
(setEvent Track 5)
)
; Move F# notes (MIDI note numbers 6, 18, 30, ...) to track 5
(if (== (mod Event.Note 12) 6)
(setEvent Track 5)
)
; Move G notes (MIDI note numbers 7, 19, 31, ...) to track 6
(if (== (mod Event.Note 12) 7)
(setEvent Track 6)
)
; Move G# notes (MIDI note numbers 8, 20, 32, ...) to track 6
(if (== (mod Event.Note 12) 😎
(setEvent Track 6)
)
; Move A notes (MIDI note numbers 9, 21, 33, ...) to track 7
(if (== (mod Event.Note 12) 9)
(setEvent Track 7)
)
; Move A# notes (MIDI note numbers 10, 22, 34, ...) to track 7
(if (== (mod Event.Note 12) 10)
(setEvent Track 7)
)
)
)
)
)
Does anyone know how to do this properly?
Thanks!