musa-dsl 0.23.15 → 0.23.19
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/series/quantizer-serie.rb +10 -7
- data/lib/musa-dsl/transport/timer-clock.rb +9 -2
- data/lib/musa-dsl/transport/timer.rb +16 -3
- 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: 69d8893b895c8b836a51be4f7fc7b51fbab501383c6e3780d0af52e82f1bb324
|
4
|
+
data.tar.gz: 017f7f8a8fb2cd5b3104d6c1f5c5acd535ea3db4c4285d15f1c81fe792cf123c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 681651cd39523a69d2cbe3fe7271b79ab6f8c0d616cabd8f7d9ef4e0af8f8bbaaed39d41977c35900a748057af8a274b5672762340b98537b9f1d2cba7c5b401
|
7
|
+
data.tar.gz: 29cc0e37bf4f3513d78e32776c9df7a6a622c913a965f7bef8944bd0961ef7f8e23bfc348dbbe9eb7d18a211e224f6f27acc95210340bbad05aacde0d34f5404
|
@@ -468,16 +468,19 @@ module Musa
|
|
468
468
|
private def next_crossings
|
469
469
|
from_time, from_value = get_time_value(@source.next_value)
|
470
470
|
|
471
|
-
|
472
|
-
raise 'time only can go forward' if @last_time && from_time <= @last_time
|
471
|
+
return unless from_time && from_value
|
473
472
|
|
474
|
-
|
473
|
+
if @last_time && from_time < @last_time
|
474
|
+
raise "time only can go forward: last time = #{@last_time} (#{@last_time.to_f}) but " \
|
475
|
+
"from_time = #{from_time} (#{from_time.to_f}) (expected last_time to be < from_time) "
|
476
|
+
end
|
475
477
|
|
476
|
-
|
478
|
+
@last_time = from_time
|
477
479
|
|
478
|
-
|
479
|
-
|
480
|
-
|
480
|
+
to_time, to_value = get_time_value(@source.peek_next_value)
|
481
|
+
|
482
|
+
if to_time && to_value
|
483
|
+
crossings(from_time, from_value, to_time, to_value)
|
481
484
|
end
|
482
485
|
end
|
483
486
|
|
@@ -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, 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,8 @@ module Musa
|
|
20
20
|
@started = false
|
21
21
|
@paused = false
|
22
22
|
|
23
|
+
@delayed_ticks_error = delayed_ticks_error
|
24
|
+
@logger = logger
|
23
25
|
@do_log = do_log
|
24
26
|
end
|
25
27
|
|
@@ -55,7 +57,12 @@ module Musa
|
|
55
57
|
@run = true
|
56
58
|
|
57
59
|
while @run
|
58
|
-
@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)
|
59
66
|
|
60
67
|
@timer.run do
|
61
68
|
yield if block_given?
|
@@ -3,10 +3,14 @@ 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
|
12
|
+
@logger = logger
|
13
|
+
@do_log = do_log
|
10
14
|
end
|
11
15
|
|
12
16
|
def run
|
@@ -19,7 +23,16 @@ module Musa
|
|
19
23
|
yield
|
20
24
|
|
21
25
|
@next_moment += @period
|
22
|
-
to_sleep = (@next_moment
|
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}s)"
|
32
|
+
else
|
33
|
+
@logger.warn "Timer delayed #{tick_errors.round(2)} ticks (#{-to_sleep}s)"
|
34
|
+
end
|
35
|
+
end
|
23
36
|
|
24
37
|
sleep to_sleep if to_sleep > 0.0
|
25
38
|
end
|
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-09-
|
3
|
+
s.version = '0.23.19'
|
4
|
+
s.date = '2021-09-28'
|
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.19
|
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-09-
|
11
|
+
date: 2021-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: citrus
|