Skip to main content
jg716
Inspiring
July 11, 2012
Question

Enhanced Microphone and SoundTransform

  • July 11, 2012
  • 1 reply
  • 813 views

Hi!

I'm trying to add a mute capability for a Enhanced Microphone.  Most of the information I can find about muting a microphone involves creating a new SoundTransform with a volume of 0 and assigning it to the soundTransform property of a microphone instance.  In the past, I have seen this work to be able to get activity level from the microphone when not attached to a NetStream (i.e. loopback = true, volume = 0).  However, this doesn't appear to work with an enhanced Microphone.  Even when I assign a new SoundTransform (volume=0) to the microphone instance, I still hear it on loopback.

Any help is greatly appreciated.

This topic has been closed for replies.

1 reply

July 23, 2012

Hi,

I am able to mute the microphone for a enhanced microphone using the method you mentioned:  Creating a new SoundTransform with a volume of 0 and assigning it to the soundTransform property of a microphone instance.

import flash.events.*;

import flash.media.Microphone;

import flash.media.SoundTransform;

muteBtn.addEventListener(MouseEvent.CLICK, muteMic);

var mic:Microphone = Microphone.getEnhancedMicrophone();

//var mic:Microphone = Microphone.getMicrophone();

mic.setLoopBack(true);

function muteMic(e:MouseEvent)

{

          trace("before muteMic: " + mic.soundTransform.volume);

          var st:SoundTransform = new SoundTransform(0);

          mic.soundTransform = st; 

          trace("after muteMic: " + mic.soundTransform.volume);

}

If you attach the microphone to a NetStream and want to mute it, you need to assign the SoundTransform instance to the soundTransform property of the incoming stream as well

function muteMic():void

{

          st = new SoundTransform(0);

          // this sets for loopback

          microphone.soundTransform = st;

 

          // set for the incoming stream as well

          if (incomingStream)

          {

                    incomingStream.soundTransform = st;

          }

}

Regards,

Ting