コード例 #1
0
ファイル: SpeexDSP.cs プロジェクト: Translab/Unity-SocialVR
 private void reset()
 {
     if (proc != null)
     {
         setOutputListener(false);
         proc.Dispose();
         proc = null;
     }
 }
コード例 #2
0
ファイル: SpeexDSP.cs プロジェクト: Translab/Unity-SocialVR
    // Message sent by PhotonVoiceRecorder
    void PhotonVoiceCreated(Voice.LocalVoice localVoice)
    {
        if (!Active)
        {
            return;
        }
        if (localVoice.Info.Channels != 1)
        {
            throw new Exception("SpeexProcessor: only mono audio signals supported.");
        }
        if (!(localVoice is Voice.LocalVoiceAudioShort))
        {
            throw new Exception("SpeexProcessor: only short audio voice supported (Set PhotonVoiceRecorder.TypeConvert option).");
        }
        var v = (Voice.LocalVoiceAudioShort)localVoice;

        // can't access the AudioSettings properties in InitAEC if it's called from not main thread
        var playChannelCount = new Dictionary <AudioSpeakerMode, int>()
        {
            { AudioSpeakerMode.Raw, 0 },
            { AudioSpeakerMode.Mono, 1 },
            { AudioSpeakerMode.Stereo, 2 },
            { AudioSpeakerMode.Quad, 4 },
            { AudioSpeakerMode.Surround, 5 },
            { AudioSpeakerMode.Mode5point1, 6 },
            { AudioSpeakerMode.Mode7point1, 8 },
            { AudioSpeakerMode.Prologic, 0 },
        }[AudioSettings.speakerMode];
        int playBufSize;
        int playBufNum;

        AudioSettings.GetDSPBufferSize(out playBufSize, out playBufNum);
        proc = new Voice.SpeexProcessor(new Logger(), () => (long)(AudioSettings.dspTime * 1000), v.FrameSize, localVoice.Info.SourceSamplingRate, localVoice.Info.Channels, AudioSettings.outputSampleRate, playChannelCount, playBufSize);
        v.AddPreProcessor(proc);
        UpdateProcProps();
        Debug.Log("SpeexDSP initialized.");
    }