lilypond-auto-insert

Comprehensive auto-insert for LilyPond
git clone git://jamzattack.xyz/lilypond-auto-insert.git
Log | Files | Refs | LICENSE

ModeNameSize
-rw-r--r--.gitignore2L
-rw-r--r--LICENSE674L
-rw-r--r--README.org479L
-rw-r--r--lilypond-auto-insert.el571L
LilyPond Auto Insert

LilyPond Auto Insert

This package provides a convenient interface to perform LilyPond auto-insertions in Emacs.

Installation

package.el

Download lilypond-auto-insert.el, and use M-x package-install-file RET path/to/lilypond-auto-insert.el.

straight.el

Evaluate the following:

(straight-use-package
 '(lilypond-auto-insert :type git
                        :repo "git://jamzattack.xyz/lilypond-auto-insert.git"))

Manual installation

  1. Download lilypond-auto-insert.el
  2. Stick it in load-path
  3. Update autoloads
  4. (optionally) byte-compile it

Motivation

LilyPond is a great way to write music, but its syntax for staves, layout, etc. can be overwhelming at times. The main entry point of this package, lilypond-auto-insert, prompts from a list of predefined instrumentations which is inserted into the buffer. This approach of inserting something close to what's needed and editing it accordingly is often far quicker than writing the whole thing manually.

Customization

Variables

This package provides some variables that adjust the content of the auto-insertions:

Header block

The header block is an important part of any lilypond document. As such, I have made it very customizable.

By default, lilypond-auto-insert will:

  • Prompt for the title.
  • Prompt for the composer.
  • Remove the tagline.

You can customize the value of lilypond-auto-insert-header-alist to either:

  1. Prompt the user
  2. Use a default string
  3. Evaluate lisp

For example, to add a copyright assignment automatically:

(add-to-list 'lilypond-auto-insert-header-alist
             '("copyright" . (format "\"Copyright (C) %s by %s\""
                                     (format-time-string "%Y")
                                     (or user-full-name
                                         user-login-name))))

Custom functions

It is possible to create your own instrumenations simply by defining a function that returns a string, and adding it to lilypond-auto-insert-alist. For example:

(defun lilypond-auto-insert-piano-trio ()
  "Create a blank document for piano trio."
  (mapconcat #'identity
             (list (lilypond-auto-insert--boilerplate)
                   (lilypond-auto-insert--header)
                   (lilypond-auto-insert-global)
                   (lilypond-auto-insert-instruments "violin" "cello" "top" "bottom")
                   (lilypond-auto-insert-score
                    (lilypond-auto-insert-piano-and-group-staff "violin" "cello")))
             "\n"))

(add-to-list 'lilypond-auto-insert-alist
             '(lilypond-auto-insert-piano-trio . "Piano Trio"))

Auto-inserting automatically

This package also provides a function to auto-insert if you are visiting an empty buffer. To enable it:

(add-hook 'LilyPond-mode-hook
          #'lilypond-auto-insert-on-empty-buffer)

Default instrumentations

These are the current instrumentations:

(I might add some more in the future, but this is enough for now.)

Solo

\version "2.20"

\header {
  title = "Title"
  composer = "Composer"
  tagline = ##f
}

global = {

}

cello = \relative {
  \global
}

\score {
  \new Staff {
    \cello
  }
  \midi { }
  \layout { }
}

Piano

\version "2.20"

\header {
  title = "Title"
  composer = "Composer"
  tagline = ##f
}

global = {

}

top = \relative {
  \global
}

bottom = \relative {
  \global
}

\score {
  \new PianoStaff <<
    \new Staff \top
    \new Staff \bottom
  >>
  \midi { }
  \layout { }
}

Piano and Solo Instrument

\version "2.20"

\header {
  title = "Title"
  composer = "Composer"
  tagline = ##f
}

global = {

}

flute = \relative {
  \global
}

top = \relative {
  \global
}

bottom = \relative {
  \global
}

\score {
  <<
    \new Staff {
      \flute
    }

    \new PianoStaff <<
      \new Staff \top
      \new Staff \bottom
    >>
  >>
  \midi { }
  \layout { }
}

Choir or Vocal Quartet

\version "2.20"

\header {
  title = "Title"
  composer = "Composer"
  tagline = ##f
}

global = {

}

soprano = \relative {
  \global
}

alto = \relative {
  \global
}

tenor = \relative {
  \global
}

bass = \relative {
  \global
}

\score {
  \new ChoirStaff <<
    \soprano
    \alto
    \tenor
    \bass
  >>
  \midi { }
  \layout { }
}

String Quartet

\version "2.20"

\header {
  title = "Title"
  composer = "Composer"
  tagline = ##f
}

global = {

}

voilin_one = \relative {
  \global
}

voilin_two = \relative {
  \global
}

viola = \relative {
  \global
}

cello = \relative {
  \global
}

\score {
  \new StaffGroup <<
    \voilin_one
    \voilin_two
    \viola
    \cello
  >>
  \midi { }
  \layout { }
}

Group without Piano

\version "2.20"

\header {
  title = "Title"
  composer = "Composer"
  tagline = ##f
}

global = {

}

oboe = \relative {
  \global
}

violin = \relative {
  \global
}

cello = \relative {
  \global
}

\score {
  <<
    \new Staff {
      \oboe
    }

    \new Staff {
      \violin
    }

    \new Staff {
      \cello
    }
  >>  \midi { }
  \layout { }
}

Group with Piano

\version "2.20"

\header {
  title = "Title"
  composer = "Composer"
  tagline = ##f
}

global = {

}

violin = \relative {
  \global
}

cello = \relative {
  \global
}

top = \relative {
  \global
}

bottom = \relative {
  \global
}

\score {
  <<
    \new Staff {
      \violin
    }

    \new Staff {
      \cello
    }

    \new PianoStaff <<
      \new Staff \top
      \new Staff \bottom
    >>
  >>
  \midi { }
  \layout { }
}

Four-part Harmony

\version "2.20"

\header {
  title = "Title"
  composer = "Composer"
  tagline = ##f
}

global = {

}

soprano = \relative {
  \global
}

alto = \relative {
  \global
}

tenor = \relative {
  \global
}

bass = \relative {
  \global
}

\score {
  \new PianoStaff <<
    \new Staff <<
      \soprano
      \\
      \alto
    >>
    \new Staff \with {
      \clef "bass"
    }
    <<
      \tenor
      \\
      \bass
    >>
  >>
  \midi { }
  \layout { }
}

License

GPL3+