Opus Encoder Error : Channel must be stereo or mono
Vertecx
✭
in Photon Voice
Im getting an error when trying to initialize the Opus encoder class in Unity3d 5.6 beta versions. The code works flawlessly on 5.5 and 5.4. I have tried b7-b9 and none of them work. Here are the error details. The project is for Daydream/GVR so we can only use 5.6 or above that has Daydream support
ArgumentOutOfRangeException: Must be Mono or Stereo Parameter name: numChannels POpusCodec.OpusEncoder..ctor (SamplingRate inputSamplingRateHz, Channels numChannels, Int32 bitrate, OpusApplicationType applicationType, Delay encoderDelay) (at Assets/Plugins/PhotonVoiceApi/Core/POpusCodec/OpusEncoder.cs:208) ExitGames.Client.Photon.Voice.LocalVoice..ctor (ExitGames.Client.Photon.Voice.VoiceClient voiceClient, Byte id, IAudioStreamBase audioStream, ExitGames.Client.Photon.Voice.VoiceInfo voiceInfo, Int32 channelId) (at Assets/Plugins/PhotonVoiceApi/Core/VoiceClient.cs:217) ExitGames.Client.Photon.Voice.LocalVoice`1[System.Single]..ctor (ExitGames.Client.Photon.Voice.VoiceClient voiceClient, Byte id, IAudioStream`1 audioStream, ExitGames.Client.Photon.Voice.VoiceInfo voiceInfo, Int32 channelId) (at Assets/Plugins/PhotonVoiceApi/Core/VoiceClient.cs:317) ExitGames.Client.Photon.Voice.LocalVoiceFloat..ctor (ExitGames.Client.Photon.Voice.VoiceClient voiceClient, Byte id, IAudioStream`1 audioStream, ExitGames.Client.Photon.Voice.VoiceInfo voiceInfo, Int32 channelId) (at Assets/Plugins/PhotonVoiceApi/Core/VoiceClient.cs:385) ExitGames.Client.Photon.Voice.VoiceClient.CreateLocalVoice (IAudioStreamBase audioStream, ExitGames.Client.Photon.Voice.VoiceInfo voiceInfo, Int32 channelId) (at Assets/Plugins/PhotonVoiceApi/Core/VoiceClient.cs:727) ExitGames.Client.Photon.Voice.LoadBalancingFrontend.CreateLocalVoice (IAudioStreamBase audioStream, ExitGames.Client.Photon.Voice.VoiceInfo voiceInfo) (at Assets/Plugins/PhotonVoiceApi/LoadBalancingFrontend.cs:152) PhotonVoiceNetwork.CreateLocalVoice (IAudioStreamFloat audioClip, ExitGames.Client.Photon.Voice.VoiceInfo voiceInfo) (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:215) PhotonVoiceRecorder.Start () (at Assets/PUNVoice/Scripts/PhotonVoiceRecorder.cs:144)
The line that's throwing the exception is in OpusEncoder.cs:208
if ((numChannels != Channels.Mono)
&& (numChannels != Channels.Stereo))
{
throw new ArgumentOutOfRangeException("numChannels", "Must be Mono or Stereo");
}
Seems like the Encoder is not being initiated correctly. Would really appreciate some feedback on how to fix this. Please help. Thanks
ArgumentOutOfRangeException: Must be Mono or Stereo Parameter name: numChannels POpusCodec.OpusEncoder..ctor (SamplingRate inputSamplingRateHz, Channels numChannels, Int32 bitrate, OpusApplicationType applicationType, Delay encoderDelay) (at Assets/Plugins/PhotonVoiceApi/Core/POpusCodec/OpusEncoder.cs:208) ExitGames.Client.Photon.Voice.LocalVoice..ctor (ExitGames.Client.Photon.Voice.VoiceClient voiceClient, Byte id, IAudioStreamBase audioStream, ExitGames.Client.Photon.Voice.VoiceInfo voiceInfo, Int32 channelId) (at Assets/Plugins/PhotonVoiceApi/Core/VoiceClient.cs:217) ExitGames.Client.Photon.Voice.LocalVoice`1[System.Single]..ctor (ExitGames.Client.Photon.Voice.VoiceClient voiceClient, Byte id, IAudioStream`1 audioStream, ExitGames.Client.Photon.Voice.VoiceInfo voiceInfo, Int32 channelId) (at Assets/Plugins/PhotonVoiceApi/Core/VoiceClient.cs:317) ExitGames.Client.Photon.Voice.LocalVoiceFloat..ctor (ExitGames.Client.Photon.Voice.VoiceClient voiceClient, Byte id, IAudioStream`1 audioStream, ExitGames.Client.Photon.Voice.VoiceInfo voiceInfo, Int32 channelId) (at Assets/Plugins/PhotonVoiceApi/Core/VoiceClient.cs:385) ExitGames.Client.Photon.Voice.VoiceClient.CreateLocalVoice (IAudioStreamBase audioStream, ExitGames.Client.Photon.Voice.VoiceInfo voiceInfo, Int32 channelId) (at Assets/Plugins/PhotonVoiceApi/Core/VoiceClient.cs:727) ExitGames.Client.Photon.Voice.LoadBalancingFrontend.CreateLocalVoice (IAudioStreamBase audioStream, ExitGames.Client.Photon.Voice.VoiceInfo voiceInfo) (at Assets/Plugins/PhotonVoiceApi/LoadBalancingFrontend.cs:152) PhotonVoiceNetwork.CreateLocalVoice (IAudioStreamFloat audioClip, ExitGames.Client.Photon.Voice.VoiceInfo voiceInfo) (at Assets/PUNVoice/Scripts/PhotonVoiceNetwork.cs:215) PhotonVoiceRecorder.Start () (at Assets/PUNVoice/Scripts/PhotonVoiceRecorder.cs:144)
The line that's throwing the exception is in OpusEncoder.cs:208
if ((numChannels != Channels.Mono)
&& (numChannels != Channels.Stereo))
{
throw new ArgumentOutOfRangeException("numChannels", "Must be Mono or Stereo");
}
Seems like the Encoder is not being initiated correctly. Would really appreciate some feedback on how to fix this. Please help. Thanks
0
Comments
-
The error is thrown due to known Unity beta version bug https://issuetracker.unity3d.com/issues/microphone-dot-start-always-has-0-channels-available
0 -
Is there any fix on this? I still have the same issue today even with Unity 2018.2.2016f1.0
-
Hi @NTNU_VR,
The issue is on Unity's side.
Either report it as a bug to Unity or switch Unity version that does not have this bug or switch to using Photon MicrophoneType if the target platform supports it.0