What I would really like, and I haven’t researched it yet, is a fast approximation to pow(x,y), in the case where \{x,y\}\in[0;1].
I know Bruce would do this with a 2D lookup table with interpolation, and I will probably do this, but if ever someone has any ideas or pointers, I’m all ears!
I haven’t studied it in enough detail to understand it yet. But the cephes library powf does it by exponentation and log.
xy = ey log(x)
It’s not clear to me without studying it harder if some parts can be discarded if you have those constraints. Nor how easy it would be to parallelise it.
out of curiosity (related to your statement): how would you convert rack::simd::float_4 pitch = rack::simd::exp(semitones * kLN2Per12f); using approxExp2_taylor5?
true, but with newer stuff I try to use SSE approximations instead of lookup tables since that tends to be better behaved and fast. But only when I can figure it out.
Well, let me wave my hands a little! The formula for pitch is pitch = k * exp2(CV). So so base 2 exponentiation is already closer to what you want. The value of k depends on the definition of pitch(0) and how you handle sample rate, etc… I would say look in VCV Fundamental VCO1 for how to do this. I copied that for my recent VCOs.
I do have an entire repo, separate from my “commercial” modules whose entire purpose is to show how to write a decent VCO. Here’s a place where I do that calculation: Demo/src/VCO3.cpp at main · squinkylabs/Demo · GitHub
Pitch in vcv is expressed in volts. Refer to the vcv manual for more on that. Since a volt is an octave, yes 1/12 of a volt is a semitone. What do you mean “not so sure about this”? you mean you aren’t sure the VCOs in that repo play in tune? Try them out. The code have been reviewed by many people, including Andrew himself. But by all means the first thing you should look at for reference is the source code for VCV Fundamental VCO. Well, first thing look at the spec in the manual.
sorry man, i’ve expressed bad myself
i meant: now sure about what 0/10 param values means related to pitch (due to configParam(PITCH_PARAM, 0, 10, 4, “Initial Pitch”)
is it just a draft? or set “4” means +4v? what about “decrease pitch” so? that’s all
Oh, that. It’s totally arbitrary. It is, after all a demo. Most of my real vcos have an octave, semitone, and fine control. But, in this case I think I meant that a setting of 4 means that zero volts outputs C4, which is of course the standard pitch. So that knob lets you transpose from the normal pitch down 4 octave to transposed up 6 octaves. The pitch cv input CV adds to this. It is bipolar, so covers a huge range.
I should note that even though this is a simple example plugin, this sort of pitch control is fairly normal. Most VCO do something similar.
Please experiment with any VCO. Measure the output pitch with one of the tuner plugins. Put in various voltages, move the knobs, and see what happens. Build one of the open source VCOs and debug it or log the internal numbers.