-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
======
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.
--- /dev/null
+\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 { }
+}
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 { }
}
}
- set_mus_property ("pitch-alist", newlist);
+ set_mus_property ("pitch-alist", gh_reverse (newlist));
}
#include "audio-item.hh"
#include "performer.hh"
+
class Key_performer : public Performer
{
public:
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);
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;
}
;
length = end - *track;
*track += length;
- return Py_BuildValue ("s", ((*track) -length));
+ return Py_BuildValue ("s#", ((*track) -length), length);
}
typedef PyObject* (*Read_midi_event)
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));
(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)))))
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'))
#
# --jcn
+ o = self.pitch / 12 - 4
+
if key.minor:
if key.sharps == 0 and key.flats == 0 and name == 'as':
name = 'gis'
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:
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])))
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]