ramekin 0.2.4 → 0.2.5

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: a249d3680d6f96fe57c566445a3add42d0287de30bd86a556131963b58b239b8
4
- data.tar.gz: df8ab404da547bd42b68fee9ef45d3eeed5c1c46201c997dea2a04cb65a8e0aa
3
+ metadata.gz: 95057d0af759892ede884da43667ad0fc05366451bb8416a696bec369e6fb2a0
4
+ data.tar.gz: 66263b7127f80e3103c23b836a5587b02a390c682a194552a5fe5350b79b72af
5
5
  SHA512:
6
- metadata.gz: 3001f9832d107a892137de8e811c842d972ad226de761e2cd033b79845d455988de28e328c55d14c78215c61a6adb5d11b3819ca35682e66a3c3b9bb0593961c
7
- data.tar.gz: b52c6b301948c3400d7c0c7db3cdc4f3da93e1827a352cd927d5fa8c7bf06d06aee67e70b21392002262fee92ede83cef2cbdd69dbf4c11d84ecb55af5e890f1
6
+ metadata.gz: 5472514c2ae5edf9a979e7b251f188518b4095a1cea88052e44c7e11fe42912ef6349c4e797b07e09b608772f4d73d91aa8d767807e55da5efb2450c0a40f1f7
7
+ data.tar.gz: 9d2f76c65d0091998970069dc49b8632d3b73c5256334a888cef06a003e5d6a39eb88d5b54bebbc0fe2e0a7a4acd9cceafdc7d76d5f2aaf56e0604073a45c921
data/README.md CHANGED
@@ -143,7 +143,7 @@ b8 #bend >>c16^16 ^^4
143
143
 
144
144
  * Tempo can alternately be declared with `#bpm:128`. This will be converted to the nearest `tXX` command. If the tempo is over `t60` (`#bpm:146`), the tempo and all note and event lengths will be halved automatically. This is similar to `#halvetempo` except that it is done automatically.
145
145
  * `p0,0` compiles to `$df`.
146
- * "Legato tie" represented by `~`, which will use `$f4$01` at appropriate times to cause the note transition to be played legato.
146
+ * "Legato tie" represented by `~`, which will use `$f4$01` at appropriate times to cause the note transition to be played legato. `#legato/toggle` can be used for a raw `$f4$01`, and `#sustain/global-toggle` for `$f4$02`.
147
147
  * If you ever want to see what exactly Ramekin is generating, just use `--txt` and you can inspect the generated AddmusicK syntax manually!
148
148
 
149
149
  # Syntax
@@ -376,6 +376,20 @@ yL2 ; tasteful pan left
376
376
  yl10 ; maximum pan left
377
377
  ```
378
378
 
379
+ #### Legato and quantization
380
+
381
+ To play notes in sequence without re-starting the note from the beginning, you can use a "legato tie", represented by `~`:
382
+
383
+ ```elisp
384
+ a4~b4~>c4
385
+ ```
386
+
387
+ This works by inserting AddmusicK's "legato toggle" command at appropriate times. To insert this toggle manually, use `#legato/toggle` - but be careful of using this command inside loops, as it can sometimes be ignored by AddmusicK, leaving you with settings that leave the toggle in an inconsistent state. Legato ties should always be safe inside loops.
388
+
389
+ To activate "sustain" mode, where notes are rekeyed but there is far less space between notes, use `#sustain/global-toggle`. AddmusicK will apply this setting to *all* channels at once. Again, this is a toggle, so be careful of activating this more than once unintentionally.
390
+
391
+ To activate staccato for a channel, you can change the "quantization" (i.e. how long notes hold compared to their length) with `qX`, where X is a number 0-7. `q7` results in the longest held notes, and q0 in the shortest. If you've used `qXY` in AddmusicK to modify GAIN before, note that Ramekin's syntax requires a comma for parsing consistency: `qX,Y`.
392
+
379
393
  ## Hex
380
394
 
381
395
  For those who want to use AddmusicK features that are not currently supported by Ramekin, Ramekin still supports manual entry of hex values with `$XX`. While these can be made slightly easier to use with macros, I would very much appreciate it if you could open an issue here or contact me via SMWC or Discord if you find you are using these heavily.
@@ -69,11 +69,16 @@ module Ramekin
69
69
  ___
70
70
  File.write("#@workdir/Addmusic_sound effects.txt", '')
71
71
 
72
- Dir.chdir(@workdir) do
72
+ res = Dir.chdir(@workdir) do
73
73
  sys './AddmusicK', '-norom', '-visualize', "ramekin/#{basename}.txt"
74
- res = $?
75
- binding.pry unless res.success?
74
+ $?
76
75
  end
76
+
77
+ unless res && res.success?
78
+ binding.pry if ENV['RAMEKIN_DEBUG'] == '1'
79
+ end
80
+
81
+ return res
77
82
  end
78
83
 
79
84
  def export(outdir)
data/lib/ramekin/bends.rb CHANGED
@@ -111,6 +111,8 @@ module Ramekin
111
111
 
112
112
  out = StringIO.new
113
113
 
114
+ leftover = @notes.last.ticks / divisor
115
+
114
116
  (0...@notes.length-1).each do |i|
115
117
  note = @notes[i]
116
118
  to_note = @notes[i+1]
@@ -125,16 +127,28 @@ module Ramekin
125
127
  out << '^'
126
128
  end
127
129
 
128
- ticks = note.ticks / divisor
130
+ bend_ticks = note.ticks / divisor
131
+ note_ticks = bend_ticks
132
+
133
+ # If we're at the last bend in the sequence, we can try to
134
+ # combine the bend with the length of the last note, if it's
135
+ # not too long, saving a tie and therefore a byte. This will
136
+ # only work if the combined length is < 0x60, since technically
137
+ # we are stretching the bend across the final two notes, but
138
+ # with a shorter tick time
139
+ if i == @notes.length-2 && ticks + leftover < 96
140
+ note_ticks += leftover
141
+ leftover = 0
142
+ end
129
143
 
130
144
  # always use tick count notation here because
131
145
  # amk can insert ties in some cases which will break $dd
132
- out << "=#{ticks}"
133
- out << dd(ticks, to_note, octave)
146
+ out << "=#{note_ticks}"
147
+ out << dd(bend_ticks, to_note, octave)
134
148
  out << '$f4$01' if @end_legato && i == 0
135
149
  end
136
150
 
137
- out << "^#{@notes.last.length_amk(divisor)}" if @notes.last.ticks > 0
151
+ out << "^#{Util.nice_length_amk(leftover)}" if leftover > 0
138
152
  out.string
139
153
  end
140
154
 
data/lib/ramekin/cli.rb CHANGED
@@ -238,7 +238,11 @@ module Ramekin
238
238
 
239
239
  if @output_spc || @output_package
240
240
  runner = AMKRunner.new(@infile, channels.meta, txt)
241
- runner.compile
241
+ result = runner.compile
242
+ unless result && result.success?
243
+ $stderr.puts "AddmusicK did not exit successfully."
244
+ exit result&.to_i || 1
245
+ end
242
246
  end
243
247
 
244
248
  FileUtils.cp(runner.spc_file, @output_spc) if @output_spc
@@ -56,7 +56,7 @@ module Ramekin
56
56
 
57
57
  post_ticks /= divisor
58
58
 
59
- post_len = KNOWN_LENGTHS.fetch(post_ticks) { "=#{post_ticks}" }
59
+ post_len = Util.nice_length_amk(post_ticks)
60
60
  "#{octave_amk(current_octave)}#{note_name}=1$f4$01^#{post_len}"
61
61
  end
62
62
 
@@ -46,21 +46,6 @@ module Ramekin
46
46
  @note.type == :native_tie
47
47
  end
48
48
 
49
- KNOWN_LENGTHS = {}.tap do |out|
50
- ticks = 192
51
- length = 1
52
-
53
- loop do
54
- out[ticks] = length.to_s
55
-
56
- break unless ticks % 2 == 0
57
-
58
- out[ticks * 3 / 2] = "#{length}."
59
- length *= 2
60
- ticks /= 2
61
- end
62
- end
63
-
64
49
  def length_amk(div)
65
50
  return '=0' if ticks == 0
66
51
 
@@ -70,9 +55,8 @@ module Ramekin
70
55
  end
71
56
 
72
57
  t = ticks / div
73
- # we use l16
74
- return '' if t == 12
75
- KNOWN_LENGTHS.fetch(t) { "=#{t}" }
58
+
59
+ tie? ? Util.nice_length_amk(t) : Util.extra_nice_length_amk(t)
76
60
  end
77
61
 
78
62
  NOTES = { 'c' => 0, 'd' => 2, 'e' => 4, 'f' => 5, 'g' => 7, 'a' => 9, 'b' => 11 }
@@ -57,8 +57,14 @@ module Ramekin
57
57
  yield "; generated from #{@filename} by Ramekin\n"
58
58
  yield "; https://codeberg.org/jneen/ramekin\n\n"
59
59
 
60
- # TODO
61
- yield "#amk #{@track.meta.amk&.value || 4}\n\n"
60
+ amk = @track.meta.amk&.value || 4
61
+ yield "#amk #{amk}\n"
62
+
63
+ if amk.to_i >= 4
64
+ yield "#option amk109hotpatch\n"
65
+ end
66
+
67
+ yield "\n"
62
68
 
63
69
  if m.instruments.any?
64
70
  yield "#path #{(m.sample_path || @filename.chomp('.rmk')).inspect}\n"
@@ -286,8 +292,10 @@ module Ramekin
286
292
  case token.value
287
293
  when 'SPC'
288
294
  # pass
289
- when 'legato'
295
+ when 'legato', 'legato/toggle'
290
296
  yield '$f4$01'
297
+ when 'sustain/global-toggle'
298
+ yield '$f4$02'
291
299
  when 'echo/toggle'
292
300
  yield '$f4$03'
293
301
  else
data/lib/ramekin/util.rb CHANGED
@@ -4,6 +4,31 @@ module Ramekin
4
4
  module Util
5
5
  extend self
6
6
 
7
+ KNOWN_LENGTHS = {}.tap do |out|
8
+ ticks = 192
9
+ length = 1
10
+
11
+ loop do
12
+ out[ticks] = length.to_s
13
+
14
+ break unless ticks % 2 == 0
15
+
16
+ out[ticks * 3 / 2] = "#{length}."
17
+ length *= 2
18
+ ticks /= 2
19
+ end
20
+ end
21
+
22
+ def extra_nice_length_amk(ticks)
23
+ # output uses l16
24
+ return '' if ticks == 12
25
+ nice_length_amk(ticks)
26
+ end
27
+
28
+ def nice_length_amk(ticks)
29
+ KNOWN_LENGTHS.fetch(ticks) { "=#{ticks}" }
30
+ end
31
+
7
32
  private
8
33
  def clear_dir(dir, force: false, remake: true)
9
34
  if Dir.exist?(dir) && !Dir.empty?(dir)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ramekin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - jneen
8
8
  bindir: gembin
9
9
  cert_chain: []
10
- date: 2025-03-08 00:00:00.000000000 Z
10
+ date: 2025-03-12 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: strscan