csr21@59
|
1 (in-package "AMUSE-GSHARP")
|
csr21@59
|
2
|
csr21@59
|
3 (defmethod time-signatures ((composition gsharp-composition))
|
csr21@59
|
4 ())
|
csr21@59
|
5
|
d@162
|
6 (defmethod get-composition ((id gsharp-gsh-identifier))
|
d@162
|
7 "Makes a gsharp buffer from .gsh file and generates a composition
|
d@162
|
8 from its first segment. N.B. 1) This is not compatible with
|
d@162
|
9 multi-segment files 2) No application frame is created (=> data flow
|
d@162
|
10 is pretty much one way)"
|
d@162
|
11 (let ((buffer (with-open-file (s (%gsharp-identifier-pathname id))
|
d@162
|
12 (gsharp::read-buffer-from-stream s))))
|
d@162
|
13 (gsharp::recompute-measures buffer)
|
d@162
|
14 (segment-composition (car (gsharp::segments buffer)))))
|
d@162
|
15
|
d@162
|
16 (defmethod get-composition ((id gsharp-mxml-identifier))
|
d@162
|
17 "Makes a gsharp buffer from .mxml file and generates a composition
|
d@162
|
18 from its first segment. N.B. 1) This is not compatible with
|
d@162
|
19 multi-segment files 2) No application frame is created (=> data flow
|
d@162
|
20 is pretty much one way)"
|
d@162
|
21 (let ((buffer (gsharp-mxml::parse-mxml
|
d@162
|
22 (gsharp-mxml::musicxml-document
|
d@162
|
23 (%gsharp-identifier-pathname id)))))
|
d@162
|
24 (gsharp::recompute-measures buffer)
|
d@162
|
25 (segment-composition (car (gsharp::segments buffer)))))
|
d@162
|
26
|
d@163
|
27 ;; These may want another file
|
d@163
|
28 (defun gsh-id (pathname)
|
d@163
|
29 "Creates an identifier for gsh files, based on a pathname"
|
d@163
|
30 (make-instance 'gsharp-gsh-identifier :path pathname))
|
d@163
|
31
|
d@163
|
32 (defun mxml-id (pathname)
|
d@163
|
33 "Creates an identifier for MusicXML files, based on a pathname"
|
d@163
|
34 (make-instance 'gsharp-mxml-identifier :path pathname))
|
d@163
|
35
|
d@162
|
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
d@162
|
37 ;;
|
d@162
|
38 ;; These versions may not be useful, but create and return a gsharp
|
d@162
|
39 ;; application frame as well as a composition
|
d@162
|
40
|
d@162
|
41 (defgeneric get-composition-with-application-frame (identifier))
|
d@162
|
42 (defmethod get-composition-with-application-frame ((id gsharp-identifier))
|
d@162
|
43 (let* ((frame (clim:make-application-frame 'gsharp:gsharp))
|
d@162
|
44 (clim:*application-frame* frame)
|
d@162
|
45 (esa:*esa-instance* frame))
|
d@162
|
46 (clim:adopt-frame (clim:find-frame-manager :server-path '(:null)) frame)
|
d@162
|
47 (import-from-identifier frame id)
|
d@162
|
48 (gsharp::recompute-measures (car (esa-buffer::buffers frame)))
|
d@162
|
49 (values (segment-composition (car (gsharp::segments (car (esa-buffer::buffers frame)))))
|
d@162
|
50 frame)))
|
d@162
|
51
|
d@162
|
52 (defgeneric import-from-identifier (frame id))
|
d@162
|
53 (defmethod import-from-identifier (frame (id gsharp-gsh-identifier))
|
d@162
|
54 (clim:execute-frame-command frame '(gsharp::com-new-buffer))
|
d@162
|
55 (gsharp::frame-find-file frame (%gsharp-identifier-pathname id)))
|
d@162
|
56 (defmethod import-from-identifier (frame (id gsharp-mxml-identifier))
|
d@162
|
57 (clim:execute-frame-command frame `(gsharp::com-import-musicxml ,(%gsharp-identifier-pathname id))))
|
d@168
|
58
|
d@168
|
59 (defmethod get-applicable-key-signatures (anchored-period (composition gsharp-composition))
|
d@168
|
60 (let ((keysigs))
|
d@168
|
61 (sequence::dosequence (event composition (reverse keysigs))
|
d@168
|
62 (cond
|
d@168
|
63 ((overlaps event anchored-period)
|
d@168
|
64 (unless (member (gsharp::keysig event) keysigs)
|
d@168
|
65 (push (gsharp::keysig event) keysigs)))
|
d@168
|
66 ((not (before event anchored-period))
|
d@168
|
67 (return-from get-applicable-key-signatures (reverse keysigs)))))))
|
d@168
|
68
|
d@168
|
69 (defmethod crotchet ((object gsharp-object))
|
d@168
|
70 (make-standard-period 1)) |