Trying to understand kRate values

Hi all,

I am trying to wrap my head around kRate values. Essentially, in the patcher a kRate values ranges from -64 to 64, but they are understood to be 27 bit values. I am wondering how this translates to larger values in code.

For example, in axoloti_math.h the MTOFEXTENDED macro passes the input value to the mtof48k_ext_q31 function, which is this:

static inline uint32_t mtof48k_ext_q31(int32_t pitch) {
    int32_t p=__SSAT(pitch,29);
    uint32_t pi = p>>21;
    int32_t y1 = pitcht[128+pi];
    int32_t y2 = pitcht[128+1+pi];
    int32_t pf= (p&0x1fffff)<<10;
    int32_t pfc = INT32_MAX - pf;
    uint32_t r;
    r = ___SMMUL(y1,pfc);
    r = ___SMMLA(y2,pf,r);
    uint32_t frequency = r<<1;
    return frequency;
}

If I understand correctly, the __SSAT function binds the pitch to a 29 bit value, so I’m assuming that pitch is a value greater than -64 to 64.

Is there any literature in the Ksoloti/Axoloti documentation that explains how the kRate values work? I hope this question makes sense. Thanks!

Ah, I got it. It’s in the fixed point Q format (which I didn’t know about until finding this very helpful link, which looks to be an old User Guide).

Using the disp/hex object, I see that every value of “1” in the bipolar domain represents a multiple of integer value of 0x200000. For example, if the value of ctrl/dial b were “3.00” the hex value would be 0x600000, etc.

Screen Shot 2024-09-07 at 10.53.00 PM

These two things were really helpful in learning how basically all of the functions in the Axoloti operate!

Hi,the common primer of how Axoloti’s Q27 values work (back on the Axoloti forum backup) is here: Coding axoloti objects - User Guide - Axoloti Community

Some good info in there but also quite confusing especially for people unfamiliar with embedded C.