コード例 #1
0
 // Update is called once per frame
 void Update()
 {
     if (SupportSpatialAudio && Player.IsStarted())
     {
         if (TargetClip == null || TargetClip.frequency != Player.GetSamplingRate())
         {
             _CreateAudioClip((int)Player.GetSamplingRate());
         }
     }
 }
コード例 #2
0
    bool _Process()
    {
        //	if (!Grabber.IsUsingCustomOutput () )
        //		return false;
        //	if (!Grabber.IsLoaded() || !Grabber.IsPlaying() )
        //		return false;
        if (Grabber == null || !Grabber.IsStarted())
        {
            return(false);
        }

        AudioSamples p;

        if (Grabber.GrabFrame())
        {
            uint sz = Grabber.GetFrameSize();
            lock (_dataMutex) {
                p = CreatePacket();
            }
            if (p.samples == null || sz != p.samples.Length)
            {
                p.samples = new float[sz];
            }
            Grabber.CopyAudioFrame(p.samples);

            lock (_dataMutex) {
                _packets.Add(p);
                if (_packets.Count > 30)
                {
                    _packets.RemoveAt(0);
                }
                PacketsCount = _packets.Count;
            }
        }
        else
        {
            return(false);
        }

        return(true);
    }