Presentation is loading. Please wait.

Presentation is loading. Please wait.

RetrogradeRetrograde. Divide and Conquer Concept first Data: ‘((0 60 1000 1 127)(1000 62 500 1 127)) We want this to look like ‘((0 62 500 1 127)(500.

Similar presentations


Presentation on theme: "RetrogradeRetrograde. Divide and Conquer Concept first Data: ‘((0 60 1000 1 127)(1000 62 500 1 127)) We want this to look like ‘((0 62 500 1 127)(500."— Presentation transcript:

1 RetrogradeRetrograde

2 Divide and Conquer Concept first Data: ‘((0 60 1000 1 127)(1000 62 500 1 127)) We want this to look like ‘((0 62 500 1 127)(500 60 1000 1 127)) So we begin the second event with 0 and then add its 0 duration to arrive at the first event’s ontime?

3 One way to do it #| requires monophonic no-rest input as in ? (RETROGRADE (reverse '((0 60 1500 1 127)(1500 61 500 1 127))) 0) ((0 61 500 1 127) (500 60 1500 1 127)) |# (defun retrograde (events ontime) “This fcn assumes that the events are reversed.” (if (null events)() (cons (cons ontime (rest (first events))) (retrograde (rest events) (+ ontime (third (first events)))))))

4 A simple top-level #| adds a top level to the above to make input clearner ? (RETROGRADE-MUSIC '((0 60 1500 1 127)(1500 61 500 1 127))) ((0 61 500 1 127) (500 60 1500 1 127)) |# (defun retrograde-music (events) “Assures that retrograde gets reversed events without making the user do it.” (retrograde (reverse events) 0))

5 But what about rests Our previous example will not work with interpolated rests in the music (i.e., '((0 60 1000 1 127)(1500 61 500 1 127)) ) will produce the same result as before, not what it should be '((0 61 500 1 127)(1000 60 1000 1 127)).

6 Allows rests #| this one allows for rests but still requires monophonic no-rest input as in ? (RETROGRADE-EVENTS (reverse '((0 60 1500 1 127)(3000 61 500 1 127))) 3500) ((0 61 500 1 127) (2000 60 1500 1 127)) |# (defun retrograde-events (events total-length) “Retrogrades events that include silences.” (if (null events)() (cons (cons (- total-length (+ (first (first events))(third (first events)))) (rest (first events))) (retrograde-events (rest events) total-length))))

7 Andrew’s (defun retrograde (events) (let* ((start-time (first (first (sort events '< :key 'first)))) ;;Find when the music starts (norm-events (delay-all events (- 0 start-time))) ;;Shift to 0 (we'll change back later) (play-time (first (sort (add-two-lists (extract-feature norm-events 0) ;;Find out how long the whole thing is (extract-feature norm-events 2)) '>))) (new-list nil)) ;;Start with an empty list (dotimes (i (length norm-events)) ;;Iterate over the list (setf new-list (append new-list ;;Keep adding elements (list (cons (- play-time ;;That are constructed by using their new times(+ (first (nth i norm-events)) (third (nth i norm-events)))) (rest (nth i norm-events))))))) (sort (delay-all new-list start-time) '< :key 'first))) ;;Add the start time again, sort chronologically (extract-feature norm-events 2)) '>))) (new-list nil)) ;;Start with an empty list (dotimes (i (length norm-events)) ;;Iterate over the list (setf new-list (append new-list ;;Keep adding elements (list (cons (- play-time ;;That are constructed by using their new times (+ (first (nth i norm-events))(third (nth i norm- events)))) (rest (nth i norm-events))))))) (sort (delay-all new-list start-time) '< :key 'first))) ;;Add the start time again, and sort chronologically

8 and (defun add-two-lists (list1 list2) (if (eq (length list1) (length list2)) ;;Make sure the lengths are equal (if (or (eq list1 nil) (eq list2 nil)) ;;If either is nil, you're done () (cons (+ (first list1) (first list2)) ;;Construct the list by adding element (add-two-lists (rest list1) (rest list2)))) ;;Recurse over the lists (format t "Lists are not the same length")))

9 and (defun delay-event (event delay) (append (list (+ delay (first event))) ;;Construct event by adding delay to start-time (rest event))) (defun delay-all (events delay) (if (eq events nil) () (cons (delay-event (first events) delay) ;;Delay the first event off the list (delay-all (rest events) delay)))) ;;Recurse over the list (defun extract-feature (events feature) ;;Pulls out one feature from each event and puts them all a list (if (eq events nil) () (cons (nth feature (first events)) ;;Pull out the nth feature and add it to list (extract-feature (rest events) feature)))) ;;Recurse over list

10 Lex (defvar *cope-events* '((0 60 2000 1 64) (2000 62 1000 1 64) (3000 64 1000 1 64) (4000 65 500 1 64) (4500 64 500 1 64) (5000 67 1000 1 64) (6000 62 1500 1 64) (7500 59 500 1 64))) (defun total-length (*cope-events*) (+ (first (first (last *cope-events*))) (third (first (last *cope-events*))))) (defun backwards (*cope-events*) (if (null *cope-events*) () (cons (cons (- (total-length *cope-events*) (first (first *cope-events*)) (third (first *cope-events*))) (nthcdr 1 (first *cope-events*))) (backwards (rest *cope-events*)))))

11 Andre (setf midi-list '( (0 60 500 1 127) (1000 61 1500 1 127) (2500 62 1000 1 127) (6400 63 250 1 127) (6650 64 250 1 127) (6900 65 250 1 127) (7150 66 250 1 127) ))

12 Some helpers (defun reverse-list (midi-list) (reverse midi-list)) (setf mirror-midi-list (reverse-list midi-list)) (defun differentiate (any-number-list) (if (equal (length any-number-list) 1) () (cons (- (second any-number-list) (first any-number-list)) (differentiate (rest any-number-list)) )))

13 More helpers (defun extract-on-set-time (midi-list) (if (null midi-list) () (cons (first (first midi-list)) (extract-on-set-time (rest midi-list)) ))) (setf on-set-durations (append (differentiate (EXTRACT-ON-SET-TIME midi-list)) '(0))) (defun sum-increasing-list (number-list) (if (null number-list) () (cons (reduce #'+ number-list) (sum-increasing-list (rest number-list)) ))) (setf on-sets (reverse (SUM-INCREASING-LIST on-set-durations)))

14 Main course (defun backwards (on-event remaining-list) (if (null on-event) () (cons (list (first on-event) (second (first remaining-list)) (third (first remaining-list)) (fourth (first remaining-list)) (fifth (first remaining-list)) ) (backwards (rest on-event) (rest remaining-list)) )))

15 Joe (defun BWD (cope ) (if (null cope) () (append (list (append ( list (- (- (+(third (first (last cope))) (first (first (last cope)))) (first (first cope)) ) (third (first cope))) (Second (first cope)) (third (first cope))) (nthcdr 3 (first cope)))) (BWD (rest cope)))))

16 Phoenix (defun backwards (event-list) (list (list (first (first event-list)) (second (third event-list)) (third (third event-list)) (nthcdr 3 (third event-list))) (list (third (third event-list)) (second (second event-list)) (third (second event-list)) (nthcdr 3 (second event-list))) (list (+ (third (third event-list)) (third (second event-list))) (second (first event-list)) (third (first event-list)) (nthcdr 3 (third event-list))))) (backwards '((0 57 1000 1 99)(1000 59 5000 1 99)(6000 56 2000 1 99))) ((0 56 2000 (1 99)) (2000 59 5000 (1 99)) (7000 57 1000 (1 99)))


Download ppt "RetrogradeRetrograde. Divide and Conquer Concept first Data: ‘((0 60 1000 1 127)(1000 62 500 1 127)) We want this to look like ‘((0 62 500 1 127)(500."

Similar presentations


Ads by Google