Mercurial > hg > amuse
changeset 22:99ccd775245a
Moved midi out of main files
darcs-hash:20061214125711-f76cc-c9e7f9af1054c67473ff6d8a8e3b84e45fe43f35.gz
author | David Lewis <d.lewis@gold.ac.uk> |
---|---|
date | Thu, 14 Dec 2006 12:57:11 +0000 |
parents | c389ba869ef9 |
children | e2e19baba730 |
files | amuse.asd classes.lisp constructors.lisp generics.lisp methods.lisp midi-classes-and-constructors.lisp package.lisp |
diffstat | 7 files changed, 69 insertions(+), 60 deletions(-) [+] |
line wrap: on
line diff
--- a/amuse.asd Wed Dec 13 16:42:49 2006 +0000 +++ b/amuse.asd Thu Dec 14 12:57:11 2006 +0000 @@ -7,4 +7,5 @@ (:file "classes") (:file "constructors") (:file "generics") - (:file "methods"))) + (:file "methods") + (:file "midi-classes-and-constructors")))
--- a/classes.lisp Wed Dec 13 16:42:49 2006 +0000 +++ b/classes.lisp Thu Dec 14 12:57:11 2006 +0000 @@ -40,23 +40,12 @@ (defclass pitch-interval (pitch-interval-designator) ((span :accessor %pitch-interval-span :initarg :span))) -(defclass midi-message () ;? - ((channel :accessor %midi-message-channel :initarg :channel) - (track :accessor %midi-message-track :initarg :track))) - ;; events (defclass event (anchored-period) ()) (defclass pitched-event (event pitch-designator) ()) (defclass chromatic-pitched-event (pitched-event chromatic-pitch) ()) -(defclass midi-pitched-event (chromatic-pitched-event midi-message) - ((velocity :initarg :velocity) - (patch :initarg :patch))) (defclass percussive-event (event) ()) -(defclass midi-percussive-event (percussive-event midi-message) - ((velocity :initarg :velocity) - (patch :initarg :patch) - (sound :initarg :sound))) ;;; Range-based `constituents' ;; Whilst these are all constituents in the CHARM sense, their @@ -81,12 +70,6 @@ ((sharp-count :accessor %basic-key-signature-sharp-count :initarg sharp-count))) -(defclass midi-key-signature (basic-key-signature) - ;; Is mode ever used in real life? Is it ever accurately used in - ;; real life? - ((mode :accessor %midi-key-signature-mode - :initarg mode))) - (defclass tempo (anchored-period) ;; accel and rit in symbolic encoding will need other structures, as ;; will textual tempo markings.
--- a/constructors.lisp Wed Dec 13 16:42:49 2006 +0000 +++ b/constructors.lisp Thu Dec 14 12:57:11 2006 +0000 @@ -38,28 +38,6 @@ :time onset :interval duration)) -(defun make-midi-pitched-event (pitch-number velocity patch - channel track onset duration) - (make-instance 'midi-pitched-event - :number pitch-number - :velocity velocity - :patch patch - :channel channel - :track track - :time onset - :interval duration)) - -(defun make-midi-percussive-event (pitch-number velocity patch - channel track onset duration) - (make-instance 'midi-percussive-event - :sound pitch-number - :velocity velocity - :patch patch - :channel channel - :track track - :time onset - :interval duration)) - (defun make-basic-time-signature (numerator denominator onset duration) (make-instance 'basic-time-signature :numerator numerator @@ -73,13 +51,6 @@ :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
--- a/generics.lisp Wed Dec 13 16:42:49 2006 +0000 +++ b/generics.lisp Thu Dec 14 12:57:11 2006 +0000 @@ -13,12 +13,12 @@ (defgeneric chromatic-pitch (pitch-designator)) ; How simple are these (defgeneric diatonic-pitch (pitch-designator)) ; if has to be computed? (defgeneric frequency (object)) ;? -(defgeneric chromatic-pitch-number (pitch-designator)) +(defgeneric midi-pitch-number (pitch-designator)) (defgeneric meredith-chromatic-pitch-number (pitch-designator) ;; David Meredith's PhD and ps13 code - (:method (p) (- (chromatic-pitch-number p) 21))) + (:method (p) (- (midi-pitch-number p) 21))) (defgeneric pitch-class (pitch-designator) - (:method (p) (mod (chromatic-pitch-number p) 12))) + (:method (p) (mod (midi-pitch-number p) 12))) (defgeneric span (pitch-interval-designator)) ;; time
--- a/methods.lisp Wed Dec 13 16:42:49 2006 +0000 +++ b/methods.lisp Thu Dec 14 12:57:11 2006 +0000 @@ -3,10 +3,10 @@ (defmethod chromatic-pitch ((pitch-designator chromatic-pitch)) pitch-designator) -(defmethod chromatic-pitch-number ((pitch-designator chromatic-pitch)) +(defmethod midi-pitch-number ((pitch-designator chromatic-pitch)) (%chromatic-pitch-number pitch-designator)) -(defmethod chromatic-pitch-number ((pitch-designator pitch)) +(defmethod midi-pitch-number ((pitch-designator pitch)) (%chromatic-pitch-number (chromatic-pitch pitch-designator))) (defmethod span ((pitch-interval-designator pitch-interval)) @@ -204,13 +204,15 @@ ;; if they don't overlap, return nil, not a negative-valued ;; period nil) - (t - (let ((new-onset (max (timepoint object1) - (timepoint object2)))) - (make-anchored-period new-onset - (time- (min (cut-off object1) - (cut-off object2)) - new-onset)))))) + ((let* ((start (if (time> (onset object2) (onset object1)) + (onset object2) + (onset object1))) + (duration (duration (time- (if (time> (cut-off object2) (cut-off object1)) + (cut-off object1) + (cut-off object2)) + start)))) + (make-anchored-period (timepoint start) duration))))) + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/midi-classes-and-constructors.lisp Thu Dec 14 12:57:11 2006 +0000 @@ -0,0 +1,52 @@ +(cl:in-package #:amuse) + +(defclass midi-message () ;? + ((channel :accessor %midi-message-channel :initarg :channel) + (track :accessor %midi-message-track :initarg :track))) + +(defclass midi-pitched-event (chromatic-pitched-event midi-message) + ((velocity :initarg :velocity) + (patch :initarg :patch))) + +(defclass midi-percussive-event (percussive-event midi-message) + ((velocity :initarg :velocity) + (patch :initarg :patch) + (sound :initarg :sound))) + +(defclass midi-key-signature (basic-key-signature) + ;; Is mode ever used in real life? Is it ever accurately used in + ;; real life? + ((mode :accessor %midi-key-signature-mode + :initarg mode))) + +;;; Constructors + +(defun make-midi-pitched-event (pitch-number velocity patch + channel track onset duration) + (make-instance 'midi-pitched-event + :number pitch-number + :velocity velocity + :patch patch + :channel channel + :track track + :time onset + :interval duration)) + +(defun make-midi-percussive-event (pitch-number velocity patch + channel track onset duration) + (make-instance 'midi-percussive-event + :sound pitch-number + :velocity velocity + :patch patch + :channel channel + :track track + :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)) +