[gsharp-devel] Microtones

Christophe Rhodes csr21 at cantab.net
Sat Jun 16 14:52:58 UTC 2007


Magnus Jonsson <magnus at smartelectronix.com> writes:

> I have got basic microtonal support working and I have attached a
> patch of my changes. There is no integration with the GUI yet (and I
> am not sure how to do that). 

As a temporary solution (maybe for your own experimentation rather
than to commit anything), a simple command such as Set Tuning would
do?  There wouldn't necessarily be any need for that to be reflected
graphically.  (In the longer term, it would be nice to develop a
status area or other representation of certain global properties of
the score, such as tempo and intended tuning...)

> This patch depends on some bugfixes to the midi package that have
> not been released yet (I sent the needed changes to Christophe, the
> maintainer of the midi package).

Are we talking about the things earlier this week or new fixes?  (I
haven't checked my work mail, and probably won't until Monday; if this
is blocking you from moving forward, could you resend to this list?)
I released on Tuesday an updated version of midi.lisp incorporating
patches from Magnus which got pitch-bend events a little bit more
right...

> Are the changes and additions in the patch okay with you guys? If so I
> will commit it to CVS once the midi package has been updated.

I've got some comments below.

> -   (tempo :initform 128 :initarg :tempo :accessor tempo)))
> +   (tempo :initform 128 :initarg :tempo :accessor tempo)
> +   (tuning :initform nil :initarg :tuning :accessor tuning)))

It might be nice to have a slightly more symbolic default: a
designator for twelve-tone equal temperament of some kind?  Or maybe
NIL is such a default in the context of Common Practice Notation, at
least in this day and age...
  
> +(defun cents-adjustment (note)
> +  (multiple-value-bind (midi-pitch cents-adjustment)
> +      (midi-pitch note)
> +    cents-adjustment))

Could be written as (nth-value 1 (midi-pitch note))
  
> +(defun average (list &key (key #'identity))
> +  (let ((sum 0)
> +        (count 0))
> +    (dolist (elem list)
> +      (incf count)
> +      (incf sum (funcall key elem)))
> +    (/ sum count)))
> +
>  (defun events-from-element (element time channel)
>    (when (typep element 'cluster)
> -    (append (mapcar (lambda (note)
> +    (append (list
> +             (make-instance 'pitch-bend-message
> +                            :time time
> +                            :status (+ #xE0 channel)
> +                            :value (+ 8192 ;; middle of pitch-bend controller
> +                                      (round
> +                                       (* 4096/100 ;; 4096 points per 100 cents
> +                                          ;; midi can only do per-channel pitch bend,
> +                                          ;; not per-note pitch bend, so as a sad
> +                                          ;; compromise we average the pitch bends
> +                                          ;; of all notes in the cluster
> +                                          (average (notes element)
> +                                           :key #'cents-adjustment))))))

Ah.  that's a shame.  I think I'd prefer to see, for my own interest,
at least a mode of midi export which performs as faithful a set of
adjustments as possible, even if that means losing the
one-channel-per-layer mode of playing in the presence of
unequal-tempered tunings.  I realise that this is significantly harder
-- needing to optimize channel placements for all simultaneities (and,
more pertinently, all overlaps), but it would also be much, much
cooler!

(That's not necessarily to say that what you posted is unacceptable --
just to suggest aiming a little bit higher if possible :-)

> +(defclass linear-tuning (tuning)
> +  ((octave-cents :initform 1200 :initarg :octave-cents :accessor octave-cents)
> +   (fifth-cents :initform 700 :initarg :fifth-cents :accessor fifth-cents)))

I'm not sure (I Am Not A Tuning System Expert), but isn't this a
log-tuning scale?  Sure, it's linear, but in log-frequency space,
rather than frequency space...

I think there might be value in making 12-tone equal temperament a
separate class, maybe a subclass of linear-tuning (or log-tuning, if
I'm right about the terminology).

Could you say what alternative tunings this linear-tuning admits?  For
instance, if I set fifth-cents to 702, do I get just intonation (and
if so, which key am I in? :-)

> +(defmethod note-cents ((note note) (tuning linear-tuning))
> +    (let ((accidentals (ecase (accidentals tuning)
                                 ^^^^^^^^^^^^^^^^^^^^
This doesn't look right, but...

> +(defmethod note-cents ((note note) (tuning linear-tuning))

... you've got a second definition of the method here anyway.

Cheers,

Christophe



More information about the gsharp-devel mailing list