ramekin 0.0.6 → 0.0.7

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: f7b36dbfb523fcdcfc98705488675f16c06ce0aed6ad2a93abe69d3ff5818eff
4
- data.tar.gz: 81c0bdc600590ed5f1a552ecd8eed52901d52b558820c9c53e69bac0cdc13053
3
+ metadata.gz: c8ecaeee8d7551d229bd4d659e37db4fb7ce51b8c8b02db5951afe2889c5766d
4
+ data.tar.gz: 306dd97179707ab87cbf615c0740495f230a5be78476c89855c5e65c3cbc8d54
5
5
  SHA512:
6
- metadata.gz: fcdf3d5540e3cbcaf92f37235a7d778c4d4389fe4d791777e849db2d40076d839a618ba7333af29878390375130963be0e98b0d232f7c6557a90b2787bec0c19
7
- data.tar.gz: 8bd4df95943b9e05ec1a849dedefdfd5c277ce53b7019098562881ec7f892532bc2fa623e0e368b5a3f817970f94e1c671f79a3a5bfa750f240e93a1cdc41e37
6
+ metadata.gz: f6496a57a0d10da8cb22d3c0da7593fc8db6949f36fa78b6bf124b39bb727f9b05176fff29961111f510029c7ec93e7d4b8edad2ee0704e312bff82b2d5b02e0
7
+ data.tar.gz: 494634f3636b32f99fd77c3337b7981021f39850aee811cbe15e6b8154fe5d1474ca51659bce91fe46e09ec4e64e7d5344488ba171523b5036ca7e53713cfcf5
data/README.md CHANGED
@@ -42,7 +42,8 @@ ramekin compile -i filename.rmk [flags]
42
42
  -i filename.rmk
43
43
  set the input file
44
44
  --txt filename.txt
45
- output amk txt to this file
45
+ output amk txt to this file.
46
+ use a single dash (-) to print txt to stdout.
46
47
  --spc filename.spc
47
48
  attempt to invoke AddmusicK to output an SPC
48
49
  requires ADDMUSICK_DIR and ASAR_COMMAND
data/lib/ramekin/cli.rb CHANGED
@@ -29,7 +29,8 @@ module Ramekin
29
29
  $stderr.puts " -i filename.rmk"
30
30
  $stderr.puts " set the input file"
31
31
  $stderr.puts " --txt filename.txt"
32
- $stderr.puts " output amk txt to this file"
32
+ $stderr.puts " output amk txt to this file."
33
+ $stderr.puts " use a single dash (-) to print txt to stdout."
33
34
  $stderr.puts " --spc filename.spc"
34
35
  $stderr.puts " attempt to invoke AddmusicK to output an SPC"
35
36
  $stderr.puts " requires ADDMUSICK_DIR and ASAR_COMMAND"
@@ -199,7 +200,9 @@ module Ramekin
199
200
  WARN
200
201
  end
201
202
 
202
- if @output_txt
203
+ if @output_txt == '-'
204
+ $stdout.puts(txt)
205
+ elsif @output_txt
203
206
  File.write(@output_txt, txt)
204
207
  end
205
208
 
data/lib/ramekin/meta.rb CHANGED
@@ -21,6 +21,33 @@ module Ramekin
21
21
  @options = {}
22
22
  end
23
23
 
24
+ def echo_channel_bits
25
+ (@echo_channels ||= Set.new).map { |x| 1 << x }.inject(&:|)
26
+ end
27
+
28
+ def echo_volumes
29
+ [(@echo_volume_l || 0) & 0xFF, (@echo_volume_r || 0) & 0xFF]
30
+ end
31
+
32
+ def echo_delay
33
+ @echo_delay || 0
34
+ end
35
+
36
+ def echo_feedback
37
+ (@echo_feedback || 0) & 0xFF
38
+ end
39
+
40
+ def echo_fir
41
+ @echo_fir || 0
42
+ end
43
+
44
+ def echo_hex
45
+ sprintf("$ef$%02x$%02x$%02x $f1$%02x$%02x$%02x",
46
+ echo_channel_bits, *echo_volumes,
47
+ echo_delay, echo_feedback, echo_fir
48
+ )
49
+ end
50
+
24
51
  def parse
25
52
  loop do
26
53
  break if @elements.empty?
@@ -40,6 +67,8 @@ module Ramekin
40
67
  @sample_groups << 'default' if @sample_groups.empty?
41
68
  end
42
69
 
70
+ SURROUND_R = (-0x7f..0x80)
71
+
43
72
  def parse_directive
44
73
  @current_directive = @current
45
74
  case @current.value
@@ -65,6 +94,64 @@ module Ramekin
65
94
 
66
95
  # TODO: real echo syntax
67
96
  when 'echo' then @echo = expect_args(*([:hex] * 8))
97
+ when 'echo/channels'
98
+ channels = @current_directive.values[1]
99
+ if channels == 'all'
100
+ @echo_channels = Set.new(0..7)
101
+ return
102
+ end
103
+
104
+ unless channels && channels =~ /\A\d(,\d)+\z/
105
+ error! 'invalid echo channels (list of single digit numbers separated by comma)'
106
+ end
107
+
108
+ @echo_channels = Set.new(channels.split(',').map(&:to_i))
109
+ unless @echo_channels.all? { |c| (0..7).include?(c) }
110
+ error! 'invalid echo channels (must be 0-7)'
111
+ end
112
+ when 'echo/volume'
113
+ vols = @current_directive.values[1]
114
+
115
+ unless vols && vols =~ /\A-?\h\h?(,\h\h?)?/
116
+ error! 'invalid echo volume (one or two hex numbers)'
117
+ end
118
+
119
+ vols = vols.split(',').map { |v| v.to_i(16) }
120
+ if vols.size == 1
121
+ @echo_volume_l = @echo_volume_r = vols[0]
122
+ else
123
+ @echo_volume_l, @echo_volume_r = vols
124
+ end
125
+
126
+ unless SURROUND_R.include?(@echo_volume_l) && SURROUND_R.include?(@echo_volume_r)
127
+ error! 'invalid echo volume (-7f to 80, use negative for surround)'
128
+ end
129
+
130
+ when 'echo/delay'
131
+ delay = @current_directive.values[1]
132
+ unless delay && delay =~ /\A[0-7]\z/
133
+ error! 'invalid echo delay (single digit 0-7)'
134
+ end
135
+
136
+ @echo_delay = delay.to_i
137
+ when 'echo/feedback'
138
+ feedback = @current_directive.values[1]
139
+ unless feedback && feedback =~ /\A-?\h\h?\z/
140
+ error! 'invalid echo feedback (one or two hex digits)'
141
+ end
142
+
143
+ @echo_feedback = feedback.to_i(16)
144
+
145
+ unless SURROUND_R.include?(@echo_feedback)
146
+ error! 'invalid echo feedback (-7F to 80, use negative for surround)'
147
+ end
148
+ when 'echo/fir'
149
+ fir = @current_directive.values[1]
150
+ unless fir && fir =~ /\A\h\h?\z/
151
+ error! 'invalid echo FIR setting (one or two hex digits)'
152
+ end
153
+
154
+ @echo_fir = fir.to_i(16)
68
155
  else
69
156
  error! 'invalid directive in header'
70
157
  end
@@ -99,7 +99,10 @@ module Ramekin
99
99
 
100
100
  yield "t#{tempo_of(m.tempo)} ; main tempo (0-60)\n" if m.tempo
101
101
  yield "w#{m.volume.value} ; main volume (0-255)\n" if m.volume
102
- yield "l16"
102
+ yield "l16\n\n"
103
+
104
+ yield "; echo settings\n"
105
+ yield m.echo_hex
103
106
  # binding.pry
104
107
  end
105
108
 
@@ -274,6 +277,8 @@ module Ramekin
274
277
  @octave = note.octave
275
278
  when 'legato'
276
279
  yield '$f4$01'
280
+ when 'echo/toggle'
281
+ yield '$f4$03'
277
282
  else
278
283
  error! "unexpected directive ##{token.value}"
279
284
  end
@@ -217,7 +217,8 @@ module Ramekin
217
217
  return [:amk, m(1)] if match /#amk\s*(\d+)/
218
218
  return [:option, m(1)] if match /#option (\w+)/
219
219
  return [:channel, m(1)] if match /#(\d+)/
220
- return [:directive, m(1)] if match /#([\w-]+)/
220
+ return [:directive, m(1), m(2)] if match /#([\w\/-]+):(\S+)/
221
+ return [:directive, m(1)] if match /#([\w\/-]+)/
221
222
  return [:lbrace] if match /[{]/
222
223
  return [:rbrace] if match /[}]/
223
224
  return [:v, m(1), m(2)] if match /v(\d+)(?:,(\d+))?/
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.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - jneen