m@24
|
1 (cl:in-package #:amuse)
|
m@24
|
2
|
m@24
|
3 ;; Time classes
|
m@24
|
4
|
m@24
|
5 (defun make-moment (time)
|
d@134
|
6 "Returns a new moment, taking a number as input for the time
|
d@134
|
7 point."
|
m@24
|
8 (make-instance 'moment :time time))
|
m@24
|
9
|
m@24
|
10 ;; N.B. period should never be constructed directly - it's either
|
m@24
|
11 ;; floating or anchored or some other subclass.
|
m@24
|
12
|
m@24
|
13 (defun make-floating-period (interval)
|
d@134
|
14 "Returns a new floating-period, taking a number for the
|
d@134
|
15 duration."
|
m@24
|
16 (make-instance 'floating-period :interval interval))
|
m@24
|
17
|
d@33
|
18
|
d@33
|
19 ;; Should this take a moment and/or a period too?
|
m@24
|
20 (defun make-anchored-period (onset interval)
|
d@134
|
21 "Returns a new floating-period, taking numbers for onset and
|
d@134
|
22 duration."
|
m@24
|
23 (make-instance 'anchored-period
|
m@24
|
24 :time onset
|
m@24
|
25 :interval interval))
|
m@24
|
26
|
m@24
|
27 ;; Pitch classes (no, not that sort of pitch class)
|
m@24
|
28
|
m@24
|
29 (defun make-chromatic-pitch (pitch-number)
|
d@134
|
30 "Returns a new chromatic pitch, taking a number for the
|
d@134
|
31 pitch."
|
m@24
|
32 (make-instance 'chromatic-pitch :number pitch-number))
|
m@24
|
33
|
m@24
|
34 (defun make-diatonic-pitch (name accidental octave)
|
d@134
|
35 "Returns a new diatonic pitch, taking as input a character for the name,
|
d@134
|
36 a positive or negative number for the accidental (+ve for sharps,
|
d@134
|
37 -ve for flats) and another for octave. (Is this description right?)"
|
c@106
|
38 (flet ((asa-string (name accidental octave)
|
c@106
|
39 (with-output-to-string (s)
|
c@106
|
40 (write-char name s)
|
c@106
|
41 (if (zerop accidental)
|
c@106
|
42 (write-char #\n s)
|
c@106
|
43 (let ((achar (if (plusp accidental) #\s #\f)))
|
c@106
|
44 (dotimes (i (abs accidental))
|
c@106
|
45 (write-char achar s))))
|
c@106
|
46 (write octave :stream s :base 10 :radix nil :pretty nil))))
|
c@106
|
47 (let* ((name (if (numberp name) (elt "ABCDEFG" name) name))
|
c@106
|
48 (asa-string (asa-string name accidental octave))
|
c@106
|
49 (p (mips:pn-p asa-string)))
|
c@109
|
50 (make-instance 'diatonic-pitch :cp (first p) :mp (second p)))))
|
m@24
|
51
|
m@81
|
52 (defun make-mips-pitch (cp mp)
|
c@109
|
53 (make-instance 'diatonic-pitch :cp cp :mp mp))
|
m@81
|
54
|
c@105
|
55 (defun make-chromatic-pitch-interval (span)
|
m@113
|
56 (make-instance 'chromatic-pitch-interval :span span))
|
m@24
|
57
|
c@111
|
58 (defun make-mips-pitch-interval (cspan mspan)
|
c@111
|
59 (make-instance 'diatonic-pitch-interval :span (list cspan mspan)))
|
c@111
|
60
|
m@24
|
61 ;; Events
|
m@24
|
62
|
m@24
|
63 (defun make-chromatic-pitched-event (pitch-number onset duration)
|
m@24
|
64 (make-instance 'chromatic-pitched-event
|
m@24
|
65 :number pitch-number
|
m@24
|
66 :time onset
|
m@24
|
67 :interval duration))
|
m@24
|
68
|
m@24
|
69 (defun make-basic-time-signature (numerator denominator onset duration)
|
m@24
|
70 (make-instance 'basic-time-signature
|
m@24
|
71 :numerator numerator
|
m@24
|
72 :denominator denominator
|
m@24
|
73 :time onset
|
m@24
|
74 :interval duration))
|
m@24
|
75
|
m@24
|
76 (defun make-basic-key-signature (sharp-count onset duration)
|
m@24
|
77 (make-instance 'basic-key-signature
|
m@24
|
78 :sharp-count sharp-count
|
m@24
|
79 :time onset
|
m@24
|
80 :interval duration))
|
m@24
|
81
|
m@40
|
82 (defun make-midi-key-signature (sharp-count mode onset duration)
|
m@40
|
83 (make-instance 'midi-key-signature
|
m@40
|
84 :sharp-count sharp-count
|
m@40
|
85 :mode mode
|
m@40
|
86 :time onset
|
m@40
|
87 :interval duration))
|
m@40
|
88
|
m@24
|
89 (defun make-tempo (bpm onset duration)
|
m@24
|
90 (make-instance 'tempo
|
m@24
|
91 :bpm bpm
|
m@24
|
92 :time onset
|
m@24
|
93 :interval duration))
|