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", "_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 # pylint: disable=too-few-public-methods
class Songbook: class Songbook:
@ -101,7 +109,11 @@ class Songbook:
) )
self._config['filename'] = output.name[:-4] self._config['filename'] = output.name[:-4]
# Processing special options
self._config['_bookoptions'] = iter_bookoptions(self._config) 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) renderer.render_tex(output, self._config)
@ -111,6 +123,25 @@ class Songbook:
if self.has_errors(): if self.has_errors():
raise errors.SongbookError("Some songs contain errors. Stopping as requested.") 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): def has_errors(self):
"""Return `True` iff errors have been encountered in the book. """Return `True` iff errors have been encountered in the book.

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

@ -85,10 +85,12 @@ description:
\authsepword{((word))} \authsepword{((word))}
(* endfor *) (* endfor *)
(* if chords.notation=="alphascale" -*) (* if chords._notenames == "alphascale" -*)
\notenamesout{A}{B}{C}{D}{E}{F}{G} \notenamesout{A}{B}{C}{D}{E}{F}{G}
(* else -*) (* elif chords._notenames == "solfedge" -*)
\notenamesout{La}{Si}{Do}{R\'e}{Mi}{Fa}{Sol} \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 *) (* endif *)
(* endblock *) (* endblock *)

11
patacrep/data/templates/songbook_model.yml

@ -56,12 +56,7 @@ schema:
- type: //str - type: //str
value: "ukulele" value: "ukulele"
notation: notation:
type: //any type: //str
of:
- type: //str
value: "alphascale"
- type: //str
value: "solfedge"
authors: authors:
type: //rec type: //rec
required: required:
@ -157,7 +152,7 @@ description:
lilypond: "Display lilypond scores" lilypond: "Display lilypond scores"
tablatures: "Display tablatures" tablatures: "Display tablatures"
instrument: "Instrument for the diagrams" instrument: "Instrument for the diagrams"
notation: "Chord notation" notation: "Chord notation. Can be `solfedge`, `alphascale`, or a space separated list of note names."
authors: authors:
separators: "Separator words between artists" separators: "Separator words between artists"
@ -183,7 +178,7 @@ description:
lilypond: "Inclure les partitions lilypond" lilypond: "Inclure les partitions lilypond"
tablatures: "Inclure les tablatures" tablatures: "Inclure les tablatures"
instrument: "Instrument pour les diagrammes d'accords" 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: authors:
separators: "Mots de séparation entre les artistes" separators: "Mots de séparation entre les artistes"

Loading…
Cancel
Save