[linux-audio-dev] XAP: Pitch control

David Olofson david at olofson.net
Tue Dec 10 15:45:00 UTC 2002


On Tuesday 10 December 2002 14.48, Nathaniel Virgo wrote:
> On Monday 09 December 2002 11:40 pm, David Olofson wrote:
> > I would be happy to see a clean solution for this, but so far,
> > these are the only alternatives we have managed come up with:
> >
> > 	1. 1.0/note for note_pitch, 1.0/octave for linear_pitch.
> > 	   Converter plugins required everywhere, even for 12tET.
> > 	   Even 12tET-only hosts have to handle this.
> >
> > 	2. 1.0/octave for linear_pitch, no note_pitch (?).
> > 	   Host calls required for conversions. Plugins have to
> > 	   find out what scales senders are using, or who is
> > 	   sending what. How does this work if multiple senders
> > 	   send to the same Channel?
> >
> > 	3. 1.0/note for note_pitch, 12.0/octave for linear_pitch,
> > 	   No conversion needed for 12tET. Converter plugins can
> > 	   be used when other scales are desired. There cannot
> > 	   be 12tET-only hosts, since scales are not a host side
> > 	   matter.
> >
> >
> > More ideas, anyone?
>
>      4. Raw frequency in Hz.

How would that make anything easier?

> 	It's only with ET scales that an exp() function is used to convert
> from the scale into the frequency,

Wrong. Linear pitch, as used by synths, is <some value>/octave, and 
that's all there is to it.

When dealing with scales, you take one form of pitch control - be it 
MIDI note numbers + pitch bend, or *Continuos* Pitch (1.0/note for 
example) - and express the note pitches as Linear Pitch, Hz 
Frequency, or whatever.

Linear Pitch is just a mathematically handy way of expressing 
frequency.


[...]
> If you want to transpose by one 12tET semitone, just multiply by
> the twelfth root of two (about 1.0595).
> Although of course for modulating by lfos etc the exponential will
> still need to be performed somewhere, so my preference is actually
> 2.

Exactly. That's why I don't think Hz frequency belongs in the API at 
all. You'll do better with linear pitch most of the time, and when 
you finally reach an oscillator that wants period or frequency, it's 
easy enough to calculate it.


> I think that insisting on an exta factor of 12 would be a bad,
> bad, bad, bad mistake.

Agreed. It's just that all other solutions seem to be just about as 
bad. :-(


> Not only would it lead to extra work in a
> great deal of cases, but you are bound to get people casting it to
> an int, which would destroy the whole purpose of having it
> continuous in the first place.

Where does the int cast get in...?


>  If the factor of 12 is there in
> some places but not others, that's an unnecessary complication
> which will lead to a loss of generality since the two different
> types of signal can no longer be interchanged.

Yes. So let's have 1.0/note for continous pitch (corresponds to MIDI 
pitch + pitch bend, sort of; this is *before* you apply scales), 
1.0/octave for linear pitch (absolute relation to Hz), and then... 
we'll have to convert continuos to linear at some point. That's the 
disadvantage; you *have* to actually convert. (Well, unless you're 
thinking in terms of one tone/octave.)

Pros with scale converter plugins:
	* They are just plugins, and can do *anything*.
	* Any host can host them - no need for explicit scale support.
	* New scale converters can be used directly with any host.

Can someone suggest alternaties and advantages with those?


//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