This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "minitest/autorun" | |
class String | |
def my_test | |
"This is my test and I can cry if I want to" | |
end | |
def unstripped |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Surface | |
#... | |
SNARE_OPTIONS = { left: -51, right: 0, note: 38 } | |
KICK_OPTIONS = { left: 0, right: 100, note: 36 } | |
HAT_OPTIONS = { left: -100, right: -50, note: 57 } | |
def initialize(drum_type=nil, *opts) | |
case drum_type | |
when :snare |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def on_frame(*args) | |
frame = args[1] | |
return if frame.pointables.empty? | |
set_finger_from(frame) | |
if @finger | |
x_position = @finger.tipPosition[0] | |
y_position = @finger.tipPosition[1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def play(volume) | |
output = UniMIDI::Output.open(:first) | |
output.open do |node| | |
node.puts(0x90, @drum_note, volume) | |
sleep(0.1) | |
node.puts(0x80, @drum_note, volume) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DrumSet < Artoo::MainRobot | |
#... | |
def initialize | |
@bass_drum = Surface.new(:kick) | |
@snare = Surface.new(:snare) | |
@hi_hat = Surface.new(:hat) | |
@crazy_sound = Surface.new(left: 151, right: 200, note: 22) | |
@drums = [@snare, @bass_drum, @hi_hat, @crazy_sound] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_a_hit?(timestamp, y_velocity) | |
if @previous[:y_velocity] && y_velocity && @previous[:y_velocity] > 0 && y_velocity < 0 && (timestamp - @previous[:timestamp] > 500) | |
true | |
end | |
false | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_a_hit?(y_position) | |
if @previous[:y_position] && @previous[:y_position] > 150 && y_position < 150 | |
true | |
else | |
false | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def drum_for(x_position, y_velocity) | |
determine_volume_from(y_velocity) | |
drum_hit = @drums.detect do |drum| | |
x_position > drum.left_boundary && x_position < drum.right_boundary | |
end | |
drum_hit.play(@volume) if drum_hit | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def determine_volume_from(velocity) | |
@volume = [[ 0, (velocity.abs/30).to_i ].max, 100].min | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
chore = "!sh -c 'git checkout -b chore/$1' -" | |
bug = "!sh -c 'git checkout -b bug/$1' -" | |
feature = "!sh -c 'git checkout -b feature/$1' -" |
OlderNewer