2 ;;; chord-name.scm -- Compile chord name
4 ;;; source file of the GNU LilyPond music typesetter
6 ;;; (c) 2000--2001 Jan Nieuwenhuizen <janneke@gnu.org>
17 ;; pitch = (octave notename accidental)
19 ;; note = (notename . accidental)
21 ;; text = scm markup text -- see font.scm and input/test/markup.ly
27 ;; * clean split/merge of bass/banter/american stuff
28 ;; * handy, documented hooks for user-override of:
29 ;; - tonic (chord) name
33 (define chord::names-alist-banter '())
34 (set! chord::names-alist-banter
40 (((0 . 0) (2 . 0)) . #f)
42 (((0 . 0) (2 . -1)) . ("m"))
44 (((0 . 0) (1 . 0) (4 . 0)) . ("" (super "2")))
46 (((0 . 0) (3 . 0) (4 . 0)) . ("" (super "4")))
48 (((0 . 0) (2 . -1) (4 . -1)) . ("dim"))
50 (((0 . 0) (2 . -1) (4 . -1) (6 . -2)) . ("" (super "o")))
52 (((0 . 0) (2 . -1) (4 . -1) (6 . -2) (1 . -1)) . ("dim" (super "9")))
53 (((0 . 0) (2 . -1) (4 . -1) (6 . -2) (1 . -1) (3 . -1)) . ("dim" (super "11")))
55 chord::names-alist-banter))
61 (define (accidental->text acc)
64 (list '(music (font-relative-size . -2))
65 (string-append "accidentals-" (number->string acc)))))
67 (define (accidental->text-super acc)
70 (cons 'super (list (accidental->text acc)))))
72 (define (accidental->text-sub acc)
75 (cons sub (list accidental->text acc))))
78 ;; these look nice, but don't work together with current inner-name-jazz
79 ;; (inner-name-jazz is a bit broken: apply append etc)
80 (define (xaccidental->textp acc pos)
83 (list (list '(music (font-relative-size . -2))
84 (list pos (string-append "accidentals-" (number->string acc))))))
87 (define (xaccidental->text acc) (accidental->textp acc 'rows))
88 (define (xaccidental->text-super acc) (accidental->textp acc 'super))
89 (define (xaccidental->text-sub acc) (accidental->textp acc 'sub))
91 (define (pitch->note-name pitch)
92 (cons (cadr pitch) (caddr pitch)))
94 ;; FIXME: see german-chords.ly
95 (define (pitch->text pitch)
97 (make-string 1 (integer->char (+ (modulo (+ (cadr pitch) 2) 7) 65)))
98 (accidental->text-super (caddr pitch))))
101 ;;; Hooks to override chord names and note names,
102 ;;; see input/tricks/german-chords.ly
104 (define (pitch->text-banter pitch)
107 ;; We need also steps, to allow for Cc name override,
108 ;; see input/test/Cc-chords.ly
109 (define (pitch->chord-name-text-banter pitch steps)
110 (pitch->text-banter pitch))
112 (define (pitch->note-name-text-banter pitch)
113 (pitch->text-banter pitch))
115 (define (step->text pitch)
117 (number->string (+ (cadr pitch) (if (= (car pitch) 0) 1 8)))
125 (define (step->text-banter pitch)
126 (if (= (cadr pitch) 6)
135 (define pitch::semitone-vec (list->vector '(0 2 4 5 7 9 11)))
137 (define (pitch::semitone pitch)
138 (+ (* (car pitch) 12)
139 (vector-ref pitch::semitone-vec (modulo (cadr pitch) 7))
142 (define (pitch::< l r)
143 (< (pitch::semitone l) (pitch::semitone r)))
145 (define (pitch::transpose pitch delta)
146 (let ((simple-octave (+ (car pitch) (car delta)))
147 (simple-notename (+ (cadr pitch) (cadr delta))))
148 (let ((octave (+ simple-octave (quotient simple-notename 7)))
149 (notename (modulo simple-notename 7)))
150 (let ((accidental (- (+ (pitch::semitone pitch) (pitch::semitone delta))
151 (pitch::semitone `(,octave ,notename 0)))))
152 `(,octave ,notename ,accidental)))))
154 (define (pitch::diff pitch tonic)
155 (let ((simple-octave (- (car pitch) (car tonic)))
156 (simple-notename (- (cadr pitch) (cadr tonic))))
157 (let ((octave (+ simple-octave (quotient simple-notename 7)
158 (if (< simple-notename 0) -1 0)))
159 (notename (modulo simple-notename 7)))
160 (let ((accidental (- (pitch::semitone pitch)
161 (pitch::semitone tonic)
162 (pitch::semitone `(,octave ,notename 0)))))
163 `(,octave ,notename ,accidental)))))
165 (define (pitch::note-pitch pitch)
166 (+ (* (car pitch) 7) (cadr pitch)))
168 (define (chord::text? text)
169 (not (or (not text) (empty? text) (unspecified? text))))
171 (define (chord::text-cleanup dirty)
173 Recursively remove '() #f, and #<unspecified> from markup text tree.
174 This allows us to leave else parts of (if # #) off.
175 Otherwise, you'd have to do (if # # '()), and you'd have to
176 filter-out the '() anyway.
179 (let ((r (car dirty)))
181 (cons (if (pair? r) (chord::text-cleanup r) r)
182 (chord::text-cleanup (cdr dirty)))
183 (chord::text-cleanup (cdr dirty))))
184 (if (chord::text? dirty)
188 (define (chord::text-append l . r)
189 (if (not (chord::text? r))
191 (if (not (chord::text? l))
195 (define (chord::step tonic pitch)
196 (- (pitch::note-pitch pitch) (pitch::note-pitch tonic)))
198 ;; text: list of word
199 ;; word: string + optional list of property
200 ;; property: align, kern, font (?), size
202 (define chord::minor-major-vec (list->vector '(0 -1 -1 0 -1 -1 0)))
205 ;; compute the relative-to-tonic pitch that goes with 'step'
206 (define (chord::step-pitch tonic step)
207 ;; urg, we only do this for thirds
208 (if (= (modulo step 2) 0)
210 (let loop ((i 1) (pitch tonic))
214 pitch `(0 2 ,(vector-ref chord::minor-major-vec
215 ;; -1 (step=1 -> vector=0) + 7 = 6
216 (modulo (+ i 6) 7)))))))))
218 (define (chord::additions steps)
220 * any even step (2, 4, 6)
221 * any uneven step that is chromatically altered,
222 (where 7-- == -1, 7- == 0, 7 == +1)
227 * TODO: any uneven step that's lower than an uneven step which is
228 chromatically altered
230 (let ((evens (filter-list (lambda (x) (!= 0 (modulo (cadr x) 2))) steps))
232 (filter-list (lambda (x)
233 (let ((n (cadr x)) (a (caddr x)))
234 (or (and (= 6 n) (!= -1 a))
239 (highest (let ((h (car (last-pair steps))))
240 (if (and (not (empty? h))
245 ;; Hmm, what if we have a step twice, can we ignore that?
246 (uniq-list (sort (apply append evens altered-unevens highest)
250 ;; FIXME: unLOOP, see ::additions
251 ;; find the pitches that are missing from `normal' chord
252 (define (chord::subtractions chord-pitches)
253 (let ((tonic (car chord-pitches)))
254 (let loop ((step 1) (pitches chord-pitches) (subtractions '()))
256 (let* ((pitch (car pitches))
257 (p-step (+ (- (pitch::note-pitch pitch)
258 (pitch::note-pitch tonic))
260 ;; pitch is an subtraction if
261 ;; a step is missing or
263 (loop (+ step 2) pitches
264 (cons (chord::step-pitch tonic step) subtractions))
265 ;; there are no pitches left, but base thirds are not yet done and
267 (= (length pitches) 1))
268 ;; present pitch is not missing step
270 (loop (+ step 2) pitches subtractions)
271 (loop (+ step 2) pitches
272 (cons (chord::step-pitch tonic step) subtractions)))
274 (loop (+ step 2) (cdr pitches) subtractions)
275 (loop step (cdr pitches) subtractions)))))
276 (reverse subtractions)))))
278 (define (chord::additions->text-banter additions subtractions)
279 (if (pair? additions)
283 (cons 'super (step->text-banter (car additions)))
284 (if (or (pair? (cdr additions))
285 (pair? subtractions))
287 (chord::additions->text-banter (cdr additions) subtractions))))
289 (define (chord::subtractions->text-banter subtractions)
290 (if (pair? subtractions)
295 (cons 'super (step->text-banter (car subtractions)))
296 (if (pair? (cdr subtractions))
298 (chord::subtractions->text-banter (cdr subtractions)))))
300 (define (chord::bass-and-inversion->text-banter bass-and-inversion)
301 (if (and (pair? bass-and-inversion)
302 (or (car bass-and-inversion)
303 (cdr bass-and-inversion)))
304 (list "/" (if (car bass-and-inversion)
305 (pitch->note-name-text-banter
306 (car bass-and-inversion))
307 (pitch->note-name-text-banter
308 (cdr bass-and-inversion))))))
310 ;; FIXME: merge this function with inner-name-jazz, -american
311 ;; iso using chord::bass-and-inversion->text-banter,
312 ;; call (chord::restyle 'chord::bass-and-inversion->text- style)
313 ;; See: chord::exceptions-lookup
316 ;; Combine tonic, exception-part of chord name,
317 ;; additions, subtractions and bass or inversion into chord name
318 (define (chord::inner-name-banter tonic exception-part additions subtractions
319 bass-and-inversion steps)
320 (let ((tonic-text (pitch->chord-name-text-banter tonic steps))
321 (except-text exception-part)
322 (sep-text (if (and (string-match "super" (format "~s" exception-part))
323 (or (pair? additions)
324 (pair? subtractions)))
326 (adds-text (chord::additions->text-banter additions subtractions))
327 (subs-text (chord::subtractions->text-banter subtractions))
328 (b+i-text (chord::bass-and-inversion->text-banter bass-and-inversion)))
330 (map chord::text-cleanup
332 '(rows) tonic-text except-text sep-text adds-text subs-text
335 (define (chord::name-banter tonic exception-part unmatched-steps
336 bass-and-inversion steps)
337 (let ((additions (chord::additions unmatched-steps))
338 (subtractions (chord::subtractions unmatched-steps)))
339 (chord::inner-name-banter tonic exception-part additions subtractions
340 bass-and-inversion steps)))
343 (define (c++-pitch->scm p)
345 (list (pitch-octave p) (pitch-notename p) (pitch-alteration p))
348 (define (chord::name-banter tonic exception-part unmatched-steps
349 bass-and-inversion steps)
350 (let ((additions (chord::additions unmatched-steps))
351 (subtractions (chord::subtractions unmatched-steps)))
352 (chord::inner-name-banter tonic exception-part additions subtractions
353 bass-and-inversion steps)))
355 (define (chord::restyle name style)
356 (ly-eval (string->symbol
357 (string-append (symbol->string name)
358 (symbol->string style)))))
360 ;; check exceptions-alist for biggest matching part of try-steps
361 ;; return (MATCHED-EXCEPTION . UNMATCHED-STEPS)
362 (define (chord::exceptions-lookup-helper
363 exceptions-alist try-steps unmatched-steps exception-part)
364 (if (pair? try-steps)
365 ;; FIXME: junk '(0 . 0) from exceptions lists?
366 ;; if so: how to handle first '((0 . 0) . #f) entry?
368 ;; FIXME: either format exceptions list as real pitches, ie,
369 ;; including octave '((0 2 -1) ..), or drop octave
370 ;; from rest of calculations,
372 (map (lambda (x) (pitch->note-name x))
373 (append '((0 0 0)) try-steps))
376 (chord::exceptions-lookup-helper
377 #f '() unmatched-steps (cdr entry))
378 (let ((r (reverse try-steps)))
379 (chord::exceptions-lookup-helper
382 (cons (car r) unmatched-steps) #f))))
383 (cons exception-part unmatched-steps)))
385 ;; return (MATCHED-EXCEPTION . BASE-CHORD-WITH-UNMATCHED-STEPS)
386 ;; BASE-CHORD-WITH-UNMATCHED-STEPS always includes (tonic 3 5)
387 (define (chord::exceptions-lookup style steps)
388 (let* ((result (chord::exceptions-lookup-helper
389 (chord::restyle 'chord::names-alist- style)
391 (exception-part (car result))
392 (unmatched-steps (cdr result))
393 (matched-steps (if (= (length unmatched-steps) 0)
395 (+ 1 (- (length steps)
396 (length unmatched-steps)))))
397 (unmatched-with-1-3-5
398 (append (do ((i matched-steps (- i 1))
399 (base '() (cons `(0 ,(* (- i 1) 2) 0) base)))
403 (list exception-part unmatched-with-1-3-5)))
406 (define (chord::name->text style tonic steps bass-and-inversion)
407 (let* ((lookup (chord::exceptions-lookup style steps))
408 (exception-part (car lookup))
409 (unmatched-steps (cadr lookup)))
410 ((chord::restyle 'chord::name- style)
411 tonic exception-part unmatched-steps bass-and-inversion steps)))
415 ;; Check for each subset of chord, full chord first, if there's a
416 ;; user-override. Split the chord into user-overridden and to-be-done
417 ;; parts, complete the missing user-override matched part with normal
418 ;; chord to be name-calculated.
420 ;; CHORD: (pitches (bass . inversion))
421 (define (default-chord-name-function style chord)
422 (let* ((pitches (map c++-pitch->scm (car chord)))
423 (modifiers (cdr chord))
424 (bass-and-inversion (if (pair? modifiers)
425 (cons (c++-pitch->scm (car modifiers))
426 (c++-pitch->scm (cdr modifiers)))
428 (diff (pitch::diff '(0 0 0) (car pitches)))
429 (steps (if (cdr pitches) (map (lambda (x)
430 (pitch::transpose x diff))
433 (chord::name->text style (car pitches) steps bass-and-inversion)))
442 ;; NOTE: Duplicates of chord names defined elsewhere occur in this list
443 ;; in order to prevent spurious superscripting of various chord names,
444 ;; such as maj7, maj9, etc.
446 ;; See input/test/american-chords.ly
448 ;; James Hammons, <jlhamm@pacificnet.net>
451 ;; DONT use non-ascii characters, even if ``it works'' in Windows
453 (define chord::names-alist-american '())
455 (set! chord::names-alist-american
459 (((0 . 0) (2 . 0)) . #f)
461 (((0 . 0) (4 . 0)) . ("5"))
463 (((0 . 0) (2 . -1)) . ("m"))
464 (((0 . 0) (3 . 0) (4 . 0)) . ("sus"))
465 (((0 . 0) (2 . -1) (4 . -1)) . ("dim"))
466 ;Alternate: (((0 . 0) (2 . -1) (4 . -1)) . ("" (super "o")))
467 (((0 . 0) (2 . 0) (4 . 1)) . ("aug"))
468 ;Alternate: (((0 . 0) (2 . 0) (4 . 1)) . ("+"))
469 (((0 . 0) (1 . 0) (4 . 0)) . ("2"))
470 ;; Common seventh chords
471 (((0 . 0) (2 . -1) (4 . -1) (6 . -2)) . ("" (super "o") "7"))
472 (((0 . 0) (2 . 0) (4 . 0) (6 . 0)) . ("maj7"))
473 ;; urg! should use (0 . 0 2 . -1) -> "m", and add "7" to that!!
474 (((0 . 0) (2 . -1) (4 . 0) (6 . -1)) . ("m7"))
475 (((0 . 0) (2 . 0) (4 . 0) (6 . -1)) . ("7"))
476 (((0 . 0) (2 . -1) (4 . 0) (6 . 0)) . ("m(maj7)"))
477 ;jazz: the delta, see jazz-chords.ly
478 ;;(((0 . 0) (2 . -1) (4 . -1) (6 . -2)) . (super ((font-family . math) "N"))
479 ;; ugh, kludge slashed o
480 ;; (((0 . 0) (2 . -1) (4 . -1) (6 . -1)) . (rows ((raise . 1) "o") ((kern . -0.85) ((raise . 0.57) ((font-relative-size . -3) "/"))) "7")) ; slashed o
481 (((0 . 0) (2 . -1) (4 . -1) (6 . -1)) . (rows ((raise . 1) "o") (((kern . -0.85) (raise . 1.1) (font-relative-size . -2)) "/") "7")) ; slashed o
483 (((0 . 0) (2 . 0) (4 . 1) (6 . -1)) . ("aug7"))
484 (((0 . 0) (2 . 0) (4 . -1) (6 . 0)) . (rows "maj7" ((font-relative-size . -2) ((raise . 0.2) (music (named "accidentals--1")))) "5"))
485 (((0 . 0) (2 . 0) (4 . -1) (6 . -1)) . (rows "7" ((font-relative-size . -2) ((raise . 0.2) (music (named "accidentals--1")))) "5"))
486 (((0 . 0) (3 . 0) (4 . 0) (6 . -1)) . ("7sus4"))
487 ;; Common ninth chords
488 (((0 . 0) (2 . 0) (4 . 0) (5 . 0) (1 . 0)) . ("6/9")) ;; we don't want the '/no7'
489 (((0 . 0) (2 . 0) (4 . 0) (5 . 0)) . ("6"))
490 (((0 . 0) (2 . -1) (4 . 0) (5 . 0)) . ("m6"))
491 (((0 . 0) (2 . 0) (4 . 0) (1 . 0)) . ("add9"))
492 (((0 . 0) (2 . 0) (4 . 0) (6 . 0) (1 . 0)) . ("maj9"))
493 (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . 0)) . ("9"))
494 (((0 . 0) (2 . -1) (4 . 0) (6 . -1) (1 . 0)) . ("m9"))
497 chord::names-alist-american))
500 ;; American style chordnames use no "no",
501 ;; but otherwise very similar to banter for now
502 (define (chord::name-american tonic exception-part unmatched-steps
503 bass-and-inversion steps)
504 (let ((additions (chord::additions unmatched-steps))
506 (chord::inner-name-banter tonic exception-part additions subtractions
507 bass-and-inversion steps)))
517 ;; Jazz chords, by Atte Andr'e Jensen <atte@post.com>
518 ;; NBs: This uses the american list as a bass.
519 ;; Some defs take up more than one line,
520 ;; be carefull when messing with ;'s!!
525 ;; This is getting out-of hand? Only exceptional chord names that
526 ;; cannot be generated should be here.
527 ;; Maybe we should have inner-jazz-name and inner-american-name functions;
531 ;; DONT use non-ascii characters, even if ``it works'' in Windows
533 (define chord::names-alist-jazz '())
534 (set! chord::names-alist-jazz
538 ; major sixth chord = 6
539 (((0 . 0) (2 . 0) (4 . 0) (5 . 0)) . (((raise . 0.5) "6")))
540 ; major seventh chord = triangle
541 ;; shouldn't this be a filled black triange, like this: ? --jcn
542 ;; (((0 . 0) (2 . 0) (4 . 0) (6 . 0)) . (((raise . 0.5)((font-family . math) "N"))))
543 (((0 . 0) (2 . 0) (4 . 0) (6 . 0)) . (((raise . 0.5)((font-family . math) "M"))))
544 ; major chord add nine = add9
545 (((0 . 0) (2 . 0) (4 . 0) (1 . 0)) . (((raise . 0.5) "add9")))
546 ; major sixth chord with nine = 6/9
547 (((0 . 0) (2 . 0) (4 . 0) (5 . 0) (1 . 0)) . (((raise . 0.5) "6/9")))
550 ; minor sixth chord = m6
551 (((0 . 0) (2 . -1) (4 . 0) (5 . 0)) . (rows("m")((raise . 0.5) "6")))
552 ;; minor major seventh chord = m triangle
553 ;; shouldn't this be a filled black triange, like this: ? --jcn
554 ;;(((0 . 0) (2 . -1) (4 . 0) (6 . 0)) . (rows ("m") ((raise . 0.5)((font-family . math) "N"))))
555 (((0 . 0) (2 . -1) (4 . 0) (6 . 0)) . (rows ("m") ((raise . 0.5)((font-family . math) "M"))))
556 ; minor seventh chord = m7
557 (((0 . 0) (2 . -1) (4 . 0) (6 . -1)) . (rows("m")((raise . 0.5) "7")))
558 ; minor sixth nine chord = m6/9
559 (((0 . 0) (2 . -1) (4 . 0) (5 . 0) (1 . 0)) . (rows("m")((raise . 0.5) "6/9")))
560 ; minor with added nine chord = madd9
561 (((0 . 0) (2 . -1) (4 . 0) (1 . 0)) . (rows("m")((raise . 0.5) "add9")))
562 ; minor ninth chord = m9
563 (((0 . 0) (2 . -1) (4 . 0) (6 . -1) (1 . 0)) . (rows("m")((raise . 0.5) "9")))
566 ; dominant seventh = 7
567 (((0 . 0) (2 . 0) (4 . 0) (6 . -1)) . (((raise . 0.5) "7")))
568 ; augmented dominant = +7
569 ;(((0 . 0) (2 . 0) (4 . +1) (6 . -1)) . (((raise . 0.5) "+7"))) ; +7 with both raised
570 (((0 . 0) (2 . 0) (4 . +1) (6 . -1)) . (rows("+")((raise . 0.5) "7"))) ; +7 with 7 raised
571 ;(((0 . 0) (2 . 0) (4 . +1) (6 . -1)) . (rows((raise . 0.5) "7(")
572 ; ((raise . 0.3)(music (named ("accidentals-1"))))
573 ; ((raise . 0.5) "5)"))); 7(#5)
574 ; dominant flat 5 = 7(b5)
575 (((0 . 0) (2 . 0) (4 . -1) (6 . -1)) . (rows((raise . 0.5) "7(")
576 ((raise . 0.3)(music (named ("accidentals--1"))))
577 ((raise . 0.5) "5)")))
579 (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . 0)) . (((raise . 0.8)"7(9)")))
580 ; dominant flat 9 = 7(b9)
581 (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . -1)) . (
583 ((raise . 0.3)(music (named ("accidentals--1"))))
584 ((raise . 0.8)"9)")))
585 ; dominant sharp 9 = 7(#9)
586 (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . +1)) . (
588 ((raise . 0.3)(music (named ("accidentals-1"))))
589 ((raise . 0.8)"9)")))
590 ; dominant 13 = 7(13)
591 (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (5 . 0)) . (((raise . 0.8)"7(13)")))
592 ; dominant flat 13 = 7(b13)
593 (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (5 . -1)) . (
595 ((raise . 0.3)(music (named ("accidentals--1"))))
596 ((raise . 0.8)"13)")))
597 ; dominant 9, 13 = 7(9,13)
598 (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . 0) (5 . 0)) . (((raise . 0.8)"7(9, 13)")))
599 ; dominant flat 9, 13 = 7(b9,13)
600 (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . -1) (5 . 0)) . (
602 ((raise . 0.3)(music (named ("accidentals--1"))))
603 ((raise . 0.8)"9, 13)")))
604 ; dominant sharp 9, 13 = 7(#9,13)
605 (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . +1) (5 . 0)) . (
607 ((raise . 0.3)(music (named ("accidentals-1"))))
608 ((raise . 0.8)"9, 13)")))
609 ; dominant 9, flat 13 = 7(9,b13)
610 (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . 0) (5 . -1)) . (
611 ((raise . 0.8)"7(9, ")
612 ((raise . 0.3)(music (named ("accidentals--1"))))
613 ((raise . 0.8)"13)")))
614 ; dominant flat 9, flat 13 = 7(b9,b13)
615 (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . -1) (5 . -1)) . (
617 ((raise . 0.3)(music (named ("accidentals--1"))))
619 ((raise . 0.3)(music (named ("accidentals--1"))))
620 ((raise . 0.8)"13)")))
621 ; dominant sharp 9, flat 13 = 7(#9,b13)
622 (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . +1) (5 . -1)) . (
624 ((raise . 0.3)(music (named ("accidentals-1"))))
626 ((raise . 0.3)(music (named ("accidentals--1"))))
627 ((raise . 0.8)"13)")))
629 ;; diminished chord(s)
630 ; diminished seventh chord = o
633 ;; DONT use non-ascii characters, even if ``it works'' in Windows
635 ;;(((0 . 0) (2 . -1) (4 . -1) (6 . -2)) . ((raise . 0.8) (size . -2) ("o")))
636 (((0 . 0) (2 . -1) (4 . -1) (6 . -2)) . ("" (super "o")))
638 ;; half diminshed chords
639 ;; half diminished seventh chord = slashed o
640 ;; (((0 . 0) (2 . -1) (4 . -1) (6 . -1)) . (((raise . 0.8) "/o")))
641 (((0 . 0) (2 . -1) (4 . -1) (6 . -1)) . (rows ((raise . 1) "o") (((kern . -0.85) (raise . 1.1) (font-relative-size . -2)) "/") "7")) ; slashed o
643 ; half diminished seventh chord with major 9 = slashed o cancelation 9
644 (((0 . 0) (2 . -1) (4 . -1) (6 . -1) (1 . 0)) . (
646 ((raise . 0.3)(music (named ("accidentals-0"))))
647 ((raise . 0.8)"9)")));
649 ;; Missing jazz chord definitions go here (note new syntax: see american for hints)
652 chord::names-alist-american))
654 (define (step->text-alternate-jazz pitch)
656 (accidental->text (caddr pitch))
657 (list (number->string (+ (cadr pitch) (if (= (car pitch) 0) 1 8))))))
659 (define (step->text-jazz pitch)
660 (if (= (cadr pitch) 6)
662 ;; sharp 7 only included for completeness?
663 ((-2) (cons (accidental->text -1) '("7")))
666 ((1) (cons (accidental->text-super 1) '("7")))
667 ((2) (cons (accidental->text-super 2) '("7"))))
668 (step->text-alternate-jazz pitch)))
670 (define (chord::additions->text-jazz additions subtractions)
671 (if (pair? additions)
675 (cons 'super (step->text-jazz (car additions)))
676 (if (or (pair? (cdr additions))
677 (pair? subtractions))
679 (chord::additions->text-jazz (cdr additions) subtractions))
682 (define (chord::subtractions->text-jazz subtractions)
683 (if (pair? subtractions)
688 (cons 'super (step->text-jazz (car subtractions)))
689 (if (pair? (cdr subtractions))
691 (chord::subtractions->text-jazz (cdr subtractions)))
695 ;; TODO: maybe merge with inner-name-banter
696 ;; Combine tonic, exception-part of chord name,
697 ;; additions, subtractions and bass or inversion into chord name
698 (define (chord::inner-name-jazz tonic exception-part additions subtractions
699 bass-and-inversion steps)
707 (pitch->chord-name-text-banter tonic steps)
709 ;; why does list->string not work, format seems only hope...
710 (if (and (string-match "super" (format "~s" exception-part))
711 (or (pair? additions)
712 (pair? subtractions)))
714 (chord::additions->text-jazz additions subtractions)
715 (chord::subtractions->text-jazz subtractions)
716 (chord::bass-and-inversion->text-banter bass-and-inversion)))))
718 ;; Jazz style--basically similar to american with minor changes
720 ;; Consider Dm6. When we get here:
721 ;; tonic = '(0 1 0) (note d=2)
722 ;; steps = '((0 0 0) '(0 2 -1) (0 4 0) (0 5 0))
723 ;; steps are transposed for tonic c, octave 0,
724 ;; so (car steps) is always (0 0 0)
726 ;; assuming that the exceptions-alist has an entry
727 ;; '(((0 . 0) (2 . -1)) . ("m"))
728 ;; (and NOT the full chord, like std jazz list, ugh)
729 ;; unmatch = '((0 0 0) (0 2 0) (0 4 0) (0 5 0))
732 ;; You can look very easily what happens, if you add some write-me calls,
733 ;; and run lilypond on a simple file, eg, containing only the chord c:m6:
735 ;; (let ((additions (write-me "adds: "
736 ;; (chord::additions (write-me "unmatched:"
737 ;; unmatched-steps))))
739 ;; If you set subtract #f, the chord::inner-name-jazz does not see any
740 ;; subtractions, ever, so they don't turn up in the chord name.
742 (define (chord::name-jazz tonic exception-part unmatched-steps
743 bass-and-inversion steps)
744 (let ((additions (chord::additions unmatched-steps))
745 ;; get no 'omit' or 'no'
746 ;; (subtractions #f))
747 (subtractions (chord::subtractions unmatched-steps)))
748 (chord::inner-name-jazz tonic exception-part additions subtractions
749 bass-and-inversion steps)))
751 ;; wip (set! chord::names-alist-jazz
752 (define chord::names-alist-jazz
755 (((0 . 0) (2 . -1)) . ("m"))
758 ;;chord::names-alist-american))