ramekin 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: 78c8f609fa645c1807ac00bf970bf5d05fc78015c185a50d55410a81faa888a4
4
- data.tar.gz: aab9adb5b304bbcedc94aee84ca95ddd4bf70307d5f807fcbca93944c79c109f
3
+ metadata.gz: 399438b57abf19c6d68cbc4db7fbb96586985bf801f0f94cea4cd1365d2839e9
4
+ data.tar.gz: 5abb75a51346fa517c749f3dd78d469459d02bef30bb3478060f2ed9527a0792
5
5
  SHA512:
6
- metadata.gz: 42986dbf7c0e96bf7e1ecff4552b052cc99fa662f7e648f8aa16e5e5f668e76759b753f563a11a315c530d2d6ef86867a1f7cb0d1080a1a6d7cfdb0a3c8ac908
7
- data.tar.gz: b7e71fecb8146fbd9b2a8391a827db80c95bff25deff7bc15a50619f8d9f8264346894dd4653629cfe36dc905b4b21c0ddf96c3054a4a2e610d5fe11759c11a6
6
+ metadata.gz: e9306550e91db609450792179302dce6752cb6fa9cb5fe97f95f1ac926bf28bc8548719c5e0d55e7909c0e4c8817149675f7caff6a86c0d4b37bbeaaf634840b
7
+ data.tar.gz: 38abeba0943b587b1559e9fe0a1fe5fe0875f349a1b7fa5883b1e7da57e1e52898a0bd0ef2b7fee02b418a8f739aae118baae74627cbfce6d773d6d4fba5a4a9
data/lib/ramekin/bends.rb CHANGED
@@ -62,11 +62,13 @@ module Ramekin
62
62
  adjust = 2 - leftover
63
63
  bend_duration -= adjust
64
64
  leftover += adjust
65
- if bend_duration < 0
65
+ if bend_duration <= 0
66
66
  return error! 'bend duration too small to insert legato-off toggle', el: self
67
67
  end
68
68
  end
69
69
 
70
+ return '' unless check_duration!(from)
71
+
70
72
  out = StringIO.new
71
73
 
72
74
  out << from.octave_amk(oct)
@@ -92,6 +94,16 @@ module Ramekin
92
94
  true
93
95
  end
94
96
 
97
+ def check_duration!(note)
98
+ ticks = note.ticks
99
+ return true if ticks > 0 && ticks <= 96
100
+
101
+ error! 'bend length too short (must be at least one tick)', el: note if ticks <= 0
102
+ error! 'bend duration too long (max 96 ticks or a half note)', el: note if ticks > 96
103
+
104
+ false
105
+ end
106
+
95
107
  def to_amk(octave, divisor)
96
108
  if massive_special_case?(divisor)
97
109
  return render_massive_special_case(octave, divisor)
@@ -113,6 +125,7 @@ module Ramekin
113
125
  end
114
126
 
115
127
  ticks /= divisor
128
+ next unless check_duration!(note)
116
129
 
117
130
  # $dd doesn't work properly if the note
118
131
  # beforehand is more than a half note, so we have to
@@ -132,6 +145,13 @@ module Ramekin
132
145
  end
133
146
 
134
147
  def dd(dur, note)
148
+ hex = note.note_hex
149
+
150
+ unless 0x80 <= hex && hex <= 0xC5
151
+ error! 'note out of range (o1c - o6a)', el: note
152
+ return ''
153
+ end
154
+
135
155
  sprintf '$dd$00$%02x$%02x', dur, note.note_hex
136
156
  end
137
157
  end
@@ -177,7 +177,7 @@ module Ramekin
177
177
  else
178
178
  @octave = nil
179
179
  unless @instrument_index.key?(token.value)
180
- error! "undeclared instrument @#{token.value}"
180
+ return error! "undeclared instrument @#{token.value}"
181
181
  end
182
182
 
183
183
  yield "@#{@instrument_index[token.value]}"
@@ -224,6 +224,12 @@ module Ramekin
224
224
  when 'C' then 10
225
225
  end
226
226
 
227
+ if pan > 20
228
+ return error! 'invalid pan (max yL10)'
229
+ elsif pan < 0
230
+ return error! 'invalid pan (max yR10)'
231
+ end
232
+
227
233
  yield "y#{pan}"
228
234
 
229
235
  when :p
@@ -257,9 +263,6 @@ module Ramekin
257
263
  # triplets are handled in NoteAggregator
258
264
  when :lbrace, :rbrace
259
265
  # pass
260
- when :rbrace
261
- yield '}'
262
-
263
266
  else
264
267
  error! "unexpected token type: #{token.type}"
265
268
  end
@@ -272,10 +275,10 @@ module Ramekin
272
275
  if time.nil?
273
276
  "v#{vol}"
274
277
  else
275
- time = time.to_i
278
+ time = time.to_i / @track.meta.divisor
276
279
  time = 255 if time > 255
277
280
  time = 0 if time < 0
278
- sprintf("$E8$%02x$%02x", time, vol)
281
+ sprintf("$e8$%02x$%02x", time, vol)
279
282
  end
280
283
  end
281
284
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ramekin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jneen