Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

coreaudio: how to get/set the system alert volume as opposed to device volume

I've been searching the documentation, mailing lists on and off for a couple of days but can't seem to find the answer to this.

I've got an OS X app that, amongst other things, queries the available hardware devices and their current volumes using kAudioDevicePropertyVolumeScalar and friends.

What I want to be able to do is get and set the -alert- volume (?) for the system output device represented by kAudioHardwarePropertyDefaultSystemOutputDevice rather than that devices volume.

To clarify from my limited understand, this is the volume setting users can adjust in System Preferences under 'Play sound effects through'.

Searching the coreaudio-api lists, I've managed to glean that this volume setting is not a device property but some kind of derived value, but I'm stumped as to where to from here.

Any help would be gratefully received.

like image 969
user1649026 Avatar asked Sep 05 '12 12:09

user1649026


1 Answers

I am not sure if you really have a requirement for reading it through CoreAudio, but the following works just fine:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults addSuiteNamed:@"com.apple.systemsound"];        
NSLog(@"%f", [defaults floatForKey:@"com.apple.sound.beep.volume"]);

Though this might change with operating system updates as the settings are stored in ~/Library/Preferences/com.apple.systemsound.plist.

like image 156
Nandeep Mali Avatar answered Sep 24 '22 10:09

Nandeep Mali