• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Re: Mute/Unmute audio device
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: Mute/Unmute audio device


  • Subject: Re: Re: Mute/Unmute audio device
  • From: email@hidden
  • Date: Thu, 12 Nov 2009 09:27:32 +0000

you could set the volume to 0.0 to mute and just store the state elsewhere for the unmute...

volume is at 0.7
call mute
mute stores 0.7
set volume 0.0
call unmute
unmute sets volume to 0.7 (from stored value)


On , Symadept <email@hidden> wrote:
> 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
> >
>
>
>
>
>
 _______________________________________________
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

  • Follow-Ups:
    • Re: Re: Mute/Unmute audio device
      • From: Symadept <email@hidden>
    • Re: Mute/Unmute audio device
      • From: Jean-Daniel Dupas <email@hidden>
  • Prev by Date: Could not hear audio queue sound to bluetooth headset‏
  • Next by Date: Re: Mute/Unmute audio device
  • Previous by thread: Re: Mute/Unmute audio device
  • Next by thread: Re: Mute/Unmute audio device
  • Index(es):
    • Date
    • Thread