Socket
Book a DemoInstallSign in
Socket

midi-topaz

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

midi-topaz

0.2.5
bundlerRubygems
Version published
Maintainers
1
Created
Source

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

  • examples
  • rdoc

Author

License

Apache 2.0, See the file LICENSE

Copyright (c) 2011-2015 Ari Russo

FAQs

Package last updated on 11 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.