1 / 49

Machaut Messe

Machaut Messe. Performance Isorhythm. Review. Remember. All Lisp expressions must have matched parentheses; that is, every open paren must appropriately have a closed paren.

fauna
Download Presentation

Machaut Messe

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Machaut Messe • Performance • Isorhythm

  2. Review

  3. Remember • All Lisp expressions must have matched parentheses; that is, every open paren must appropriately have a closed paren. • Document all of your work by placing comments after a “;” or enclosing in “”, or placing between #| this is documentation |# • Name variables and everything you do such that later on you can tell what they mean and does.

  4. Remember • Readability is @#$%^&* everything

  5. One flew over the parentheses nest!

  6. Hummmmmmm • (+ (first *my-numbers*) (third *my-numbers*) (first *my-numbers*)) Note how much easier the above is to read than: • (+ (first *my-numbers*)(third *my-numbers*)(first *my-numbers*)) • 4

  7. More exercises • (nth 5 ‘(1 2 3 4 5 6)) • 6 • Remember to check whether the primitive you’re using is zero or one based as in • (nthcdr 5 ‘(1 2 3 4 5 6)) • 6 • whew

  8. More? • (position 1 '(2 1 3 4 5)) • 1 (position 2 '(2 1 3 4 5)) 0 And so on.

  9. From (0 60 1000 1 64) get: • 1) 0 • 2) 64 • 3) 1000 • 4) (1000 1 64) • 5) (60 1000) • 6) (0 60 1000) • 7) (0 1) • 8) ((0)) • 9) (60 1000 64) • 10) (60 0)

  10. From (((a) b) c) get: • 1) a • 2) c • 3) b • 4) (a b) • 5) (a (b c)))

  11. From (a b c d e) get: • 1) (d e) • 2) 5 • 3) (a (b (c (d (e))))) • 4) (e d c b a) • 5) (a b c d)

  12. From a get: • 1) (a) • 2) (a . a) • 3) (a (a)) • 4) ((a) a) • 5) (a ())

  13. From a and (b c) get: • 1) (a b c) • 2) ((a) b c) • 3) (a (b c)) • 4) (a c) • 5) (c b a)

  14. From (a b) and (c d) get: • 1) (a b c d) • 2) ((a b) c d) • 3) ((a b)(c d)) • 4) (b a d c) • 5) (a (b c) d)

  15. (append '((1)) '(2 3))

  16. ((1) 2 3)

  17. (append '((2)(3)) '(4 5))

  18. ((2) (3) 4 5)

  19. (first '(((a)) (b c d e)))

  20. ((A))

  21. (rest '(((((f))))))

  22. nil

  23. (first '(rest (a b c)))

  24. rest

  25. (first (second '(((1 2))(2 3 4)((5 6 7)))))

  26. 2

  27. (second (first '(((1 2))(2 3 4)((5 6 7)))))

  28. nil

  29. Cope-event • (0 60 1000 1 127) • On-time (1000 per second) • Pitch number (24 108) • Duration (1000 per second) • Channel (1-16) • Loudness (1- 127)

  30. Therefore • (0 60 1000 1 127) • Translates to • A loud quarter-note middle C on channel 1 • Channel assignments are separate and (except for channel 10 usually) can produce any general MIDI sound • When saved to MIDI file and opened in a notation program produces the above.

  31. Cope-events • ((0 60 1000 1 127)(1000 62 1000 1 127)(2000 64 1000 1 127)(3000 65 1000 1 127)(4000 67 1000 1 127)(5000 69 1000 1 127)(6000 71 1000 1 127)(7000 72 1000 1 127)) • Produces a loud C-major scale in quarter notes.

  32. Some more functions • + (can have any number of args) • - (can have any number of args) • / (can have any number of args) • * (can have any number of args) • sort (be careful) • exp • sqrt • sin, cosin, tan (etc.)

  33. Predicates • Some Lisp functions serve as test functions as in • (listp 1) • which returns nil because its argument is not a list • (atomp ‘(1)) • which returns nil because its argument is not an atom • The suffix “p” stands for predicate

  34. Conditionals • Some functions in Common Lisp—called conditionals—test data for certain attributes. • For example, the function if tests its first argument and returns its second argument if it proves true, or its third argument if it proves false.

  35. Example • ? (if (numberp 1) t nil) • Returns • T • because “1” is a number and thus the first choice (t) is the result • Note that Lisp is case insensitive.

  36. Named • This combination is often termed an if-then-else clause.

  37. Quiz • ? (if (numberp (second ‘(a 2 b d f)) ‘yes ‘no) returns • > yes

  38. Quiz • ? (cons 1 (rest ‘(1 2 3 4 5))) returns > (1 2 3 4 5) Whew.

  39. Now you think of some questions!

  40. Let’s try for a few combinations • (defvar *my-numbers* ‘(1 2 3)) • (if (equal (first *my-numbers*) 2) (third *my-numbers*) (first *my-numbers*)) What’s the answer?

  41. Answer • 1

  42. Another • (append (append *my-numbers* *my-numbers*) (rest *my-numbers*))

  43. Answer • (1 2 3 1 2 3 2 3)

  44. A little harder • (if *my-numbers* (last *my-numbers*) ())

  45. Answer • (3) • N.B. The function “last” returns a list of the last number. Weird, but true.

  46. Try this: • (if (equal *my-numbers* (1 2 3)) (reverse *my-numbers*))

  47. Answer • Error! (forget the single quote on data!!!)

  48. Whew! • (third ‘((((a)) b)(c ((d) e) f)(((g)) h I))

  49. Answer • (((g)) h I))

More Related