-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLilyShowableObj.sc
99 lines (66 loc) · 2.14 KB
/
LilyShowableObj.sc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
LilyShowableObj : LilyObj {
var <>fileName = "~/Desktop/sketch";
var <>pdfViewer = "xpdf -remote sclyserver";
var <>midiPlayer = "vlc";
var <>textEditor = "frescobaldi";
var <>template = "doc";
var <>lilyCmd= "lilypond";
var <>templatesFolder;
*new {
^super.new.initShowableObj;
}
initShowableObj {
templatesFolder = Platform.userExtensionDir ++ "/LilyCollider/templates";
}
/* Music expression between curly brackets */
musicString {
^("{\n" ++ this.string ++ "\n}\n").asString;
}
/* Path of the choosen template LilyPond file */
templateFile {
^(this.templatesFolder ++ "/" ++ this.template ++ ".ly").standardizePath
}
header {
var file, content;
file = File(this.templateFile,"r");
content = file.readAllString;
file.close;
^content;
}
/* Write the File to Disk */
write {
var file;
file = File(this.fileName.standardizePath ++ ".ly","w");
file.write(this.header);
file.write(this.musicString);
file.close;
}
/* Array of the available LilyPond templates Paths */
templatePathList {
^(templatesFolder ++ "/*").pathMatch
}
/* Array of the available LilyPond templates Names */
templateList {
^(this.templatePathList.collect {|i| i.basename})
}
/* Call the PDF Viewer to show the produced PDF File: */
show { (this.pdfViewer ++ " " ++ this.fileName.standardizePath ++ ".pdf" ).unixCmd }
/* Call the MIDI player program */
playMidi { ( this.midiPlayer ++ " " ++ this.fileName.standardizePath ++ ".midi" ).unixCmd }
/* Produce the score with LilyPond, when it's done open with the PDF viewer */
plot {
fork {
this.write;
0.1.wait;
(
this.lilyCmd ++ " -o " ++ this.fileName.standardizePath ++ " " ++
this.fileName.standardizePath ++ ".ly"
).unixCmd { this.show };
}
}
/* Call the text editor to open the .ly file */
edit {
this.write;
(this.textEditor ++ " " ++ this.fileName.standardizePath ++ ".ly").unixCmd;
}
}