]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.5.17.jcn2
authorJan Nieuwenhuizen <janneke@gnu.org>
Mon, 15 Oct 2001 15:03:56 +0000 (17:03 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Mon, 15 Oct 2001 15:03:56 +0000 (17:03 +0200)
1.5.17.jcn2

CHANGES
VERSION
input/test/midi-scales.ly [new file with mode: 0644]
input/test/scales.ly
lily/command-request.cc
lily/key-performer.cc
lily/parser.yy
modules/midi.c
scm/midi.scm
scripts/midi2ly.py

diff --git a/CHANGES b/CHANGES
index 60db4fa721649b3fc737db8b60c7ce7e3c15cb9c..4fa070cebc606b2c2ece7636591972a3b05c7fd6 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,8 +1,13 @@
-1.5.17.jcn1
+1.5.17.jcn2
 ===========
 
 * Some more random hacking at midi2ly.py.
 
+* Bugfix: Key_change_req::transpose: don't deliver reversed list.
+
+* Bugfix: Key_performer::create_audio_elements: transpose list to
+`do', before determining tonality.
+
 1.5.17
 ======
 
diff --git a/VERSION b/VERSION
index ab74d3e452e7aa1a1ef95be3d590b373e335639d..fdee57d419f4a0d8a5833a6047a78502ec0f55b4 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=5
 PATCH_LEVEL=17
-MY_PATCH_LEVEL=jcn1
+MY_PATCH_LEVEL=jcn2
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
diff --git a/input/test/midi-scales.ly b/input/test/midi-scales.ly
new file mode 100644 (file)
index 0000000..9a31e52
--- /dev/null
@@ -0,0 +1,103 @@
+\header {
+texidoc="MIDI and midi2ly test file.  Diff between this and midi2ly.py (experimental, 1.5.17) should be minimal"
+}
+
+scales = \notes {
+
+  % [INSTRUMENT_NAME] bright acoustic
+  \key c \major  % sharp-major
+  c4 d4 e4 f4 g4 a4 b4 c4 
+
+  \key g \major
+  g4 a4 b4 c4 d4 e4 fis4 g4 
+
+  \key d \major
+  d4 e4 fis4 g4 a4 b4 cis4 d4 
+
+  \key a \major
+  a4 b4 cis4 d4 e4 fis4 gis4 a4 
+
+  \key e \major
+  e4 fis4 gis4 a4 b4 cis4 dis4 e4 
+
+  \key b \major
+  b4 cis4 dis4 e4 fis4 gis4 ais4 b4 
+
+  \key fis \major
+  fis4 gis4 ais4 b4 cis4 dis4 eis4 fis4 
+
+  \key cis \major
+  cis4 dis4 eis4 fis4 gis4 ais4 bis4 cis4 
+
+  \key a \minor  % sharp-minor
+  a4 b4 c4 d4 e4 f4 gis4 a4 
+
+  \key e \minor
+  e4 fis4 g4 a4 b4 c4 dis4 e4 
+
+  \key b \minor
+  b4 cis4 d4 e4 fis4 g4 ais4 b4 
+
+  \key fis \minor
+  fis4 gis4 a4 b4 cis4 d4 eis4 fis4 
+
+  \key cis \minor
+  cis4 dis4 e4 fis4 gis4 a4 bis4 cis4 
+
+  \key gis \minor
+  gis4 ais4 b4 cis4 dis4 e4 fisis4 gis4 
+
+  \key dis \minor
+  dis4 eis4 fis4 gis4 ais4 b4 cisis4 dis4 
+
+  \key ais \minor
+  ais4 bis4 cis4 dis4 eis4 fis4 gisis4 ais4 
+
+  \key f \major  % flat-major
+  f4 g4 a4 bes4 c4 d4 e4 f4 
+
+  \key bes \major
+  bes4 c4 d4 ees4 f4 g4 a4 bes4 
+
+  \key ees \major
+  ees4 f4 g4 aes4 bes4 c4 d4 ees4 
+
+  \key aes \major
+  aes4 bes4 c4 des4 ees4 f4 g4 aes4 
+
+  \key des \major
+  des4 ees4 f4 ges4 aes4 bes4 c4 des4 
+
+  \key ges \major
+  ges4 aes4 bes4 ces'4 des4 ees4 f4 ges4 
+
+  \key ces \major
+  ces'4 des4 ees4 fes4 ges4 aes4 bes4 ces'4 
+
+  \key d \minor  % flat-minor
+  d4 e4 f4 g4 a4 bes4 cis4 d4 
+
+  \key g \minor
+  g4 a4 bes4 c4 d4 ees4 fis4 g4 
+
+  \key c \minor
+  c4 d4 ees4 f4 g4 aes4 b4 c4 
+
+  \key f \minor
+  f4 g4 aes4 bes4 c4 des4 e4 f4 
+
+  \key bes \minor
+  bes4 c4 des4 ees4 f4 ges4 a4 bes4 
+
+  \key ees \minor
+  ees4 f4 ges4 aes4 bes4 ces'4 d4 ees4 
+
+  \key aes \minor
+  aes4 bes4 ces'4 des4 ees4 fes4 g4 aes4 
+}
+
+\score {
+  \context Voice \scales
+  \paper { }
+  \midi { }
+}
index 151c9e10cebbd091067e31d07017d5816f783934..f2eb85fb4cbc6eac96d48e9b137b4943f129e2eb 100644 (file)
        es,, f ges as bes ces d es
        
        \key as\minor
-       as, bes ces des es fes g as}
+       as, bes ces des es fes g as
+}
 
   \paper { }  
   \midi { }
index 51bb291202d72ee479ce4bd2fdb590da13a014af..13089e274377c011f99f4766cba8b2ddbf0fd760 100644 (file)
@@ -56,7 +56,7 @@ Key_change_req::transpose (Pitch p)
        }
     }
 
-  set_mus_property ("pitch-alist", newlist);
+  set_mus_property ("pitch-alist", gh_reverse (newlist));
 }
 
 
index 22a3f2c84a014719db2638ec9a412e68f8bc47cb..e1c335ca0136687c09bf6e16af6cbbbb3f142925 100644 (file)
@@ -11,6 +11,7 @@
 #include "audio-item.hh"
 #include "performer.hh"
 
+
 class Key_performer : public Performer
 {
 public:
@@ -46,7 +47,24 @@ Key_performer::create_audio_elements ()
       SCM proc = scm_primitive_eval (ly_symbol2scm ("accidentals-in-key")); 
       SCM acc = gh_call1 (proc, pitchlist);
       proc = scm_primitive_eval (ly_symbol2scm ("major-key"));
-      SCM major = gh_call1 (proc, pitchlist);
+      Pitch my_do (0, 
+                  gh_scm2int (ly_caar (pitchlist)),
+                  gh_scm2int (ly_cdar (pitchlist)));
+                 
+      Pitch to_c (-1,
+                  (7 - gh_scm2int (ly_caar (pitchlist))) % 7,
+                  -gh_scm2int (ly_cdar (pitchlist)));
+
+      my_do.transpose (to_c);
+      to_c.alteration_i_ -= my_do.alteration_i_;
+
+      Key_change_req *key = new Key_change_req;
+      key->set_mus_property ("pitch-alist", scm_list_copy (pitchlist));
+      ((Music*)key)->transpose (to_c);
+      SCM c_pitchlist = key->get_mus_property ("pitch-alist");
+      SCM major = gh_call1 (proc, c_pitchlist);
+
       audio_p_ = new Audio_key (gh_scm2int (acc), major == SCM_BOOL_T); 
       Audio_element_info info (audio_p_, key_req_l_);
       announce_element (info);
index 85278a58f7daaab764e7511f8afde08b613f4ebd..27e3e1cdec00f57a6153194d9776602c4ed8b4eb 100644 (file)
@@ -1278,7 +1278,7 @@ verbose_command_req:
                Key_change_req *key_p= new Key_change_req;
                
                key_p->set_mus_property ("pitch-alist", $3);
((Music* )key_p)->transpose (* unsmob_pitch ($2));
              ((Music*)key_p)->transpose (* unsmob_pitch ($2));
                $$ = key_p; 
        }
        ;
index e1153f23d79ab2621c1bbe991de33432765d96b7..a5fab33c309aeaa9c816657d09c439851d6f8415 100644 (file)
@@ -196,7 +196,7 @@ read_string (unsigned char **track, unsigned char *end)
     length = end - *track;
 
   *track += length;
-  return Py_BuildValue ("s", ((*track) -length));
+  return Py_BuildValue ("s#", ((*track) -length), length);
 }
 
 typedef PyObject* (*Read_midi_event)
@@ -215,14 +215,8 @@ read_f0_byte (unsigned char **track, unsigned char *end,
       unsigned char z = (*track)[0 ];
       *track += 1;
       debug_print ("%x:%s", z, "f0-event\n");
-      
-      if (z == 0x2f && (*track)[0] == 0x00) /* end of track */
-       {
-         *track += 1;
-         return 0;
-       }
-      else
-       return Py_BuildValue ("(iiO)", x, z, read_string (track, end));
+
+      return Py_BuildValue ("(iiO)", x, z, read_string (track, end));
     }
 
   return Py_BuildValue ("(iO)", x, read_string (track, end));
index 46cb81c803e412000f430a46c454a2ff53356c24..e4b57135efcf2cd653c0d7a59674aee3804d7361 100644 (file)
   (apply + (map cdr pitch-list)))
 
 ;; Characterise the key as major if the alteration of the 
-;; third scale note is the same as that of the main note
+;; third scale note is the same as that of the main note.
 ;; Note: MIDI cannot handle other tonalities than major/minor.
 (define (major-key pitch-list)
-  (eq? (cdr (list-ref pitch-list 4)) (cdr (list-ref pitch-list 6))))
+  ;; This charactersition is only true for a scale that starts at `c'.
+  (if (not (equal? (car pitch-list) '(0 . 0)))
+      (begin
+       (ly-warn "Attempt to determine tonality of transposed scale")
+       #t)
+  (eq? (cdr (list-ref pitch-list 4)) (cdr (list-ref pitch-list 6)))))
index 96f19649b244614a4663bfac52d9d4ac538500c9..9c5ff1845246baaec58738bfac037da15cfaf269 100644 (file)
@@ -60,12 +60,13 @@ class Note:
        def dump (self):
                # major scale: do-do
                # minor scale: la-la  (= + 5) '''
-       
-               n = self.names[self.pitch % 12]
-               a = self.accidentals[(key.minor * 5 + self.pitch) % 12]
+
+               n = self.names[(self.pitch) % 12]
+               a = self.accidentals[(self.pitch) % 12]
+
                if a and key.flats:
-                       a = -a
-                       n = (n + 1) % 7
+                       a = - self.accidentals[(self.pitch) % 12]
+                       n = (n - a) % 7
 
                name = chr ((n + 2)  % 7 + ord ('a'))
 
@@ -98,6 +99,8 @@ class Note:
                #
                #  --jcn
 
+               o = self.pitch / 12 - 4
+
                if key.minor:
                        if key.sharps == 0 and key.flats == 0 and name == 'as':
                                name = 'gis'
@@ -111,15 +114,21 @@ class Note:
                                name = 'cisis'
                        elif key.sharps == 7 and name == 'a':
                                name = 'gisis'
-                               
-                       if key.flats >= 6 and name == 'b':
-                               name = 'ces'
-                       if key.sharps >= 7 and name == 'e':
-                               name = 'fes'
+
+               if key.flats >= 6 and name == 'b':
+                       name = 'ces'
+                       o = o + 1
+               if key.flats >= 7 and name == 'e':
+                       name = 'fes'
+
+               if key.sharps >= 3 and name == 'f':
+                       name = 'eis'
+               if key.sharps >= 4 and name == 'c':
+                       name = 'bis'
+                       o = o - 1
 
                 s = name
                
-               o = self.pitch / 12 - 4
                if o > 0:
                        s = s + "'" * o
                elif o < 0:
@@ -257,17 +266,14 @@ def events_on_channel (channel):
                                den = 2 ** dur 
                                events.append ((t, Time (num, den)))
                        elif e[1][1] == midi.KEY_SIGNATURE:
-                               if len (e[1][2]) != 2:
-                                       # circumvent lilypond bug
-                                       (accidentals, minor) = (0,0)
-                               else:   
-                                       (accidentals, minor) = map (ord, e[1][2])
+                               (accidentals, minor) = map (ord, e[1][2])
                                sharps = 0
                                flats = 0
                                if accidentals < 127:
                                        sharps = accidentals
                                else:
                                        flats = 256 - accidentals
+
                                events.append ((t, Key (sharps, flats, minor)))
                        elif e[1][1] >= midi.SEQUENCE_NUMBER and e[1][1] <= midi.CUE_POINT:
                                events.append ((t, Text (e[1][1], e[1][2])))
@@ -378,7 +384,8 @@ def dump_channel (thread):
 
        lines = ['']
        for ch in chs:
-               if len (lines[-1]) > LINE_BELL:
+               i = string.rfind (lines[-1], '\n')
+               if len (lines[-1][i:]) > LINE_BELL:
                        lines.append ('')
                        
                t = ch[0]