Re: Setting the device volume
Re: Setting the device volume
- Subject: Re: Setting the device volume
- From: Jeff Moore <email@hidden>
- Date: Thu, 11 Nov 2004 15:17:38 -0800
The HAL/IOAudio family deal just with what devices have. They don't
provide any support for things that the hardware can't do. In your
case, the USB device you are working doesn't have any volume controls
on it. So if you want to provide volume control for your application,
then you have to do the volume scaling yourself prior to handing the
data off to the HAL.
While I'm on the subject, I'll take a second and reiterate that because
they are global for the entire system, hardware settings (that includes
volume, mute, format, etc.) belong to the user. By and large
applications shouldn't need to adjust hardware settings. Applications
that want to control the volume of the audio they are feeding to the
hardware should always do it in software. There are exceptions of
course, but this is the general guideline that folks should follow.
I should also point out that AUHAL provides a master volume control and
most apps should be using AUHAL for interacting with the hardware
anyway.
On Nov 11, 2004, at 2:57 PM, patrick machielse wrote:
Op 11-nov-04 om 21:03 heeft Michael Thornburgh het volgende geschreven:
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.
OK. It seems I was playing through a device that has neither the
kAudioDevicePropertyVolumeDecibels nor the
kAudioDevicePropertyVolumeScalar property. (tried both on channel 0
(master) and channel 1, for both directions). This is a usb Yamaha
AP-U70 'personal amplifier'. When I use the build-in audio on my
powerbook I am able to get both properties. In the 'Sound' system
preference pane I also cannot adjust the volume of the device, so
maybe that is related to this issue.
Is there an alternative route I can take to adjust the playback volume
of any device, regardless of whether it supports these properties? Or
is the only reliable way to adjust the playback volume through direct
manipulation of the audio data?
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.
Thanks for this info (I'm a sound newby, and CoreAudio isn't very
friendly to newbies.) I'll try to think 'decibels' in future...
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);
}
_______________________________________________
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
--
Jeff Moore
Core Audio
Apple
_______________________________________________
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