Created
September 26, 2012 21:47
-
-
Save sneakyness/3790826 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get sample rate of the default input device | |
OSStatus MyGetDefaultInputDeviceSampleRate(Float64 *outSampleRate) | |
{ | |
OSStatus error; | |
AudioDeviceID deviceID = 0; | |
// get the default input device | |
AudioObjectPropertyAddress propertyAddress; | |
UInt32 propertySize; | |
propertyAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice; | |
propertyAddress.mScope = kAudioObjectPropertyScopeGlobal; | |
propertyAddress.mElement = 0; | |
propertySize = sizeof(AudioDeviceID); | |
error = AudioHardwareServiceGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &propertySize, &deviceID); | |
if (error) return error; | |
// get its sample rate | |
propertyAddress.mSelector = kAudioDevicePropertyNominalSampleRate; | |
propertyAddress.mScope = kAudioObjectPropertyScopeGlobal; | |
propertyAddress.mElement = 0; | |
propertySize = sizeof(Float64); | |
error = AudioHardwareServiceGetPropertyData(deviceID, &propertyAddress, 0, NULL, &propertySize, outSampleRate); | |
return error; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well doesn't this look like fun