void OnDisable() { recorder.OnAudioReady -= OnAudioReady; encoder.Dispose(); encoder = null; pcmQueue.Clear(); }
void OnEnable() { recorder = GetComponent <MyRecorder>(); recorder.OnAudioReady += OnAudioReady; encoder = new UnityOpus.Encoder( UnityOpus.SamplingFrequency.Frequency_48000, UnityOpus.NumChannels.Mono, UnityOpus.OpusApplication.Audio) { Bitrate = bitrate, Complexity = 10, Signal = UnityOpus.OpusSignal.Music }; }