Adaptive Sampling Rate
I am trying to implement adaptive sampling rate in my Max patch (on a Mac) so that the sample rate in my Max patch changes to match the sampling rate on the audio device when the latter is changed directly on the physical device itself (say a USB audio interface) or through Audio Midi Setup.
I know how to change the the sampling rate of the device from the Max patch (using adstatus sr) but I cannot find a way to do the reverse, i.e. have the sr in Max change when I change the sampling rate for that device in Audio Midi Setup (or on the hardware device itself, which changes the sampling rate in Audio Midi Setup).
It boils down to finding a way to query the actual sr of the device itself from Max (which adstatus sr does not seem to be able do). If I could do that somehow, I could then easily use adstatus sr to change the sr in Max to match it.
I have tried to find shell script commands or Applescirpts that would allow me to query the actual sr of the device (or any way to get that info from Audio Midi Setup) but could not find anything.
Any help would be much appreciated.
I know that the SR info I need can easily be obtained through the CoreAudio API, it's a simple call to AudioDeviceGetProperty for the kAudioDevicePropertyStreamFormat property, but I have no idea if this could be done from Max.