Je ne parviens pas à lire les paquets d'opus décodés à l'aide de Naudio
pour Windows Universal. Le son est joué pendant une fraction de seconde puis s'arrête avec une exception. L'exception que je reçois est InvalidOperation - Timed out waiting for event
.NAudio Universal: expiré en attente d'un événement
Voici mon code:
public void ForStackOverFlow()
{
var waveOut = new WasapiOutRT(AudioClientShareMode.Shared, 200);
waveOut.PlaybackStopped += WaveOut_PlaybackStopped;
var opusDecoder = OpusDecoder.Create(48000, 1);
var ms = new MemoryStream();
var voiceData1 = "3OxQRhb/datLhcmWgOhYPrYGwxyciCulHDwJl8RmJHkdWVcENoAYvgLtcFn0LBLbLJ2jHRPv8Wb/oZSsTp3oJbllORxffNIyZO1TCCf2L + dkN5AMKRmiIyYaJQrh5Bt4ucLfNskhwKwz/CfLV7RRTZrBJM + 0AqBXS9dt3 + yeBofItCGUm/GCT94pW5fl9U7Zez + RodOAzyEemdCS + Zfpquw0XctnM0L/b1llt3oHZOpot1BUY + tDyXmSNbcfxPjYmVvPT2y4aQ ==";
var sample = Convert.FromBase64String(voiceData1);
int frameSize = 1920;
short[] outputBuffer = new short[frameSize];
var decodedLen = opusDecoder.Decode(sample, 0, sample.Length, outputBuffer, 0, frameSize, false);
short[] finalOutput = new short[frameSize];
Array.Copy(outputBuffer, finalOutput, finalOutput.Length);
var audioBytes = AudioMath.ShortsToBytes(finalOutput, 0, finalOutput.Length);
System.Diagnostics.Debug.WriteLine("AUDIOBYTES:" + Convert.ToBase64String(audioBytes));
ms.Write(audioBytes, 0, audioBytes.Length);
ms.Flush();
ms.Seek(0, SeekOrigin.Begin);
IWaveProvider provider = new RawSourceWaveStream(ms, new WaveFormat(48000, 16, 1));
waveOut.Init(provider);
waveOut.Play();
}
private void WaveOut_PlaybackStopped(object sender, StoppedEventArgs e)
{
//event fires with exception.
}
Toute aide serait appréciée.
Quelle bibliothèque avez-vous utilisé pour '' OpusDecoder' et AudioMath'? –