module Musicality

Autogenerated from a Treetop grammar. Edits may be lost.

Autogenerated from a Treetop grammar. Edits may be lost.

Autogenerated from a Treetop grammar. Edits may be lost.

Autogenerated from a Treetop grammar. Edits may be lost.

Autogenerated from a Treetop grammar. Edits may be lost.

Autogenerated from a Treetop grammar. Edits may be lost.

Autogenerated from a Treetop grammar. Edits may be lost.

Autogenerated from a Treetop grammar. Edits may be lost.

Autogenerated from a Treetop grammar. Edits may be lost.

Autogenerated from a Treetop grammar. Edits may be lost.

Autogenerated from a Treetop grammar. Edits may be lost.

Autogenerated from a Treetop grammar. Edits may be lost.

Autogenerated from a Treetop grammar. Edits may be lost.

Autogenerated from a Treetop grammar. Edits may be lost.

Autogenerated from a Treetop grammar. Edits may be lost.

Constants

ARTICULATION_SYMBOLS

These symbols all need to match the notation parsers

CLEFS
DRUM_PARTS
MARK_SYMBOLS
PITCH_CLASSES
UnsupportedDurationError
VERSION

Public Class Methods

dh(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 43
def dh(*pitch_groups)
  pitch_groups.map {|pg| Note.dotted_half(pg) }
end
dq(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 33
def dq(*pitch_groups)
  pitch_groups.map {|pg| Note.dotted_quarter(pg) }
end
ds(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 13
def ds(*pitch_groups)
  pitch_groups.map {|pg| Note.dotted_sixteenth(pg) }
end
e(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 18
def e(*pitch_groups)
  pitch_groups.map {|pg| Note.eighth(pg) }
end
h(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 38
def h(*pitch_groups)
  pitch_groups.map {|pg| Note.half(pg) }
end
make_note(dur, pitch_group) click to toggle source
# File lib/musicality/composition/util/note_generation.rb, line 3
def make_note dur, pitch_group
  if dur > 0
    Musicality::Note.new(dur,pitch_group)
  else
    Musicality::Note.new(-dur)
  end
end
make_notes(rhythm, pitch_groups) click to toggle source

Whichever is longer, rhythm or pitch_groups, is iterated over once while the smaller will cycle as necessary.

# File lib/musicality/composition/util/note_generation.rb, line 14
def make_notes rhythm, pitch_groups
  m,n = rhythm.size, pitch_groups.size
  raise EmptyError, "rhythm is empty" if m == 0
  raise EmptyError, "pitch_groups is empty" if n == 0
  
  if m > n
    Array.new(m) do |i|
      make_note(rhythm[i],pitch_groups[i % n])
    end
  else
    Array.new(n) do |i|
      make_note(rhythm[i % m],pitch_groups[i])
    end
  end
end
q(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 28
def q(*pitch_groups)
  pitch_groups.map {|pg| Note.quarter(pg) }
end
s(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 8
def s(*pitch_groups)
  pitch_groups.map {|pg| Note.sixteenth(pg) }
end
transpose(notes, diff) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 3
def transpose notes, diff
  notes.map {|n| n.transpose(diff) }
end
w(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 48
def w(*pitch_groups)
  pitch_groups.map {|pg| Note.whole(pg) }
end

Public Instance Methods

de(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 23
def de(*pitch_groups)
  pitch_groups.map {|pg| Note.dotted_eighth(pg) }
end

Private Instance Methods

dh(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 43
def dh(*pitch_groups)
  pitch_groups.map {|pg| Note.dotted_half(pg) }
end
dq(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 33
def dq(*pitch_groups)
  pitch_groups.map {|pg| Note.dotted_quarter(pg) }
end
ds(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 13
def ds(*pitch_groups)
  pitch_groups.map {|pg| Note.dotted_sixteenth(pg) }
end
e(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 18
def e(*pitch_groups)
  pitch_groups.map {|pg| Note.eighth(pg) }
end
h(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 38
def h(*pitch_groups)
  pitch_groups.map {|pg| Note.half(pg) }
end
make_note(dur, pitch_group) click to toggle source
# File lib/musicality/composition/util/note_generation.rb, line 3
def make_note dur, pitch_group
  if dur > 0
    Musicality::Note.new(dur,pitch_group)
  else
    Musicality::Note.new(-dur)
  end
end
make_notes(rhythm, pitch_groups) click to toggle source

Whichever is longer, rhythm or pitch_groups, is iterated over once while the smaller will cycle as necessary.

# File lib/musicality/composition/util/note_generation.rb, line 14
def make_notes rhythm, pitch_groups
  m,n = rhythm.size, pitch_groups.size
  raise EmptyError, "rhythm is empty" if m == 0
  raise EmptyError, "pitch_groups is empty" if n == 0
  
  if m > n
    Array.new(m) do |i|
      make_note(rhythm[i],pitch_groups[i % n])
    end
  else
    Array.new(n) do |i|
      make_note(rhythm[i % m],pitch_groups[i])
    end
  end
end
q(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 28
def q(*pitch_groups)
  pitch_groups.map {|pg| Note.quarter(pg) }
end
s(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 8
def s(*pitch_groups)
  pitch_groups.map {|pg| Note.sixteenth(pg) }
end
transpose(notes, diff) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 3
def transpose notes, diff
  notes.map {|n| n.transpose(diff) }
end
w(*pitch_groups) click to toggle source
# File lib/musicality/composition/convenience_methods.rb, line 48
def w(*pitch_groups)
  pitch_groups.map {|pg| Note.whole(pg) }
end