public new void Dispose() { base.Dispose(); try { VGMStreamNative.CloseVGMStream(_Vgmstream); } catch { } }
public override int Read(byte[] buffer, int offset, int count) { short[] sBuffer = new short[count / 2]; // Generate samples. VGMStreamNative.RenderVGMStream(sBuffer, sBuffer.Length / _Channels, _Vgmstream); // Convert the short samples to byte samples and place them // in the NAudio byte sample buffer. Buffer.BlockCopy(sBuffer, 0, buffer, 0, buffer.Length); _TotalPlayed += sBuffer.Length / _Channels; return(buffer.Length); }
/// <summary> /// Constructor. /// </summary> /// <param name="filename">File to open in VGMStream.</param> public VGMStreamReader(string filename) { _Vgmstream = VGMStreamNative.InitVGMStream(filename); if (_Vgmstream == IntPtr.Zero) { _FileLoaded = false; return; } _FileLoaded = true; _SampleRate = VGMStreamNative.GetVGMStreamSampleRate(_Vgmstream); _Channels = VGMStreamNative.GetVGMStreamChannelCount(_Vgmstream); _TotalSamplesToPlay = VGMStreamNative.GetVGMStreamPlaySamples(loopCount, 0, 0, _Vgmstream); _LoopStartSample = VGMStreamNative.GetVGMStreamLoopStartSample(_Vgmstream); _LoopEndSample = VGMStreamNative.GetVGMStreamLoopEndSample(_Vgmstream) - 1; //Smash values always seem to be 1 less. _TotalSamples = VGMStreamNative.GetVGMStreamTotalSamples(_Vgmstream); _WaveFormat = new WaveFormat(_SampleRate, 16, _Channels); }
public void ResetVGM() { _TotalPlayed = 0; VGMStreamNative.ResetVGMStream(_Vgmstream); }