Mercurial > hg > amuse
view base/constructors.lisp @ 111:f49aa290b5c3
diatonic pitch intervals
Implement diatonic pitch intervals. In the process, the pitch-foo methods
have been slightly rearranged: the system currently should reject attempts
to add chromatic intervals to diatonic pitches and vice versa. Complain
(or, preferably, fix) if any breakage results...
darcs-hash:20070726151244-dc3a5-3587adb88c494f7074c5e36a3983fde1a3d69da1.gz
author | c.rhodes <c.rhodes@gold.ac.uk> |
---|---|
date | Thu, 26 Jul 2007 16:12:44 +0100 |
parents | a9a1c7aa86a9 |
children | 3ceaa5a08dc5 |
line wrap: on
line source
(cl:in-package #:amuse) ;; Time classes (defun make-moment (time) (make-instance 'moment :time time)) ;; N.B. period should never be constructed directly - it's either ;; floating or anchored or some other subclass. (defun make-floating-period (interval) (make-instance 'floating-period :interval interval)) ;; Should this take a moment and/or a period too? (defun make-anchored-period (onset interval) (make-instance 'anchored-period :time onset :interval interval)) ;; Pitch classes (no, not that sort of pitch class) (defun make-chromatic-pitch (pitch-number) (make-instance 'chromatic-pitch :number pitch-number)) (defun make-diatonic-pitch (name accidental octave) (flet ((asa-string (name accidental octave) (with-output-to-string (s) (write-char name s) (if (zerop accidental) (write-char #\n s) (let ((achar (if (plusp accidental) #\s #\f))) (dotimes (i (abs accidental)) (write-char achar s)))) (write octave :stream s :base 10 :radix nil :pretty nil)))) (let* ((name (if (numberp name) (elt "ABCDEFG" name) name)) (asa-string (asa-string name accidental octave)) (p (mips:pn-p asa-string))) (make-instance 'diatonic-pitch :cp (first p) :mp (second p))))) (defun make-mips-pitch (cp mp) (make-instance 'diatonic-pitch :cp cp :mp mp)) (defun make-chromatic-pitch-interval (span) (make-instance 'pitch-interval :span span)) (defun make-mips-pitch-interval (cspan mspan) (make-instance 'diatonic-pitch-interval :span (list cspan mspan))) ;; Events (defun make-chromatic-pitched-event (pitch-number onset duration) (make-instance 'chromatic-pitched-event :number pitch-number :time onset :interval duration)) (defun make-basic-time-signature (numerator denominator onset duration) (make-instance 'basic-time-signature :numerator numerator :denominator denominator :time onset :interval duration)) (defun make-basic-key-signature (sharp-count onset duration) (make-instance 'basic-key-signature :sharp-count sharp-count :time onset :interval duration)) (defun make-midi-key-signature (sharp-count mode onset duration) (make-instance 'midi-key-signature :sharp-count sharp-count :mode mode :time onset :interval duration)) (defun make-tempo (bpm onset duration) (make-instance 'tempo :bpm bpm :time onset :interval duration))