Exemplo n.º 1
0
 public void Close()
 {
     if (_audioGrabber != null)
     {
         _audioGrabber.Close();
         _audioProcessor.Close();
     }
     _audioProcessor = null;
     _audioGrabber   = null;
     Output.Clear();
     _audioCreated = false;
 }
Exemplo n.º 2
0
    public void Init()
    {
        _audioCreated = true;



        //_audioGrabber.Init(AudioPort, (int)channelsCount, Output.SamplingRate);
        //_audioGrabber.Start();

        //         if (AudioPort == 0)
        //             AudioPort = _audioGrabber.GetAudioPort();

        // Debug.Log("Playing audio from port:" + AudioPort.ToString());

        // next create the audio grabber to encapsulate the audio processing
        _audioProcessor         = new GstAudioPacketProcessor();
        _audioProcessor.Grabber = _audioGrabber;

        //link processor with the channels
        var c = Output.GetChannel(0, true);

        c.channel = channelsMap;
        _audioProcessor.AttachedPlayers.Add(c);
    }
Exemplo n.º 3
0
    void _initAudioPlayers()
    {
        _audioCreated   = true;
        _configReceived = false;
        //Create audio playback
        if (AudioStream)
        {
            string audioPorts = "";
            TxEarsOutput.SourceChannel[] channels;
            if (!_isSpatialAudio)
            {
                channels = new TxEarsOutput.SourceChannel[1] {
                    TxEarsOutput.SourceChannel.Both
                };
                for (int i = 0; i < _audioSourceCount; ++i)
                {
                    var c = Output.GetChannel(i, true);
                    c.AudioLocation = Vector3.zero;
                }
            }
            else
            {
                //check number of audio locations
                for (int i = 0; i < 2 * _audioSourceCount; ++i)
                {
                    var c = Output.GetChannel(i, true);
                    c.AudioLocation = Vector3.zero;
                }

                channels = new TxEarsOutput.SourceChannel[2] {
                    TxEarsOutput.SourceChannel.Right, TxEarsOutput.SourceChannel.Left
                };
            }

            int idx          = 0;
            int channelIndex = 0;
            for (int i = 0; i < _audioSourceCount; ++i)
            {
                GstNetworkAudioGrabber  grabber;
                GstAudioPacketProcessor processor;

                grabber = new GstNetworkAudioGrabber();

                uint   audioPort = (uint)Settings.Instance.GetPortValue("AudioPort", 0);
                string ip        = Settings.Instance.GetValue("Ports", "ReceiveHost", _ifo.IP);
                grabber.Init(audioPort, 2, AudioSettings.outputSampleRate);
                grabber.Start();

                audioPort = grabber.GetAudioPort();
                Debug.Log("Playing audio from port:" + audioPort.ToString());
                audioPorts += audioPort.ToString();
                if (i != _audioSourceCount - 1)
                {
                    audioPorts += ",";
                }

                // next create the audio grabber to encapsulate the audio player
                processor         = new GstAudioPacketProcessor();
                processor.Grabber = grabber;
                _audioProcessor.Add(processor);

                //link processor with the channels
                for (int j = 0; j < channels.Length; ++j, ++channelIndex)
                {
                    var c = Output.GetChannel(channelIndex, true);
                    c.channel = channels [j];
                    processor.AttachedPlayers.Add(c);
                }

                _audioGrabber.Add(grabber);
            }
            RobotConnector.Connector.SendData(TxKitEars.ServiceName, "AudioPort", audioPorts, true);
        }
    }