Browse Source

New feature: Can now explicitely define note names

Closes #117
pull/217/head
Louis 9 years ago
parent
commit
6f3440b108
  1. 31
      patacrep/build.py
  2. 6
      patacrep/data/templates/songbook/default.tex
  3. 11
      patacrep/data/templates/songbook_model.yml

31
patacrep/build.py

@ -29,7 +29,15 @@ GENERATED_EXTENSIONS = [
"_title.sxd",
]
class BookError(errors.SharedError):
"""Global book error."""
def __init__(self, message):
super().__init__()
self.message = message
def __str__(self):
return self.message
# pylint: disable=too-few-public-methods
class Songbook:
@ -101,7 +109,11 @@ class Songbook:
)
self._config['filename'] = output.name[:-4]
# Processing special options
self._config['_bookoptions'] = iter_bookoptions(self._config)
self._config['chords']['_notenames'] = self._process_chord_notation(
self._config['chords']['notation']
)
renderer.render_tex(output, self._config)
@ -111,6 +123,25 @@ class Songbook:
if self.has_errors():
raise errors.SongbookError("Some songs contain errors. Stopping as requested.")
def _process_chord_notation(self, notation):
notation = notation.strip()
if notation in ['solfedge', 'alphascale']:
return notation
names = notation.split(" ")
if len(names) == 7:
return names
error = BookError(
"Option `notation` of section `chords` must be `solfedge`, "
"`alphascale` or a space separated list of exactly seven note "
"names."
)
self._errors.append(error)
LOGGER.warning(str(error))
if len(names) < 7:
return names + ["?"] * (7-len(names))
else:
return names[:7]
def has_errors(self):
"""Return `True` iff errors have been encountered in the book.

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

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

11
patacrep/data/templates/songbook_model.yml

@ -56,12 +56,7 @@ schema:
- type: //str
value: "ukulele"
notation:
type: //any
of:
- type: //str
value: "alphascale"
- type: //str
value: "solfedge"
type: //str
authors:
type: //rec
required:
@ -157,7 +152,7 @@ description:
lilypond: "Display lilypond scores"
tablatures: "Display tablatures"
instrument: "Instrument for the diagrams"
notation: "Chord notation"
notation: "Chord notation. Can be `solfedge`, `alphascale`, or a space separated list of note names."
authors:
separators: "Separator words between artists"
@ -183,7 +178,7 @@ description:
lilypond: "Inclure les partitions lilypond"
tablatures: "Inclure les tablatures"
instrument: "Instrument pour les diagrammes d'accords"
notation: "Notation des accords"
notation: "Notation des accords. Peut être `solfedge` (DO RE MI...), `alphascale` (A B C...), ou une liste des noms de notes séparés par des espaces, en commençant par LA."
authors:
separators: "Mots de séparation entre les artistes"

Loading…
Cancel
Save