class MidiScales

Public Instance Methods

change_channels() click to toggle source
# File lib/examples/midi_scales.rb, line 51
def change_channels 
  0.upto(6) do |channel| 
    play channel, 50, 100
  end
end
change_pressure() click to toggle source
# File lib/examples/midi_scales.rb, line 45
def change_pressure
  110.upto(127) do |pressure| 
     play 0, 45, pressure
  end
end
change_tone() click to toggle source
# File lib/examples/midi_scales.rb, line 39
def change_tone 
  110.upto(127) do |note|
    play 0, note, 127
  end
end
loop() click to toggle source
# File lib/examples/midi_scales.rb, line 30
def loop
  change_tone if button_one.read_input
  change_pressure if button_two.read_input
  change_channels if button_three.read_input
  read_sensor_one
  read_sensor_two
  read_sensor_three
end
pre_play(current_note, last_note, channel) click to toggle source
# File lib/examples/midi_scales.rb, line 75
  def pre_play(current_note, last_note, channel) # warning, don't use last as a parameter...
    n = 1 + channel
    unless current_note == last_note
      @note = ((current_note /16) + 40)
      play_with_no_delay( channel, @note, 100 )
    end
  end
    
  def play(chan, note, pressure)
    note_on(chan, note, pressure)
    delay 100 # adjust to need
    note_off(chan, note, 0)
  end
  
  def play_with_no_delay(chan, note, pressure) # note is not turned off
    note_on(chan, note, pressure)
  end


end
read_sensor_one() click to toggle source
# File lib/examples/midi_scales.rb, line 57
def read_sensor_one
  @current_note = sensor_one.soft_lock
  pre_play(@current_note, @last_note_one, 13)
  @last_note_one = @current_note
end
read_sensor_three() click to toggle source
# File lib/examples/midi_scales.rb, line 69
def read_sensor_three
  @current_note = sensor_three.soft_lock
  pre_play(@current_note, @last_note_three, 15)
  @last_note_three = @current_note
end
read_sensor_two() click to toggle source
# File lib/examples/midi_scales.rb, line 63
def read_sensor_two
  @current_note = sensor_two.soft_lock
  pre_play(@current_note, @last_note_two, 14)
  @last_note_two = @current_note
end
setup() click to toggle source
# File lib/examples/midi_scales.rb, line 26
def setup
  delay 3000
end