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

Added support for extremely high sample rates to audio devices

This commit is contained in:
jules 2018-10-24 10:33:14 +01:00
parent 2666842fa5
commit 86b4fd72a0
3 changed files with 15 additions and 18 deletions

View file

@ -289,15 +289,16 @@ public:
if (OK (AudioObjectGetPropertyData (deviceID, &pa, 0, nullptr, &size, ranges)))
{
static const double possibleRates[] = { 44100.0, 48000.0, 88200.0, 96000.0, 176400.0, 192000.0, 352800.0, 384000.0 };
for (int i = 0; i < numElementsInArray (possibleRates); ++i)
for (auto r : { 44100, 48000, 88200, 96000, 176400,
192000, 352800, 384000, 705600, 768000 })
{
auto rate = (double) r;
for (int j = size / (int) sizeof (AudioValueRange); --j >= 0;)
{
if (possibleRates[i] >= ranges[j].mMinimum - 2 && possibleRates[i] <= ranges[j].mMaximum + 2)
if (rate >= ranges[j].mMinimum - 2 && rate <= ranges[j].mMaximum + 2)
{
newSampleRates.add (possibleRates[i]);
newSampleRates.add (rate);
break;
}
}

View file

@ -346,11 +346,9 @@ public:
if (asioObject != nullptr)
{
const int possibleSampleRates[] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000 };
for (int index = 0; index < numElementsInArray (possibleSampleRates); ++index)
if (asioObject->canSampleRate ((double) possibleSampleRates[index]) == 0)
newRates.add ((double) possibleSampleRates[index]);
for (auto rate : { 32000, 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000, 705600, 768000 })
if (asioObject->canSampleRate ((double) rate) == 0)
newRates.add ((double) rate);
}
if (newRates.isEmpty())

View file

@ -387,21 +387,19 @@ public:
// Got a format that is supported by the device so we can ask what sample rates are supported (in whatever format)
}
static const int ratesToTest[] = { 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000 };
for (int i = 0; i < numElementsInArray (ratesToTest); ++i)
{
if (rates.contains (ratesToTest[i]))
for (auto rate : { 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000, 705600, 768000 })
{
if (rates.contains (rate))
continue;
format.Format.nSamplesPerSec = (DWORD) ratesToTest[i];
format.Format.nSamplesPerSec = (DWORD) rate;
format.Format.nAvgBytesPerSec = (DWORD) (format.Format.nSamplesPerSec * format.Format.nChannels * format.Format.wBitsPerSample / 8);
if (SUCCEEDED (tempClient->IsFormatSupported (useExclusiveMode ? AUDCLNT_SHAREMODE_EXCLUSIVE
: AUDCLNT_SHAREMODE_SHARED,
(WAVEFORMATEX*) &format, 0)))
if (! rates.contains (ratesToTest[i]))
rates.addUsingDefaultSort (ratesToTest[i]);
if (! rates.contains (rate))
rates.addUsingDefaultSort (rate);
}
}