* Modes in the Key of C ** Processes *** Generate Bass Line #+name: generate_bassline(root="") #+begin_src ruby :results silent one_bar = "#{root},,8 #{root}, #{root}, #{root}, " + "#{root},, #{root}, #{root}, #{root}16 #{root},16 | " one_bar + one_bar + one_bar + one_bar #+end_src *** Generate Triad #+name: generate_triad_sequence(root="c",chord="c") #+begin_src ruby :results silent @key_of_c = ["c","d","e","f","g","a","b"] @key_of_g = ["g","a","b","c","d","e","fis"] def triad(key, root, chord, duration) note = key.index(root) + (chord - 1) "< " + key.fetch(key.index(root)) + "' "+ key.fetch(note % 7) + "'" + # * (note < 7 ? 1 : 2) + " " + key.fetch((note + 2) % 7) + "'" + # * ((note + 2) < 7 ? 1 : 2) + " " + key.fetch((note + 4) % 7) + "'" + # * ((note + 4) < 7 ? 1 : 2) + " " + ">" + " " + duration.to_s end triad(@key_of_c, root, chord, 4) + triad(@key_of_c, root, chord, 4) + triad(@key_of_c, root, chord, 4) + triad(@key_of_c, root, chord, 4) #+end_src *** Generate arpeggio #+name: generate_arpeggio(root="c",ascending="t") #+begin_src ruby :results silent @key_of_c = ["c","d","e","f","g","a","b"] @key_of_g = ["g","a","b","c","d","e","fis"] def note(key, root, value) value = key.index(root) + value note_value = key.fetch(value % 7) pitch = "'" pitch += "'" if value >= 7 note_value + pitch + "16 " end def arpeggio(key, root, ascending) if ascending == 1 x,y = 0, 1 else x,y = 7, -1 end notes = "" 8.times do notes += note(key, root, x) x = x + y end notes + "r2 " end arpeggio @key_of_c, root, ascending #+end_src ** Version #+begin_src lilypond \version "2.12.3" #+end_src ** Notes *** Arpeggios #+begin_src lilypond Carp = { <> <> } Garp = { <> <> } Darp = { <> <> } Aarp = { <> <> } Earp = { <> <> } Barp = { <> <> } Farp = { <> <> } #+end_src *** Triads #+begin_src lilypond Ctriads = { <> <> } Gtriads = { <> <> } Dtriads = { <> <> } Atriads = { <> <> } Etriads = { <> <> } Btriads = { <> <> } Ftriads = { <> <> } #+end_src ** Drums (four bars) #+begin_src lilypond DrumsFourBars = { \drummode { bd16 hh16 hh16 hh16 sn16 hh16 hh16 hh16 bd16 hh16 hh16 hh16 sn16 hh16 hh16 hh16 | bd16 hh16 hh16 hh16 sn16 hh16 hh16 hh16 bd16 hh16 hh16 hh16 sn16 hh16 hh16 bd16 | bd16 hh16 hh16 hh16 sn16 hh16 hh16 hh16 bd16 hh16 hh16 hh16 sn16 hh16 hh16 hh16 | bd16 hh16 hh16 hh16 sn16 hh16 hh16 hh16 bd16 hh16 hh16 hh16 sn16 hh16 sn16 bd16 | } } #+end_src ** Number of bars to compile (showLastLength) #+begin_src lilypond % showLastLength = R1*8 #+end_src ** Score #+begin_src lilypond \score { << \new Staff { \relative c' \key c \major \set Staff.midiInstrument = #"acoustic grand" \Barp \Barp \Earp \Earp \Aarp \Aarp \Darp \Darp \Garp \Garp \Carp \Carp \Farp \Farp \Carp \Carp \Garp \Garp \Darp \Darp \Aarp \Aarp \Earp \Earp \Barp \Barp \Farp \Farp \Carp \Carp } \new Staff { \relative c' \key c \major \set Staff.midiInstrument = #"acoustic grand" \Btriads \Btriads \Etriads \Etriads \Atriads \Atriads \Dtriads \Dtriads \Gtriads \Gtriads \Ctriads \Ctriads \Ftriads \Ftriads \Ctriads \Ctriads \Gtriads \Gtriads \Dtriads \Dtriads \Atriads \Atriads \Etriads \Etriads \Btriads \Btriads \Ftriads \Ftriads \Ctriads \Ctriads } \new Staff { \clef bass \relative c \key c \major \set Staff.midiInstrument = #"slap bass 2" <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> } \new DrumStaff { \DrumsFourBars \DrumsFourBars \DrumsFourBars \DrumsFourBars \DrumsFourBars \DrumsFourBars \DrumsFourBars \DrumsFourBars \DrumsFourBars \DrumsFourBars \DrumsFourBars \DrumsFourBars \DrumsFourBars \DrumsFourBars \DrumsFourBars } >> \layout { } \midi { \context { \Score tempoWholesPerMinute = #(ly:make-moment 60 4) } } } #+end_src ** Paper #+begin_src lilypond \paper { #(define dump-extents #t) indent = 0\mm line-width = 200\mm - 2.0 * 0.4\in ragged-right = #"" force-assignment = #"" line-width = #(- line-width (* mm 3.000000)) } #+end_src ** Header #+begin_src lilypond \header { title = \markup \center-column {"Modes in the Key of C"} composer = \markup \center-column { "Music by" \small "Martyn Jago" } poet = \markup \center-column { "ob-lilypond" \small "example 2" } } #+end_src