ramekin 0.1.2 → 0.1.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
  SHA256:
3
- metadata.gz: f693295d87c86072d5d220f3a9cfed4b8a19aa5ae1bcfc468c4554eb89063945
4
- data.tar.gz: 5d4890321e9f3d49ce4487e0539babe104bb03a1719ecf641040d22eadc7ba2a
3
+ metadata.gz: 05452ce105a35c32216d5236506aaddbe28564e7645a8f3aa53c517eaedc44db
4
+ data.tar.gz: a65a65ac28b44078bf626a141ec6ecc9b3a725b65d562f957d6c67fee2a57d0d
5
5
  SHA512:
6
- metadata.gz: 530beedb41422b51818f44445802ff95ba1b23c73f43e24b1d44c563bbe4479c46ac55c3a6c26ee722e1dd4e555ef61bd66f501380853085cd766734117b919b
7
- data.tar.gz: 45a1589c63119cef6fc062feff81afe66445356974260953bbb8adb79a25e570329afecaf695b6b4781bbce9b067b25d4d85c5c7d9fc257262a44e4d9c77c86b
6
+ metadata.gz: 050f82c12f9f39d82b224cbab93244913b21cde8f08cdfe4ecd389dd6c1a97348fc9066978cce076935bcaa44f027263070461f6dd9ac12df1a8030047f888c5
7
+ data.tar.gz: a9cad79a5b20128fa0d2d8a3838af346a9c01d43635a984c2ae25ce907f0a74e1907a5ba0fe057e724e7eb7aea34ba1c6e04ee521ceb03f31898ce8d015b0477
@@ -49,7 +49,7 @@ module Ramekin
49
49
  ln("#@amk_path/samples/optimized", "#@workdir/samples/optimized")
50
50
  ln("#@amk_path/samples/EMPTY.brr", "#@workdir/samples/EMPTY.brr")
51
51
  if @meta.instruments.any?
52
- sample_dir = "#@workdir/samples/#{basename}"
52
+ sample_dir = "#@workdir/samples/#{@meta.sample_path || basename}"
53
53
  FileUtils.mkdir_p(sample_dir)
54
54
 
55
55
  @meta.instruments.each do |inst|
@@ -80,9 +80,11 @@ module Ramekin
80
80
  FileUtils.cp("#@workdir/Visualizations/#{basename}.png", "./#{basename}.png")
81
81
  File.write("./#{basename}.txt", @txt)
82
82
 
83
- FileUtils.mkdir_p("samples/#{basename}")
84
- @meta.instruments.each do |inst|
85
- FileUtils.cp(inst.sample_path, "./samples/#{basename}/#{inst.sample_name}")
83
+ if @meta.instruments.any?
84
+ FileUtils.mkdir_p("samples/#{basename}")
85
+ @meta.instruments.each do |inst|
86
+ FileUtils.cp(inst.sample_path, "./samples/#{basename}/#{inst.sample_name}")
87
+ end
86
88
  end
87
89
 
88
90
  packs = @meta.instruments.map(&:pack).uniq
@@ -1,11 +1,12 @@
1
1
  module Ramekin
2
2
  class ChannelSeparator
3
- def self.parse(stream)
4
- new.tap { |x| x.parse(stream) }
3
+ def self.parse(stream, *a)
4
+ new(*a).tap { |x| x.parse(stream) }
5
5
  end
6
6
 
7
7
  attr_reader :preamble, :channels, :meta
8
- def initialize
8
+ def initialize(sample_path=nil)
9
+ @sample_path = sample_path
9
10
  @preamble = []
10
11
  @channels = []
11
12
 
@@ -19,7 +20,7 @@ module Ramekin
19
20
  def parse(stream)
20
21
  stream.each do |el|
21
22
  if Token === el && el.type == :channel
22
- @meta = Meta.new(@preamble.dup).tap(&:parse) if preamble?
23
+ @meta = Meta.new(@preamble.dup, @sample_path).tap(&:parse) if preamble?
23
24
  @meta.parse
24
25
 
25
26
  @current = (@channels[el.value.to_i] ||= [])
data/lib/ramekin/cli.rb CHANGED
@@ -106,6 +106,8 @@ module Ramekin
106
106
  when '--help', '-help', '-h', '-?'
107
107
  usage
108
108
  return 0
109
+ when '--sample-path'
110
+ @sample_path = argv.shift or usage! 'missing path for --sample-path'
109
111
  when '--txt'
110
112
  @output_txt = argv.shift or usage! 'missing filename after --txt'
111
113
  when '--spc'
@@ -169,7 +171,7 @@ module Ramekin
169
171
 
170
172
  expanded = outer_chain.call(tokens)
171
173
 
172
- channels = ChannelSeparator.parse(expanded)
174
+ channels = ChannelSeparator.parse(expanded, @sample_path)
173
175
 
174
176
  inner_chain = Processor.compose(
175
177
  NoteAggregator,
@@ -29,13 +29,19 @@ module Ramekin
29
29
 
30
30
  class LegatoLastNote < NoteWrapper
31
31
  def ticks
32
- @note.ticks / 2
32
+ @note.ticks
33
33
  end
34
34
 
35
35
  def to_amk(current_octave=nil, divisor=1)
36
- post_ticks = @note.ticks - ticks
36
+ post_ticks = @note.ticks - divisor
37
+ if post_ticks <= 0 || post_ticks % divisor != 0
38
+ return error! "too fast for legato: must have at least #{divisor*2} ticks at this bpm.", el: self
39
+ end
40
+
41
+ post_ticks /= divisor
42
+
37
43
  post_len = KNOWN_LENGTHS.fetch(post_ticks) { "=#{post_ticks}" }
38
- "#{octave_amk(current_octave)}#{note_name}#{length_amk(divisor)}$f4$01^#{post_len}"
44
+ "#{octave_amk(current_octave)}#{note_name}=1$f4$01^#{post_len}"
39
45
  end
40
46
 
41
47
  def inspect
data/lib/ramekin/meta.rb CHANGED
@@ -14,10 +14,12 @@ module Ramekin
14
14
  attr_reader :volume
15
15
  attr_reader :tempo
16
16
  attr_reader :echo
17
- def initialize(elements)
17
+ attr_reader :sample_path
18
+ def initialize(elements, sample_path=nil)
18
19
  @elements = elements
19
20
  @instruments = []
20
21
  @sample_groups = []
22
+ @sample_path = sample_path
21
23
  @options = {}
22
24
  end
23
25
 
@@ -76,9 +78,13 @@ module Ramekin
76
78
  end
77
79
  end
78
80
 
81
+ def done?
82
+ @elements.empty? && @peek.nil?
83
+ end
84
+
79
85
  def parse
80
86
  loop do
81
- break if @elements.empty?
87
+ break if done?
82
88
  next!
83
89
 
84
90
  case @current.type
@@ -86,7 +92,8 @@ module Ramekin
86
92
  when :amk then @amk = @current
87
93
  when :option then @options[@current.value] = true
88
94
  when :w then @volume = @current
89
- when :t, :bpm then @tempo = @current; @t_with_divisor = nil
95
+ when :t, :bpm then
96
+ @tempo = @current; @t_with_divisor = nil
90
97
  else
91
98
  error! 'invalid token in header'
92
99
  end
@@ -298,7 +305,7 @@ module Ramekin
298
305
 
299
306
  def pack_hexes
300
307
  # TODO: alts
301
- @pack_hexes ||= @pack.tunings_for(sample_name).first
308
+ @pack_hexes ||= @pack.tunings_for(@path.value).first
302
309
  end
303
310
 
304
311
  def pack_gain
@@ -99,15 +99,13 @@ module Ramekin
99
99
  end
100
100
 
101
101
  def ticks
102
- if @extensions.empty? && default_length.nil?
103
- return 192 / 16
104
- end
105
-
106
102
  exts = @extensions
107
- exts = [default_length] if exts.empty?
103
+ default = default_length&.value || '16'
104
+ exts = [default] if exts.empty?
108
105
 
109
106
  base = exts.map do |ext|
110
107
  ext = ext.value if Token === ext
108
+ ext ||= default
111
109
 
112
110
  case ext
113
111
  when /\A=(\d+)\z/ then $1.to_i
@@ -77,7 +77,7 @@ module Ramekin
77
77
  yield "#amk #{@track.meta.amk&.value || 2}\n\n"
78
78
 
79
79
  if m.instruments.any?
80
- yield "#path #{@filename.chomp('.rmk').inspect}\n"
80
+ yield "#path #{(m.sample_path || @filename.chomp('.rmk')).inspect}\n"
81
81
  yield "#samples {\n"
82
82
  if m.sample_groups.empty?
83
83
  yield " #default"
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.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - jneen
8
8
  autorequire:
9
9
  bindir: gembin
10
10
  cert_chain: []
11
- date: 2025-03-02 00:00:00.000000000 Z
11
+ date: 2025-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: strscan