[CM] cmn, fixed length

Bill Schottstaedt bil at ccrma.Stanford.EDU
Mon May 30 08:50:18 PDT 2011

> Is there a way to forbid justification (varying the free-expansion-factor, 
> to adapt the length) ? 

I think you can use spacing-hook, as in pmn.lisp.  Here's an example:

(in-package :cmn)

(defvar *pmn-line-thickness* 0.1)
(defvar *pmn-stem-choice* :none)

(defun xmn (&rest args)
  (apply #'cmn
         (automatic-ties nil)
         (automatic-rests nil)
          #'(lambda (score)
              (let ((beat-scl 0.0))
                (let ((cur-fx 0.0))
                  (loop for td in (time-line score) do
                    (incf cur-fx (tld-fx0 td))
                    (setf (tld-acc-x td) (+ (tld-cx td) cur-fx))
                    (incf cur-fx (tld-fx1 td))))
                (let* ((td0 (first (time-line score)))
                       (t0 (tld-time td0))
                       (x0 (tld-acc-x td0))
                       (cur-min-t 100.0)
                       (cur-max-x 0.0))
                  (loop for td1 in (cdr (time-line score)) do
                    (when (> (tld-time td1) t0)
                      (let ((dt (- (tld-time td1) t0))
                            (dx (- (tld-acc-x td1) x0)))
                        (when (<= dt cur-min-t)
                          (setf cur-min-t dt)
                          (when (> dx cur-max-x)
                            (setf cur-max-x dx)))
                        (setf td0 td1)
                        (setf t0 (tld-time td0))
                        (setf x0 (tld-acc-x td0)))))
                  (setf beat-scl (* (/ cur-max-x cur-min-t))))
                (loop for td in (time-line score) do
                  (let ((dx0 (- (tld-cx td) (tld-x td))))
                    (setf (tld-cx td) (* beat-scl (tld-time td)))
                    (setf (tld-x td) (- (tld-cx td) dx0)))))))

;;; (xmn staff treble c4 q e4 h bf4 q bar)
;;; (xmn staff treble (chord (notes c4 e4 g4) q) e4 h bf4 q bar)
;;; (xmn (size 16) (free-expansion-factor 1.5) (staff treble c4 q c4 e c4 q c4 s c4 s c4 q bar) (staff 
bass c4 e c4 e c4 q c4 q c4 e bar))
;;; (xmn staff treble (c4 h (onset 0)) (e4 h (onset .5)) (chord h (notes c4 g4) (onset 4.0)))

More information about the Cmdist mailing list