Re: Setting the device volume
Re: Setting the device volume
- Subject: Re: Setting the device volume
- From: Michael Thornburgh <email@hidden>
- Date: Thu, 11 Nov 2004 10:28:11 -0800
in the code you included, you are asking the device for the master
volume (channel 0) of the input direction (isInput = true) of the audio
device. your device may not have an input side, or may not have a
master volume control. also, kAudioDevicePropertyVolumeScalar is a
number between 0.0 and 1.0, but it isn't necessarily the scaling factor
by which your samples are multiplied. the values 0..1 are mapped onto
the full range of volume levels supported by the device, but in a
potentially non-uniform, non-continuous, non-linear fashion.
what you *probably* want to do is:
check the output direction of the device, not the input
check the master volume (if it exists) *and* individual channel
volumes, if they exist, for each channel you're going to be sending
audio to
check for the kAudioDevicePropertyVolumeDecibels property instead of
kAudioDevicePropertyVolumeScalar
-mike
On Nov 11, 2004, at 7:20 AM, patrick machielse wrote:
Another beginner's question:
I'm trying to manipulate the volume of the audio I'm playing. As a
first step I want to know the current device volume. I use the
following code to find out the volume setting:
Float32 the_volume;
UInt32 the_size = sizeof the_volume;
OSStatus err;
err = AudioDeviceGetProperty(device,
0,
true,
kAudioDevicePropertyVolumeScalar,
&the_size,
&the_volume);
if ( err != kAudioHardwareNoError ) {
NSString *errStr = [NSString stringWithCString:(const char *)&err
length:4];
NSLog(@"get kAudioDevicePropertyVolumeScalar error \'%@\'", errStr);
}
However, this always returns an error 'who?'
(kAudioHardwareUnknownPropertyError)
I must be missing something obvious, but it's not obvious to me...
TIA,
Patrick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden