; Create an appoggiatura (grace note) on or before the current note(s) ; by Bob Crispen ; revbob@crispen.org ; 18 September 1997 (do (int step 1) ; step size and direction of appoggiatura ; +ve=step up, -ve=step down (int ticks 10) ; duration of appoggiatura in ticks (int before 1) ; 1=insert appoggiatura of dur "ticks" ; before current beat ; -1=put appoggiatura on current beat and ; shift current beat right by "ticks" (getInt step "How big an appoggiatura (+ve=rising)?" -127 127) (getInt ticks "How long an appoggiatura (ticks)?" -120 120) (getInt before "Before (1) or on (0) the current note?" 0 1) (forEachEvent (if (== Event.Kind NOTE) (do (if (== before 1) (do ; Insert the appoggiatura before the current note (insert (- Event.Time ticks) Event.Chan NOTE (- Note.Key step) Note.Vel ticks ) ) ; else (do ; Shift the current note right and take off ; the length of the appoggiatura, so it still ; finishes at the same time it used to (+= Event.Time ticks) (-= Note.Dur ticks) ; Stick the appoggiatura on the current beat (insert (- Event.Time ticks) ; decrement back to orig. Event.Chan NOTE (- Note.Key step) Note.Vel ticks ) ) ) ) ) ) )