Here's how I would do the same with music.rb
line [c4, df4, d4, df4].map { |p| notes(p, f4, g4, af4, g4, f4) }.flatten
def notes(*pitches) pitches.map { |pitch| note(pitch, Rational(1,8)) } end
def line(notes) notes.inject(&:) end
Still more verbose than cosy, but it's easy to add new helpers and abstractions.
More information about formatting options
Reducing Musical Redundancy: music.rb
Here's how I would do the same with music.rb
line [c4, df4, d4, df4].map { |p|
notes(p, f4, g4, af4, g4, f4)
}.flatten
def notes(*pitches)
pitches.map { |pitch| note(pitch, Rational(1,8)) }
end
def line(notes) notes.inject(&:) end
Still more verbose than cosy, but it's easy to add new helpers and abstractions.