machaut messe performance performance performance isorhythm isorhythm
TRANSCRIPT
Machaut MesseMachaut Messe
Performance Performance
IsorhythmIsorhythm
ReviewReview
Remember Remember
All Lisp expressions must have matched parentheses; All Lisp expressions must have matched parentheses; that is, every open paren must appropriately have a that is, every open paren must appropriately have a closed paren.closed paren.
Document all of your work by placing comments after a Document all of your work by placing comments after a “;” or enclosing in “”, or placing between #| this is “;” or enclosing in “”, or placing between #| this is documentation |#documentation |#
Name variables and everything you do such that later on Name variables and everything you do such that later on you can tell what they mean and does.you can tell what they mean and does.
Remember Remember
Readability is Readability is @#$%^&* @#$%^&* everythingeverything
One flew over the parentheses nest!One flew over the parentheses nest!
Hummmmmmm Hummmmmmm
(+ (first *my-numbers*)(+ (first *my-numbers*) (third *my-numbers*)(third *my-numbers*) (first *my-numbers*))(first *my-numbers*))
Note how much easier the above is to read than:Note how much easier the above is to read than: (+ (first *my-numbers*)(third *my-numbers*)(first (+ (first *my-numbers*)(third *my-numbers*)(first
*my-numbers*))*my-numbers*)) 4 4
More exercisesMore exercises
(nth 5 ‘(1 2 3 4 5 6))(nth 5 ‘(1 2 3 4 5 6)) 66 Remember to check whether the primitive Remember to check whether the primitive
you’re using is zero or one based as in you’re using is zero or one based as in (nthcdr 5 ‘(1 2 3 4 5 6))(nthcdr 5 ‘(1 2 3 4 5 6)) 66 whewwhew
More?More? (position 1 '(2 1 3 4 5))(position 1 '(2 1 3 4 5)) 11
(position 2 '(2 1 3 4 5))(position 2 '(2 1 3 4 5))
00
And so on.And so on.
From (0 60 1000 1 64) get:From (0 60 1000 1 64) get:
1) 01) 0
2) 642) 64
3) 10003) 1000
4) (1000 1 64)4) (1000 1 64)
5) (60 1000)5) (60 1000)
6) (0 60 1000)6) (0 60 1000)
7) (0 1)7) (0 1)
8) ((0))8) ((0))
9) (60 1000 64)9) (60 1000 64)
10) (60 0)10) (60 0)
From (((a) b) c) get:From (((a) b) c) get:
1) a1) a
2) c2) c
3) b3) b
4) (a b)4) (a b)
5) (a (b c)))5) (a (b c)))
From (a b c d e) get:From (a b c d e) get:
1) (d e)1) (d e)
2) 52) 5
3) (a (b (c (d (e)))))3) (a (b (c (d (e)))))
4) (e d c b a)4) (e d c b a)
5) (a b c d)5) (a b c d)
From a get:From a get:
1) (a)1) (a)
2) (a . a)2) (a . a)
3) (a (a))3) (a (a))
4) ((a) a)4) ((a) a)
5) (a ())5) (a ())
From a and (b c) get:From a and (b c) get:
1) (a b c)1) (a b c)
2) ((a) b c)2) ((a) b c)
3) (a (b c))3) (a (b c))
4) (a c)4) (a c)
5) (c b a)5) (c b a)
From (a b) and (c d) get:From (a b) and (c d) get:
1) (a b c d)1) (a b c d)
2) ((a b) c d)2) ((a b) c d)
3) ((a b)(c d))3) ((a b)(c d))
4) (b a d c)4) (b a d c)
5) (a (b c) d)5) (a (b c) d)
(append '((1)) '(2 3))(append '((1)) '(2 3))
((1) 2 3)((1) 2 3)
(append '((2)(3)) '(4 5))(append '((2)(3)) '(4 5))
((2) (3) 4 5)((2) (3) 4 5)
(first '(((a)) (b c d e)))(first '(((a)) (b c d e)))
((A))((A))
(rest '(((((f))))))(rest '(((((f))))))
nilnil
(first '(rest (a b c)))(first '(rest (a b c)))
restrest
(first (second '(((1 2))(2 3 4)((5 6 7)))))(first (second '(((1 2))(2 3 4)((5 6 7)))))
22
(second (first '(((1 2))(2 3 4)((5 6 7)))))(second (first '(((1 2))(2 3 4)((5 6 7)))))
nilnil
Cope-eventCope-event
(0 60 1000 1 127)(0 60 1000 1 127)
On-time (1000 per second)On-time (1000 per second) Pitch number (24 108)Pitch number (24 108) Duration (1000 per second)Duration (1000 per second) Channel (1-16)Channel (1-16) Loudness (1- 127)Loudness (1- 127)
Therefore Therefore
(0 60 1000 1 127)(0 60 1000 1 127) Translates toTranslates to A loud quarter-note middle C on channel 1A loud quarter-note middle C on channel 1 Channel assignments are separate and Channel assignments are separate and
(except for channel 10 usually) can (except for channel 10 usually) can produce any general MIDI soundproduce any general MIDI sound
When saved to MIDI file and opened in a When saved to MIDI file and opened in a notation program produces the above.notation program produces the above.
Cope-eventsCope-events
((0 60 1000 1 127)(1000 62 1000 1 127)((0 60 1000 1 127)(1000 62 1000 1 127)(2000 64 1000 1 127)(3000 65 1000 1 (2000 64 1000 1 127)(3000 65 1000 1 127)(4000 67 1000 1 127)(5000 69 1000 1 127)(4000 67 1000 1 127)(5000 69 1000 1 127)(6000 71 1000 1 127)(7000 72 1000 1 127)(6000 71 1000 1 127)(7000 72 1000 1 127))127))
Produces a loud C-major scale in quarter Produces a loud C-major scale in quarter notes.notes.
Some more functionsSome 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) / (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)sort (be careful) expexp sqrtsqrt sin, cosin, tan (etc.)sin, cosin, tan (etc.)
Predicates Predicates
Some Lisp functions serve as test Some Lisp functions serve as test functions as infunctions as in
(listp 1)(listp 1) which returns nil because its argument is which returns nil because its argument is
not a listnot a list (atomp ‘(1))(atomp ‘(1)) which returns nil because its argument is which returns nil because its argument is
not an atomnot an atom The suffix “p” stands for predicateThe suffix “p” stands for predicate
Conditionals Conditionals
Some functions in Common Lisp—Some functions in Common Lisp—called conditionals—test data for called conditionals—test data for certain attributes.certain attributes.
For example, the function For example, the function ifif tests its tests its first argument and returns its first argument and returns its second argument if it proves true, or second argument if it proves true, or its third argument if it proves false. its third argument if it proves false.
Example Example
? ? (if (numberp 1) t nil)(if (numberp 1) t nil) ReturnsReturns TT because “1” is a number and thus because “1” is a number and thus
the first choice (t) is the resultthe first choice (t) is the result Note that Lisp is case insensitive.Note that Lisp is case insensitive.
Named Named
This combination is often termed an This combination is often termed an if-then-elseif-then-else clause. clause.
Quiz Quiz
? (if (numberp (second ‘(a 2 b d f)) ‘yes ‘no)? (if (numberp (second ‘(a 2 b d f)) ‘yes ‘no)
returns returns > yes> yes
Quiz Quiz
? (cons 1 (rest ‘(1 2 3 4 5)))? (cons 1 (rest ‘(1 2 3 4 5)))
returnsreturns
> (1 2 3 4 5)> (1 2 3 4 5)
Whew.Whew.
Now you think of some Now you think of some questions!questions!
Let’s try for a few Let’s try for a few combinationscombinations
(defvar *my-numbers* ‘(1 2 3))(defvar *my-numbers* ‘(1 2 3)) (if (equal (first *my-numbers*) 2)(if (equal (first *my-numbers*) 2)
(third *my-numbers*)(third *my-numbers*)
(first *my-numbers*))(first *my-numbers*))
What’s the answer?What’s the answer?
AnswerAnswer
11
AnotherAnother
(append (append
(append *my-numbers* *my-numbers*)(append *my-numbers* *my-numbers*)
(rest *my-numbers*))(rest *my-numbers*))
AnswerAnswer
(1 2 3 1 2 3 2 3)(1 2 3 1 2 3 2 3)
A little harderA little harder
(if *my-numbers* (last *my-numbers*) (if *my-numbers* (last *my-numbers*)
())())
AnswerAnswer
(3)(3)
N.B. The function “last” returns a list of the N.B. The function “last” returns a list of the last number. Weird, but true. last number. Weird, but true.
Try this:Try this:
(if (equal *my-numbers* (1 2 3)) (if (equal *my-numbers* (1 2 3))
(reverse *my-numbers*))(reverse *my-numbers*))
AnswerAnswer
Error! (forget the single quote on data!!!)Error! (forget the single quote on data!!!)
Whew! Whew!
(third ‘((((a)) b)(c ((d) e) f)(((g)) h I))(third ‘((((a)) b)(c ((d) e) f)(((g)) h I))
AnswerAnswer
(((g)) h I))(((g)) h I))