Blue Cat's Plug'n Script 3.3: Knob value 1 is still 0?

Official support for: bluecataudio.com
Post Reply New Topic
RELATED
PRODUCTS

Post

Cant get it working, when one of the knobs is set to 1, that the value will be set to 1. It works in the GUIless version, but not with a GUI. What i'm doing wrong?

Parameter def:

Code: Select all

array <string> inputParametersNames = {"Mode", "Note split", "Change octave"};
array<double> inputParameters(inputParametersNames.length);
array<double> inputParametersMin = {0, 0, -2};
array<double> inputParametersMax = {3, 127, 2};
array<double> inputParametersDefault = {0, 36, 0};
array <string> inputParametersFormats = {".0", ".0", ".0"};
array <string> inputParametersEnums = {modes, midiNotes};
array<int> inputParametersSteps = {3, 127, 5};
Update function:

Code: Select all

void updateInputParameters() {
    mode = int8(inputParameters[0]);
    noteSplit = int8(inputParameters[1]);
    addOct = int16(inputParameters[2]);
}
System: Windows 10, Renoise 64bit, Plug'n Script v3.3

Little screen recording:
You do not have the required permissions to view the files attached to this post.

Post

Same problem here, don't know why. I think the internal param values are somehow treated differently, it may not even be a bug.
Solved it this way: int iValue = int( float(inputParameters[0]));

First the cast to float, then to int. At least this worked for me...
http://www.pulpoaudio.com
Virtual Percussion Instruments
email: pulpo@pulpoaudio.com

Post

I thought it might just be some rounding error when normalizing/denormalizing internally. What I do when converting from double to int is using a "round to nearest function" by adding 0.5 to the double value before rounding. That way everything below x.5 will round down and every above will round up. Precision sometimes is a b**** :D

Post

That's indeed a rounding issue. when using direct conversion, it actually truncates the floating point value, so you may indeed end up with very strange behavior. You can use the method described by Kumal for positive values or create a simple rounding function if you need both positive and negative values.

Post

Ok thanks, i use this function now. Works fine.

Code: Select all

int round(double x) {
    if (x < 0.0)
        return int(x - 0.5);
    else
        return int(x + 0.5);
}

Post

I use the following code to round a floating point number to an integer.
Rounding means: Add 0.5, then truncate towards minus infinity.

int roundDoubleToInt(double d)
{
return int(floor(d + 0.5));
}
// convert double number to closest integer (rounding)

The next example shows how to round a floating point number,
e.g. two places after the decimal point:

double roundDoubleTo2Places(double d)
{
return floor(d*100 + 0.5) / 100;
}
// round double number to 2 places after decimal point

Post Reply

Return to “Blue Cat Audio”