musa-dsl 0.42.0 → 0.42.1
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 613cf84af52f6eb5dcfd399b94417f1e175242f32f8dc7cb2ab6452ebb58e9d0
|
|
4
|
+
data.tar.gz: 2a19dc6002ab89ae77f973d8a4405de380e73230bbd3f986d240071f654d505d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e61a579a8c116af3e420ec7c98756734a7b00252981a8b42a2fe8472fd18bea679793fa879ab2dc1e279558472b55ba55bcdd7d1cab5889bf39af204db3b461f
|
|
7
|
+
data.tar.gz: b1678d001558905ed9939580849e48e8ef5a79c3d3131959e46f0d2c4505c77b1030c91bc6c156cc650b1e42bd1b7d32d978bc730fb14e576b8b29a0e0b552d5
|
|
@@ -88,6 +88,20 @@ end
|
|
|
88
88
|
transport.start
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
+
## Times and durations
|
|
92
|
+
|
|
93
|
+
The Sequencer internally encodes time using `Rational`. It is preferable to use Rational values (`1/2r`, `1r`, `3/4r`) instead of Float (`0.5`, `1.0`, `0.75`) for times and durations, as this avoids potential precision issues in the internal conversion.
|
|
94
|
+
|
|
95
|
+
```ruby
|
|
96
|
+
# Preferable
|
|
97
|
+
at 1/2r do ... end
|
|
98
|
+
wait 3/4r do ... end
|
|
99
|
+
every 1/4r do ... end
|
|
100
|
+
|
|
101
|
+
# Works but may cause imprecision
|
|
102
|
+
at 0.5 do ... end
|
|
103
|
+
```
|
|
104
|
+
|
|
91
105
|
## API Reference
|
|
92
106
|
|
|
93
107
|
**Complete API documentation:**
|
|
@@ -21,8 +21,6 @@ module Musa::Sequencer
|
|
|
21
21
|
private def _play_timed(timed_serie, start_position, control, &block)
|
|
22
22
|
|
|
23
23
|
if first_value_sample = timed_serie.peek_next_value
|
|
24
|
-
debug "_play_timed: first_value_sample #{first_value_sample}"
|
|
25
|
-
|
|
26
24
|
hash_mode = first_value_sample[:value].is_a?(Hash)
|
|
27
25
|
|
|
28
26
|
if hash_mode
|
|
@@ -43,6 +43,12 @@ module Musa
|
|
|
43
43
|
# - Time signature-based composition (4/4, 3/4, etc.)
|
|
44
44
|
# - Tick-precise event scheduling
|
|
45
45
|
#
|
|
46
|
+
# ## Rational vs Float
|
|
47
|
+
#
|
|
48
|
+
# The sequencer internally encodes time as Rational. It is preferable to use
|
|
49
|
+
# Rational values for positions and durations, as using Float may cause
|
|
50
|
+
# precision issues in the conversion.
|
|
51
|
+
#
|
|
46
52
|
# @example Creating tick-based sequencer (4/4, 96 ticks per beat)
|
|
47
53
|
# sequencer = BaseSequencer.new(4, 96) # 4 beats, 96 ticks/beat
|
|
48
54
|
# sequencer.ticks_per_bar # => 384r
|
|
@@ -202,19 +208,18 @@ module Musa
|
|
|
202
208
|
ticks_position = position / @tick_duration
|
|
203
209
|
|
|
204
210
|
if ticks_position.round != ticks_position
|
|
205
|
-
original_position = position
|
|
206
|
-
position = ticks_position.round * @tick_duration
|
|
207
|
-
|
|
208
211
|
if warn
|
|
209
212
|
@logger.warn('BaseSequencer') do
|
|
210
213
|
'_check_position: rounding ' \
|
|
211
|
-
"position #{
|
|
212
|
-
"to tick precision: #{
|
|
214
|
+
"position #{position.inspect} (#{position.to_f.round(5)}) "\
|
|
215
|
+
"to tick precision: #{(ticks_position.round * @tick_duration).inspect} (#{(ticks_position.round * @tick_duration).to_f.round(5)})"
|
|
213
216
|
end
|
|
214
217
|
end
|
|
215
218
|
end
|
|
216
219
|
|
|
217
|
-
|
|
220
|
+
# Always convert to Rational to ensure consistent hash key types
|
|
221
|
+
# (Float keys like 1.5 would not match Rational keys like 3/2r in timeslots hash)
|
|
222
|
+
ticks_position.round * @tick_duration
|
|
218
223
|
end
|
|
219
224
|
|
|
220
225
|
# Holds tick accumulation during fast-forward.
|
data/lib/musa-dsl/version.rb
CHANGED