Baloran Forum

The 3FX => Discussions => Topic started by: unclewayback on June 07, 2026, 05:13:00 PM

Title: Control Scaling: Comment convertir un NRPN MIDI en millisecondes/Hz ?
Post by: unclewayback on June 07, 2026, 05:13:00 PM
Hello Laurent, hello all,

I recently received my 3FX and the first thing I must say is Wow! It sounds great! I love the silkscreen print on it too. In due course I hope to share a bit more of what I get up to, but for now I have a question.

I use Linux exclusively so at the moment I don't think there is a way for me to use the application or the plugin, but the onboard web app is really good.

Of course there is a complete MIDI implementation using NRPN, and I am currently building a patch using Pure Data, that will act as controller in my personal system (and I will share it for others in the same situation of course).

I have the MIDI working great, and am pleased to see the web app responding in real time to the messages. My question concerns the scaling of the controls.

For example, I would like to convert the delay time from 0-1024 to the same values you show on the web app, 427-35.7, inside my patch... I played around with some common curves, different exponents and logorithms, but cannot find a simple match, so I thought I would just ask and see if you could help.

Of course I could just try every value and make a table but this would be nice to avoid if possible! :-)

I think it is mostly just the conversion for the Delay Times, i.e. DELAY 1/2 VALUE. And for the Modulation Frequency (512 seconds to 8 Hertz) ... But maybe the VCF Value too?

Any insight would be appreciated,
sorry for the long message, I hope it is clear!

Thanks for the music :-)

---

Bonjour Laurent, bonjour à tous,

J'ai récemment reçu mon 3FX et la première chose que je dois dire, c'est : « Waouh ! » Le son est génial ! J'adore aussi le motif sérigraphié dessus. J'espère pouvoir bientôt vous en dire un peu plus sur ce que je fais avec, mais pour l'instant, j'ai une question.

J'utilise exclusivement Linux, donc pour l'instant je ne pense pas qu'il y ait de moyen pour moi d'utiliser l'application ou le plugin, mais l'application web intégrée est vraiment bonne.

Bien sûr, il y a une implémentation MIDI complète utilisant NRPN, et je suis en train de créer un patch avec Pure Data, qui servira de contrôleur dans mon système personnel (et je le partagerai bien sûr avec d'autres dans la même situation).

Le MIDI fonctionne très bien, et je suis ravi de voir l'application web répondre en temps réel aux messages. Ma question concerne la mise à l'échelle des commandes.

Par exemple, j'aimerais convertir le temps de délai de 0 à 1024 en les mêmes valeurs que celles affichées sur l'application web, soit 427 à 35,7, au sein de mon patch... J'ai testé quelques courbes standard, différents exposants et logarithmes, mais je ne trouve pas de correspondance simple, alors j'ai pensé vous demander si vous pouviez m'aider.

Bien sûr, je pourrais simplement essayer toutes les valeurs et créer un tableau, mais ce serait bien d'éviter cela si possible ! :-)

Je pense qu'il s'agit principalement de la conversion des temps de délai, c'est-à-dire la DELAY 1/2 VALUE. Et pour la fréquence de modulation (512 secondes à 8 hertz)... Mais peut-être aussi la valeur VCF ?

Tout conseil serait apprécié,
désolé pour ce long message, j'espère qu'il est clair !

Merci pour la musique :-)
Title: Re: Control Scaling: Comment convertir un NRPN MIDI en millisecondes/Hz ?
Post by: Baloran on June 08, 2026, 10:02:03 AM
Thanks unclewayback ! Very happy to read you ;)

That's perfectly normal, it's not a simple curve ;) The PT2399's internal conversion is analog. Although documented by the manufacturer, I had to take my own measurements to get something usable — but by no means exact. There are differences between individual PT2399 units: it's a quirky component, but I love it anyway :D :D
Below is the code I developed to translate 0..1024 into time.


// Structure representing a calibration point (x = parameter 0..1024, y = internal frequency)
typedef struct { int16_t x; int16_t y; } Point;

// Look-up table (LUT) built from empirical measurements on the PT2399.
// x : parameter value (0..1024)
// y : corresponding PT2399 internal frequency (manufacturer units, non-linear)
// Note: the x=400 point is intentionally missing — the 300→500 segment
//       is treated as linear (measurement gap filled by interpolation).
static const Point table[] = {
    {0,1600},{100,2360},{200,3330},{300,4620},{500,8470},
    {600,10869},{700,13157},{800,15500},{900,17699},
    {1000,19000},{1024,19200}
};

// Converts a parameter value x (0..1024) to a PT2399 internal frequency
// using linear interpolation between LUT points.
// Returns the interpolated frequency, or the last table value if x >= 1024.

int32_t freq_from_param_LUT(int32_t x)
{
    for (int i = 0; i < (int)(sizeof(table) / sizeof(table[0])) - 1; ++i)
    {
        // Find the segment [table, table[i+1]] that contains x
        if (x <= table[i + 1].x)
        {
            int32_t x0 = table.x, x1 = table[i + 1].x;
            int32_t y0 = table.y, y1 = table[i + 1].y;
            // Linear interpolation: y = y0 + (y1-y0) * (x-x0) / (x1-x0)
            return y0 + (y1 - y0) * (x - x0) / (x1 - x0);
        }
    }
    // x exceeds the table range: return the last value (clamped)
    return table[sizeof(table) / sizeof(table[0]) - 1].y;
}

// Converts a parameter value v (0..1024) to a millisecond string.
String convert_value_to_ms(uint16_t v)
{
    double freq   = freq_from_param_LUT((int32_t)v);
    double millis = (double)(683200.0 / freq + 0.09); // Convert frequency → delay in ms

    // Below 100 ms: display with one decimal place (e.g. "47.3 ms")
    if (millis < 100.0) return String(millis, 1) + " ms";

    // Above 100 ms: round to nearest integer (e.g. "347 ms")
    short smillis = (short)(millis + 0.5);
    return String(smillis) + " ms";
}
Title: Re: Control Scaling: Comment convertir un NRPN MIDI en millisecondes/Hz ?
Post by: Baloran on June 08, 2026, 10:07:19 AM
Regarding Linux, all software is developed using the cross-platform JUCE 8 framework.
Compiling for Linux is technically possible, but honestly, I can't see myself adding yet another development platform on top of everything else — Windows and Mac already keep me plenty busy ;)
That said, my sources will be available for anyone willing to dive into that adventure ;)
Title: Re: Control Scaling: Comment convertir un NRPN MIDI en millisecondes/Hz ?
Post by: unclewayback on June 10, 2026, 11:29:57 AM
Ah yes, that's fantastic thanks. I will enjoy translating your code. Personally I am happy with a tasty bit of imprecision, but I might sometimes want to enter a value in msecs as a starting point. But certainly I'll mostly be using my ears/the tiny tongues inside them/tweaking according to taste  :P

Also very pleased to hear you'll be making the sources available to those who are willing. For me I am actually very fond of Pure Data as a platform, it, rather than a DAW, forms the core of the way I like to play around, and so your excellent MIDI implementation I think is all I really need. (Though the information about the conversion is very nice to have).

Merci beaucoup!
Title: Re: Control Scaling: Comment convertir un NRPN MIDI en millisecondes/Hz ?
Post by: Baloran on June 11, 2026, 12:43:02 AM
Thanks for your kind words. Anyway, I'm not going anywhere—I'm here if you need me, and I'd be happy to help ;)