diff options
author | Carl Sorensen <c_sorensen@byu.edu> | 2010-12-23 08:19:46 -0700 |
---|---|---|
committer | Carl Sorensen <c_sorensen@byu.edu> | 2011-01-07 03:54:33 -0700 |
commit | 17f11c2f5ab963bfb07b7652b4860dc4dda5540a (patch) | |
tree | 97d086112dbe48c06e3f848a37d3e4c5e21b1902 /ly | |
parent | 283d0306745f28a1a8a8cade05ff5bf220d511b6 (diff) |
Change stringTunings from list of semitones to list of pitches
This will allow the creation of a tab key that will list the tuning
of each of the strings.
* ly/string-tuning-init.ly
- define music function makeStringTuning that accepts a chord
in absolute octave mode to define string tuning.
- define music function contextStringTuning that performs the
function of makeStringTuning but also sets TabStaff.stringTunings
and FretBoards.stringTunings to the newly-defined tuning
- include predefined string tunings in makeStringTuning format
- add predefined tunings for orchestral strings
* scm/tablature.scm
- Eliminate the predefined string tunings (they're moved to
ly/string-tuning-init.ly
* python/convertrules.py
- Add rule to convert \set stringTunings = #'(...) to
\set stringTunings = #`((ly:make-pitch x y z)...)
with ly:make-pitch entries automatically calculated.
* Documentation/*
- Update documentation as necessary.
- Added automatically-generate list of predefined string tunings.
* input/regression/*
- Update regression tests for new syntax.
* Add changes entry
* Modify code in changes
* run makelsr.py
Diffstat (limited to 'ly')
-rw-r--r-- | ly/declarations-init.ly | 47 | ||||
-rw-r--r-- | ly/string-tunings-init.ly | 135 |
2 files changed, 160 insertions, 22 deletions
diff --git a/ly/declarations-init.ly b/ly/declarations-init.ly index 08ff4d21a3..39aeabdb61 100644 --- a/ly/declarations-init.ly +++ b/ly/declarations-init.ly @@ -94,6 +94,31 @@ melismaEnd = #(context-spec-music (make-property-unset 'melismaBusy) 'Bottom) laissezVibrer = #(make-music 'LaissezVibrerEvent) repeatTie = #(make-music 'RepeatTieEvent) +\include "dynamic-scripts-init.ly" +\include "spanners-init.ly" + +%% MAKE-HASH-TABLE in GUILE 1.6 takes mandatory size parameter. +#(define musicQuotes (make-hash-table 29)) + +#(define toplevel-book-handler print-book-with-defaults) +#(define toplevel-bookpart-handler collect-bookpart-for-book) +#(define toplevel-music-handler collect-music-for-book) +#(define toplevel-score-handler collect-scores-for-book) +#(define toplevel-text-handler collect-scores-for-book) + +#(define book-bookpart-handler ly:book-add-bookpart!) +#(define book-music-handler collect-book-music-for-book) +#(define book-score-handler ly:book-add-score!) +#(define book-text-handler ly:book-add-score!) + +#(define bookpart-score-handler ly:book-add-score!) +#(define bookpart-text-handler ly:book-add-score!) +#(define bookpart-music-handler collect-book-music-for-book) + +\include "predefined-fretboards-init.ly" +\include "string-tunings-init.ly" +\include "property-init.ly" + \include "grace-init.ly" \include "midi-init.ly" \include "paper-defaults-init.ly" @@ -112,7 +137,6 @@ repeatTie = #(make-music 'RepeatTieEvent) } #(set-default-paper-size (ly:get-option 'paper-size)) - partCombineListener = \layout { \context { \Score @@ -122,28 +146,7 @@ partCombineListener = \layout { } } -\include "dynamic-scripts-init.ly" -\include "spanners-init.ly" -\include "property-init.ly" - setDefaultDurationToQuarter = { c4 } -%% MAKE-HASH-TABLE in GUILE 1.6 takes mandatory size parameter. -#(define musicQuotes (make-hash-table 29)) -#(define toplevel-book-handler print-book-with-defaults) -#(define toplevel-bookpart-handler collect-bookpart-for-book) -#(define toplevel-music-handler collect-music-for-book) -#(define toplevel-score-handler collect-scores-for-book) -#(define toplevel-text-handler collect-scores-for-book) - -#(define book-bookpart-handler ly:book-add-bookpart!) -#(define book-music-handler collect-book-music-for-book) -#(define book-score-handler ly:book-add-score!) -#(define book-text-handler ly:book-add-score!) -#(define bookpart-score-handler ly:book-add-score!) -#(define bookpart-text-handler ly:book-add-score!) -#(define bookpart-music-handler collect-book-music-for-book) - -\include "predefined-fretboards-init.ly" diff --git a/ly/string-tunings-init.ly b/ly/string-tunings-init.ly new file mode 100644 index 0000000000..5bcdbfdd86 --- /dev/null +++ b/ly/string-tunings-init.ly @@ -0,0 +1,135 @@ +%%%% This file is part of LilyPond, the GNU music typesetter. +%%%% +%%%% Copyright (C) 2010 Carl D. Sorensen <c_sorensen@byu.edu> +%%%% +%%%% LilyPond is free software: you can redistribute it and/or modify +%%%% it under the terms of the GNU General Public License as published by +%%%% the Free Software Foundation, either version 3 of the License, or +%%%% (at your option) any later version. +%%%% +%%%% LilyPond is distributed in the hope that it will be useful, +%%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%%%% GNU General Public License for more details. +%%%% +%%%% You should have received a copy of the GNU General Public License +%%%% along with LilyPond. If not, see <http://www.gnu.org/licenses/>. + +\version "2.13.46" + +%% A stringTuning is a list of pitches ordered by string number +%% from 1 to N. +%% Here we define a number of default string tunings. + +%% A scheme function for converting a chord to a string tuning +#(define (chord->tuning parser tuning-symbol chord) + (let* ((ev-chord (car (extract-named-music chord 'EventChord))) + (pitches (event-chord-pitches ev-chord))) + (ly:parser-define! parser tuning-symbol (reverse pitches)))) + +%% A music function for converting a chord to a string tuning. +%% The music argument for \makeStringTuning must be a chord in +%% absolute mode ordered from the highest string number to the +%% lowest string number + +makeStringTuning = +#(define-music-function (parser location tuning chord) + (symbol? ly:music?) + (_ "Convert @{chord} to a string tuning stored in @code{tuning}. +@{chord} must be in absolute pitches and should have the highest +string number (generally the lowest pitch) first. @code{tuning} +should be a string that will be converted to a symbol.") + (begin + (chord->tuning parser tuning chord) + (make-music 'SequentialMusic 'void #t))) + + +%% A music function for converting a chord to a string tuning +%% and setting the current context stringTunings property to +%% the newly-defined-string tuning. + +contextStringTuning = +#(define-music-function (parser location tuning chord) + (symbol? ly:music?) + (_ "Convert @{chord} to a string tuning stored in @code{tuning}, +and set @code{stringTunings} of the current context to the +newly-defined tuning. +@{chord} must be in absolute pitches and should have the highest +string number (generally the lowest pitch) first. @code{tuning} +should be a string that will be converted to a symbol.") + (begin + (chord->tuning parser tuning chord) + #{ + \set TabStaff.stringTunings = $(ly:parser-lookup parser tuning) + \set FretBoards.stringTunings = $(ly:parser-lookup parser tuning) + #})) + +%% A music function for converting an alist to string-tunings +makeDefaultStringTunings = +#(define-music-function (parser location default-tuning-alist) + (cheap-list?) + (_ "Define default string tunings for each element of +@code{default-tuning-alist}.") + (begin + (for-each (lambda (alist-entry) + (chord->tuning parser (car alist-entry) (cdr alist-entry))) + default-tuning-alist) + (make-music 'SequentialMusic 'void #t))) + +% tuning definitions require default pitchnames +\languageSaveAndChange #default-language + +%% Define alist of default string tunings +defaultStringTunings = +#`( + ;; guitar tunings + (guitar-tuning . ,#{<e, a, d g b e'>#}) + (guitar-seven-string-tuning . ,#{<b,, e, a, d g b e'>#}) + (guitar-drop-d-tuning . ,#{<d, a, d g b e'>#}) + (guitar-open-g-tuning . ,#{<d, g, d g b d'>#}) + (guitar-open-d-tuning . ,#{<d, a, d fis a d'>#}) + (guitar-dadgad-tuning . ,#{<d, a, d g a d'>#}) + (guitar-lute-tuning . ,#{<e, a, d fis b e'>#}) + (guitar-asus4-tuning . ,#{<e, a, d e a e'>#}) + + ;; bass tunings + (bass-tuning . ,#{<e,, a,, d, g,>#}) + (bass-four-string-tuning . ,#{<e,, a,, d, g,>#}) + (bass-drop-d-tuning . ,#{<d,, a,, d, g,>#}) + (bass-five-string-tuning . ,#{<b,,, e,, a,, d, g,>#}) + (bass-six-string-tuning . ,#{<b,,, e,, a,, d, g, c>#}) + + ;; mandolin tunings + (mandolin-tuning . ,#{<g d' a' e''>#}) + + ;; tunings for 5-string banjo + (banjo-open-g-tuning . ,#{<g' d g b d'>#}) + (banjo-c-tuning . ,#{<g' c g b d'>#}) + (banjo-modal-tuning . ,#{<g' d g c' d'>#}) + (banjo-open-d-tuning . ,#{<a' d fis a d'>#}) + (banjo-open-dm-tuning . ,#{<a' d fis a d'>#}) + + ;; ukulele tunings + (ukulele-tuning . ,#{<g' c' e' a'>#}) + (ukulele-d-tuning . ,#{<a' d' fis' b'>#}) + (tenor-ukulele-tuning . ,#{<a' e' c' g>#}) + (baritone-ukulele-tuning . ,#{<e' b g d>#}) + + ;; orchestral strings + (violin-tuning . ,#{<g d' a' e''>#}) + (viola-tuning . ,#{<c g d' a'>#}) + (cello-tuning . ,#{<c, g, d a>#}) + (double-bass-tuning . ,#{<e,, a,, d, g,>#}) + ) + +%% convert 5-string banjo tuning to 4-string by removing the 5th string +#(define-public (four-string-banjo tuning) + (reverse (cdr (reverse tuning)))) + +%% make all of the default string tunings + +\makeDefaultStringTunings #defaultStringTunings + +% restore the language +\languageRestore + |