Quantcast
Channel: NAudio
Viewing all articles
Browse latest Browse all 5831

New Post: failed to play the following sound file in naudiodemo

$
0
0
Hi ..
in the naudio demo I tried to play back the following file (same file on both links ):
http://www.filedropper.com/mix4stereochannels16bitpcm10sec

http://www.4shared.com/music/zSpIZ2JRba/Mix_4StereoChannels_16BitPcm_1.html


I need to select the direct sound as output driver ...
and play to primary sound driver..
(check the image below)

it says:
value does not fall within the expected range.

iam using the naudio 1.7

any help is really appreciated ..

Image

in my c# application iam trying to play the audio file (but when I click to play the audio file, it just calls the WaveOutPlaybackStopped event, I think it is the same error as in naudio):
private DirectSoundOut waveOut;
private MeteringSampleProvider postVolumeMeter;
...

this.AudioFile = new AudioFileReader(this.audioFilePath);
 AudioFileTotalTime = this.AudioFile.TotalTime.TotalMilliseconds;
this.waveOut = new DirectSoundOut(this.deviceGuid);
this.postVolumeMeter = new MeteringSampleProvider(this.AudioFile);
this.postVolumeMeter.StreamVolume += OnPostVolumeMeter;
waveOut.PlaybackStopped += WaveOutPlaybackStopped;
this.waveOut.Init(new SampleToWaveProvider(this.postVolumeMeter));
return true;
...
        private void WaveOutPlaybackStopped(object sender, StoppedEventArgs e)
        {
            PlayBackStopped = true;
        }

public bool Deinitialize()
        {
            if (this.waveOut != null)
            {
                Stop();

                DispatcherControlledCall(() => this.waveOut.Dispose());
                this.waveOut.PlaybackStopped -= WaveOutPlaybackStopped;
                this.waveOut = null;
            }
            
            if (this.AudioFile != null)
            {
                this.AudioFile.Dispose();
                this.AudioFile = null;
            }

            if (this.postVolumeMeter != null)
            {
                this.postVolumeMeter.StreamVolume -= OnPostVolumeMeter;
                this.postVolumeMeter = null;
            }
            return true;
        }

        private void OnPostVolumeMeter(object sender, StreamVolumeEventArgs e)
        {
            if (e.MaxSampleValues != null)
            {
                LeftChannelStreamVolume = e.MaxSampleValues[0];
                if (e.MaxSampleValues.Length > 1)
                {
                    RightChannelStreamVolume = e.MaxSampleValues[1];
                }
            }
        }


Viewing all articles
Browse latest Browse all 5831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>