This project has moved and is read-only. For the latest updates, please go here.

Missing WaveOut in UWP Projects

Nov 25, 2016 at 5:30 PM
Hi,

I'm, trying to convert an app which uses NAudio to the UWP (Universal Windows Platform) platform. I have installed the Nuget package for NAudio to my UWP solution, but the WaveOut object no longer seems to exist.

Has this been removed for UWP projects? If so what is the alternative and is there any documentation on this? If not then does anyone know why it appears to be missing. I have exactly the same version (1.7.3) running just fine in a standard Windows Forms app so it definitely seems to be a problem related to the UWP platform.

Many thanks,

Damien
Nov 27, 2016 at 1:59 PM
Edited Nov 27, 2016 at 2:00 PM
After some further research I've found that WaveOut is replaced by WasapiOutRT for Windows Store Apps. I have had to make quite a few code changes. However, I'm having problem making any sound. My code is as follows:
WasapiOutRT _wavePlayer;
BufferedWaveProvider _bufferProvider;

public Audio()
{
_wavePlayer = new WasapiOutRT(NAudio.CoreAudioApi.AudioClientShareMode.Shared, 100);

            _wavePlayer.Init(() =>
            {
                WaveFormat waveFormat = new WaveFormat(SAMPLE_RATE, 16, 2);
                _bufferProvider = new BufferedWaveProvider(waveFormat);
                _bufferProvider.DiscardOnBufferOverflow = true;
                return _bufferProvider;
            });
}

public bool TrySubmitBuffer(byte[] buffer, int buffer_size)
        {
            if (buffer_size >= SUBMIT_SIZE)
            {
                if (_wavePlayer.PlaybackState == PlaybackState.Stopped)
                {
                    _wavePlayer.Play();
                }
                else
                {
                    _bufferProvider.AddSamples(buffer, 0, buffer_size);
                }

                return true;
            }

            return false;
        }
Does this look right? Audio is called once to set up the class then TrySubmitBuffer is continually called by my AY sound chip emulator. I can see the data is passed into the BufferProvider instance but I can't see it being passed to the WasapiOutRT instance.