DISTRHO / Cardinal

Virtual modular synthesizer plugin
https://cardinal.kx.studio/
GNU General Public License v3.0
2.29k stars 154 forks source link

[Sassy Scope] Inconsistency between frequency and note #688

Open ValeraTychov opened 4 months ago

ValeraTychov commented 4 months ago

Version

24.05

Plugin type

Native / JACK, AU, CLAP, LV2, VST2, VST3

OS

Windows

DAW / Host (if applicable)

No response

Description

Sassy Scope incorrectly calculates note from frequency. C#6 instead of A5 (~880 Hz) Ableton_Live_12_Lite_5SJpLGlcPF C#5 instead of A4 (~440 Hz) Ableton_Live_12_Lite_Se0ETsc9eA E3 instead of C3 (~130.8 Hz) Ableton_Live_12_Lite_zxG8i4K0jd

https://en.wikipedia.org/wiki/Piano_key_frequencies

The root cause is wrong calculation here https://github.com/DISTRHO/Cardinal/blob/7bee0220eb4da4c143d194192050b614d60b25b7/plugins/Cardinal/src/sassy/sassy_scope.cpp#L510

Most likely this worked correctly previously with a different value of sizef.

I'd suggest to exclude sizef from the expression because note index only depends to variable frequency and base note frequency. So the final expression should be something like the following int note = (int)(12 * log(<Multiplicative_inverse_of_C-1_frequency> * (freqbins[(int)(mp.x / uiScale)])) / log(2));