-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to change sample rate in the settings menu #7719
Add ability to change sample rate in the settings menu #7719
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some issues with this PR.
- The UI defaults to 8000 now
- The spinbox encourages selecting arbitrary sample rates. I don't think that we want this.
- ExportProjectDialog uses different values. Shouldn't these match?
lmms/src/gui/modals/ExportProjectDialog.cpp
Line 159 in d145f78
const auto samplerates = std::array{44100, 48000, 88200, 96000, 192000};
Also, I would love a small explanation about the use-case for this PR to justify values such as 8000
(this may be common sense or a very common value to some that I do not know about, so perhaps it would benefit this PR to explain this value in a few words?).
@tresf, The reason for 8000 as a minimum was because it was the lowest value listed in the table here. If it's a bad minimum it can be changed no problem. I'll change the UI element to be a slider, I just have to figure out how to limit it to only a few defined values. The sample rates listed in other places should match. |
The points Tresf is bringing up here are correct, and this PR would break a lot of things and encourage users to do things that aren't good. Before going into the issues, the first thing to point out is that there is absolutely no quality advantage to changing the sample rate to arbitrary values. Changing the sample rate simply changes the maximum frequency the audio can support (Nyquist, which is half of the sample rate). The standard sample rate of 44100 Hz already has a Nyquist of 22050 Hz, far above the upper range of human hearing. This means, regardless of whether the audio is 44100 Hz, 47628 Hz, or 9000000000 Hz, it will sound absolutely identical. If you go far below 44100 Hz, the audio won't even be able to store frequencies across the entire range of human hearing. For example, a sample rate of 8000 Hz (the current UI default) would only be able to store frequencies up to 4000 Hz. It would sound like you put an infinitely steep 4000 Hz lowpass filter on everything. Here are some of the issues that would pop up from setting arbitrary sample rate values:
This is quite a lot of downside with no upside (especially point #1 which is the most important). For compatibility reasons, the user should be encouraged to only use standard sample rates. I recommend 44100, 48000, 96000, 192000, and 384000. If we still want to support arbitrary sample rates (almost nobody does, for the reasons I explained), it should be an advanced feature that the average user is heavily dissuaded from ever touching. |
@sakertooth hard crash when the settings dialog is raised. Remove |
Not too sure. Just pushed some new commits though, let me know if anything changes 👍 |
Still crashes. Here' the bt:
Here's the full bt: https://gist.github.com/tresf/699f188b8df8ad9902d65614737606a8 |
Ah, I think I know why. |
I figured out why but in doing so I found a quite sinister bug in |
The latest rounds of patches fixes the crash when the Setup Dialog is raised. I tested a few non-44100 sample rates with SDL and PortAudio without any observable issues. The only thing that stands out to me is that the export dialog should probably default to the same sample rate as the Setup Dialog for consistency purposes. This way if a plugin misbehaves on playback at certain sample rates, the user will be encouraged to use the same sample rate for export, theoretically resulting in a
If impacting the export dialog in this way is out of scope for this PR, it may make sense as a follow-up PR. Note Functionally, approving in current form for macOS on above contingency.
|
I agree. I'll try to get this done soon. |
On top of this, even when working with plugins that do support all of these sample rates, any change in sample rate can (and will, in the large majority of cases) result in a drastic change in the sound. For example, LMMS's Equalizer filter shapes have cramping near Nyquist, meaning a sample rate change would completely change what your filter shape even is. The amount of aliasing present in audio rate modulations and distortion plugins and such would also change. It's essential that the user is encouraged to export at the same sample rate they're working in, or we'll otherwise get flooded with bug reports of people asking why their export sounds completely different from their playback. |
…rent output sample rate by default
A slider was added in the audio settings menu that allows users to change the sample rate. The slider only allows the choice of a few standard sample rates, those currently being 44100, 48000, 88200, 96000, and 192000.