ramekin 0.1.2 → 0.1.3

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: 71e89ff9027d3342649de107de02ed46c622a95a9940fe94bb0ece781ac18790
4
+ data.tar.gz: 1d3b3a89ab873ab15e55a000912791ee7c232a53d462377803fdd8f9ef80e4e8
5
5
  SHA512:
6
- metadata.gz: 530beedb41422b51818f44445802ff95ba1b23c73f43e24b1d44c563bbe4479c46ac55c3a6c26ee722e1dd4e555ef61bd66f501380853085cd766734117b919b
7
- data.tar.gz: 45a1589c63119cef6fc062feff81afe66445356974260953bbb8adb79a25e570329afecaf695b6b4781bbce9b067b25d4d85c5c7d9fc257262a44e4d9c77c86b
6
+ metadata.gz: e716543bbac8f7ae0fa72e5504fd3fad883b283b4adc3085f0de7bb5220bf1533dac433af06527d949a8acdb46a25beffa20334cf72bbb208ff2d2408a225fd1
7
+ data.tar.gz: 1cc81d357db65d9be8e5f54677ff3117c336656e1ee40ee53183b49f7ceee9c483d05cafdd190bc783dcc65d687af098f80ee7e54378c6c48eb2d62ebbbc64b7
@@ -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
 
@@ -298,7 +300,7 @@ module Ramekin
298
300
 
299
301
  def pack_hexes
300
302
  # TODO: alts
301
- @pack_hexes ||= @pack.tunings_for(sample_name).first
303
+ @pack_hexes ||= @pack.tunings_for(@path.value).first
302
304
  end
303
305
 
304
306
  def pack_gain
@@ -57,15 +57,19 @@ module Ramekin
57
57
  end
58
58
  end
59
59
 
60
- def length_amk(div)
61
- if ticks % div != 0
60
+ def check_length!(t, div)
61
+ if t % div != 0
62
62
  divisible = div == 2 ? 'even' : "divisible by #{div}"
63
63
  error!("too fast! tick count must be #{divisible} at this tempo", el: self)
64
64
  end
65
+ end
66
+
67
+ def length_amk(div)
68
+ check_length!(ticks, div)
65
69
 
66
70
  t = ticks / div
67
71
  # we use l16
68
- return '' if t == 12
72
+ # return '' if t == 12
69
73
  KNOWN_LENGTHS.fetch(t) { "=#{t}" }
70
74
  end
71
75
 
@@ -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"
@@ -297,13 +297,7 @@ module Ramekin
297
297
 
298
298
  ticks = sprintf("%02x", note.ticks)
299
299
  yield "$dd$#{ticks}$#{ticks}#{note.octave_amk}#{note.note.value}"
300
-
301
- case peek
302
- when NoteEvent
303
- peek.extensions.concat(note.extensions)
304
- else
305
- yield "^=#{note.ticks}"
306
- end
300
+ yield "^=#{note.ticks}"
307
301
 
308
302
  @octave = note.octave
309
303
  when 'legato'
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.3
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-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: strscan