Browse Source

Merge pull request #217 from patacrep/notenames

New feature: Can now explicitely define note names
pull/219/head
Louis 9 years ago
parent
commit
2a46dff1e6
  1. 15
      patacrep/build.py
  2. 6
      patacrep/data/templates/songbook/default.tex
  3. 21
      patacrep/data/templates/songbook_model.yml

15
patacrep/build.py

@ -29,8 +29,6 @@ GENERATED_EXTENSIONS = [
"_title.sxd",
]
# pylint: disable=too-few-public-methods
class Songbook:
"""Represent a songbook (.yaml) file.
@ -101,7 +99,11 @@ class Songbook:
)
self._config['filename'] = output.name[:-4]
# Processing special options
self._config['_bookoptions'] = iter_bookoptions(self._config)
self._config['chords']['_notenames'] = self._get_chord_names(
self._config['chords']['notation']
)
renderer.render_tex(output, self._config)
@ -111,6 +113,15 @@ class Songbook:
if self.has_errors():
raise errors.SongbookError("Some songs contain errors. Stopping as requested.")
@staticmethod
def _get_chord_names(notation):
"""Return a list of chord names, given the user option."""
if notation == "alphascale":
return ["A", "B", "C", "D", "E", "F", "G"]
if notation == "solfedge":
return ["La", "Si", "Do", r"R\'e", "Mi", "Fa", "Sol"]
return notation
def has_errors(self):
"""Return `True` iff errors have been encountered in the book.

6
patacrep/data/templates/songbook/default.tex

@ -85,11 +85,7 @@ description:
\authsepword{((word))}
(* endfor *)
(* if chords.notation=="alphascale" -*)
\notenamesout{A}{B}{C}{D}{E}{F}{G}
(* else -*)
\notenamesout{La}{Si}{Do}{R\'e}{Mi}{Fa}{Sol}
(* endif *)
\notenamesout{(( chords._notenames[0] ))}{(( chords._notenames[1] ))}{(( chords._notenames[2] ))}{(( chords._notenames[3] ))}{(( chords._notenames[4] ))}{(( chords._notenames[5] ))}{(( chords._notenames[6] ))}
(* endblock *)
(* block title *)

21
patacrep/data/templates/songbook_model.yml

@ -56,12 +56,17 @@ schema:
- type: //str
value: "ukulele"
notation:
type: //any
of:
- type: //str
value: "alphascale"
- type: //str
value: "solfedge"
type: //any
of:
- type: //str
value: "alphascale"
- type: //str
value: "solfedge"
- type: //arr
contents: //str
length:
min: 7
max: 7
authors:
type: //rec
required:
@ -157,7 +162,7 @@ description:
lilypond: "Display lilypond scores"
tablatures: "Display tablatures"
instrument: "Instrument for the diagrams"
notation: "Chord notation"
notation: "List of chord names, with special values `solfedge` being an alias for `['La', 'Si', 'Do', 'Ré', 'Mi', 'Fa', 'Sol']`, and `alphascale` for `['A', 'B', 'C', 'D', 'E', 'F', 'G']`."
authors:
separators: "Separator words between artists"
@ -183,7 +188,7 @@ description:
lilypond: "Inclure les partitions lilypond"
tablatures: "Inclure les tablatures"
instrument: "Instrument pour les diagrammes d'accords"
notation: "Notation des accords"
notation: "Liste des noms de notes, en commençant par LA, sachant que `solfedge` est un alias pour `['La', 'Si', 'Do', 'Ré', 'Mi', 'Fa', 'Sol']`, et `alphascale` pour `['A', 'B', 'C', 'D', 'E', 'F', 'G']`."
authors:
separators: "Mots de séparation entre les artistes"

Loading…
Cancel
Save