[gsharp-cvs] CVS gsharp
crhodes
crhodes at common-lisp.net
Thu Mar 2 09:21:34 UTC 2006
Update of /project/gsharp/cvsroot/gsharp
In directory clnet:/tmp/cvs-serv31804
Modified Files:
buffer.lisp drawing.lisp gui.lisp measure.lisp packages.lisp
score-pane.lisp
Log Message:
Implement octaviated treble clefs. This isn't terribly general, I
concede; the clef protocol might need to be rethought. However, it does
capture functionality which was previously expressed in multiple places
in the functions B-POSITION, F-POSITION and BOTTOM-LINE.
--- /project/gsharp/cvsroot/gsharp/buffer.lisp 2006/02/28 23:42:12 1.35
+++ /project/gsharp/cvsroot/gsharp/buffer.lisp 2006/03/02 09:21:34 1.36
@@ -43,21 +43,29 @@
;;; The bottom line of the staff is number 1.
(defgeneric lineno (clef))
+;;; for key signature drawing calcluations. FIXME: in fact the layout
+;;; of key signatures isn't the same across all clefs.
+(defgeneric b-position (clef))
+(defgeneric f-position (clef))
+
+;;; the note number of the bottom line of this clef.
+(defgeneric bottom-line (clef))
+
(defclass clef (gsharp-object name-mixin)
((print-character :allocation :class :initform #\K)
(lineno :reader lineno :initarg :lineno
:type (or (integer 2 6) null))))
(defun make-clef (name &key lineno)
- (declare (type (member :treble :bass :c :percussion) name)
+ (declare (type (member :treble :treble8 :bass :c :percussion) name)
(type (or (integer 2 6) null) lineno))
(when (null lineno)
(setf lineno
(ecase name
- (:treble 2)
- (:bass 6)
- (:c 4)
- (:percussion 3))))
+ ((:treble :treble8) 2)
+ (:bass 6)
+ (:c 4)
+ (:percussion 3))))
(make-instance 'clef :name name :lineno lineno))
(defmethod print-gsharp-object :after ((c clef) stream)
@@ -71,6 +79,26 @@
#'read-clef-v3
*gsharp-readtable-v3*)
+(defmethod b-position ((clef clef))
+ (ecase (name clef)
+ (:bass (- (lineno clef) 4))
+ ((:treble :treble8) (+ (lineno clef) 2))
+ (:c (- (lineno clef) 1))))
+
+(defmethod f-position ((clef clef))
+ (ecase (name clef)
+ (:bass (lineno clef))
+ ((:treble :treble8) (+ (lineno clef) 6))
+ (:c (+ (lineno clef) 3))))
+
+(defmethod bottom-line ((clef clef))
+ (- (ecase (name clef)
+ (:treble 32)
+ (:bass 24)
+ (:c 28)
+ (:treble8 25))
+ (lineno clef)))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Staff
--- /project/gsharp/cvsroot/gsharp/drawing.lisp 2006/03/02 03:27:33 1.64
+++ /project/gsharp/cvsroot/gsharp/drawing.lisp 2006/03/02 09:21:34 1.65
@@ -40,19 +40,13 @@
:x ,(+ x1 10)
:staff-step ,(lineno (clef staff)))
:stream pane)
- (let ((yoffset (ecase (name (clef staff))
- (:bass (- (lineno (clef staff)) 4))
- (:treble (+ (lineno (clef staff)) 2))
- (:c (- (lineno (clef staff)) 1)))))
+ (let ((yoffset (b-position clef)))
(loop for pitch in '(6 2 5 1 4 0 3)
for line in '(0 3 -1 2 -2 1 -3)
for x from (+ x1 10 (score-pane:staff-step 8)) by (score-pane:staff-step 2)
while (eq (aref (alterations (keysig staff)) pitch) :flat)
do (score-pane:draw-accidental pane :flat x (+ line yoffset))))
- (let ((yoffset (ecase (name (clef staff))
- (:bass (lineno (clef staff)))
- (:treble (+ (lineno (clef staff)) 6))
- (:c (+ (lineno (clef staff)) 3)))))
+ (let ((yoffset (f-position clef)))
(loop for pitch in '(3 0 4 1 5 2 6)
for line in '(0 -3 1 -2 -5 -1 -4)
for x from (+ x1 10 (score-pane:staff-step 8)) by (score-pane:staff-step 2.5)
@@ -639,8 +633,7 @@
(yoffset (- (gsharp-drawing::staff-yoffset staff))))
(if (typep staff 'fiveline-staff)
(let* ((clef (clef staff))
- (bottom-line (- (ecase (name clef) (:treble 32) (:bass 24) (:c 28))
- (lineno clef)))
+ (bottom-line (bottom-line clef))
(lnote-offset (score-pane:staff-step (- last-note bottom-line))))
(draw-line* pane
x (+ sy (- (+ (score-pane:staff-step 12) yoffset)))
--- /project/gsharp/cvsroot/gsharp/gui.lisp 2006/03/01 00:15:42 1.57
+++ /project/gsharp/cvsroot/gsharp/gui.lisp 2006/03/02 09:21:34 1.58
@@ -175,9 +175,8 @@
(defmethod note-position ((note note))
(let ((clef (clef (staff note))))
- (+ (- (pitch note)
- (ecase (name clef) (:treble 32) (:bass 24) (:c 28)))
- (lineno clef))))
+ (- (pitch note)
+ (bottom-line clef))))
(defmethod display-element ((frame gsharp) pane)
(when (handler-case (cur-cluster)
@@ -1015,7 +1014,7 @@
(lambda (so-far mode)
(complete-from-possibilities
so-far
- '(:treble :bass :c :percussion)
+ '(:treble :treble8 :bass :c :percussion)
'()
:action mode
:predicate (constantly t)
--- /project/gsharp/cvsroot/gsharp/measure.lisp 2006/02/15 02:44:48 1.27
+++ /project/gsharp/cvsroot/gsharp/measure.lisp 2006/03/02 09:21:34 1.28
@@ -119,9 +119,8 @@
(defmethod note-position ((note note))
(let ((clef (clef (staff note))))
- (+ (- (pitch note)
- (ecase (name clef) (:treble 32) (:bass 24) (:c 28)))
- (lineno clef))))
+ (- (pitch note)
+ (bottom-line clef))))
;;; given a list of notes, return the one that is at the top
(defun top-note (notes)
--- /project/gsharp/cvsroot/gsharp/packages.lisp 2006/03/01 00:15:42 1.47
+++ /project/gsharp/cvsroot/gsharp/packages.lisp 2006/03/02 09:21:34 1.48
@@ -196,7 +196,8 @@
#:add-staff-to-layer
#:remove-staff-from-layer
#:stem-direction #:undotted-duration #:duration
- #:clef #:keysig #:staff-pos #:xoffset #:read-everything
+ #:clef #:f-position #:b-position #:bottom-line
+ #:keysig #:staff-pos #:xoffset #:read-everything
#:read-buffer-from-stream
#:key-signature #:alterations #:more-sharps #:more-flats
#:line-width #:min-width #:spacing-style #:right-edge #:left-offset
--- /project/gsharp/cvsroot/gsharp/score-pane.lisp 2006/02/26 22:18:39 1.21
+++ /project/gsharp/cvsroot/gsharp/score-pane.lisp 2006/03/02 09:21:34 1.22
@@ -249,7 +249,10 @@
(define-pixmap-recording (draw-clef (name))
(ecase name
- (:treble +glyph-g-clef+)
+ ;; FIXME: while using the same glyph for :TREBLE and :TREBLE8 is
+ ;; fine from a musical point of view, some differentiation (by
+ ;; putting an italic 8 underneath, for instance) would be good.
+ ((:treble :treble8) +glyph-g-clef+)
(:bass +glyph-f-clef+)
(:c +glyph-c-clef+)))
More information about the Gsharp-cvs
mailing list