forked from rubiety/vexflow-json
/
examples.html
172 lines (149 loc) · 5.36 KB
/
examples.html
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<html lang="en">
<head>
<meta charset="utf-8">
<title>VexFlow JSON Examples</title>
<script src="vendor/underscore.js" type="text/javascript"></script>
<script src="vendor/vexflow.js" type="text/javascript"></script>
<script src="vexflow-json.js" type="text/javascript"></script>
<script type="text/javascript">
function render_vexflow(element_id, data, render_options) {
var element = document.getElementById(element_id);
var json = new Vex.Flow.JSON(data);
if (render_options) {
json.render(element, render_options);
} else {
json.render(element, data);
}
}
</script>
</head>
<body>
<h1>VexFlow JSON Examples</h1>
<h2>Simple Chord</h2>
<canvas id="simple-chord" width="200" height="120"></canvas>
<script type="text/javascript">
render_vexflow("simple-chord", ["C", "E", "G", "Bb"]);
</script>
<h2>Simple Chord (SVG)</h2>
<svg id="simple-chord-svg" width="200" height="120"></svg>
<script type="text/javascript">
render_vexflow("simple-chord-svg", ["C", "E", "G", "Bb"]);
</script>
<h2>Simple Chord Scaled 75%</h2>
<canvas id="simple-chord-scaled" width="200" height="120"></canvas>
<script type="text/javascript">
render_vexflow("simple-chord-scaled", ["C", "E", "G", "Bb"], { scale: 0.75 });
</script>
<h2>Simple Chord with Octaves</h2>
<canvas id="simple-chord-with-octaves" width="600" height="120"></canvas>
<script type="text/javascript">
render_vexflow("simple-chord-with-octaves", ["C/5", "E/5", "G/5", "Bb/5"], { width: 200 });
</script>
<h2>Simple Chord with Duration</h2>
<canvas id="simple-chord-with-duration" width="600" height="120"></canvas>
<script type="text/javascript">
render_vexflow("simple-chord-with-duration", {
duration: "h",
keys: ["C", "E", "G", "Bb"]
});
</script>
<h2>Simple List of Notes</h2>
<canvas id="simple-list-of-notes" width="600" height="120"></canvas>
<script type="text/javascript">
render_vexflow("simple-list-of-notes", [["C"], ["D"], ["E"], ["F"], ["G"]]);
</script>
<h2>Simple Sequence of Chords</h2>
<canvas id="simple-sequence-of-chords" width="600" height="120"></canvas>
<script type="text/javascript">
render_vexflow("simple-sequence-of-chords", [
["C", "Eb", "G", "Bb"],
["C", "Eb", "F", "A"],
["Bb", "D", "F", "A"],
"|",
["C", "Eb", "G", "Bb"],
["C", "Eb", "F", "A"],
["Bb", "D", "F", "A"]
]);
</script>
<h2>Explicit Sequence of Chords</h2>
<canvas id="explicit-sequence-of-chords" width="600" height="120"></canvas>
<script type="text/javascript">
render_vexflow("explicit-sequence-of-chords", {
clef: "treble",
notes: [
{ duration: "q", keys: ["C", "Eb", "G", "Bb"] },
{ duration: "q", keys: ["C", "Eb", "F", "A"] },
{ duration: "h", keys: ["Bb", "D", "F", "A"] },
{ duration: "h", keys: ["Bb", "D", "F", "A"] },
]
});
</script>
<h2>Grand Staff: Chord Across Treble & Bass Clefs</h2>
<canvas id="chord-across-clefs" width="150" height="200"></canvas>
<script type="text/javascript">
render_vexflow("chord-across-clefs", {
clef: ["treble", "bass"],
duration: "w",
keys: ["C/3", "E/3", "G/3", "Bb/3", "C/5"],
add_right_double_line: true,
});
</script>
<h2>Bass: the notes know they are bass: C_4 (underscore)</h2>
<canvas id="just-bass" width="150" height="200"></canvas>
<script type="text/javascript">
render_vexflow("just-bass", {
clef: ["treble", "bass"],
duration: "w",
keys: ["E_3", "G_3", "Bb_3", "C_4"],
add_right_double_line: true,
});
</script>
<h2>Treble: the notes know they are treble: C-5 (hyphen)</h2>
<canvas id="just-treble" width="150" height="200"></canvas>
<script type="text/javascript">
render_vexflow("just-treble", {
clef: ["treble", "bass"],
duration: "w",
keys: ["E-3", "G-3", "Bb-3", "E-4", "C-5"],
add_right_double_line: true,
});
</script>
<h2>Combined: the notes know which hand (_ and -)</h2>
<canvas id="bass-treble-explicit" width="150" height="200"></canvas>
<script type="text/javascript">
render_vexflow("bass-treble-explicit", {
clef: ["treble", "bass"],
duration: "w",
keys: ["C_2", "G_2", "Bb_2", "E_3", "Bb-3", "E-4", "G-4"],
add_right_double_line: true,
});
</script>
<h2>Explicit Voices</h2>
<canvas id="explicit-voices" width="900" height="200"></canvas>
<script type="text/javascript">
render_vexflow("explicit-voices", {
clef: "treble",
voices: [
{ time: "4/4", notes: [
{ duration: "h", keys: ["C", "Eb", "F", "A"] },
{ duration: "h", keys: ["Bb", "D", "F", "A"] },
{ barnote: true },
{ duration: "q", keys: ["C", "Eb", "G", "Bb"] },
{ duration: "q", keys: ["C", "Eb", "F", "A"] },
{ duration: "h", keys: ["Bb", "D", "F", "A"] },
{ barnote: true },
{ duration: "q", keys: ["C", "Eb", "G", "Bb"] },
{ duration: "q", keys: ["C", "Eb", "F", "A"] },
{ duration: "h", keys: ["Bb", "D", "F", "A"] },
{ barnote: true },
{ duration: "q", keys: ["C", "Eb", "G", "Bb"] },
{ duration: "q", keys: ["C", "Eb", "F", "A"] },
{ duration: "h", keys: ["Bb", "D", "F", "A"] }
]}
]
});
</script>
<h2>Explicit Voices with Beaming</h2>
<h2>TODO</h2>
</body>
</html>