tuning just

Tuning table for tonewheels using just intonation.
Author: Johannes Taelman
License: BSD
Github: jt/tuning just.axo

Inlets

frac32 in semitones

int32 root note

Outlets

None

Parameters

frac32.s.map.pitch C

frac32.s.map.pitch Db

frac32.s.map.pitch D

frac32.s.map.pitch Eb

frac32.s.map.pitch E

frac32.s.map.pitch F

frac32.s.map.pitch Gb

frac32.s.map.pitch G

frac32.s.map.pitch Ab

frac32.s.map.pitch A

frac32.s.map.pitch Bb

frac32.s.map.pitch B

Declaration
static const uint32_t LENGTHPOW = 4;
static const uint32_t LENGTH = 1 << LENGTHPOW;
static const uint32_t LENGTHMASK = (1 << LENGTHPOW) - 1;
static const uint32_t BITS = 32;
static const uint32_t GAIN = 0;
int32_t array[LENGTH];
Init
int i;
for (i = 0; i < LENGTH; i++) {
  array[i] = 0;
}
Control Rate
int r = inlet_root + 12 * 8 + 4;
r = r - 12 * (r / 12);
int pitch = 0;

switch (r) {
case 0:
  pitch = param_C;
  break;
case 1:
  pitch = param_Db;
  break;
case 2:
  pitch = param_D;
  break;
case 3:
  pitch = param_Eb;
  break;
case 4:
  pitch = param_E;
  break;
case 5:
  pitch = param_F;
  break;
case 6:
  pitch = param_Gb;
  break;
case 7:
  pitch = param_G;
  break;
case 8:
  pitch = param_Ab;
  break;
case 9:
  pitch = param_A;
  break;
case 10:
  pitch = param_Bb;
  break;
case 11:
  pitch = param_B;
  break;
default:
  break;
}

int32_t f0 = mtof48k_ext_q31(pitch + inlet_detune);

static const int32_t intervals[] = {0,
                                    (1ll << 31) / 15,
                                    (1ll << 31) / 8,
                                    (1ll << 31) / 5,
                                    (1ll << 31) / 4,
                                    (1ll << 31) / 3,
                                    (2ll << 31) / 5,
                                    (1ll << 31) / 2,
                                    (3ll << 31) / 5,
                                    (2ll << 31) / 3,
                                    (7ll << 31) / 9,
                                    (7ll << 31) / 8};

// LCM = 5*3*3*2*2*2 = 360

static const int32_t intervals2[] = {
    360 + 0,   360 + 24,  360 + 48,  360 + 72,  360 + 90,  360 + 120,
    360 + 144, 360 + 180, 360 + 216, 360 + 240, 360 + 280, 360 + 315};

int32_t f1 = f0 / 2880;
f1 = f1 << 3;
int i;
int j = 0;
for (i = r; i < 12; i++) {
  array[i] = f1 * intervals2[j++];
}
i -= 12;
f1 = f1 >> 1;
for (; i < r; i++) {
  array[i] = f1 * intervals2[j++];
}

Privacy

© 2024 Zrna Research