midi-topaz 0.0.12 → 0.0.13

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.
Files changed (4) hide show
  1. data/README.rdoc +2 -2
  2. data/lib/topaz/tempo.rb +16 -19
  3. data/lib/topaz.rb +1 -1
  4. metadata +1 -1
data/README.rdoc CHANGED
@@ -42,7 +42,7 @@ You may also use another MIDI device to generate timing and control the tempo.
42
42
 
43
43
  @input = UniMIDI::Input.first.open # an midi input
44
44
 
45
- @tempo = Topaz::Tempo.new(:midi => @input) { seq.step }
45
+ @tempo = Topaz::Tempo.new(@input) { seq.step }
46
46
 
47
47
  Topaz can also act as a master clock. If a MIDI output is passed to Topaz, MIDI start, stop and clock signals will automatically be sent to that output at the appropriate time
48
48
 
@@ -52,7 +52,7 @@ Topaz can also act as a master clock. If a MIDI output is passed to Topaz, MIDI
52
52
 
53
53
  Input and multiple outputs can be used simultaneously
54
54
 
55
- @tempo = Topaz::Tempo.new(:midi => [@input, @output1, @output2]) { seq.step }
55
+ @tempo = Topaz::Tempo.new(@input, :midi => [@output1, @output2]) { seq.step }
56
56
 
57
57
  Once the Tempo object is initialized, start the clock
58
58
 
data/lib/topaz/tempo.rb CHANGED
@@ -10,7 +10,7 @@ module Topaz
10
10
 
11
11
  def_delegators :source, :tempo, :interval, :interval=, :join
12
12
 
13
- def initialize(*args, &event)
13
+ def initialize(tempo_or_input, options = {}, &event)
14
14
  @paused = false
15
15
  @destinations = []
16
16
  @actions = {
@@ -23,17 +23,16 @@ module Topaz
23
23
 
24
24
  on_tick(&event)
25
25
 
26
- if args.first.kind_of?(Numeric)
27
- @source = InternalTempo.new(@actions, args.shift)
26
+ if tempo_or_input.kind_of?(Numeric)
27
+ @source = InternalTempo.new(@actions, tempo_or_input)
28
+ else
29
+ midi_clock_source = tempo_or_input
28
30
  end
29
- options = args.first
30
-
31
- initialize_midi_io(options)
31
+
32
+ initialize_midi_io(options[:midi], midi_clock_source)
32
33
  raise "You must specify an internal tempo rate or an external tempo source" if @source.nil?
33
-
34
- unless options.nil?
35
- @source.interval = options[:interval] unless options[:interval].nil?
36
- end
34
+
35
+ @source.interval = options[:interval] unless options[:interval].nil?
37
36
 
38
37
  end
39
38
 
@@ -157,15 +156,13 @@ module Topaz
157
156
 
158
157
  private
159
158
 
160
- def initialize_midi_io(args)
161
- ports = args.kind_of?(Hash) ? args[:midi] : args
162
- unless ports.nil?
163
- if ports.kind_of?(Array)
164
- ports.each { |port| initialize_midi_io(port) }
165
- elsif ports.type.eql?(:input) && @source.nil?
166
- @source = ExternalMIDITempo.new(@actions, ports)
167
- elsif ports.type.eql?(:output)
168
- @destinations << MIDISyncOutput.new(ports)
159
+ def initialize_midi_io(midi_ports, midi_clock = nil)
160
+ @source = ExternalMIDITempo.new(@actions, midi_clock) unless midi_clock.nil? || !@source.nil?
161
+ unless midi_ports.nil?
162
+ if midi_ports.kind_of?(Array)
163
+ midi_ports.each { |port| initialize_midi_io(port) }
164
+ elsif midi_ports.type.eql?(:output)
165
+ @destinations << MIDISyncOutput.new(midi_ports)
169
166
  end
170
167
  end
171
168
  end
data/lib/topaz.rb CHANGED
@@ -18,6 +18,6 @@ require 'topaz/tempo'
18
18
 
19
19
  module Topaz
20
20
 
21
- VERSION = "0.0.12"
21
+ VERSION = "0.0.13"
22
22
 
23
23
  end
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.12
5
+ version: 0.0.13
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ari Russo