Notes in lower strings
authorJelmer Vernooij <jelmer@samba.org>
Fri, 18 Jun 2004 06:32:58 +0000 (07:32 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 18 Jun 2004 06:32:58 +0000 (07:32 +0100)
ChangeLog
ptb2ly.c

index 4bc49f08ab05e7c737be58ecc6dc72a508f7ad78..68750ba0f2fac7851d66ced5438f105c7097650e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@ All changes, unless specified otherwise, made by Jelmer Vernooij
  * Keep beaming information
  * Escape invalid lilypond stuff
  * Generate MusicXML using XSL script
+ * Fix a couple of problems with notes in lower strings
  * Various other improvements
 
 0.2:
index f79d75f6219a9cb2aeac21cdf6f347fe1fc34059..f28516a2f9a362215f1053cb03359d714b5dd2b1 100644 (file)
--- a/ptb2ly.c
+++ b/ptb2ly.c
@@ -22,7 +22,7 @@
 #include "ptb.h"
 
 char *note_names[12] = {
-       "a", "ais", "b", "c", "cis", "d", "dis", "e", "f", "fis", "g", "gis"
+        "a", "ais", "b", "c", "cis", "d", "dis", "e", "f", "fis", "g", "gis"
 };
 
 char *ly_escape(char *data)
@@ -159,25 +159,25 @@ void ly_write_position(FILE *out, struct ptb_position *pos)
                struct ptb_linedata *d = gl->data;
                int note = d->detailed.fret;
                int i;
-               int j;
+               int octave;
+#define DEFAULT_OCTAVE 4
                
                switch(d->detailed.string) {
-               case 0: note+= 19; break;
-               case 1: note+= 14; break;
-               case 2: note+= 10; break;
-               case 3: note+= 5; break;
-               case 4: note+= 0; break;
-               case 5: note+= -7; break;
+               case 0: note+= 64; break;
+               case 1: note+= 59; break;
+               case 2: note+= 55; break;
+               case 3: note+= 50; break;
+               case 4: note+= 45; break;
+               case 5: note+= 40; break;
+               default:fprintf(stderr, "Unknown string %d", d->detailed.string);
                }
                
-               fprintf(out, "%s", note_names[abs(note)%12]);
+               fprintf(out, "%s", note_names[(note+3)%12]);
 
-               j = abs((note+9) / 12);
-               if(note < 0) {
-                       for(i = j; i < 1; i++) fprintf(out, ",");
-               } else if(note > 0) {
-                       for(i = 1; i < j; i++) fprintf(out, "'");
-               }
+               octave = note / 12;
+
+               for(i = octave; i < DEFAULT_OCTAVE; i++) fprintf(out, ",");
+               for(i = DEFAULT_OCTAVE; i < octave; i++) fprintf(out, "'");
 
                if(pos->palm_mute & POSITION_STACCATO) 
                        fprintf(out, "-.");