Re: Mute/Unmute audio device
Re: Mute/Unmute audio device
- Subject: Re: Mute/Unmute audio device
- From: Symadept <email@hidden>
- Date: Thu, 12 Nov 2009 16:52:19 +0800
Hi,
I am using core audio to Set/Get the Audio device volume. With reference to
the following code
+ (float)volume:(NSString*)deviceName isInput:(BOOL)isInput{
float b_vol;
OSStatus err;
UInt32 size;
UInt32 channels[2];
float volume[2];
AudioDeviceID device = [AudioUtils DeviceIdFor:deviceName isInput
:isInput];
NSLog(@"Device:[%x] IsInput:[%d]", device, isInput);
//Assume here I am getting the device id of the devices with the specific
name.
// try set master volume (channel 0)
size = sizeof( b_vol);
err = AudioDeviceGetProperty(device, 0, isInput,
kAudioDevicePropertyVolumeScalar, &size, &b_vol);
NSLog(@"Volume:[%f]", b_vol);
if(noErr==err) return b_vol;
// otherwise, try seperate channels
// get channel numbers
size = sizeof(channels);
err = AudioDeviceGetProperty(device, 0, isInput,
kAudioDevicePropertyPreferredChannelsForStereo, &size,&channels);
if(err!=noErr) NSLog(@"error getting channel-numbers");
size = sizeof(float);
err = AudioDeviceGetProperty(device, channels[0], isInput,
kAudioDevicePropertyVolumeScalar, &size, &volume[0]);
if(noErr!=err) NSLog(@"error getting volume of channel %d",channels[0]);
err = AudioDeviceGetProperty(device, channels[1], isInput,
kAudioDevicePropertyVolumeScalar, &size, &volume[1]);
if(noErr!=err) NSLog(@"error getting volume of channel %d",channels[1]);
b_vol = (volume[0]+volume[1])/2.00;
NSLog(@"Volumes:V1[%f] V2[%f] Final:[%f]", volume[0], volume[1], b_vol);
return b_vol;
}
This code works fine for getting volume. Similarly can I set the audio
device to Mute/Unmute.
Any pointers highly appreciable.
Regards
Mustafa
On Thu, Nov 12, 2009 at 12:58 PM, <email@hidden> wrote:
> which technology are you asking about?
>
>
> On Nov 12, 2009 2:47pm, Symadept <email@hidden> wrote:
> > Hi,
> >
> > How to Mute/Unmute audio device.
> >
> > Regards
> > Mustafa
> >
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden