[gsharp-cvs] CVS update: gsharp/drawing.lisp gsharp/sdl.lisp

Robert Strandh rstrandh at common-lisp.net
Fri Nov 11 19:19:41 UTC 2005


Update of /project/gsharp/cvsroot/gsharp
In directory common-lisp.net:/tmp/cvs-serv19393

Modified Files:
	drawing.lisp sdl.lisp 
Log Message:
added comments 

Date: Fri Nov 11 20:19:40 2005
Author: rstrandh

Index: gsharp/drawing.lisp
diff -u gsharp/drawing.lisp:1.17 gsharp/drawing.lisp:1.18
--- gsharp/drawing.lisp:1.17	Fri Nov 11 19:47:08 2005
+++ gsharp/drawing.lisp	Fri Nov 11 20:19:39 2005
@@ -485,18 +485,30 @@
   (loop for note in notes do
 	(draw-note pane note notehead dots (final-xposition note) (note-position note))))
 
+;;; given a group of notes (i.e. a list of notes, all displayed on the
+;;; same staff, compute their final x offsets.  This is a question of
+;;; determining whether the note goes to the right or to the left of
+;;; the stem.  The head-note of the stem goes to the left of an
+;;; up-stem and to the right of a down-stem.  The x offset of a cluster
+;;; gives the x position of the head-note. 
 (defun compute-final-xpositions (group x direction)
   (setf group (sort (copy-list group)
 		    (if (eq direction :up)
 			(lambda (x y) (< (note-position x) (note-position y)))
 			(lambda (x y) (> (note-position x) (note-position y))))))
   (score-pane:with-suspended-note-offset offset
+    ;; the first element of the group is the head-note
     (setf (final-xposition (car group)) x)
+    ;; OFFSET is a positive quantity that determines the 
+    ;; absolute difference between the x offset of a suspended
+    ;; note and that of a normally positioned note. 
     (when (eq direction :down) (setf offset (- offset)))
     (loop for note in (cdr group)
 	  and old-note = (car group) then note
 	  do (let* ((pos (note-position note))
 		    (old-pos (note-position old-note))
+		    ;; if adjacent notes are just one staff step apart, 
+		    ;; then one must be suspended. 
 		    (dx (if (= (abs (- pos old-pos)) 1) offset 0))) 
 	       (setf (final-xposition note) (+ x dx))
 	       ;; go back to ordinary offset
@@ -612,6 +624,8 @@
 	       (setf (accidental-position choice)
 		     (accidental-min-xpos choice notes staff-step))))))
 
+;;; given a list of notes, group them so that every note in the group
+;;; is displayed on the same staff.  Return the list of groups. 
 (defun group-notes-by-staff (notes)
   (let ((groups '()))
     (loop while notes do


Index: gsharp/sdl.lisp
diff -u gsharp/sdl.lisp:1.8 gsharp/sdl.lisp:1.9
--- gsharp/sdl.lisp:1.8	Thu Nov 10 19:32:19 2005
+++ gsharp/sdl.lisp	Fri Nov 11 20:19:39 2005
@@ -19,7 +19,9 @@
 (defgeneric notehead-right-offsets (font))
 (defgeneric notehead-left-offsets (font))
 (defgeneric bar-line-offsets (font))
-(defgeneric suspended-note-offset (font))
+(defgeneric suspended-note-offset (font)
+  (:documentation "the x offset of a suspended note compared to that
+of a normal note.  This function always returns a positive value"))
 
 (defclass font ()
   ((gf-font :initarg :gf-font :reader gf-font)




More information about the Gsharp-cvs mailing list