3 Replies Latest reply on Nov 27, 2012 7:21 PM by Michael Thornburgh

    Multicast: can you "cancel out" your own audio?

    okzdev

      Suppose you set up both a broadcast and receive for a multicast group voice chat:

       

      var groupspec:GroupSpecifier = new GroupSpecifier("myGroup/multicastOne");

      groupspec.serverChannelEnabled = true;

      groupspec.multicastEnabled = true;

       

      //Broadcast

      var mic:Microphone = Microphone.getMicrophone();

      bc_stream = new NetStream(nc, groupspec.groupspecWithAuthorizations());

      bc_stream.client = this;

      bc_stream.attachAudio(mic);

      bc_stream.publish("multicast");

       

      //Receive

      rc_stream = new NetStream(nc, groupspec.groupspecWithAuthorizations());

      rc_stream.client = this;

      rc_stream.play("multicast");

      video.attachNetStream(rc_stream);

       

      is there any way you can configure "canceling out" your own mic audio coming back to you over the multicast stream?

        • 1. Re: Multicast: can you "cancel out" your own audio?
          Michael Thornburgh Adobe Employee

          i'm not sure i exactly understand what you're asking.

           

          there's no loopback of multicast streams in a NetConnection, so you can't subscribe to & play a stream you're publishing without creating a new, separate NetConnection (which would have a different peer ID), making a separate connection to the group with it, and subscribing to the stream you're publishing from the other NetConnection.

           

          if you mean you want to do echo cancellation so that the microphone doesn't pick up what's being played out by the streams you're subscribed to, then you might be able to use the new "enhanced microphone" acoustic echo canceller stuff.  while i don't know whether or not it works with multicast streams, i don't know of any reason why it wouldn't.  for more information on using the echo canceller, see the ActionScript reference page for Microphone and the "Learn More" links for some examples.

          • 2. Re: Multicast: can you "cancel out" your own audio?
            okzdev Level 1

            Hi Michael,

             

            thanks for answering.

             

            you can't subscribe to & play a stream you're publishing without creating a new, separate NetConnection (which would have a different peer ID), making a separate connection to the group with it, and subscribing to the stream you're publishing from the other NetConnection.

             

            I wrote a base class + a broadcast and a receiver subclass, but they indeed create a separate netconnection, to reflect that in  the code excerpt:

             

             

            //Broadcast

            var nc1:NetConnection = new NetConnection();

            nc1.connect(SERVER+DEVKEY);

            var mic:Microphone = Microphone.getMicrophone();

            bc_stream = new NetStream(nc1, groupspec.groupspecWithAuthorizations());

            bc_stream.client = this;

            bc_stream.attachAudio(mic);

            bc_stream.publish("multicast");

             

            //Receive

            var nc2:NetConnection = new NetConnection();

            nc2.connect(SERVER+DEVKEY);

            rc_stream = new NetStream(nc2, groupspec.groupspecWithAuthorizations());

            rc_stream.client = this;

            rc_stream.play("multicast");

            video.attachNetStream(rc_stream);

             

             

            The result is I'm "hearing myself speak" on the multicast stream. My question was, is there any way to set up a multicast in which I can hear what everyone else in the group is streaming, but not my own audio stream within the multicast? Or would I need to publish a separate NetConnection + named stream for each participant, like:

             

            var nc1:NetConnection = new NetConnection();

            nc1.connect(SERVER+DEVKEY);

            var mic:Microphone = Microphone.getMicrophone();

            bc_stream = new NetStream(nc1, groupspec.groupspecWithAuthorizations());

            bc_stream.client = this;

            bc_stream.attachAudio(mic);

            bc_stream.publish(myName);

             

             

             

            and then

             

            for(participantName:String in participants)

            {

            if(participantName != myName)

            {

            var ncr:NetConnection = new NetConnection();

            ncr.connect(SERVER+DEVKEY);

            rc_stream = new NetStream(ncr, groupspec.groupspecWithAuthorizations());

            rc_stream.client = this;

            rc_stream.play(participantName);

            var video:Video = new Video();

            video.attachNetStream(rc_stream);

            }

            }

             

            the latter would obviously result in significantly more streams and P2P optimization, so I was wondering if there was a built-in "filter" to do the same from one stream, like in a video encoded with multiple sound/metadata tracks.

            • 3. Re: Multicast: can you "cancel out" your own audio?
              Michael Thornburgh Adobe Employee

              if you have only one NetConnection, then you can't subscribe to/play your own stream.  so it seems to me that if you do the easier thing and only have one NetConnection, you won't "hear your own microphone".  that is also more efficient for the group in general.