annotate base/constructors.lisp @ 113:3ceaa5a08dc5

base/: more print-object methods darcs-hash:20070726161241-c0ce4-7a27d0a24569bdc83daba9433cd163656ea2798b.gz
author Marcus Pearce <m.pearce@gold.ac.uk>
date Thu, 26 Jul 2007 17:12:41 +0100
parents f49aa290b5c3
children 5e362d998f29
rev   line source
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)
m@24 6 (make-instance 'moment :time time))
m@24 7
m@24 8 ;; N.B. period should never be constructed directly - it's either
m@24 9 ;; floating or anchored or some other subclass.
m@24 10
m@24 11 (defun make-floating-period (interval)
m@24 12 (make-instance 'floating-period :interval interval))
m@24 13
d@33 14
d@33 15 ;; Should this take a moment and/or a period too?
m@24 16 (defun make-anchored-period (onset interval)
m@24 17 (make-instance 'anchored-period
m@24 18 :time onset
m@24 19 :interval interval))
m@24 20
m@24 21 ;; Pitch classes (no, not that sort of pitch class)
m@24 22
m@24 23 (defun make-chromatic-pitch (pitch-number)
m@24 24 (make-instance 'chromatic-pitch :number pitch-number))
m@24 25
m@24 26 (defun make-diatonic-pitch (name accidental octave)
c@106 27 (flet ((asa-string (name accidental octave)
c@106 28 (with-output-to-string (s)
c@106 29 (write-char name s)
c@106 30 (if (zerop accidental)
c@106 31 (write-char #\n s)
c@106 32 (let ((achar (if (plusp accidental) #\s #\f)))
c@106 33 (dotimes (i (abs accidental))
c@106 34 (write-char achar s))))
c@106 35 (write octave :stream s :base 10 :radix nil :pretty nil))))
c@106 36 (let* ((name (if (numberp name) (elt "ABCDEFG" name) name))
c@106 37 (asa-string (asa-string name accidental octave))
c@106 38 (p (mips:pn-p asa-string)))
c@109 39 (make-instance 'diatonic-pitch :cp (first p) :mp (second p)))))
m@24 40
m@81 41 (defun make-mips-pitch (cp mp)
c@109 42 (make-instance 'diatonic-pitch :cp cp :mp mp))
m@81 43
c@105 44 (defun make-chromatic-pitch-interval (span)
m@113 45 (make-instance 'chromatic-pitch-interval :span span))
m@24 46
c@111 47 (defun make-mips-pitch-interval (cspan mspan)
c@111 48 (make-instance 'diatonic-pitch-interval :span (list cspan mspan)))
c@111 49
m@24 50 ;; Events
m@24 51
m@24 52 (defun make-chromatic-pitched-event (pitch-number onset duration)
m@24 53 (make-instance 'chromatic-pitched-event
m@24 54 :number pitch-number
m@24 55 :time onset
m@24 56 :interval duration))
m@24 57
m@24 58 (defun make-basic-time-signature (numerator denominator onset duration)
m@24 59 (make-instance 'basic-time-signature
m@24 60 :numerator numerator
m@24 61 :denominator denominator
m@24 62 :time onset
m@24 63 :interval duration))
m@24 64
m@24 65 (defun make-basic-key-signature (sharp-count onset duration)
m@24 66 (make-instance 'basic-key-signature
m@24 67 :sharp-count sharp-count
m@24 68 :time onset
m@24 69 :interval duration))
m@24 70
m@40 71 (defun make-midi-key-signature (sharp-count mode onset duration)
m@40 72 (make-instance 'midi-key-signature
m@40 73 :sharp-count sharp-count
m@40 74 :mode mode
m@40 75 :time onset
m@40 76 :interval duration))
m@40 77
m@24 78 (defun make-tempo (bpm onset duration)
m@24 79 (make-instance 'tempo
m@24 80 :bpm bpm
m@24 81 :time onset
m@24 82 :interval duration))