midi-topaz 0.0.7 → 0.0.8
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.
- data/lib/topaz.rb +1 -1
- data/lib/topaz/tempo.rb +19 -3
- data/test/test_internal_tempo.rb +3 -3
- metadata +2 -2
data/lib/topaz.rb
CHANGED
data/lib/topaz/tempo.rb
CHANGED
@@ -60,14 +60,22 @@ module Topaz
|
|
60
60
|
@actions[:stop] = block
|
61
61
|
end
|
62
62
|
|
63
|
-
# pass in a callback which will
|
63
|
+
# pass in a callback which will stop the clock if it evaluates to true
|
64
64
|
def stop_when(&block)
|
65
|
-
|
65
|
+
proc = Proc.new do
|
66
|
+
if yield
|
67
|
+
stop
|
68
|
+
true
|
69
|
+
else
|
70
|
+
false
|
71
|
+
end
|
72
|
+
end
|
73
|
+
@actions[:stop_when] = proc
|
66
74
|
end
|
67
75
|
|
68
76
|
# pass in a callback which will be fired on each tick
|
69
77
|
def on_tick(&block)
|
70
|
-
proc = Proc.new do
|
78
|
+
proc = Proc.new do
|
71
79
|
@destinations.each { |d| d.send(:tick) if d.respond_to?(:tick) }
|
72
80
|
yield
|
73
81
|
end
|
@@ -104,14 +112,22 @@ module Topaz
|
|
104
112
|
# accepts MIDISyncOutput or another Tempo object
|
105
113
|
def add_destination(tempo)
|
106
114
|
@destinations << tempo
|
115
|
+
@start_time.nil? ? tempo.stop : tempo.start
|
107
116
|
end
|
108
117
|
alias_method :<<, :add_destination
|
118
|
+
alias_method :sync_from, :add_destination
|
109
119
|
|
110
120
|
# sync to another Tempo object
|
111
121
|
def sync_to(tempo)
|
112
122
|
tempo.add_destination(self)
|
113
123
|
end
|
114
124
|
|
125
|
+
# remove all sync connections to <em>tempo</em>
|
126
|
+
def unsync(tempo)
|
127
|
+
@destinations.delete(tempo)
|
128
|
+
tempo.unsync(self)
|
129
|
+
end
|
130
|
+
|
115
131
|
protected
|
116
132
|
|
117
133
|
def tick
|
data/test/test_internal_tempo.rb
CHANGED
@@ -18,12 +18,12 @@ class InternalTempoTest < Test::Unit::TestCase
|
|
18
18
|
assert_equal(count_to, i)
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
21
|
+
def test_change_on_tick
|
22
22
|
i = 0
|
23
23
|
count_to = 5
|
24
24
|
|
25
25
|
tempo = Tempo.new(120) { i += 1 }
|
26
|
-
tempo.stop_when { i
|
26
|
+
tempo.stop_when { i == count_to }
|
27
27
|
tempo.start
|
28
28
|
|
29
29
|
assert_equal(count_to, i)
|
@@ -32,7 +32,7 @@ class InternalTempoTest < Test::Unit::TestCase
|
|
32
32
|
count_to = 1000
|
33
33
|
|
34
34
|
tempo.on_tick { i += 100 }
|
35
|
-
tempo.stop_when { i
|
35
|
+
tempo.stop_when { i == count_to }
|
36
36
|
tempo.start
|
37
37
|
|
38
38
|
assert_equal(count_to, i)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: midi-topaz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ari Russo
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-28 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|