Asio device change and crackle (with solution) in


#1

in AudioDeviceSelectorComponent:

When i change the Audio Device type from “Direct Sound” to "Asio"
and then change from one to another ASIO Device, it is possible that the currently used bufferSize doesn’t match the bufferSizes that are available and you will here noise!
I added something to the AudioDeviceSelectorComponent (look at //*****new, which checks this possibility and change the buffersize to a size which is currently supported)

[code] void comboBoxChanged (ComboBox* comboBoxThatHasChanged)
{
if (comboBoxThatHasChanged == 0)
return;

    AudioDeviceManager::AudioDeviceSetup config;
    setup.manager->getAudioDeviceSetup (config);
    String error;

    if (comboBoxThatHasChanged == outputDeviceDropDown
          || comboBoxThatHasChanged == inputDeviceDropDown)
    {
        if (outputDeviceDropDown != 0)
            config.outputDeviceName = outputDeviceDropDown->getSelectedId() < 0 ? String::empty
                                                                                : outputDeviceDropDown->getText();

        if (inputDeviceDropDown != 0)
            config.inputDeviceName = inputDeviceDropDown->getSelectedId() < 0 ? String::empty
                                                                              : inputDeviceDropDown->getText();

        if (! type->hasSeparateInputsAndOutputs())
            config.inputDeviceName = config.outputDeviceName;

        if (comboBoxThatHasChanged == inputDeviceDropDown)
            config.useDefaultInputChannels = true;
        else
            config.useDefaultOutputChannels = true;

        error = setup.manager->setAudioDeviceSetup (config, true);

 
		//******** new
		if (error.isEmpty())
		{
			int numBufferSizesAvailable=setup.manager->getCurrentAudioDevice()->getNumBufferSizesAvailable();
			
			bool bufferSizeMatched=false;
			for (int i=0 ; i<numBufferSizesAvailable; i++)
			{
				if (config.bufferSize == setup.manager->getCurrentAudioDevice()->getBufferSizeSamples (i))
				{
					bufferSizeMatched=true;
				}
			}
			if ((!bufferSizeMatched) && (numBufferSizesAvailable>0))
			{
				config.bufferSize=setup.manager->getCurrentAudioDevice()->getBufferSizeSamples(numBufferSizesAvailable-1);
				error = setup.manager->setAudioDeviceSetup (config, true);
			}
		}
		//***********


        showCorrectDeviceName (inputDeviceDropDown, true);
        showCorrectDeviceName (outputDeviceDropDown, false);

        updateControlPanelButton();
        resized();
    }
   //etc.

[/code]


#2

Out of curiosity, is this relevant, and, is it going to be added to the juce source code ?


#3

i hope, it defiantly fixes a problem with my rme fireface driver. Maybe there is a better solution, but this fix works


#4

Sorry, I hadn’t seen this post.

I see what’s going on, but this is the wrong place to fix it - I’ll add something to the AudioDeviceManager to check the buffer size when you call setAudioSettings.


#5

cool, also i’m wondering about the direct-Sound default-buffersize “960”, this cause minor crackle on some systems. Maybe we should change it to a “power of two” 1024, which is i think more common