lydown 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lydown/core_ext.rb +13 -6
- data/lib/lydown/rendering/music.rb +11 -3
- data/lib/lydown/rendering/notes.rb +6 -1
- data/lib/lydown/rendering/settings.rb +5 -0
- data/lib/lydown/templates/lilypond_doc.erb +1 -0
- data/lib/lydown/templates/part.erb +11 -5
- data/lib/lydown/version.rb +1 -1
- data/lib/lydown/work.rb +60 -23
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de11dc5e615a172e26be2794ac4d4ef9ffe1f6cf
|
4
|
+
data.tar.gz: a084d3a2ff38cf986562543ee7cdeba0d42d9b1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 283987261fae1293645577aa9ef8dd47dd444a1414568f30c41e60588a2789296c6aa214627e7421c607fb948a9338de49e33aea17d2759afe0d1adf398ed0cc
|
7
|
+
data.tar.gz: c6d97d5602792d02ae693cabb6d5c605d6cf7371ca40c7c9ea795d6ec03becfbd6a55b0f97f392a6fcec357b4bf11c964591358417009c3027c4871030afca1c
|
data/lib/lydown/core_ext.rb
CHANGED
@@ -11,13 +11,16 @@ class Hash
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def deep_merge!(hash)
|
14
|
-
hash
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
unless self.hash == hash.hash
|
15
|
+
hash.each do |key, value|
|
16
|
+
svalue = self.old_get(key)
|
17
|
+
|
18
|
+
if (value.is_a? Hash) && (svalue.is_a? Hash)
|
19
|
+
old_set(key, svalue.deep_merge(value))
|
20
|
+
else
|
21
|
+
old_set(key, value)
|
22
|
+
end
|
18
23
|
end
|
19
|
-
|
20
|
-
self[key] = hash[key]
|
21
24
|
end
|
22
25
|
|
23
26
|
self.deep = true
|
@@ -96,6 +99,10 @@ class Hash
|
|
96
99
|
@deep = true
|
97
100
|
self
|
98
101
|
end
|
102
|
+
|
103
|
+
def is_deep?
|
104
|
+
!!@deep
|
105
|
+
end
|
99
106
|
end
|
100
107
|
|
101
108
|
class String
|
@@ -34,14 +34,22 @@ module Lydown::Rendering
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def translate
|
37
|
+
# close tuplet braces
|
38
|
+
if @work['process/tuplet_mode']
|
39
|
+
TupletDuration.emit_tuplet_end(@work)
|
40
|
+
@work['process/tuplet_mode'] = nil
|
41
|
+
end
|
42
|
+
|
37
43
|
if next_event && next_event[:type] == :stand_alone_figures
|
38
44
|
@work['process/figures_duration_value'] = "#{@event[:value]}*#{@event[:fraction]}"
|
39
45
|
else
|
40
|
-
@
|
46
|
+
value = LILYPOND_DURATIONS[@event[:value]] || @event[:value]
|
47
|
+
|
48
|
+
@work['process/duration_values'] = [value]
|
41
49
|
@work['process/last_value'] = nil
|
42
50
|
@work['process/tuplet_mode'] = true
|
43
|
-
|
44
|
-
group_value =
|
51
|
+
|
52
|
+
group_value = value.to_i / @event[:group_length].to_i
|
45
53
|
@work.emit(:music, "\\tuplet #{@event[:fraction]} #{group_value} { ")
|
46
54
|
end
|
47
55
|
end
|
@@ -32,11 +32,16 @@ module Lydown::Rendering
|
|
32
32
|
def self.calc_accidentals_map(accidentals)
|
33
33
|
accidentals.inject({}) { |h, a| h[a[0]] = (a[1] == '+') ? 1 : -1; h}
|
34
34
|
end
|
35
|
+
|
36
|
+
ACCIDENTAL_VALUES = {
|
37
|
+
'+' => 1,
|
38
|
+
'-' => -1
|
39
|
+
}
|
35
40
|
|
36
41
|
def self.lilypond_note_name(note, key_signature = 'c major')
|
37
42
|
value = 0
|
38
43
|
# accidental value from note
|
39
|
-
note = note.gsub(/[\-\+]/) { |c| value +=
|
44
|
+
note = note.gsub(/[\-\+]/) { |c| value += ACCIDENTAL_VALUES[c]; '' }
|
40
45
|
# add key signature value
|
41
46
|
value += accidentals_for_key_signature(key_signature)[note] || 0
|
42
47
|
|
@@ -29,8 +29,11 @@ module Lydown::Rendering
|
|
29
29
|
@work[key] = value
|
30
30
|
case key
|
31
31
|
when 'part'
|
32
|
+
@work.set_part_context(value)
|
33
|
+
|
32
34
|
# when changing parts we repeat the last set time and key signature
|
33
35
|
render_setting('time', @work[:time]) unless @work[:time] == '4/4'
|
36
|
+
|
34
37
|
key = @work[:key]
|
35
38
|
render_setting('key', key) unless key == 'c major'
|
36
39
|
|
@@ -113,3 +116,5 @@ module Lydown::Rendering
|
|
113
116
|
end
|
114
117
|
end
|
115
118
|
end
|
119
|
+
|
120
|
+
|
@@ -11,20 +11,26 @@
|
|
11
11
|
|
12
12
|
|
13
13
|
score_mode = self['render_opts/mode'] == :score
|
14
|
+
|
15
|
+
part['settings'] ||= {
|
16
|
+
'pickup' => @context[:pickup],
|
17
|
+
'key' => @context[:key],
|
18
|
+
'tempo' => @context[:tempo]
|
19
|
+
}.deep!
|
14
20
|
|
15
21
|
clef = Lydown::Rendering::Staff.clef(name)
|
16
22
|
beaming_mode = Lydown::Rendering::Staff.beaming_mode(name)
|
17
|
-
partial =
|
18
|
-
|
23
|
+
partial = part['settings'][:pickup] ? "\\partial #{part['settings'][:pickup]}" : ""
|
24
|
+
|
19
25
|
end_barline = Lydown::Rendering::Staff.end_barline(self, movement)
|
20
26
|
|
21
|
-
cadenza =
|
27
|
+
cadenza = part['settings'][:time] == 'unmetered'
|
22
28
|
%>
|
23
29
|
|
24
30
|
<<
|
25
31
|
|
26
|
-
<% if
|
27
|
-
\tempo "<%=
|
32
|
+
<% if part['settings'][:tempo] %>
|
33
|
+
\tempo "<%= part['settings'][:tempo] %>"
|
28
34
|
<% end %>
|
29
35
|
|
30
36
|
\new Staff = <%= staff_id %> \with {
|
data/lib/lydown/version.rb
CHANGED
data/lib/lydown/work.rb
CHANGED
@@ -26,7 +26,7 @@ module Lydown
|
|
26
26
|
|
27
27
|
def reset_context(mode)
|
28
28
|
case mode
|
29
|
-
when :work
|
29
|
+
when :work
|
30
30
|
@context[:time] = '4/4'
|
31
31
|
@context[:tempo] = nil
|
32
32
|
@context[:cadenza_mode] = nil
|
@@ -35,6 +35,8 @@ module Lydown
|
|
35
35
|
@context[:beaming] = nil
|
36
36
|
@context[:end_barline] = nil
|
37
37
|
@context[:part] = nil
|
38
|
+
when :movement
|
39
|
+
@context[:part] = nil
|
38
40
|
end
|
39
41
|
if @context['process/tuplet_mode']
|
40
42
|
Lydown::Rendering::TupletDuration.emit_tuplet_end(self)
|
@@ -84,7 +86,7 @@ module Lydown
|
|
84
86
|
part = @context[:part]
|
85
87
|
path = "movements/#{movement}/parts/#{part}/#{subpath}"
|
86
88
|
end
|
87
|
-
@context[path] ||= ''
|
89
|
+
@context[path] ||= (subpath == :settings) ? {} : ''
|
88
90
|
end
|
89
91
|
|
90
92
|
def to_lilypond(opts = {})
|
@@ -157,6 +159,39 @@ module Lydown
|
|
157
159
|
def []=(path, value)
|
158
160
|
context[path] = value
|
159
161
|
end
|
162
|
+
|
163
|
+
# Helper method to preserve context while processing a file or directory.
|
164
|
+
# This method is called with a block. After the block is executed, the
|
165
|
+
# context is restored.
|
166
|
+
def preserve_context
|
167
|
+
old_context = @context
|
168
|
+
new_context = old_context.deep_merge({})
|
169
|
+
@context = new_context
|
170
|
+
yield
|
171
|
+
ensure
|
172
|
+
@context = old_context
|
173
|
+
if new_context['movements']
|
174
|
+
if @context['movements']
|
175
|
+
@context['movements'].deep_merge! new_context['movements']
|
176
|
+
else
|
177
|
+
@context['movements'] = new_context['movements']
|
178
|
+
end
|
179
|
+
if @context['movements/01-intro/parts/violino1/settings'] && @context['movements/01-intro/parts/violino1/settings'].keys.include?('pickup')
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def set_part_context(part)
|
185
|
+
movement = @context[:movement]
|
186
|
+
path = "movements/#{movement}/parts/#{part}/settings"
|
187
|
+
|
188
|
+
settings = {}.deep!
|
189
|
+
settings[:pickup] = @context[:pickup]
|
190
|
+
settings[:key] = @context[:key]
|
191
|
+
settings[:tempo] = @context[:tempo]
|
192
|
+
|
193
|
+
@context[path] = settings
|
194
|
+
end
|
160
195
|
|
161
196
|
def process_work_files
|
162
197
|
path = @context[:path]
|
@@ -174,32 +209,34 @@ module Lydown
|
|
174
209
|
DEFAULT_BASENAMES = %w{work movement}
|
175
210
|
|
176
211
|
def process_directory(path, recursive = true)
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
212
|
+
preserve_context do
|
213
|
+
# process work code
|
214
|
+
process_lydown_file(File.join(path, 'work.ld'))
|
215
|
+
# process movement specific code
|
216
|
+
process_lydown_file(File.join(path, 'movement.ld'))
|
217
|
+
|
218
|
+
# Iterate over sorted directory entries
|
219
|
+
Dir["#{path}/*"].entries.sort.each do |entry|
|
220
|
+
if File.file?(entry) && (entry =~ /\.ld$/)
|
221
|
+
part = File.basename(entry, '.*')
|
222
|
+
unless DEFAULT_BASENAMES.include?(part)
|
223
|
+
preserve_context do
|
224
|
+
process_lydown_file(entry, [
|
225
|
+
{type: :setting, key: 'part', value: part}
|
226
|
+
])
|
227
|
+
end
|
228
|
+
end
|
229
|
+
elsif File.directory?(entry) && recursive
|
230
|
+
movement = File.basename(entry)
|
231
|
+
process([{type: :setting, key: 'movement', value: movement}])
|
232
|
+
process_directory(entry, false)
|
191
233
|
end
|
192
|
-
elsif File.directory?(entry) && recursive
|
193
|
-
basename = File.basename(entry)
|
194
|
-
# set movement
|
195
|
-
process([{type: :setting, key: 'movement', value: basename}])
|
196
|
-
process_directory(entry, false)
|
197
234
|
end
|
198
235
|
end
|
199
236
|
end
|
200
237
|
|
201
|
-
def process_lydown_file(path)
|
202
|
-
process LydownParser.parse(IO.read(path)) if File.file?(path)
|
238
|
+
def process_lydown_file(path, prefix = [])
|
239
|
+
process(prefix + LydownParser.parse(IO.read(path))) if File.file?(path)
|
203
240
|
end
|
204
241
|
end
|
205
242
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lydown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: treetop
|