Mercurial > hg > amuse
comparison implementations/gsharp/methods.lisp @ 162:110e957a7e3c
Add get-composition methods for gsharp
darcs-hash:20071218104432-40ec0-5fdd50a969609f1f50623d2c88a1746f391c984a.gz
author | d.lewis <d.lewis@gold.ac.uk> |
---|---|
date | Tue, 18 Dec 2007 10:44:32 +0000 |
parents | 08468c3d5801 |
children | 83023a2668d2 |
comparison
equal
deleted
inserted
replaced
161:676283afe8fb | 162:110e957a7e3c |
---|---|
1 (in-package "AMUSE-GSHARP") | 1 (in-package "AMUSE-GSHARP") |
2 | 2 |
3 (defmethod time-signatures ((composition gsharp-composition)) | 3 (defmethod time-signatures ((composition gsharp-composition)) |
4 ()) | 4 ()) |
5 | 5 |
6 (defmethod get-composition ((id gsharp-gsh-identifier)) | |
7 "Makes a gsharp buffer from .gsh file and generates a composition | |
8 from its first segment. N.B. 1) This is not compatible with | |
9 multi-segment files 2) No application frame is created (=> data flow | |
10 is pretty much one way)" | |
11 (let ((buffer (with-open-file (s (%gsharp-identifier-pathname id)) | |
12 (gsharp::read-buffer-from-stream s)))) | |
13 (gsharp::recompute-measures buffer) | |
14 (segment-composition (car (gsharp::segments buffer))))) | |
15 | |
16 (defmethod get-composition ((id gsharp-mxml-identifier)) | |
17 "Makes a gsharp buffer from .mxml file and generates a composition | |
18 from its first segment. N.B. 1) This is not compatible with | |
19 multi-segment files 2) No application frame is created (=> data flow | |
20 is pretty much one way)" | |
21 (let ((buffer (gsharp-mxml::parse-mxml | |
22 (gsharp-mxml::musicxml-document | |
23 (%gsharp-identifier-pathname id))))) | |
24 (gsharp::recompute-measures buffer) | |
25 (segment-composition (car (gsharp::segments buffer))))) | |
26 | |
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
28 ;; | |
29 ;; These versions may not be useful, but create and return a gsharp | |
30 ;; application frame as well as a composition | |
31 | |
32 (defgeneric get-composition-with-application-frame (identifier)) | |
33 (defmethod get-composition-with-application-frame ((id gsharp-identifier)) | |
34 (let* ((frame (clim:make-application-frame 'gsharp:gsharp)) | |
35 (clim:*application-frame* frame) | |
36 (esa:*esa-instance* frame)) | |
37 (clim:adopt-frame (clim:find-frame-manager :server-path '(:null)) frame) | |
38 (import-from-identifier frame id) | |
39 (gsharp::recompute-measures (car (esa-buffer::buffers frame))) | |
40 (values (segment-composition (car (gsharp::segments (car (esa-buffer::buffers frame))))) | |
41 frame))) | |
42 | |
43 (defgeneric import-from-identifier (frame id)) | |
44 (defmethod import-from-identifier (frame (id gsharp-gsh-identifier)) | |
45 (clim:execute-frame-command frame '(gsharp::com-new-buffer)) | |
46 (gsharp::frame-find-file frame (%gsharp-identifier-pathname id))) | |
47 (defmethod import-from-identifier (frame (id gsharp-mxml-identifier)) | |
48 (clim:execute-frame-command frame `(gsharp::com-import-musicxml ,(%gsharp-identifier-pathname id)))) |