Lisp Chord Progressions

2006-03-01 06:42:00


(defun chord-progression (prog key)
  (cond ((null prog) ())
        (t
         (cons (funcall (getf *chord-progressions* (car prog)) key)
               (chord-progression (cdr prog) key)))))

I added the chord progression function. It uses a plist to setup aliases to the scale position functions that I added last time.


(defparameter *chord-progressions*
  (list :I #'1st :II #'2nd :III #'3rd :IV #'4th :V #'5th 
        :VI #'6th :VII #'7th :VIII #'8th :IX #'9th :X #'10th
        :XI #'11th :XII #'12th))

This allows us to generate I IV V chord progressions like this:


CL-USER> (chord-progression '(:I :IV :V) 'g)
(G C D)

Here is a function that will generate all I IV V progressions.


CL-USER> (format t "~:{~3A ~3A ~3A~&~}" (mapcar #'(lambda (x) (show-sharps (chord-progression '(:I :IV :V) x))) *notes*))
A   D   E  
A#  D#  F  
B   E   F# 
C   F   G  
C#  F#  G# 
D   G   A  
D#  G#  A# 
E   A   B  
F   A#  C  
F#  B   C# 
G   C   D  
G#  C#  D# 
NIL

You can get the code here