Mercurial > hg > amuse
comparison utils/utils.lisp @ 136:fd85f52d9f9d
Class revolution
* PITCH-DESIGNATOR -> PITCH (PITCH removed)
* MOMENT-DESIGNATOR -> MOMENT , MOMENT -> STANDARD-MOMENT
* PERIOD-DESIGNATOR -> PERIOD , PERIOD -> STANDARD-PERIOD
* ANCHORED-PERIOD-DESIGNATOR -> ANCHORED-PERIOD , ANCHORED-PERIOD -> STANDARD-ANCHORED-PERIOD
* FLOATING-PERIOD removed
* TIME-SIGNATURE-DESIGNATOR -> TIME-SIGNATURE & TIME-SIGNATURE-PERIOD
* TIME-SIGNATURE -> STANDARD-TIME-SIGNATURE & STANDARD-TIME-SIGNATURE-PERIOD
* KEY-SIGNATURE-DESIGNATOR -> KEY-SIGNATURE (& ...-PERIOD)
* KEY-SIGNATURE -> STANDARD-KEY-SIGNATURE (& ...-PERIOD)
* TEMPO now abstract (& TEMPO-PERIOD)
* STANDARD-TEMPO AND STANDARD-TEMPO-PERIOD
* COMPOSITION, CONSTITUENT & TIME-ORDERED-CONSTITUENT all have STANDARD- forms
make-x methods and specialisers changes appropriately
darcs-hash:20070831142943-f76cc-7be0d08963de06d87b36e4922076287d565c7ee2.gz
author | David Lewis <d.lewis@gold.ac.uk> |
---|---|
date | Fri, 31 Aug 2007 15:29:43 +0100 |
parents | 5e362d998f29 |
children | ebfe054eea1c |
comparison
equal
deleted
inserted
replaced
135:188fe5ea837f | 136:fd85f52d9f9d |
---|---|
15 (:documentation "Convenient function for finding the number of | 15 (:documentation "Convenient function for finding the number of |
16 crotchet beats in a bar based on the provided | 16 crotchet beats in a bar based on the provided |
17 time-signature. It should be borne in mind that this needn't be | 17 time-signature. It should be borne in mind that this needn't be |
18 an integer - a time signature of 3/8, for example, should yield | 18 an integer - a time signature of 3/8, for example, should yield |
19 an answer of 3/2")) | 19 an answer of 3/2")) |
20 (defmethod crotchets-in-a-bar ((time-signature basic-time-signature)) | 20 (defmethod crotchets-in-a-bar ((time-signature standard-time-signature)) |
21 (let ((num (time-signature-numerator time-signature)) | 21 (let ((num (time-signature-numerator time-signature)) |
22 (den (time-signature-denominator time-signature))) | 22 (den (time-signature-denominator time-signature))) |
23 (* num (/ 4 den)))) | 23 (* num (/ 4 den)))) |
24 | 24 |
25 (defgeneric beats-to-seconds (object1 object2)) | 25 (defgeneric beats-to-seconds (object1 object2)) |
26 (defmethod beats-to-seconds ((object1 anchored-period) | 26 (defmethod beats-to-seconds ((object1 standard-anchored-period) |
27 (object2 constituent)) | 27 (object2 constituent)) |
28 (let ((tempi (or (get-applicable-tempi object1 object2) | 28 (let ((tempi (or (get-applicable-tempi object1 object2) |
29 (signal 'undefined-action | 29 (signal 'undefined-action |
30 :operation 'beats-to-seconds | 30 :operation 'beats-to-seconds |
31 :datatype 'constituent))) | 31 :datatype 'constituent))) |
32 (s 0)) | 32 (s 0)) |
33 (dolist (tempo tempi (/ s 1000000)) | 33 (dolist (tempo tempi (/ s 1000000)) |
34 (incf s (if (disjoint tempo object1) | 34 (incf s (if (disjoint tempo object1) |
35 0 | 35 0 |
36 (* (duration (period-intersection tempo object1)) | 36 (* (/ (duration (period-intersection tempo object1)) |
37 (duration (crotchet constituent))) | |
37 (amuse:microseconds-per-crotchet tempo))))))) | 38 (amuse:microseconds-per-crotchet tempo))))))) |
38 (defmethod beats-to-seconds ((object1 moment) | 39 (defmethod beats-to-seconds ((object1 standard-moment) |
39 (object2 constituent)) | 40 (object2 constituent)) |
40 (beats-to-seconds (time- (onset object1) | 41 (beats-to-seconds (time- (onset object1) |
41 (make-moment 0)) | 42 (make-standard-moment 0)) |
42 object2)) | 43 object2)) |
43 | 44 |
44 ;; Not as simple as it seems - have to take into account numbering | 45 ;; Not as simple as it seems - have to take into account numbering |
45 ;; practices and leading silences in representations where bar number | 46 ;; practices and leading silences in representations where bar number |
46 ;; isn't part of the explicit structure. | 47 ;; isn't part of the explicit structure. |