lydown 0.6.3 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de11dc5e615a172e26be2794ac4d4ef9ffe1f6cf
4
- data.tar.gz: a084d3a2ff38cf986562543ee7cdeba0d42d9b1f
3
+ metadata.gz: 60fcdf6a08bf0d2bcb5696459558cc363eedd69e
4
+ data.tar.gz: 34a2c3748611306069d495586549a0de7443d133
5
5
  SHA512:
6
- metadata.gz: 283987261fae1293645577aa9ef8dd47dd444a1414568f30c41e60588a2789296c6aa214627e7421c607fb948a9338de49e33aea17d2759afe0d1adf398ed0cc
7
- data.tar.gz: c6d97d5602792d02ae693cabb6d5c605d6cf7371ca40c7c9ea795d6ec03becfbd6a55b0f97f392a6fcec357b4bf11c964591358417009c3027c4871030afca1c
6
+ metadata.gz: 866094223b9c739569ec266c621a934eccf9d0cd11ac7eb9453d682c5532ffa3e71e9624af070333fba4854213ec26547369315f969f71b4effb95b52f7899fd
7
+ data.tar.gz: 640142f2131b45050bba63b9e25e2f50d5dd477947a0519c840063e4ba4c02df93a72aa8517baabb3306a898d07c47e4e36457e8074418f31bad38e0f222d583
@@ -44,7 +44,7 @@ grammar Lydown
44
44
  [ \t]+
45
45
  end
46
46
  rule event
47
- (inline_command / inline_lyrics / voice_selector / barline / duration /
47
+ (inline_command / inline_lyrics / voice_selector / barline / grace_duration / duration /
48
48
  chord / note / standalone_figures / rest / silence / phrasing / tie) white_space*
49
49
  end
50
50
  rule barline
@@ -55,6 +55,12 @@ grammar Lydown
55
55
  rule duration
56
56
  tuplet_value / duration_value / duration_macro
57
57
  end
58
+ rule grace_duration
59
+ '$' grace_duration_type* number <GraceDuration>
60
+ end
61
+ rule grace_duration_type
62
+ [\/\^]
63
+ end
58
64
  rule tuplet_value
59
65
  number '%' (number '/' number)? <TupletValue>
60
66
  end
@@ -77,6 +77,20 @@ module Lydown::Parsing
77
77
  end
78
78
  end
79
79
 
80
+ module GraceDuration
81
+ GRACE_KIND = {
82
+ nil => :grace,
83
+ '/' => :acciaccatura,
84
+ '^' => :appoggiatura
85
+ }
86
+
87
+ def to_stream(stream)
88
+ if text_value =~ /^\$([\/\^])?(\d+)$/
89
+ stream << {type: :grace, value: $2, kind: GRACE_KIND[$1]}
90
+ end
91
+ end
92
+ end
93
+
80
94
  module Note
81
95
  include Root
82
96
 
@@ -15,6 +15,11 @@ module Lydown::Rendering
15
15
  @work['process/tuplet_mode'] = nil
16
16
  end
17
17
 
18
+ if @work['process/grace_mode']
19
+ Grace.emit_grace_end(@work)
20
+ @work['process/grace_mode'] = nil
21
+ end
22
+
18
23
  value = @event[:value].sub(/^[0-9]+/) {|m| LILYPOND_DURATIONS[m] || m}
19
24
 
20
25
  if next_event && next_event[:type] == :stand_alone_figures
@@ -54,6 +59,28 @@ module Lydown::Rendering
54
59
  end
55
60
  end
56
61
  end
62
+
63
+ class Grace < Base
64
+ def self.emit_grace_end(work)
65
+ work.emit(:music, '} ')
66
+ end
67
+
68
+ def translate
69
+ # close tuplet braces
70
+ if @work['process/grace_mode']
71
+ Grace.emit_grace_end(@work)
72
+ @work['process/grace_mode'] = nil
73
+ end
74
+
75
+ value = LILYPOND_DURATIONS[@event[:value]] || @event[:value]
76
+
77
+ @work['process/duration_values'] = [value]
78
+ @work['process/last_value'] = nil
79
+ @work['process/grace_mode'] = true
80
+
81
+ @work.emit(:music, "\\#{@event[:kind]} { ")
82
+ end
83
+ end
57
84
 
58
85
  class Note < Base
59
86
  include Notes
@@ -1,3 +1,3 @@
1
1
  module Lydown
2
- VERSION = "0.6.3"
2
+ VERSION = "0.6.4"
3
3
  end
data/lib/lydown/work.rb CHANGED
@@ -41,6 +41,9 @@ module Lydown
41
41
  if @context['process/tuplet_mode']
42
42
  Lydown::Rendering::TupletDuration.emit_tuplet_end(self)
43
43
  end
44
+ if @context['process/grace_mode']
45
+ Lydown::Rendering::Grace.emit_grace_end(self)
46
+ end
44
47
 
45
48
  if @context['process/voice_selector']
46
49
  Lydown::Rendering::VoiceSelect.render_voices(self)
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.3
4
+ version: 0.6.4
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-21 00:00:00.000000000 Z
11
+ date: 2015-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop