Skip to content

Instantly share code, notes, and snippets.

@unclejamal
Created May 29, 2014 22:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save unclejamal/5a7c2020738079b0697e to your computer and use it in GitHub Desktop.
Save unclejamal/5a7c2020738079b0697e to your computer and use it in GitHub Desktop.
require_relative 'music'
describe "music kata" do
it "models octaves" do
Notes.c(:simple, 1).pitch.should == 4
Notes.c(:simple, 2).pitch.should == 16
Notes.c(:simple, 8).pitch.should == 88
Notes.e(:simple, 1).pitch.should == 8
end
it "models accidentals" do
Notes.c(:sharp, 1).pitch.should == 5
Notes.c(:flat, 1).pitch.should == 3
Notes.c(:sharp, 6).pitch.should == 65
end
it "models frequencies" do
Notes.c(:simple, 1).frequency.should == 32.7032
Notes.c(:sharp, 1).frequency.should == 34.6478
Notes.c(:simple, 8).frequency.should == 4186.009
end
it "models intervals" do
Interval.between(Notes.c(:simple, 1), Notes.e(:simple, 1)).should == :major_third
Interval.between(Notes.c(:simple, 1), Notes.e(:flat, 1)).should == :minor_third
end
end
describe "roots" do
it "models roots" do
Roots.rootn(16, 4).should == 2
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment