1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

AudioDeviceSelectorComponent: Always show the actual samplerate of the device

Previously, the samplerate combo would display as a blank box in the
case that the device's actual samplerate wasn't one of the "available"
samplerates reported by the device.
This commit is contained in:
reuk 2021-08-10 12:51:53 +01:00
parent fd87195941
commit ceae64dd40
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -692,13 +692,17 @@ private:
sampleRateDropDown->onChange = nullptr;
}
const auto getFrequencyString = [] (int rate) { return String (rate) + " Hz"; };
for (auto rate : currentDevice->getAvailableSampleRates())
{
auto intRate = roundToInt (rate);
sampleRateDropDown->addItem (String (intRate) + " Hz", intRate);
const auto intRate = roundToInt (rate);
sampleRateDropDown->addItem (getFrequencyString (intRate), intRate);
}
sampleRateDropDown->setSelectedId (roundToInt (currentDevice->getCurrentSampleRate()), dontSendNotification);
const auto intRate = roundToInt (currentDevice->getCurrentSampleRate());
sampleRateDropDown->setText (getFrequencyString (intRate), dontSendNotification);
sampleRateDropDown->onChange = [this] { updateConfig (false, false, true, false); };
}