Perhaps transpose.lisp will help -- the key signature is found with key-p while scanning the staff data list.