]> git.donarmstrong.com Git - lilypond.git/blob - scm/chord-name.scm
patch::: 1.3.112.jcn3
[lilypond.git] / scm / chord-name.scm
1 ;;;
2 ;;; chord-name.scm -- Compile chord name
3 ;;;
4 ;;; source file of the GNU LilyPond music typesetter
5 ;;; 
6 ;;; (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
7 ;;;
8
9
10 (use-modules
11    (ice-9 debug)
12    ;; urg, these two only to guess if a '/' is needed to separate
13    ;; user-chord-name and additions/subtractions
14    (ice-9 format)
15    (ice-9 regex)
16    )
17
18 ;;
19 ;; (octave notename accidental)
20 ;;
21
22 ;;
23 ;; text: scm markup text -- see font.scm and input/test/markup.ly
24 ;;
25
26 ;; TODO
27 ;;
28 ;; * clean split of base/banter/american stuff
29 ;; * text definition is rather ad-hoc
30 ;; * do without format module
31 ;; * finish and check american names
32 ;; * make notename (tonic) configurable from lilypond
33 ;; * fix append/cons stuff in inner-name-banter
34 ;; * doc strings.
35
36 ;;;;;;;;;
37 (define chord::names-alist-banter '())
38 (set! chord::names-alist-banter
39       (append 
40         '(
41         ; C iso C.no3.no5
42         (((0 . 0)) . #f)
43         ; C iso C.no5
44         (((0 . 0) (2 . 0)) . #f)
45         ; Cm iso Cm.no5
46         (((0 . 0) (2 . -1)) . ("m"))
47         ; C2 iso C2.no3
48         (((0 . 0) (1 . 0) (4 . 0)) . (super "2"))
49         ; C4 iso C4.no3
50         (((0 . 0) (3 . 0) (4 . 0)) . (super "4"))
51         ; Cdim iso Cm5-
52         (((0 . 0) (2 . -1) (4 . -1)) . ("dim"))
53         ; Co iso Cm5-7-
54         ; urg
55         (((0 . 0) (2 . -1) (4 . -1) (6 . -2)) . (super "o"))
56         ; Cdim9
57         (((0 . 0) (2 . -1) (4 . -1) (6 . -2) (1 . -1)) . ("dim" (super "9")))
58         (((0 . 0) (2 . -1) (4 . -1) (6 . -2) (1 . -1) (3 . -1)) . ("dim" (super "11")))
59         )
60       chord::names-alist-banter))
61
62
63 ;; NOTE: Duplicates of chord names defined elsewhere occur in this list
64 ;; in order to prevent spurious superscripting of various chord names,
65 ;; such as maj7, maj9, etc.
66 ;;
67 ;; See input/test/american-chords.ly
68 ;;
69 ;; James Hammons, <jlhamm@pacificnet.net>
70 ;;
71
72 ;; DONT use non-ascii characters, even if ``it works'' in Windows
73
74 (define chord::names-alist-american '())
75
76 (set! chord::names-alist-american
77       (append 
78        '(
79          (((0 . 0)) . #f)
80          (((0 . 0) (2 . 0)) . #f)
81          ;; Root-fifth chord
82          (((0 . 0) (4 . 0)) . ("5"))
83          ;; Common triads
84          (((0 . 0) (2 . -1)) . ("m"))
85          (((0 . 0) (3 . 0) (4 . 0)) . ("sus"))
86          (((0 . 0) (2 . -1) (4 . -1)) . ("dim"))
87 ;Alternate:      (((0 . 0) (2 . -1) (4 . -1)) . ((super "o")))
88          (((0 . 0) (2 . 0) (4 . 1)) . ("aug"))
89 ;Alternate:      (((0 . 0) (2 . 0) (4 . 1)) . ("+"))
90          (((0 . 0) (1 . 0) (4 . 0)) . ("2"))
91          ;; Common seventh chords
92          (((0 . 0) (2 . -1) (4 . -1) (6 . -2)) . (rows (super "o") "7"))
93          (((0 . 0) (2 . 0) (4 . 0) (6 . 0)) . ("maj7"))
94          (((0 . 0) (2 . -1) (4 . 0) (6 . -1)) . ("m7"))
95          (((0 . 0) (2 . 0) (4 . 0) (6 . -1)) . ("7"))
96          (((0 . 0) (2 . -1) (4 . 0) (6 . 0)) . ("m(maj7)"))
97          ;jazz: the delta, see jazz-chords.ly
98          ;;(((0 . 0) (2 . -1) (4 . -1) (6 . -2)) .  (super ((font-family . math) "N"))
99          ;; ugh, kludge slashed o
100          (((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
101          (((0 . 0) (2 . 0) (4 . 1) (6 . -1)) . ("aug7"))
102          (((0 . 0) (2 . 0) (4 . -1) (6 . 0)) . (rows "maj7" ((font-relative-size . -2) ((raise . 0.2) (music (named "accidentals--1")))) "5"))
103          (((0 . 0) (2 . 0) (4 . -1) (6 . -1)) . (rows "7" ((font-relative-size . -2) ((raise . 0.2) (music (named "accidentals--1")))) "5"))
104          (((0 . 0) (3 . 0) (4 . 0) (6 . -1)) . ("7sus4"))
105          ;; Common ninth chords
106          (((0 . 0) (2 . 0) (4 . 0) (5 . 0) (1 . 0)) . ("6/9")) ;; we don't want the '/no7'
107          (((0 . 0) (2 . 0) (4 . 0) (5 . 0)) . ("6"))
108          (((0 . 0) (2 . -1) (4 . 0) (5 . 0)) . ("m6"))
109          (((0 . 0) (2 . 0) (4 . 0) (1 . 0)) . ("add9"))
110          (((0 . 0) (2 . 0) (4 . 0) (6 . 0) (1 . 0)) . ("maj9"))
111          (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . 0)) . ("9"))
112          (((0 . 0) (2 . -1) (4 . 0) (6 . -1) (1 . 0)) . ("m9"))
113
114          )
115       chord::names-alist-american))
116
117 ;; Jazz chords, by Atte Andr'e Jensen <atte@post.com>
118 ;; NBs: This uses the american list as a base.
119 ;;      Some defs take up more than one line,
120 ;; be carefull when messing with ;'s!!
121
122
123 ;; FIXME
124 ;;
125 ;; This is getting out-of hand?  Only exceptional chord names that
126 ;; cannot be generated should be here.
127 ;; Maybe we should have inner-jazz-name and inner-american-name functions;
128 ;; 
129 ;;       
130 ;;
131 ;; DONT use non-ascii characters, even if ``it works'' in Windows
132
133 (define chord::names-alist-jazz '())
134 (set! chord::names-alist-jazz
135       (append 
136       '(
137         ;; major chords
138         ; major sixth chord = 6
139         (((0 . 0) (2 . 0) (4 . 0) (5 . 0)) . (((raise . 0.5) "6")))
140         ; major seventh chord = triangle
141         (((0 . 0) (2 . 0) (4 . 0) (6 . 0)) .  (((raise . 0.5)((font-family . "math") "M"))))
142         ; major chord add nine = add9
143         (((0 . 0) (2 . 0) (4 . 0) (1 . 0)) . (((raise . 0.5) "add9")))
144         ; major sixth chord with nine = 6/9
145         (((0 . 0) (2 . 0) (4 . 0) (5 . 0) (1 . 0)) . (((raise . 0.5) "6/9")))
146
147         ;; minor chords
148         ; minor sixth chord = m6
149         (((0 . 0) (2 . -1) (4 . 0) (5 . 0)) . (rows("m")((raise . 0.5) "6")))
150         ; minor major seventh chord = m triangle
151         (((0 . 0) (2 . -1) (4 . 0) (6 . 0)) . (rows ("m") ((raise . 0.5)((font-family . "math") "M"))))
152         ; minor seventh chord = m7
153         (((0 . 0) (2 . -1) (4 . 0) (6 . -1)) . (rows("m")((raise . 0.5) "7")))
154         ; minor sixth nine chord = m6/9
155         (((0 . 0) (2 . -1) (4 . 0) (5 . 0) (1 . 0)) . (rows("m")((raise . 0.5) "6/9")))
156         ; minor with added nine chord = madd9
157         (((0 . 0) (2 . -1) (4 . 0) (1 . 0)) . (rows("m")((raise . 0.5) "add9")))
158         ; minor ninth chord = m9
159         (((0 . 0) (2 . -1) (4 . 0) (6 . -1) (1 . 0)) . (rows("m")((raise . 0.5) "9")))
160
161         ;; dominant chords
162         ; dominant seventh = 7
163         (((0 . 0) (2 . 0) (4 . 0) (6 . -1)) . (((raise . 0.5) "7")))
164         ; augmented dominant = +7
165         ;(((0 . 0) (2 . 0) (4 . +1) (6 . -1)) . (((raise . 0.5) "+7"))) ; +7 with both raised
166         (((0 . 0) (2 . 0) (4 . +1) (6 . -1)) . (rows("+")((raise . 0.5) "7"))) ; +7 with 7 raised
167         ;(((0 . 0) (2 . 0) (4 . +1) (6 . -1)) . (rows((raise . 0.5) "7(")
168         ;       ((raise . 0.3)(music (named ("accidentals-1"))))
169         ;       ((raise . 0.5) "5)"))); 7(#5)
170         ; dominant flat 5 = 7(b5)
171         (((0 . 0) (2 . 0) (4 . -1) (6 . -1)) . (rows((raise . 0.5) "7(")
172                 ((raise . 0.3)(music (named ("accidentals--1"))))
173                 ((raise . 0.5) "5)")))
174         ; dominant 9 = 7(9)
175         (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . 0)) . (((raise . 0.8)"7(9)")))
176         ; dominant flat 9 = 7(b9)
177         (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . -1)) . (
178                 ((raise . 0.8)"7(")
179                 ((raise . 0.3)(music (named ("accidentals--1"))))
180                 ((raise . 0.8)"9)")))
181         ; dominant sharp 9 = 7(#9)
182         (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . +1)) . (
183                 ((raise . 0.8)"7(")
184                 ((raise . 0.3)(music (named ("accidentals-1"))))
185                 ((raise . 0.8)"9)")))
186         ; dominant 13 = 7(13)
187         (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (5 . 0)) . (((raise . 0.8)"7(13)")))
188         ; dominant flat 13 = 7(b13)
189         (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (5 . -1)) . (
190                 ((raise . 0.8)"7(")
191                 ((raise . 0.3)(music (named ("accidentals--1"))))
192                 ((raise . 0.8)"13)")))
193         ; dominant 9, 13 = 7(9,13)
194         (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . 0) (5 . 0)) . (((raise . 0.8)"7(9, 13)")))
195         ; dominant flat 9, 13 = 7(b9,13)
196         (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . -1) (5 . 0)) . (
197                 ((raise . 0.8)"7(")
198                 ((raise . 0.3)(music (named ("accidentals--1"))))
199                 ((raise . 0.8)"9, 13)")))
200         ; dominant sharp 9, 13 = 7(#9,13)
201         (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . +1) (5 . 0)) . (
202                 ((raise . 0.8)"7(")
203                 ((raise . 0.3)(music (named ("accidentals-1"))))
204                 ((raise . 0.8)"9, 13)")))
205         ; dominant 9, flat 13 = 7(9,b13)
206         (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . 0) (5 . -1)) . (
207                 ((raise . 0.8)"7(9, ")
208                 ((raise . 0.3)(music (named ("accidentals--1"))))
209                 ((raise . 0.8)"13)")))
210         ; dominant flat 9, flat 13 = 7(b9,b13)
211         (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . -1) (5 . -1)) . (
212                 ((raise . 0.8)"7(")
213                 ((raise . 0.3)(music (named ("accidentals--1"))))
214                 ((raise . 0.8)"9, ")
215                 ((raise . 0.3)(music (named ("accidentals--1"))))
216                 ((raise . 0.8)"13)")))
217         ; dominant sharp 9, flat 13 = 7(#9,b13)
218         (((0 . 0) (2 . 0) (4 . 0) (6 . -1) (1 . +1) (5 . -1)) . (
219                 ((raise . 0.8)"7(")
220                 ((raise . 0.3)(music (named ("accidentals-1"))))
221                 ((raise . 0.8)"9, ")
222                 ((raise . 0.3)(music (named ("accidentals--1"))))
223                 ((raise . 0.8)"13)")))
224
225         ;; diminished chord(s)
226         ; diminished seventh chord =  o
227
228
229         ;; DONT use non-ascii characters, even if ``it works'' in Windows
230         
231         ;;(((0 . 0) (2 . -1) (4 . -1) (6 . -2)) . (((raise . 0.8)"o"))); works, but "o" is a little big
232         (((0 . 0) (2 . -1) (4 . -1) (6 . -2)) . ((raise . 0.8) (size . -2) ("o")))
233
234         ;; half diminshed chords
235         ; half diminished seventh chord = slashed o
236         (((0 . 0) (2 . -1) (4 . -1) (6 . -1)) . (((raise . 0.8)"/o")))
237         ; half diminished seventh chord  with major 9 = slashed o cancelation 9
238         (((0 . 0) (2 . -1) (4 . -1) (6 . -1) (1 . 0)) . (
239                 ((raise . 0.8)"/o(")
240                 ((raise . 0.3)(music (named ("accidentals-0"))))
241                 ((raise . 0.8)"9)"))); 
242
243 ;; Missing jazz chord definitions go here (note new syntax: see american for hints)
244
245         )
246       chord::names-alist-american))
247
248 ;;;;;;;;;;
249
250
251 (define (pitch->note-name pitch)
252   (cons (cadr pitch) (caddr pitch)))
253   
254 (define (pitch->text pitch)
255   (cons
256     (make-string 1 (integer->char (+ (modulo (+ (cadr pitch) 2) 7) 65)))
257     (if (= (caddr pitch) 0)
258       '()
259       (list
260        (append '(music)
261                (list
262                 (append '(named)
263                         (list
264                           (append '((font-relative-size . -2))
265                                 (list (append '((raise . 0.6))
266                                   (list
267                                    (string-append "accidentals-" 
268                                                   (number->string (caddr pitch)))))))))))))))
269
270 (define (step->text pitch)
271   (string-append
272     (number->string (+ (cadr pitch) (if (= (car pitch) 0) 1 8)))
273     (case (caddr pitch)
274       ((-2) "--")
275       ((-1) "-")
276       ((0) "")
277       ((1) "+")
278       ((2) "++"))))
279
280 (define (pitch->text-banter pitch)
281   (pitch->text pitch))
282   
283 (define (step->text-banter pitch)
284   (if (= (cadr pitch) 6)
285       (case (caddr pitch)
286         ((-2) "7-")
287         ((-1) "7")
288         ((0) "maj7")
289         ((1) "7+")
290         ((2) "7+"))
291       (step->text pitch)))
292
293 (define pitch::semitone-vec (list->vector '(0 2 4 5 7 9 11)))
294
295 (define (pitch::semitone pitch)
296   (+ (* (car pitch) 12) 
297      (vector-ref pitch::semitone-vec (modulo (cadr pitch) 7)) 
298      (caddr pitch)))
299
300 (define (pitch::transpose pitch delta)
301   (let ((simple-octave (+ (car pitch) (car delta)))
302         (simple-notename (+ (cadr pitch) (cadr delta))))
303     (let ((octave (+ simple-octave (quotient simple-notename 7)))
304            (notename (modulo simple-notename 7)))
305       (let ((accidental (- (+ (pitch::semitone pitch) (pitch::semitone delta))
306                            (pitch::semitone `(,octave ,notename 0)))))
307         `(,octave ,notename ,accidental)))))
308     
309 (define (pitch::diff pitch tonic)
310   (let ((simple-octave (- (car pitch) (car tonic)))
311         (simple-notename (- (cadr pitch) (cadr tonic))))
312     (let ((octave (+ simple-octave (quotient simple-notename 7)
313                      (if (< simple-notename 0) -1 0)))
314           (notename (modulo simple-notename 7)))
315       (let ((accidental (- (pitch::semitone pitch)
316                           (pitch::semitone tonic) 
317                           (pitch::semitone `(,octave ,notename 0)))))
318         `(,octave ,notename ,accidental)))))
319
320 (define (pitch::note-pitch pitch)
321   (+ (* (car pitch) 7) (cadr pitch)))
322
323 (define (chord::step tonic pitch)
324  (- (pitch::note-pitch pitch) (pitch::note-pitch tonic)))
325
326 ;; text: list of word
327 ;; word: string + optional list of property
328 ;; property: align, kern, font (?), size
329
330 (define chord::minor-major-vec (list->vector '(0 -1 -1 0 -1 -1 0)))
331
332 ;; compute the relative-to-tonic pitch that goes with 'step'
333 (define (chord::step-pitch tonic step)
334   ;; urg, we only do this for thirds
335   (if (= (modulo step 2) 0)
336     '(0 0 0)
337     (let loop ((i 1) (pitch tonic))
338       (if (= i step) pitch
339         (loop (+ i 2) 
340               (pitch::transpose 
341                 pitch `(0 2 ,(vector-ref chord::minor-major-vec 
342                 ;; -1 (step=1 -> vector=0) + 7 = 6
343                 (modulo (+ i 6) 7)))))))))
344
345 ;; find the pitches that are not part of `normal' chord
346 (define (chord::additions chord-pitches)
347   (let ((tonic (car chord-pitches)))
348     ;; walk the chord steps: 1, 3, 5
349     (let loop ((step 1) (pitches chord-pitches) (additions '()))
350       (if (pair? pitches)
351         (let* ((pitch (car pitches))
352                (p-step (+ (- (pitch::note-pitch pitch)
353                              (pitch::note-pitch tonic))
354                           1)))
355           ;; pitch is an addition if 
356           (if (or 
357                 ;; it comes before this step or
358                 (< p-step step)
359                 ;; its step is even or
360                 (= (modulo p-step 2) 0)
361                 ;; has same step, but different accidental or
362                 (and (= p-step step)
363                      (not (equal? pitch (chord::step-pitch tonic step))))
364                 ;; is the last of the chord and not one of base thirds
365                 (and (> p-step  5)
366                      (= (length pitches) 1)))
367             (loop step (cdr pitches) (cons pitch additions))
368           (if (= p-step step)
369             (loop step (cdr pitches) additions)
370             (loop (+ step 2) pitches additions))))
371       (reverse additions)))))
372
373 ;; find the pitches that are missing from `normal' chord
374 (define (chord::subtractions chord-pitches)
375   (let ((tonic (car chord-pitches)))
376     (let loop ((step 1) (pitches chord-pitches) (subtractions '()))
377       (if (pair? pitches)
378         (let* ((pitch (car pitches))
379                (p-step (+ (- (pitch::note-pitch pitch)
380                              (pitch::note-pitch tonic))
381                           1)))
382           ;; pitch is an subtraction if 
383           ;; a step is missing or
384           (if (> p-step step)
385             (loop (+ step 2) pitches
386                 (cons (chord::step-pitch tonic step) subtractions))
387           ;; there are no pitches left, but base thirds are not yet done and
388           (if (and (<= step 5)
389                    (= (length pitches) 1))
390             ;; present pitch is not missing step
391             (if (= p-step step)
392               (loop (+ step 2) pitches subtractions)
393               (loop (+ step 2) pitches 
394                     (cons (chord::step-pitch tonic step) subtractions)))
395             (if (= p-step step)
396               (loop (+ step 2) (cdr pitches) subtractions)
397               (loop step (cdr pitches) subtractions)))))
398         (reverse subtractions)))))
399
400 ;; combine tonic, user-specified chordname,
401 ;; additions, subtractions and base or inversion to chord name
402 ;;
403 (define (chord::inner-name-banter tonic user-name additions subtractions base-and-inversion)
404   (apply append
405          '(rows)
406          (pitch->text-banter tonic)
407          (if user-name user-name '())
408          ;; why does list->string not work, format seems only hope...
409          (if (and (string-match "super" (format "~s" user-name))
410                   (or (pair? additions)
411                       (pair? subtractions)))
412              '((super "/"))
413              '())
414          (let loop ((from additions) (to '()))
415            (if (pair? from)
416                (let ((p (car from)))
417                  (loop (cdr from) 
418                        (append to
419                                (cons
420                                 (list 'super (step->text-banter p))
421                                 (if (or (pair? (cdr from))
422                                         (pair? subtractions))
423                                     '((super "/"))
424                                     '())))))
425                to))
426          (let loop ((from subtractions) (to '()))
427            (if (pair? from)
428                  (let ((p (car from)))
429                    (loop (cdr from) 
430                          (append to
431                                  (cons '(super "no")
432                                        (cons
433                                         (list 'super (step->text-banter p))
434                                         (if (pair? (cdr from))
435                                             '((super "/"))
436                                             '())))))) ; nesting?
437                  to))
438          (if (and (pair? base-and-inversion)
439                   (or (car base-and-inversion)
440                       (cdr base-and-inversion)))
441              (cons "/" (append
442                         (if (car base-and-inversion)
443                             (pitch->text 
444                              (car base-and-inversion))
445                             (pitch->text 
446                              (cdr base-and-inversion)))
447                         '()))
448              '())
449          '()))
450
451 (define (chord::name-banter tonic user-name pitches base-and-inversion)
452   (let ((additions (chord::additions pitches))
453         (subtractions (chord::subtractions pitches)))
454     (chord::inner-name-banter tonic user-name additions subtractions base-and-inversion)))
455
456 ;; american chordnames use no "no",
457 ;; but otherwise very similar to banter for now
458 (define (chord::name-american tonic user-name pitches base-and-inversion)
459   (let ((additions (chord::additions pitches))
460         (subtractions #f))
461     (chord::inner-name-banter tonic user-name additions subtractions base-and-inversion)))
462
463 ;; Jazz style--basically similar to american with minor changes
464 (define (chord::name-jazz tonic user-name pitches base-and-inversion)
465   (let ((additions (chord::additions pitches))
466         (subtractions #f))
467     (chord::inner-name-banter tonic user-name additions subtractions base-and-inversion)))
468
469 (define (new-to-old-pitch p)
470   (if (pitch? p)
471       (list (pitch-octave p) (pitch-notename p) (pitch-alteration p))
472       #f
473   ))
474
475
476
477 ;; C++ entry point
478 ;; 
479 ;; Check for each subset of chord, full chord first, if there's a
480 ;; user-override.  Split the chord into user-overridden and to-be-done
481 ;; parts, complete the missing user-override matched part with normal
482 ;; chord to be name-calculated.
483 ;;
484 ;; CHORD: (pitches (base . inversion))
485 (define (default-chord-name-function style chord)
486   (let* ((pitches (map new-to-old-pitch (car chord)))
487          (modifiers (cdr chord))
488          (base-and-inversion (if (pair? modifiers)
489                                  (cons (new-to-old-pitch (car modifiers))
490                                        (new-to-old-pitch (cdr modifiers)))
491                                  '(() . ())))
492          (diff (pitch::diff '(0 0 0) (car pitches)))
493          (name-func 
494           (ly-eval (string->symbol (string-append "chord::name-" style))))
495          (names-alist 
496           (ly-eval (string->symbol (string-append "chord::names-alist-" style)))))
497   (let loop ((note-names (reverse pitches))
498              (chord '())
499              (user-name #f))
500     (if (pair? note-names)
501       (let ((entry (assoc 
502                      (reverse 
503                        (map (lambda (x) 
504                               (pitch->note-name (pitch::transpose x diff)))
505                             note-names))
506                      names-alist)))
507         (if entry
508           ;; urg? found: break loop
509           (loop '() chord (cdr entry))
510           (loop (cdr note-names) (cons (car note-names) chord) #f)))
511       (let* ((transposed (if pitches 
512                            (map (lambda (x) (pitch::transpose x diff)) chord)
513                            '()))
514              (matched (if (= (length chord) 0)
515                           3
516                           (- (length pitches) (length chord))))
517              (completed 
518               (append (do ((i matched (- i 1))
519                            (base '() (cons `(0 ,(* (- i 1) 2) 0) base)))
520                            ((= i 0) base)
521                            ())
522                   transposed)))
523       (name-func (car pitches) user-name completed base-and-inversion))))))
524
525