commit 65edd010d82cf93469ea6be773528e7ee4744017
parent 874456f641efd2f86160ae6d735ec16bcf481858
Author: nibo <nibo@relim.de>
Date: Sun, 1 Dec 2024 17:27:43 +0100
chord diagram: show transformed chord name
Depending on the notation system configured chord names
might show up different than specified in the file.
e.g. the chord 'Bm' will show up as 'Hm' in the german
notation system.
Diffstat:
2 files changed, 4 insertions(+), 19 deletions(-)
diff --git a/chord_diagram.c b/chord_diagram.c
@@ -321,17 +321,10 @@ string_diagram_free(struct StringDiagram *d)
free(d);
}
-/* struct StringDiagram {
- char *name;
- int8_t base_fret;
- int8_t frets[12];
- int8_t fingers[12];
-}; */
static struct StringDiagram *
-string_diagram_copy(struct StringDiagram *diagram)
+string_diagram_copy_all_but_name(struct StringDiagram *diagram)
{
struct StringDiagram *copy = emalloc(sizeof(struct StringDiagram));
- copy->name = strdup(diagram->name);
copy->base_fret = diagram->base_fret;
copy->frets[0] = diagram->frets[0];
copy->frets[1] = diagram->frets[1];
@@ -547,23 +540,21 @@ chord_diagrams_create(struct Config *config, struct ChoChord ***chords)
{
struct ChordDiagram **diagrams = NULL;
struct ChoChord **c = *chords;
- char *name;
int d = 0;
size_t i;
switch (config->output->diagram->instrument) {
case INS_GUITAR:
while (*c) {
- name = cho_chord_name_generate(*c);
for (i = 0; i<LENGTH(guitar_diagrams); i++) {
- if (!strcmp(name, guitar_diagrams[i].name)) {
+ if (!strcmp((*c)->name, guitar_diagrams[i].name)) {
diagrams = erealloc(diagrams, (d+1) * sizeof(struct ChordDiagram *));
diagrams[d] = emalloc(sizeof(struct ChordDiagram));
diagrams[d]->is_string_instrument = true;
- diagrams[d]->u.sd = string_diagram_copy(&guitar_diagrams[i]);
+ diagrams[d]->u.sd = string_diagram_copy_all_but_name(&guitar_diagrams[i]);
+ diagrams[d]->u.sd->name = cho_chord_name_generate(*c);
d++;
}
}
- free(name);
c++;
}
break;
diff --git a/out_pdf.c b/out_pdf.c
@@ -820,7 +820,6 @@ out_pdf_get_chords(struct ChoSong **songs, struct ChoChord ***chords)
struct ChoSection **se;
struct ChoLine **li;
struct ChoLineItemAbove **above;
- // char *name;
while (*s) {
se = (*s)->sections;
while (*se) {
@@ -832,11 +831,6 @@ out_pdf_get_chords(struct ChoSong **songs, struct ChoChord ***chords)
if (!cho_chords_has(*chords, (*above)->u.chord)) {
cho_chords_add(chords, (*above)->u.chord);
}
- /* name = cho_chord_name_generate((*above)->u.chord);
- if (!strs_has(*chords, name)) {
- strs_add(chords, name);
- }
- free(name); */
}
above++;
}