LMMS / lmms

Cross-platform music production software
https://lmms.io
GNU General Public License v2.0
7.8k stars 985 forks source link

Vibed - Issues exporting at 192 kHz #7221

Open zonkmachine opened 2 months ago

zonkmachine commented 2 months ago

System Information

Ubuntu 22.04

LMMS Version(s)

1.2.2, master at bda042e1e

Bug Summary

Vibed has issues exporting at 192 kHz.

Expected Behaviour

It exports at 192 kHz all the time?

Steps To Reproduce

Export VibedExport.mmp.txt at 192 kHz! (remove .txt) Observe the curve (see image). Export the project again but adjust the knob Length (string length) to 2. The exported soundfile now looks like expected.

The steps above was done with fpe debugging flags set so no floating point errors detected.

Screenshots / Minimum Reproducible Project

vibed

Rossmaxx commented 2 months ago

If you are talking about oversampling, that is indeed bugged and i remember @LostRobotMusic campaigning for it to be removed.

zonkmachine commented 2 months ago

If you are talking about oversampling,

I'm not. I'm talking about export frequency sampling rate. Please test the steps above.

zonkmachine commented 2 months ago

...Sampling rate.

Rossmaxx commented 2 months ago

Please test the steps above.

That's my main limitation rn. I don't have my pc with me so can't test anything.+ College sucking up my time and energy.

michaelgregorius commented 2 months ago

This is caused in the constructor of VibratingString.cpp. Line 46 seems to be the relevant line: https://github.com/LMMS/lmms/blob/71dd300f43d6c1e69cbf1362174a8747427ff248/plugins/Vibed/VibratingString.cpp#L46

m_oversample is 0 here which means that stringLength becomes 1.

Why is m_oversample though? That's because of this line in the constructor: https://github.com/LMMS/lmms/blob/71dd300f43d6c1e69cbf1362174a8747427ff248/plugins/Vibed/VibratingString.cpp#L39

oversample is set to 1, sampleRate is set to 192000 and Engine::audioEngine()->baseSampleRate() is 44100.

This gives 2 * 1 / (192000 / 44100) ~ 2 / 4.35 ~ 0.46. This rounds down to 0 for the int.

softrabbit commented 6 days ago

I wonder... should the plugins really know about any other sample rates than the one they're supposed to spit out samples at? I mean, is there (and should there be) a difference between e.g. 88200 Hz and 44100 Hz with 2x oversampling?

michaelgregorius commented 4 days ago

IMO the plugins should only know about the sample rate that the DAW tells it to process data at. This is the sample rate at which audio is coming in and expected to come out of the plugin. This is how it's implemented in all the plugin standards, e.g. VST, CLAP, etc., as well.

The plugin should not access any other data from the DAW. In fact "regular" plugins cannot even do that because DAWs are different and all they know is the interface of the plugin standard they are implemented in.