Dup Ver Goto 📝

LogScaleSlider

PT2/music/reaper-jsfx reaper jsfx does not exist
To
25 lines, 125 words, 832 chars Page 'LogScaleSlider' does not exist.

The sliders in Reaper are always linear. Perhaps one day they will have logarithmithic sliders. For now, what we can do if we want frequencies logarithmically, we can use MIDI pitches with fractional values, and possibly negative. Essentially our slider value is \(s\), and the frequency \(f\) is given by \[f=440\cdot 2^{\frac{s-69}{12}}\] (The 440 comes from A440, which is midi note 69, so \(s=69\) will give \(f=440) which is what we desire. We can then display this \(f\) using the gfx facilities in JSFX.

JSFX

desc: jda log freq slider example

slider1:60<0,169,0.1> Freq Midi Pitch

@slider
cutoff_freq = 440*(pow(2,(slider1-69)/12)); // hack for logarithmic slider

@gfx 640 200
x = 640*(slider1/127.0);

gfx_set(1,1,1);
gfx_x = 10;
gfx_y = 10;
gfx_printf("Cutoff midi %.01f == %.02fHz\n",slider1,cutoff_freq);