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.

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
You must answer the following question to post. This prevents automated spam submissions. If you answer incorrectly, a different question will be provided so you can try again.
kiloh_rtz: