Project

midi-topaz

0.01
No release in over 3 years
Low commit activity in last 3 years
A tempo source that is capable of synchronizing with MIDI clocks.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 5.5.0, ~> 5.5
>= 1.1.0, ~> 1.1
>= 10.4.2, ~> 10.4
>= 1.2.1, ~> 1.2

Runtime

>= 0.3, ~> 0
>= 0.3.7, ~> 0.3
>= 0.4.4, ~> 0.4
>= 0.4.6, ~> 0.4
 Project Readme

Topaz

pic

MIDI syncable tempo in Ruby

Installation

gem install midi-topaz

or with Bundler, add this to your Gemfile

gem "midi-topaz"

Usage

require "topaz"

For demonstration purposes, here's a mock sequencer class and object

class Sequencer

  def step
    @i ||= 0
    puts "step #{@i+=1}"
  end

end

sequencer = Sequencer.new

The Topaz clock can now be used to step that sequencer. Timed by Topaz, the passed in block will be called repeatedly at 130 BPM

@clock = Topaz::Clock.new(130) { sequencer.step }

A MIDI device can be used to time and control the tempo. To accomplish this, pass a unimidi input to the Clock constructor

@input = UniMIDI::Input.gets # select a midi input

@clock = Topaz::Clock.new(@input) { sequencer.step }

Topaz can also act as a MIDI master clock. If a MIDI output is passed to Topaz, MIDI clock messages will automatically be sent to that output at the appropriate time

@output = UniMIDI::Output.gets # select a midi output

@clock = Topaz::Clock.new(120, :midi => @output) do
  sequencer.step
end

Input and multiple outputs can be used simultaneously, for MIDI thru

@clock = Topaz::Clock.new(@input, :midi => [@output1, @output2]) do
  sequencer.step
end

Once the Clock object is initialized, start the clock

@clock.start

Topaz will run in a background thread if the option :background => true is passed in.

@clock.start(:background => true)

If you are syncing to an external MIDI source, this will start the listener waiting for MIDI clock messages.

You can view the current tempo:

@clock.tempo
  => 132.422000

Pass in a block that will stop the clock when it evaluates to true

@clock.trigger.stop { @i == 20 }

Documentation

Author

License

Apache 2.0, See the file LICENSE

Copyright (c) 2011-2015 Ari Russo