lmms
lmms copied to clipboard
Mallets - Add random knob function
Add a random knob to liven up the sound a bit. Originally introduced as a part of https://github.com/LMMS/lmms/pull/2671.
The values of Position and Hardness in the first nine instruments and the values of Modulator and Crossfeed in Tubular Bells are randomly nudged by the value of Random.
:robot: Hey, I'm @LmmsBot from github.com/lmms/bot and I made downloads for this pull request, click me to make them magically appear! :tophat:
Windows
- Windows 32-bit:
lmms-1.3.0-alpha.1.217+g25ce965f8-mingw-win32.exe
(build link
) - Windows 64-bit:
lmms-1.3.0-alpha.1.217+g25ce965f8-mingw-win64.exe
(build link
) - Windows 32-bit:
lmms-1.3.0-alpha-msvc2017-win32.exe
(build link
) - Windows 64-bit:
lmms-1.3.0-alpha-msvc2017-win64.exe
(build link
)
Linux
- Linux (AppImage):
lmms-1.3.0-alpha.1.217+g25ce965f8-linux-x86_64.AppImage
(build link
)
macOS
:robot:
{"platform_name_to_artifacts": {"Windows": [{"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://output.circle-artifacts.com/output/job/a07001d6-fab2-4e0b-99d9-63ebc241375b/artifacts/0/lmms-1.3.0-alpha.1.217+g25ce965f8-mingw-win32.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/17807?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://output.circle-artifacts.com/output/job/f04021aa-e4ed-4878-89e1-5a07107ca5f3/artifacts/0/lmms-1.3.0-alpha.1.217+g25ce965f8-mingw-win64.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/17810?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/j83ih0lq8in5b5oc/artifacts/build/lmms-1.3.0-alpha-msvc2017-win32.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/44229167"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/974bsn986grgyow3/artifacts/build/lmms-1.3.0-alpha-msvc2017-win64.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/44229167"}], "Linux": [{"artifact": {"title": {"title": "(AppImage)", "platform_name": "Linux"}, "link": {"link": "https://output.circle-artifacts.com/output/job/446abe06-73ee-464e-8da3-19c3cec84fd3/artifacts/0/lmms-1.3.0-alpha.1.217+g25ce965f8-linux-x86_64.AppImage"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/17806?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}], "macOS": [{"artifact": {"title": {"title": "", "platform_name": "macOS"}, "link": {"link": "https://output.circle-artifacts.com/output/job/e1798616-75ab-4ad9-b1a2-20220a857ef5/artifacts/0/lmms-1.3.0-alpha.1.217+g25ce965f8-mac10.14.dmg"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/17809?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}]}, "commit_sha": "befe1f155fd131a11f1f4b7da200c676e28b488d"}
i know this isnt a fix but i would appreciate if a fix for #6464 was included on this pr.
I suggest using
<random>
provided by the C++ standard library instead ofrand
. It has far more control in terms of PRNG as you can specify the distribution explicitly as well as the random number engin
Thanks! I've been ruminating over random engines quite a lot. Looking at <random>
was actually the inspiration to the random distribution hacks in the arpeggiator but I ended up going the fast_rand way with them and I was actually thinking of switching to fast_rand() here also. The reason is that <random>
, tries to solve problems that we don't really need. Predictability, quality of randomness, etc. Speed is only one of the variables in there, but in our case it may be the only one we really should care about. In this PR we only run rand() on note on so that is not going to be a problem really, but the other qualities from more advanced random engines isn't going to help us either. The quality of good random distribution is eaten up by the low resolution here. %128 and %64 makes 7 and 6 bits resolution respectively. Maybe random distribution would matter a bit actually as Mallets seem to be quite sensitive to position. In theory that is. I wouldn't bother.
Out of curiosity I stitched the fast_rand() function from lmms into the test in the article below to see how it compares. mersenne
and mersenne 64
are the ones form <random>
. I omitted some tests from the article that didn't compile or otherwise acted up.
How competitive are C++ standard random number generators
fast_rand 0.957325 ns per rand
rand 13.1842 ns per rand
mersenne 6.91625 ns per rand
mersenne 64 5.71177 ns per rand
fast_rand 0.955309 ns per rand
rand 13.1856 ns per rand
mersenne 6.94733 ns per rand
mersenne 64 5.71553 ns per rand
fast_rand 0.956868 ns per rand
rand 13.1891 ns per rand
mersenne 6.94192 ns per rand
mersenne 64 5.71617 ns per rand
This makes fast_rand() some 13 times faster than rand(). In the case of this PR I can't see how we could benefit from a better random engine but I'm definitely keeping that library in the back of my mind. Here are some other random engines that look interesting: splitmix, xorshift and pcg. https://arvid.io/2018/07/02/better-cxx-prng/
- Rebased on latest master.
- rand() changed to fast_rand(). No advanced rand needed here.
As for the gui, that isn't my cup of tea. You could add some visual indication of how the random knob affects the synth. Like an arrow drawn from the random knob to the affected knobs (updated artwork). And/Or reorganize the knobs so the random knob is situated by the affected knobs. This is a later project.