Class: MidiBeatBox

Inherits:
ArduinoSketch show all
Defined in:
lib/examples/midi_beat_box.rb

Instance Attribute Summary

Attributes inherited from ArduinoSketch

#pins

Instance Method Summary collapse

Methods inherited from ArduinoSketch

#add, add_to_setup, #array, #assembler, #comment_box, #compose_setup, #define, #delay, #digitalWrite, #formatted_print, #initialize, #input_pin, #input_pins, output_pin, #output_pin, post_process_ruby_to_c_methods, pre_process, #serial_begin

Methods included from ExternalVariableProcessing

#c_type, #check_variable_type, #post_process_arrays, #post_process_vars, #pre_process_vars, #process_external_vars, #translate_variables

Constructor Details

This class inherits a constructor from ArduinoSketch

Instance Method Details

#firstObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/examples/midi_beat_box.rb', line 26

def first
  play 39, 52, 37
  play  0,  0,  0
  play 36, 52,  0
  play 37, 52, 39

  play 37,  0,  0
  play 36,  0,  0
  play 39, 50,  0
  play  0,  0,  0

  play 52, 36, 37
  play 0,  0,   0
  play 39,  0,  0
  play 36, 37,  0

  play 36, 37, 39
  play 36, 38,  0
  play 50,  0,  0
  play 0,   0,  0
end

#loopObject



16
17
18
19
20
21
22
23
24
# File 'lib/examples/midi_beat_box.rb', line 16

def loop
  8.times {first}
  2.times do 
    second
    third
  end
  4.times {first}
  2.times {second}
end

#play(one, two, three) ⇒ Object



73
74
75
76
77
78
79
80
81
82
# File 'lib/examples/midi_beat_box.rb', line 73

def play(one, two, three)
  n = 1 + one + two + three # ack to coerce parameters to int
  note_on(@channel, one, 127) unless one == 0
  note_on(@channel, two, 127) unless two == 0
  note_on(@channel, three, 127) unless three == 0
  delay 310 - sensor_one.soft_lock # start slowly 
  note_off(@channel, one, 0) unless one == 0
  note_off(@channel, two, 0) unless two == 0
  note_off(@channel, three, 0) unless three == 0
end

#secondObject



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/examples/midi_beat_box.rb', line 48

def second
  play 39, 52, 37
  play 36,  0,  0
  play  0,  0,  0
  play 37, 52, 39

  play 38,  0,  0
  play 36,  0,  0
  play 39, 50,  0
  play  0,  0,  0
end

#setupObject



12
13
14
# File 'lib/examples/midi_beat_box.rb', line 12

def setup
  delay 3000
end

#thirdObject



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/examples/midi_beat_box.rb', line 60

def third
  play  0, 36, 37
  play  0,  0,   0
  play 39, 36,  0
  play 36, 37, 50

  play 36, 37, 39
  play 36, 37,  0
  play 50,  0,  0
  play 39,  0,  0
end