| 1234567891011121314151617181920212223242526 |
- using NAudio.Wave;
- namespace Client.MirSounds.Libraries
- {
- class OneShotProvider : ISampleProvider
- {
- private readonly CachedSound cachedSound;
- private long position;
-
- public OneShotProvider(CachedSound cachedSound)
- {
- this.cachedSound = cachedSound;
- }
- public int Read(float[] buffer, int offset, int count)
- {
- var availableSamples = cachedSound.AudioData.Length - position;
- var samplesToCopy = Math.Min(availableSamples, count);
- Array.Copy(cachedSound.AudioData, position, buffer, offset, samplesToCopy);
- position += samplesToCopy;
- return (int)samplesToCopy;
- }
- public WaveFormat WaveFormat { get { return cachedSound.WaveFormat; } }
- }
- }
|