コード例 #1
0
        public MyAudioFileReader(Stream stream, WaveStreamType waveStreamType)
        {
            _lockObject = new object();
            CreateReaderStream(stream, waveStreamType);

            _sourceBytesPerSample = _readerStream.WaveFormat.BitsPerSample / 8 * _readerStream.WaveFormat.Channels;
            _sampleChannel        = new NAudio.Wave.SampleProviders.SampleChannel(_readerStream, false);
            _destBytesPerSample   = 4 * _sampleChannel.WaveFormat.Channels;
            _length = SourceToDest(_readerStream.Length);
        }
コード例 #2
0
 private void initWaveOut()
 {
     if (this.waveOut != null)
     {
         this.waveOut.Dispose();
     }
     this.volumeWhenCached     = getBackgroundVolume();
     this.deviceIdWhenCached   = AudioPlayer.naudioBackgroundPlaybackDeviceId;
     this.waveOut              = new NAudio.Wave.WaveOutEvent();
     this.waveOut.DeviceNumber = this.deviceIdWhenCached;
     NAudio.Wave.SampleProviders.SampleChannel sampleChannel = new NAudio.Wave.SampleProviders.SampleChannel(reader);
     sampleChannel.Volume = this.volumeWhenCached;
     this.waveOut.Init(new NAudio.Wave.SampleProviders.SampleToWaveProvider(sampleChannel));
 }