musa-dsl 0.21.3 → 0.21.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 +4 -4
- data/lib/musa-dsl/repl/repl.rb +4 -8
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-play-helper.rb +1 -1
- data/lib/musa-dsl/sequencer/base-sequencer-implementation.rb +10 -8
- data/lib/musa-dsl/sequencer/base-sequencer-tick-based.rb +3 -5
- data/lib/musa-dsl/transport/input-midi-clock.rb +19 -12
- data/lib/musa-dsl/transport/transport.rb +6 -6
- data/musa-dsl.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dae00405142514f16df2be12de1eb9327893f3996ad3c86ec76fc315db521e7d
|
|
4
|
+
data.tar.gz: f3ebf69b72452ab83ec33ab873221ee1f0d59954e2c67277c2386fc174278a7c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 006f3143b93237b86600bde3b7229f14cae909a50603af4c0d1f33050835c582988325f8b2db63b74d20826d1682f09d51960e32d977f47ce86d69b4d25cd53b
|
|
7
|
+
data.tar.gz: 7c07575e0bcf7a2b5f9e6361d8ae2b64193b8bba31bec3badfbf02f8c83f8a3595bc84df42aa6c8976c947528c82752f9869ed7c19240c9d0d536cb435b4da86
|
data/lib/musa-dsl/repl/repl.rb
CHANGED
|
@@ -39,6 +39,7 @@ module Musa
|
|
|
39
39
|
case line
|
|
40
40
|
when '#begin'
|
|
41
41
|
buffer = StringIO.new
|
|
42
|
+
|
|
42
43
|
when '#end'
|
|
43
44
|
@@repl_mutex.synchronize do
|
|
44
45
|
@block_source = buffer.string
|
|
@@ -48,8 +49,8 @@ module Musa
|
|
|
48
49
|
binder.eval @block_source, "(repl)", 1
|
|
49
50
|
|
|
50
51
|
rescue StandardError, ScriptError => e
|
|
51
|
-
@logger.
|
|
52
|
-
@logger.
|
|
52
|
+
@logger.warn('REPL') { 'code execution error' }
|
|
53
|
+
@logger.warn('REPL') { e.full_message(highlight: true, order: :top) }
|
|
53
54
|
|
|
54
55
|
send_exception e, output: @connection
|
|
55
56
|
else
|
|
@@ -65,12 +66,6 @@ module Musa
|
|
|
65
66
|
@logger.warn('REPL') { 'lost connection' }
|
|
66
67
|
@logger.warn('REPL') { e.full_message(highlight: true, order: :top) }
|
|
67
68
|
|
|
68
|
-
rescue Exception, SystemExit, Interrupt
|
|
69
|
-
puts "EXCEPTION / SYSTEM EXIT / INTERUPT"
|
|
70
|
-
$stdout.flush
|
|
71
|
-
@logger.warn('REPL') { 'received interruption; will close connection...' }
|
|
72
|
-
raise
|
|
73
|
-
|
|
74
69
|
ensure
|
|
75
70
|
@logger.debug("REPL") { "closing connection (running #{@run})" }
|
|
76
71
|
@connection.close
|
|
@@ -92,6 +87,7 @@ module Musa
|
|
|
92
87
|
|
|
93
88
|
@main_thread.terminate
|
|
94
89
|
Thread.pass
|
|
90
|
+
|
|
95
91
|
@main_thread = nil
|
|
96
92
|
|
|
97
93
|
@client_threads.each { |t| t.terminate; Thread.pass }
|
|
@@ -66,7 +66,7 @@ module Musa
|
|
|
66
66
|
@timeslots[at_position] << value
|
|
67
67
|
end
|
|
68
68
|
else
|
|
69
|
-
|
|
69
|
+
@logger.warn('BaseSequencer') { "._raw_numeric_at: warning: ignoring past at command for #{at_position}" }
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
nil
|
|
@@ -90,7 +90,7 @@ module Musa
|
|
|
90
90
|
key_parameters[:control] = control if block_key_parameters_binder.key?(:control)
|
|
91
91
|
|
|
92
92
|
if at_position == @position
|
|
93
|
-
@
|
|
93
|
+
@on_debug_at.each { |c| c.call } if @logger.sev_threshold >= ::Logger::Severity::DEBUG
|
|
94
94
|
|
|
95
95
|
begin
|
|
96
96
|
locked = @tick_mutex.try_lock
|
|
@@ -103,13 +103,17 @@ module Musa
|
|
|
103
103
|
|
|
104
104
|
@timeslots[at_position] ||= []
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
if @logger.sev_threshold <= ::Logger::Severity::DEBUG
|
|
107
|
+
@on_debug_at.each do |block|
|
|
108
|
+
@timeslots[at_position] << { parent_control: control, block: block }
|
|
109
|
+
end
|
|
110
|
+
end
|
|
107
111
|
|
|
108
112
|
@timeslots[at_position] << { parent_control: control, block: block_key_parameters_binder,
|
|
109
113
|
value_parameters: value_parameters,
|
|
110
114
|
key_parameters: key_parameters }
|
|
111
115
|
else
|
|
112
|
-
|
|
116
|
+
@logger.warn('BaseSequencer') { "._numeric_at: warning: ignoring past 'at' command for #{at_position}" }
|
|
113
117
|
end
|
|
114
118
|
|
|
115
119
|
nil
|
|
@@ -661,10 +665,8 @@ module Musa
|
|
|
661
665
|
end
|
|
662
666
|
|
|
663
667
|
def _rescue_error(e)
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
log e.full_message(order: :top)
|
|
667
|
-
end
|
|
668
|
+
@logger.error('BaseSequencer') { e.to_s }
|
|
669
|
+
@logger.error('BaseSequencer') { e.full_message(highlight: true, order: :top) }
|
|
668
670
|
|
|
669
671
|
@on_error.each do |block|
|
|
670
672
|
block.call e
|
|
@@ -48,11 +48,9 @@ module Musa
|
|
|
48
48
|
original_position = position
|
|
49
49
|
position = ticks_position.round * @tick_duration
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"to tick precision: #{position} (#{position.to_f.round(5)})"
|
|
55
|
-
end
|
|
51
|
+
@logger.warn('BaseSequencer') { "._numeric_at: warning: rounding "\
|
|
52
|
+
"position #{position} (#{original_position.to_f.round(5)}) "\
|
|
53
|
+
"to tick precision: #{position} (#{position.to_f.round(5)})" }
|
|
56
54
|
end
|
|
57
55
|
|
|
58
56
|
position
|
|
@@ -4,13 +4,20 @@ require 'nibbler'
|
|
|
4
4
|
module Musa
|
|
5
5
|
module Clock
|
|
6
6
|
class InputMidiClock < Clock
|
|
7
|
-
def initialize(input, do_log: nil)
|
|
7
|
+
def initialize(input, logger: nil, do_log: nil)
|
|
8
8
|
do_log ||= false
|
|
9
9
|
|
|
10
10
|
super()
|
|
11
11
|
|
|
12
12
|
@input = input
|
|
13
|
-
@
|
|
13
|
+
@logger = logger
|
|
14
|
+
|
|
15
|
+
if logger
|
|
16
|
+
@logger = logger
|
|
17
|
+
else
|
|
18
|
+
@logger = Musa::Logger::Logger.new
|
|
19
|
+
@logger.debug! if do_log
|
|
20
|
+
end
|
|
14
21
|
|
|
15
22
|
@nibbler = Nibbler.new
|
|
16
23
|
end
|
|
@@ -52,7 +59,7 @@ module Musa
|
|
|
52
59
|
messages[index + 1].name == 'Song Position Pointer' &&
|
|
53
60
|
messages[index + 2].name == 'Continue'
|
|
54
61
|
|
|
55
|
-
|
|
62
|
+
@logger.debug('InputMidiClock') { 'processing Stop + Song Position Pointer + Continue...' }
|
|
56
63
|
|
|
57
64
|
process_start unless @started
|
|
58
65
|
|
|
@@ -62,7 +69,7 @@ module Musa
|
|
|
62
69
|
|
|
63
70
|
index += 2
|
|
64
71
|
|
|
65
|
-
|
|
72
|
+
@logger.debug('InputMidiClock') { 'processing Stop + Song Position Pointer + Continue... done' }
|
|
66
73
|
|
|
67
74
|
else
|
|
68
75
|
process_message messages[index] do
|
|
@@ -84,12 +91,12 @@ module Musa
|
|
|
84
91
|
private
|
|
85
92
|
|
|
86
93
|
def process_start
|
|
87
|
-
|
|
94
|
+
@logger.debug('InputMidiClock') { 'processing Start...' }
|
|
88
95
|
|
|
89
96
|
@on_start.each(&:call)
|
|
90
97
|
@started = true
|
|
91
98
|
|
|
92
|
-
|
|
99
|
+
@logger.debug('InputMidiClock') { 'processing Start... done' }
|
|
93
100
|
end
|
|
94
101
|
|
|
95
102
|
def process_message(m)
|
|
@@ -98,16 +105,16 @@ module Musa
|
|
|
98
105
|
process_start
|
|
99
106
|
|
|
100
107
|
when 'Stop'
|
|
101
|
-
|
|
108
|
+
@logger.debug('InputMidiClock') { 'processing Stop...' }
|
|
102
109
|
|
|
103
110
|
@on_stop.each(&:call)
|
|
104
111
|
@started = false
|
|
105
112
|
|
|
106
|
-
|
|
113
|
+
@logger.debug('InputMidiClock') { 'processing Stop... done' }
|
|
107
114
|
|
|
108
115
|
when 'Continue'
|
|
109
|
-
|
|
110
|
-
|
|
116
|
+
@logger.debug('InputMidiClock') { 'processing Continue...' }
|
|
117
|
+
@logger.debug('InputMidiClock') { 'processing Continue... done' }
|
|
111
118
|
|
|
112
119
|
when 'Clock'
|
|
113
120
|
yield if block_given? && @started
|
|
@@ -116,9 +123,9 @@ module Musa
|
|
|
116
123
|
new_position_in_midi_beats =
|
|
117
124
|
m.data[0] & 0x7F | ((m.data[1] & 0x7F) << 7)
|
|
118
125
|
|
|
119
|
-
|
|
126
|
+
@logger.debug('InputMidiClock') { "processing Song Position Pointer new_position_in_midi_beats #{new_position_in_midi_beats}..." }
|
|
120
127
|
@on_change_position.each { |block| block.call midi_beats: new_position_in_midi_beats }
|
|
121
|
-
|
|
128
|
+
@logger.debug('InputMidiClock') { "processing Song Position Pointer new_position_in_beats #{new_position_in_midi_beats}... done" }
|
|
122
129
|
end
|
|
123
130
|
end
|
|
124
131
|
end
|
|
@@ -126,21 +126,21 @@ module Musa
|
|
|
126
126
|
private
|
|
127
127
|
|
|
128
128
|
def do_before_begin
|
|
129
|
-
logger.debug('Transport') { 'doing before_begin initialization...' unless @before_begin.empty?
|
|
129
|
+
logger.debug('Transport') { 'doing before_begin initialization...' } unless @before_begin.empty?
|
|
130
130
|
@before_begin.each { |block| block.call @sequencer }
|
|
131
|
-
logger.debug('Transport') { 'doing before_begin initialization... done' unless @before_begin.empty?
|
|
131
|
+
logger.debug('Transport') { 'doing before_begin initialization... done' } unless @before_begin.empty?
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
def do_on_start
|
|
135
|
-
logger.debug('Transport') { 'starting...' unless @on_start.empty?
|
|
135
|
+
logger.debug('Transport') { 'starting...' } unless @on_start.empty?
|
|
136
136
|
@on_start.each { |block| block.call @sequencer }
|
|
137
|
-
logger.debug('Transport') { 'starting... done' unless @on_start.empty?
|
|
137
|
+
logger.debug('Transport') { 'starting... done' } unless @on_start.empty?
|
|
138
138
|
end
|
|
139
139
|
|
|
140
140
|
def do_stop
|
|
141
|
-
logger.debug('Transport') { 'stopping...' unless @after_stop.empty?
|
|
141
|
+
logger.debug('Transport') { 'stopping...' } unless @after_stop.empty?
|
|
142
142
|
@after_stop.each { |block| block.call @sequencer }
|
|
143
|
-
logger.debug('Transport') { 'stopping... done' unless @after_stop.empty?
|
|
143
|
+
logger.debug('Transport') { 'stopping... done' } unless @after_stop.empty?
|
|
144
144
|
|
|
145
145
|
logger.debug('Transport') { 'resetting sequencer...' }
|
|
146
146
|
@sequencer.reset
|
data/musa-dsl.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'musa-dsl'
|
|
3
|
-
s.version = '0.21.
|
|
3
|
+
s.version = '0.21.4'
|
|
4
4
|
s.date = '2020-10-20'
|
|
5
5
|
s.summary = 'A simple Ruby DSL for making complex music'
|
|
6
6
|
s.description = 'Musa-DSL: A Ruby DSL for algorithmic music composition, device language neutral (MIDI, OSC, etc)'
|