Toggle NonRealTime

Nikolas K's icon

Is there any "easy way" to toggle the NonRealTime driver on/off?

I have a patcher that does something! -Done
I want to render an audio file in NonRealTime. -Done. (If the NonRealDriver is selected by hand)
I want the audio driver to reset back to the previously selected "real time" driver when finished, like nothing ever happened! (Preferably with a bang!)

What I have already done:
When the audio driver menu is populated (from the [adstatus driver]), I check where the "NonRealTime" symbol is, and store the index.
Then I use the index to switch between the NonRealTime and the last "real time" audio driver, but it seems to be quite susceptible to crashes.

Any suggestions or tips, or is there any Max-native way to do this?

Thanks,
Nick

Source Audio's icon

This should work :
;
dsp stop, setdriver NonRealTime, start
-----------
;
dsp stop, setdriver "Core Audio", start

and so on

Nikolas K's icon

Thank you Source Audio,
I wasn't aware of the existence of "setdriver"! Looks its working fine for what I want!

Source Audio's icon

You are welcome.
setdriver is easier method for changing driver than menu selection , but turning dsp off before doing so is
esential to prevent crashes.