ramekin 0.0.8 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 463b021dd0273151c13a7590db845acf584a2df021596dd715721964e777f6d9
4
- data.tar.gz: 432c1eccc9c5443cc63ec828f87a319141caeb3080c847948634b7935553ec86
3
+ metadata.gz: e6d502b095f92786dc1c94da24e1144d744f8462f609a1d7623a9c46a541b5f9
4
+ data.tar.gz: 2de364d731e7760f8dc1111d18aad6b4de5a5b713e5d3ec424af3c80f180ec52
5
5
  SHA512:
6
- metadata.gz: fbe078d3e43b620748e3bcd91360d06e1bf2b9b804821d21a6479479fe519abb7d48643a8a95f45abfcfe512b2654b1a1f6424773282d294503799e2ee31175b
7
- data.tar.gz: bd829fcd1272ac8279757c73963e407b90ef9257d104475aa07a5c52cf3ed16ce691d25ade84a3333fa2c243854948b92a7fcbfa90b47ee2fedad9c845b54c33
6
+ metadata.gz: 0a1aed7dde26850dd627da1ac9e0b7445d41097128dcae4ba464afc7c0868e7905f8adb2b395bfc93aa3d9ea28e7739cb2e5bb36fdf6de679726d938913de179
7
+ data.tar.gz: 6402af26f0cbd457a8246121eefcfe976a5331925ed97849520fec05faafbdf47c8124a95bdb398a38115dcb6a6dce2fd7ff0bac6e1678787d433e4e7cfcc247
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Ramekin is a pre-processor for AddMusicK syntax that is in very early development.
4
4
 
5
+ Please keep in mind that as alpha software, **I may make breaking changes at any time.** After initial testing is done, I will release 1.0.0, at which point I will make a reasonable commitment to back-compatibility. That time is not yet.
6
+
5
7
  # Installation
6
8
 
7
9
  First, [Install Ruby](https://ruby-lang.org). Windows users can use [RubyInstaller](https://rubyinstaller.org/).
@@ -3,6 +3,8 @@ require_relative 'amk_runner/sample_groups'
3
3
 
4
4
  module Ramekin
5
5
  class AMKRunner
6
+ include Util
7
+
6
8
  def initialize(filename, meta, txt)
7
9
  @filename = File.expand_path(filename)
8
10
  @amk_path = Ramekin.config.amk_dir
@@ -40,6 +42,8 @@ module Ramekin
40
42
 
41
43
  ln("#@amk_path/asm", "#@workdir/asm")
42
44
 
45
+ FileUtils.mkdir_p("#@workdir/Visualizations")
46
+
43
47
  FileUtils.mkdir_p("#@workdir/samples")
44
48
  ln("#@amk_path/samples/default", "#@workdir/samples/default")
45
49
  ln("#@amk_path/samples/optimized", "#@workdir/samples/optimized")
@@ -62,7 +66,7 @@ module Ramekin
62
66
  File.write("#@workdir/Addmusic_sound effects.txt", '')
63
67
 
64
68
  Dir.chdir(@workdir) do
65
- system "./AddmusicK -norom ramekin/#{basename}.txt"
69
+ sys './AddmusicK', '-norom', '-visualize', "ramekin/#{basename}.txt"
66
70
  res = $?
67
71
  binding.pry unless res.success?
68
72
  end
@@ -73,6 +77,7 @@ module Ramekin
73
77
  FileUtils.cp(@filename, "./#{basename}.rmk")
74
78
  FileUtils.cp(spc_file, "./#{basename}.spc")
75
79
  FileUtils.cp(stats_file, "./#{basename}.stats.txt")
80
+ FileUtils.cp("#@workdir/Visualizations/#{basename}.png", "./#{basename}.png")
76
81
  File.write("./#{basename}.txt", @txt)
77
82
 
78
83
  FileUtils.mkdir_p("samples/#{basename}")
data/lib/ramekin/cli.rb CHANGED
@@ -139,7 +139,7 @@ module Ramekin
139
139
  # have a path to render the SPC file to.
140
140
  if @play || @wav_file
141
141
  if @output_package
142
- @play_spc = "#@output_package/#{File.basename(@infile)}.spc"
142
+ @play_spc = "#@output_package/#{File.basename(@infile, '.rmk')}.spc"
143
143
  elsif @output_spc
144
144
  @play_spc = @output_spc
145
145
  else
data/lib/ramekin/meta.rb CHANGED
@@ -282,7 +282,7 @@ module Ramekin
282
282
 
283
283
  def ext_gain
284
284
  gain = @extensions.select { |e| e.type == :gain }.last
285
- gain && gain.value
285
+ gain && to_hex(gain.value.to_i(16))
286
286
  end
287
287
 
288
288
  def gain
@@ -299,7 +299,13 @@ module Ramekin
299
299
  adsr1 = ((7 - d)*16 | 0x80) + (15 - a)
300
300
  adsr2 = (s*32 + (31-r))
301
301
 
302
- [adsr1.to_s(16), adsr2.to_s(16), g, t1, t2]
302
+ [to_hex(adsr1), to_hex(adsr2), g, t1, t2]
303
+ end
304
+
305
+ def to_hex(x)
306
+ return x if x.is_a?(String)
307
+
308
+ sprintf("%02x", x)
303
309
  end
304
310
 
305
311
  def to_amk
@@ -58,7 +58,7 @@ module Ramekin
58
58
 
59
59
  render_preamble(&b)
60
60
 
61
- @track.channels.each { |c| render_channel(c, &b) }
61
+ @track.channels.compact.each { |c| render_channel(c, &b) }
62
62
  end
63
63
 
64
64
  def render_preamble(&b)
@@ -113,7 +113,7 @@ module Ramekin
113
113
  def tempo_of(el)
114
114
  case el.type
115
115
  when :t then el.value
116
- when :bpm then (el.value.to_i * 256 / 625.0).round
116
+ when :bpm then (el.value.to_i * 8192 / 20025.0).round
117
117
  end
118
118
  end
119
119
 
@@ -188,11 +188,25 @@ module Ramekin
188
188
  end
189
189
  when :v
190
190
  vol, time = token.values.compact.map(&:to_i)
191
- yield velocity_command(vol, time)
191
+
192
+ unless Token === peek && [:v, :relv].include?(peek.type)
193
+ yield velocity_command(vol, time)
194
+ end
195
+
192
196
  @volume = vol
193
197
  when :relv
194
198
  relvol, duration = token.values
195
- yield velocity_command(@volume + relvol.to_i, duration)
199
+
200
+ unless Token === peek && [:v, :relv].include?(peek.type)
201
+ yield velocity_command(@volume + relvol.to_i, duration)
202
+ end
203
+ when :q
204
+ token.value =~ /(\d),?(\h)?/
205
+ qval = $1
206
+ gain = $2 || 'F'
207
+ yield "q#{qval}#{gain}"
208
+ when :w
209
+ yield "w#{token.value}"
196
210
  when :adsr
197
211
  vals = token.value.split(',').map { |x| x.to_i(16) }
198
212
  error! 'invalid #adsr, expected 4 arguments' unless vals.size == 4
@@ -257,7 +257,7 @@ module Ramekin
257
257
  return [:w, m(1)] if match /w(\d+)/
258
258
  return [:l, m(1)] if match /l(\d+)/
259
259
  return [:amp] if match /[&]/
260
- return [:q, m(1)] if match /q(\h\h)/
260
+ return [:q, m(1)] if match /q(\d(?:,\h)?)/
261
261
  return [:n, m(1)] if match /n(\h\h?)/
262
262
 
263
263
  error! "unknown token near: #{@scanner.peek(10)}", el: @last_token
data/lib/ramekin/util.rb CHANGED
@@ -44,11 +44,24 @@ module Ramekin
44
44
  env = {}
45
45
  kw.each { |k, v| env[k.to_s] = v }
46
46
 
47
+ $stderr.puts "run: #{a.map(&method(:shell_inspect)).join(' ')}"
47
48
  system(env, *a.map(&:to_s))
48
49
  rescue Interrupt
49
50
  # allow interrupt out of the subprocess but capture it for ramekin itself
50
51
  end
51
52
 
53
+ # for diagnostic purposes only, not a real escape system.
54
+ # our shellouts don't need escapes since they are not actually
55
+ # interpreted by a shell.
56
+ def shell_inspect(s)
57
+ s = s.to_s
58
+ if s =~ /[\s'"&*]/
59
+ s.inspect
60
+ else
61
+ s
62
+ end
63
+ end
64
+
52
65
  def executable?(path)
53
66
  stat = File.stat(path)
54
67
  stat.file? && stat.executable?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ramekin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - jneen
8
8
  autorequire:
9
9
  bindir: gembin
10
10
  cert_chain: []
11
- date: 2025-02-18 00:00:00.000000000 Z
11
+ date: 2025-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: strscan