;; adjust-dur.sal -- example using score-adjacent-events ;; ;; (c) 2008 by Roger B. Dannenberg ;; this is a variation of a previous my-score; ;; this one has short notes so we can hear the ;; effect of running adjust-durations ;; set my-score = {{0.0 0.1 {plucked-string pitch: 67 vel: 90 cutoff: 4000}} {0.5 0.1 {plucked-string pitch: 69 vel: 95 cutoff: 5000}} {1.0 0.1 {plucked-string pitch: 71 vel: 100 cutoff: 6000}} {1.5 0.1 {plucked-string pitch: 72 vel: 105 cutoff: 7000}} {2.0 0.1 {plucked-string pitch: 71 vel: 100 cutoff: 6000}} {2.5 0.1 {plucked-string pitch: 69 vel: 95 cutoff: 5000}} {3.0 1.0 {plucked-string pitch: 67 vel: 90 cutoff: 4000}}} ;; plucked-string comes from plucked-string.sal, but it is ;; copied here to make this program work without external ;; dependencies -- we could also write: ;; load "plucked-string" ;; to include the other file ;; define function plucked-string(pitch: 60, vel: 100, cutoff: 10000) begin return ((0.00768553 * vel + 0.0239372) ^ 2) * lp(pluck(pitch), cutoff) end ; a predicate that returns true when pitch is ; less than 70 define function not-very-high(expression) return expr-get-attr(expression, keyword(pitch), 100) < 72 ; a function of 3 notes Ð extend duration of current ; note to the starting time of the next note define function adjust-durations( previous, current, next) begin if not-very-high(event-expression(current)) & next then return event-set-dur(current, event-time(next) - event-time(current)) else return current end print "Here is my-score without alterations\n" exec score-play(my-score) print "Here is my-score processed with adjust-durations\n" exec score-play(score-adjacent-events( my-score, quote(adjust-durations)))