[linux-audio-dev] XAP: Pitch control

David Olofson david at olofson.net
Mon Dec 9 22:02:00 UTC 2002


On Tuesday 10 December 2002 01.31, Steve Harris wrote:
[...]
> > With 1.0/note for note_pitch, and 12.0/octave for linear_pitch,
> > we have a nice and extremely simple "shortcut" available for all
> > those that use only or mostly 12tET:
>
> and a headache if you dont want to work in 12tET. Its not like the
> conversion is hard, the host could od it explicity if it only wants
> 12tET, and if its wants other htings then its going to have to work
> anyway.

How and when would the host do this? It normally won't touch or even 
see events passed from one plugin to another, so there is no natural 
place to do this.


> > 	linear_pitch = note_pitch * (12.0 / 16.0);
> >
> > That is, "stretch" the scale so you need 16.0 note_pitch units to
> > span one octave. Now, all of a sudden, your synths - apparently
> > written for 12tET - can play 16tET. They don't know it, or
> > understand it, but they're playing the right notes.
>
> Sure, I just think the factor of 12 is ugly.

Well, so do I... 1/12 is just as bad IMHO, but hopefully, we'll only 
see that in note editors, appregiators and that kind of places. (And 
we could actually wrap it in macros, to keep people from having bad 
ideas... *heh*)


> > > > If you don't like 12.0, scale and use whatever you like
> > > > internally. It doesn't change anything.
> > >
> > > But it does mess up the API.
> >
> > And forcing plugins to request information about what's going on
> > outside their input ports, and passing that to non-optional host
> > callbacks does not?
>
> Well, that is optional, having to remove the factor of 12 isn't.

And given that "real" plugins think only in linear pitch, note/scale 
oriented plugins should pay? Well, I would like to have some actual 
statistics on this...

On the VST list, it's exactly the other way around - but then, they 
have *MIDI* in thier events, so what can you expect? ;-)


> > No, but event processor coders are going to think that
> > multiplying with 12.0 to get actual note_pitch is rather strange
> > when there could be any number of tones/octave... ;-)
>
> But youre always multiplying by the number of tones (for ET), so
> its much less confusing!

You can't do that. You can't implement useful scale conversion that 
easy anyway, so we're talking about a hardcoded pitch*12.0, just to 
convert the note_pitch we asked for from (1/12)/note to the much more 
sensible 1.0/note.

It's a matter of "packing" the 1.0/note note_pitch into something 
that's physically equivalent to 1.0/octave when dealing with 12tET, 
just so you don't have to use scale converters at all for 12tET.

When you actually *need* a scale converter, it would also get 
(1/12)/note (as anyone that asks for note_pitch) and scale it to 
1.0/note for internal calculations. Then it would output 1.0/octave, 
linear_pitch, of course, since that is the only truly sensible unit.


> > > Thsi has been a long discussion, so, my position:
> > >
> > > 	I do like 1.0 per octave, linear pitch
> > > 	I dont like "notes" being in the API.
> >
> > I agree. But how much is that allowed to cost?
>
> The notes issue, maybe, but 1.0 / oct doesnt cost anything: Its not
> confusing (to anyone), it doesnt cost any cycles.

Right. Nor does 12.0 / octave. One looks nice in syths and various 
event processors, and the other looks nice in note/scale oriented 
things. Both result in note_pitch and linear_pitch being the same 
value for the same actual pitch in 12tET, so you *only* need to mess 
with scale converters when you actually want non-12tET.

I suggest new terminology:

Linear pitch becomes...
	* Actual Pitch
		1.0/octave, period.

and note pitch becomes...
	* Virtual Pitch
		(1/12)/note.
		Can be cast directly to Actual Pitch for 12tET.
		Scale converters needed for other scales.
		Editors and processors need not understand
		scales completely, as VP is *alway* (1/12)/note.

Why? Well, both are linear pitch. The only difference is in the 
interpretation. Actual pitch is complete, self contained data, while 
Virtual Pitch is related to a scale that you may or may not need to 
understand to deal with the data.


//David Olofson - Programmer, Composer, Open Source Advocate

.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. |
| RT and off-line synth. Scripting. Sample accurate timing. |
`---------------------------> http://olofson.net/audiality -'
.- M A I A -------------------------------------------------.
|    The Multimedia Application Integration Architecture    |
`----------------------------> http://www.linuxdj.com/maia -'
   --- http://olofson.net --- http://www.reologica.se ---



More information about the Linux-audio-dev mailing list