class Banjo::Channel
Constants
- DEFAULT_DURATION
Attributes
output[RW]
Public Class Methods
channels()
click to toggle source
# File lib/banjo/channel.rb, line 21 def self.channels @channels ||= [] end
inherited(child)
click to toggle source
# File lib/banjo/channel.rb, line 25 def self.inherited(child) channels << child end
new()
click to toggle source
# File lib/banjo/channel.rb, line 29 def initialize @output = UniMIDI::Output.all[channel] end
Public Instance Methods
arpeggio(notes, velocity = 50)
click to toggle source
# File lib/banjo/channel.rb, line 45 def arpeggio(notes, velocity = 50) step = (1.0 * Banjo.ticks_per_period / notes.size).round notes.each_with_index do |note, index| tick_note((index * step), note, velocity) end end
channel()
click to toggle source
# File lib/banjo/channel.rb, line 9 def channel 0 end
hush()
click to toggle source
# File lib/banjo/channel.rb, line 52 def hush output.puts 0xB0, 0x7B, 0 end
midi_messages()
click to toggle source
# File lib/banjo/channel.rb, line 17 def midi_messages [0x90, 0x80] end
modulation(value = 0)
click to toggle source
# File lib/banjo/channel.rb, line 33 def modulation(value = 0) output.puts 0xB0, 0x01, value end
pitch(value = 63)
click to toggle source
# File lib/banjo/channel.rb, line 37 def pitch(value = 63) output.puts 0xE0, 0, value end
play(note)
click to toggle source
# File lib/banjo/channel.rb, line 13 def play(note) Note.new(self, note) end
play_note!(note, velocity = 100, duration = DEFAULT_DURATION)
click to toggle source
# File lib/banjo/channel.rb, line 56 def play_note!(note, velocity = 100, duration = DEFAULT_DURATION) output.puts(midi_messages[0], note, velocity) EventMachine.add_timer(duration, proc { output.puts(midi_messages[1], note, 100) }) end
sustain(value = 0)
click to toggle source
# File lib/banjo/channel.rb, line 41 def sustain(value = 0) output.puts 0xB0, 0x40, value end
within(lower, upper, &block)
click to toggle source
# File lib/banjo/channel.rb, line 61 def within(lower, upper, &block) if(Banjo.tick >= lower && Banjo.tick <= upper) block.call end end