It's not true, and you do need to watch for changes. I think it's an override of setSampleRate in VST.mistertoast wrote:"usualy in a VST the sample rate can't change"
Is that true? I've been wondering whether I'll need to watch for sample rate change messages in my VSTi.
exp(-2 * PI * X) approx
-
- KVRian
- 646 posts since 18 Feb, 2006 from California
-
- KVRAF
- Topic Starter
- 1718 posts since 3 Sep, 2003
No, I think you should be able to handle samplerate changes. There is a setSamplerate method after all. If you don't overload it, I think it will just update the samplerate variable from the base class.mistertoast wrote:"usualy in a VST the sample rate can't change"
Is that true? I've been wondering whether I'll need to watch for sample rate change messages in my VSTi.
I usually go like this:
Code: Select all
void VSTPlug::setSampleRate (float sampleRate)
{
AudioEffectX::setSampleRate (sampleRate);
myStuff->setSampleRate(sampleRate);
}
-
- KVRAF
- 3404 posts since 15 Sep, 2002
I haven't thought about taking mine to assembly yet, but the C could look like this:
Code: Select all
float A = 0.44225212101E-01;
float B = 0.83381933629E+00;
float C = 0.23339518021E+01;
float t = B - X;
float t2 = t * t;
float out = A + t2 * t2 * t * C;
Swing is the difference between a drum machine and a sex machine.
-
- KVRAF
- 3404 posts since 15 Sep, 2002
OK. I guess I'll deal with it if other VSTis do.Rock Hardbuns wrote:No, I think you should be able to handle samplerate changes. There is a setSamplerate method after all. If you don't overload it, I think it will just update the samplerate variable from the base class.mistertoast wrote:"usualy in a VST the sample rate can't change"
Is that true? I've been wondering whether I'll need to watch for sample rate change messages in my VSTi.
I usually go like this:Code: Select all
void VSTPlug::setSampleRate (float sampleRate) { AudioEffectX::setSampleRate (sampleRate); myStuff->setSampleRate(sampleRate); }
Swing is the difference between a drum machine and a sex machine.
-
Christian Budde Christian Budde https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=25572
- KVRAF
- 1538 posts since 14 May, 2004 from Europe
I am using the native int->float / float->int conversation of the CPU as starting point for the approximations for exp/log.
It gives you a very fast (but rough) approximation of 2^x and log2(x). You can gain higher accuracy with a polynomial approximation to shape the error close to the desired function.
It uses slightly more than your x^4 approximation, but it is also closer to the real values.
By scaling the formulas you can derive exp(a * x) or log10(x) or anything else. The order of the polynomial can change the accuracy ranging from very fast and rough to very close and slow. But even a very slow version can perform faster than the native exp() function, especially when only single accuracy is needed.
If you combine this with psychoacoustical listening tests, you can usually use even more rough approximations.
I'm on a vacation right now, but I'll post some formulas if I found the time next week.
Kind regards,
Christian
It gives you a very fast (but rough) approximation of 2^x and log2(x). You can gain higher accuracy with a polynomial approximation to shape the error close to the desired function.
It uses slightly more than your x^4 approximation, but it is also closer to the real values.
By scaling the formulas you can derive exp(a * x) or log10(x) or anything else. The order of the polynomial can change the accuracy ranging from very fast and rough to very close and slow. But even a very slow version can perform faster than the native exp() function, especially when only single accuracy is needed.
If you combine this with psychoacoustical listening tests, you can usually use even more rough approximations.
I'm on a vacation right now, but I'll post some formulas if I found the time next week.
Kind regards,
Christian
-
- KVRAF
- 3404 posts since 15 Sep, 2002
Yeah, I've seen similar stuff. I'd like to see your code. There's this in the musicdsp archive...Christian Budde wrote:I am using the native int->float / float->int conversation of the CPU as starting point for the approximations for exp/log.
It gives you a very fast (but rough) approximation of 2^x and log2(x). You can gain higher accuracy with a polynomial approximation to shape the error close to the desired function.
It uses slightly more than your x^4 approximation, but it is also closer to the real values.
By scaling the formulas you can derive exp(a * x) or log10(x) or anything else. The order of the polynomial can change the accuracy ranging from very fast and rough to very close and slow. But even a very slow version can perform faster than the native exp() function, especially when only single accuracy is needed.
If you combine this with psychoacoustical listening tests, you can usually use even more rough approximations.
I'm on a vacation right now, but I'll post some formulas if I found the time next week.
Kind regards,
Christian
http://www.musicdsp.org/showone.php?id=133
Swing is the difference between a drum machine and a sex machine.
-
Christian Budde Christian Budde https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=25572
- KVRAF
- 1538 posts since 14 May, 2004 from Europe
Just to give you a rough idea (PASCAL code):
This gives a continuous error around the real value. A similar "MinError" version can be found which might jump between the next rough steps of the processor based conversation.
In my open source project there are similar versions for Exp() /Log() and such with varying orders (in the above case it's a 3rd order polynomial).
I once wrote a paper about this approximations, but I kind of lost it somewhere on my HD (I guess I still have it, but can't remember the name/folder right now)
Christian
Code: Select all
const
CP2ContError3 : array [0..2] of Single = (
6.93282526441610814E-1,
2.42201488582370950E-1,
5.50043626970249666E-2);
function FastPower2ContinousError3(Value: Single): Single;
var
IntCast : Integer absolute result;
begin
IntCast := round(Value);
Value := Value - IntCast;
IntCast := ($7F + Intcast) shl 23;
Result := Result * (1 +
Value * (CP2ContError3[0] +
Value * (CP2ContError3[1] +
Value * CP2ContError3[2])));
end;
In my open source project there are similar versions for Exp() /Log() and such with varying orders (in the above case it's a 3rd order polynomial).
I once wrote a paper about this approximations, but I kind of lost it somewhere on my HD (I guess I still have it, but can't remember the name/folder right now)
Christian
-
- KVRAF
- 3404 posts since 15 Sep, 2002
I'm so tempted to start an approximations web page or blog and get opinions and papers from different people. Should I?
Swing is the difference between a drum machine and a sex machine.
-
- Banned
- 2623 posts since 20 Feb, 2004 from in ur head pullin cablez out [boston, ma]
You guys are all a bunch of nerds..
I wish I could do all this cool stuff too
I wish I could do all this cool stuff too
-
- KVRAF
- 3404 posts since 15 Sep, 2002
I gave up contact lenses and hiding my nerdiness once I got married.rlahalla wrote:You guys are all a bunch of nerds..
I wish I could do all this cool stuff too
Swing is the difference between a drum machine and a sex machine.
-
- Banned
- 2623 posts since 20 Feb, 2004 from in ur head pullin cablez out [boston, ma]
mistertoast wrote:I gave up contact lenses and hiding my nerdiness once I got married.rlahalla wrote:You guys are all a bunch of nerds..
I wish I could do all this cool stuff too
-
Christian Budde Christian Budde https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=25572
- KVRAF
- 1538 posts since 14 May, 2004 from Europe
You can get my whole approximation code here: http://delphiasiovst.svn.sourceforge.ne ... iew=markup
The unit is not formated as good as it could, but it should give you a clue.
Christian
The unit is not formated as good as it could, but it should give you a clue.
Christian
-
- KVRAF
- 3404 posts since 15 Sep, 2002
Thanks!Christian Budde wrote:You can get my whole approximation code here: http://delphiasiovst.svn.sourceforge.ne ... iew=markup
The unit is not formated as good as it could, but it should give you a clue.
Christian
Swing is the difference between a drum machine and a sex machine.
-
- KVRAF
- 3404 posts since 15 Sep, 2002
Finally someone agrees. I think I should lead with a post that links to Christian's file.LOSER wrote:Yes.mistertoast wrote:Should I?
Swing is the difference between a drum machine and a sex machine.
