Skip to content

Instantly share code, notes, and snippets.

@mgarriss
Created November 23, 2011 16:07
Show Gist options
  • Save mgarriss/1389067 to your computer and use it in GitHub Desktop.
Save mgarriss/1389067 to your computer and use it in GitHub Desktop.
require 'forwardable'
require 'peas/pitch_class'
module Peas
NamedValueClass Pitch:Fixnum, constrain:0..127 do
minus_a 'Interval::Base' do |lhs,minus,rhs|
minus.call rhs.inverse
end
all_operators_with_a Pitch, raise:SyntaxError
end
PitchClass::NamedValues::Collection.each do |pclass|
Pitch "#{pclass}_1" => pclass.value, pitch_class:pclass, octave:-1,
sharp:pclass.is_sharp?, flat:pclass.is_flat?, natural:pclass.is_natural?
0.upto(9) do |octave|
name = pclass.to_s + octave.to_s
Pitch name => (((octave+1)*12)+pclass), pitch_class:pclass, octave:octave,
sharp:pclass.is_sharp?, flat:pclass.is_flat?, natural:pclass.is_natural?
end
end
module Pitches
include Pitch::NamedValues
include PitchClass::NamedValues
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment