AudioDeviceManager(), stop and start stream possible/needed?

Hi

In my small application I have an algorithm real-time processing the line-input of the sound card. I added a button in the application which opens the audioDeviceManager configuration window. When chosing another soundcard than the deafult one the program breaks; I believe this could be solved by stopping the processing of the line-in stream when the configuration window is opened and when the configuration has been carried out the streaming should be started again (or maybe I should just do a reset). I might be wrong here!

If I’m not how can I do this (I couldn’t find a halt/stop member function of the audioDeviceManager class)?

If I’m wrong what then seems to be the problem?

Best Regards
Thomas

When you say it ‘breaks’, what do you mean? Just that it glitches? (which is kind of inevitable when you change device!)

If you need to smooth it out, why not just disconnect your own source from the processing chain, and reconnect it after the dialog has been closed?

[quote=“jules”]When you say it ‘breaks’, what do you mean? Just that it glitches? (which is kind of inevitable when you change device!)

If you need to smooth it out, why not just disconnect your own source from the processing chain, and reconnect it after the dialog has been closed?[/quote]

Hi Jules,

Sorry I know I’m not very elaborate here. With ‘Breaks’ I refer to when Visual Express 2008 prompts: “unhandled
exception at 0xsomething in juce applica…”

I just tried to do as you suggest (by disconnecting before the dialog and reconnect after) but that didn’t
work out much better…although now the program doesn’t break when the dialog window opens but it does when
it is closed.

I added a boolean (runAlgo) which is set to false when the dialog window is opened and set to true when closing
allowing the algorithm to run again. See code below!

THIS MIGHT BE COMPLETE NONSENSE - I hope I’m not waisting your time here…your replies are highly appreciated!

ButtonListener:

[code]if (buttonThatWasClicked == configButton)
{

	runAlgo = 0;

	AudioDeviceSelectorComponent audioSettingsComp (AnAudioDeviceManager,
		0, 1,
		2, 2,
		true,
		false);

	audioSettingsComp.setSize (500, 400);

	DialogWindow::showModalDialog (T("Audio Settings"),
		&audioSettingsComp,
		this,
		Colours::azure,
		true);

	runAlgo = 1;
}

[/code]
audioDeviceIOCallback

[code]{

peakLevel = 0;

if(runAlgo)
{
	for (int j = 0; j < numSamples; ++j)
	{
		outputChannelData [0][j]=inputChannelData [0][j];
		outputChannelData [1][j]=inputChannelData [0][j];

	}
}

}[/code]

Ok, I see… well, you clearly have a few things to learn about multithreading! What I meant was actually to remove the audio callback before showing the dialog and put it back afterwards, which would be safer than what you’re attempting there. But really, if it’s crashing, you probably just need to find out what’s messing up and fix it. If your code is robust, you shouldn’t have to do anything special to cope with changing devices.

Thanks again…and yes I have much to learn!

I think I have to go with your advice on removing the audio-callback while the dialog window is open; even the

outputChannelData [0][j]=inputChannelData [0][j]; outputChannelData [1][j]=inputChannelData [0][j];

makes the program crash!

Thanks a lot for answering my question!

Best Regards
Thomas

Thanks again…and yes I have much to learn!

I think I have to go with your advice on removing the audio-callback while the dialog window is open; even the

outputChannelData [0][j]=inputChannelData [0][j]; outputChannelData [1][j]=inputChannelData [0][j];

makes the program crash!

Thanks a lot for answering my question!

Best Regards
Thomas[/quote]

I tried to remove the callback before the dialog window and activating it again the following way…seemed logical to me…didn’t work though :frowning:

If I’m completely off-track I understand you pass this mail!

ButtonListener:

[code]if (buttonThatWasClicked == configButton)
{

	AnAudioDeviceManager.setAudioCallback (0);

	AudioDeviceSelectorComponent audioSettingsComp (AnAudioDeviceManager,
		0, 1,
		2, 2,
		true,
		false);

	audioSettingsComp.setSize (500, 400);

	DialogWindow::showModalDialog (T("Audio Settings"),
		&audioSettingsComp,
		this,
		Colours::azure,
		true);

	AnAudioDeviceManager.setAudioCallback (this);
}
else if (buttonThatWasClicked == debugButton)
{

}

[/code]

Like I said, if your code’s not robust, then trying to work around it by starting/stopping the manager is probably pointless. Find out why it’s crashing and fix it!