musa-dsl 0.23.18 → 0.23.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/musa-dsl/repl/repl.rb +7 -0
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb +2 -2
- data/lib/musa-dsl/sequencer/base-sequencer.rb +9 -6
- data/lib/musa-dsl/transport/timer-clock.rb +8 -2
- data/lib/musa-dsl/transport/timer.rb +13 -6
- data/lib/musa-dsl.rb +1 -1
- data/musa-dsl.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e29d8270f71037a8b9463b9aeecb86a1b1e2387078ff31c0db4d9e2688d91a8a
|
4
|
+
data.tar.gz: 1c10fd8b4656376184274828d75fc32162ee45247fd9b660ecdd792ebbf0469b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c6257b0fe2142959b31e66be05c14ea98ec7754a962ebd047f414e1e694b4e8ccab6cfc284a55002951e6bdb93d807b14b4e513305d3da45b4ac692122111e5
|
7
|
+
data.tar.gz: ced439462deba1da30f80e3c1fd4e8a822583a89f6c48bf133fb47d08a3eb7c8d45cde012f640fb5bc43793db92a7d036572ad18bac313612b85a4058096d058
|
data/lib/musa-dsl/repl/repl.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'socket'
|
2
|
+
require 'pathname'
|
2
3
|
|
3
4
|
module Musa
|
4
5
|
module REPL
|
@@ -37,7 +38,13 @@ module Musa
|
|
37
38
|
|
38
39
|
line.chomp!
|
39
40
|
case line
|
41
|
+
when '#path'
|
42
|
+
buffer = StringIO.new
|
43
|
+
|
40
44
|
when '#begin'
|
45
|
+
user_path = buffer&.string
|
46
|
+
binder.receiver.instance_variable_set(:@user_pathname, Pathname.new(user_path)) if user_path
|
47
|
+
|
41
48
|
buffer = StringIO.new
|
42
49
|
|
43
50
|
when '#end'
|
@@ -4,7 +4,7 @@ module Musa::Sequencer
|
|
4
4
|
class BaseSequencer
|
5
5
|
using Musa::Extension::InspectNice
|
6
6
|
|
7
|
-
private def _play_timed(timed_serie, control, &block)
|
7
|
+
private def _play_timed(timed_serie, start_position, control, &block)
|
8
8
|
|
9
9
|
if first_value_sample = timed_serie.peek_next_value
|
10
10
|
debug "_play_timed: first_value_sample #{first_value_sample}"
|
@@ -25,7 +25,7 @@ module Musa::Sequencer
|
|
25
25
|
binder = Musa::Extension::SmartProcBinder::SmartProcBinder.new(block)
|
26
26
|
|
27
27
|
_play_timed_step(hash_mode, component_ids, extra_attribute_names, timed_serie,
|
28
|
-
|
28
|
+
start_position, last_positions, binder, control)
|
29
29
|
end
|
30
30
|
|
31
31
|
private def _play_timed_step(hash_mode,
|
@@ -21,9 +21,9 @@ module Musa
|
|
21
21
|
logger: nil,
|
22
22
|
do_log: nil, do_error_log: nil, log_position_format: nil)
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
unless beats_per_bar && ticks_per_beat || beats_per_bar.nil? && ticks_per_beat.nil?
|
25
|
+
raise ArgumentError, "'beats_per_bar' and 'ticks_per_beat' parameters should be both nil or both have values"
|
26
|
+
end
|
27
27
|
|
28
28
|
if logger
|
29
29
|
@logger = logger
|
@@ -39,9 +39,9 @@ module Musa
|
|
39
39
|
@beats_per_bar = Rational(beats_per_bar)
|
40
40
|
@ticks_per_beat = Rational(ticks_per_beat)
|
41
41
|
|
42
|
-
|
42
|
+
singleton_class.include TickBasedTiming
|
43
43
|
else
|
44
|
-
|
44
|
+
singleton_class.include TicklessBasedTiming
|
45
45
|
end
|
46
46
|
|
47
47
|
_init_timing
|
@@ -215,10 +215,13 @@ module Musa
|
|
215
215
|
end
|
216
216
|
|
217
217
|
def play_timed(timed_serie,
|
218
|
+
at: nil,
|
218
219
|
on_stop: nil,
|
219
220
|
after_bars: nil, after: nil,
|
220
221
|
&block)
|
221
222
|
|
223
|
+
at ||= position
|
224
|
+
|
222
225
|
control = PlayTimedControl.new(@event_handlers.last,
|
223
226
|
on_stop: on_stop, after_bars: after_bars, after: after)
|
224
227
|
|
@@ -230,7 +233,7 @@ module Musa
|
|
230
233
|
|
231
234
|
@event_handlers.push control
|
232
235
|
|
233
|
-
_play_timed(timed_serie.instance, control, &block)
|
236
|
+
_play_timed(timed_serie.instance, at, control, &block)
|
234
237
|
|
235
238
|
@event_handlers.pop
|
236
239
|
|
@@ -3,7 +3,7 @@ require_relative 'clock'
|
|
3
3
|
module Musa
|
4
4
|
module Clock
|
5
5
|
class TimerClock < Clock
|
6
|
-
def initialize(period = nil, ticks_per_beat: nil, bpm: nil, correction: nil, logger: nil, do_log: nil)
|
6
|
+
def initialize(period = nil, ticks_per_beat: nil, bpm: nil, correction: nil, delayed_ticks_error: nil, logger: nil, do_log: nil)
|
7
7
|
do_log ||= false
|
8
8
|
|
9
9
|
super()
|
@@ -20,6 +20,7 @@ module Musa
|
|
20
20
|
@started = false
|
21
21
|
@paused = false
|
22
22
|
|
23
|
+
@delayed_ticks_error = delayed_ticks_error
|
23
24
|
@logger = logger
|
24
25
|
@do_log = do_log
|
25
26
|
end
|
@@ -56,7 +57,12 @@ module Musa
|
|
56
57
|
@run = true
|
57
58
|
|
58
59
|
while @run
|
59
|
-
@timer = Timer.new(@period,
|
60
|
+
@timer = Timer.new(@period,
|
61
|
+
correction: @correction,
|
62
|
+
stop: true,
|
63
|
+
delayed_ticks_error: @delayed_ticks_error,
|
64
|
+
logger: @logger,
|
65
|
+
do_log: @do_log)
|
60
66
|
|
61
67
|
@timer.run do
|
62
68
|
yield if block_given?
|
@@ -3,10 +3,12 @@ module Musa
|
|
3
3
|
class Timer
|
4
4
|
attr_accessor :period
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@period =
|
6
|
+
def initialize(tick_period_in_seconds, correction: nil, stop: nil, delayed_ticks_error: nil, logger: nil, do_log: nil)
|
7
|
+
@period = tick_period_in_seconds.rationalize
|
8
8
|
@correction = (correction || 0r).rationalize
|
9
9
|
@stop = stop || false
|
10
|
+
|
11
|
+
@delayed_ticks_error = delayed_ticks_error || 1.0
|
10
12
|
@logger = logger
|
11
13
|
@do_log = do_log
|
12
14
|
end
|
@@ -21,10 +23,15 @@ module Musa
|
|
21
23
|
yield
|
22
24
|
|
23
25
|
@next_moment += @period
|
24
|
-
to_sleep = (@next_moment
|
25
|
-
|
26
|
-
if @do_log && to_sleep.negative?
|
27
|
-
|
26
|
+
to_sleep = (@next_moment + @correction) - Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
27
|
+
|
28
|
+
if @do_log && to_sleep.negative? & @logger
|
29
|
+
tick_errors = -to_sleep / @period
|
30
|
+
if tick_errors >= @delayed_ticks_error
|
31
|
+
@logger.error "Timer delayed #{tick_errors.round(2)} ticks (#{-to_sleep.round(3)}s)"
|
32
|
+
else
|
33
|
+
@logger.warn "Timer delayed #{tick_errors.round(2)} ticks (#{-to_sleep.round(3)}s)"
|
34
|
+
end
|
28
35
|
end
|
29
36
|
|
30
37
|
sleep to_sleep if to_sleep > 0.0
|
data/lib/musa-dsl.rb
CHANGED
data/musa-dsl.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'musa-dsl'
|
3
|
-
s.version = '0.23.
|
4
|
-
s.date = '2021-
|
3
|
+
s.version = '0.23.22'
|
4
|
+
s.date = '2021-10-26'
|
5
5
|
s.summary = 'A simple Ruby DSL for making complex music'
|
6
6
|
s.description = 'Musa-DSL: A Ruby framework and DSL for algorithmic sound and musical thinking and composition'
|
7
7
|
s.authors = ['Javier Sánchez Yeste']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: musa-dsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.23.
|
4
|
+
version: 0.23.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Sánchez Yeste
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: citrus
|