Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
StereoPanSampleProvider.cs
1using NAudio.Wave;
2
4
6internal sealed class StereoPanSampleProvider : ISampleProvider
7{
8 private readonly ISampleProvider _source;
9
17 public StereoPanSampleProvider(ISampleProvider source)
18 {
19 if (source.WaveFormat.Channels != 2)
20 throw new ArgumentException("StereoPanSampleProvider requires a stereo source.", nameof(source));
21
22 _source = source;
23 }
24
28 public WaveFormat WaveFormat => _source.WaveFormat;
29
33 public float LeftVolume { get; set; } = 1.0f;
34
38 public float RightVolume { get; set; } = 1.0f;
39
47 public int Read(float[] buffer, int offset, int count)
48 {
49 var read = _source.Read(buffer, offset, count);
50 for (var index = 0; index + 1 < read; index += 2)
51 {
52 buffer[offset + index] *= LeftVolume;
53 buffer[offset + index + 1] *= RightVolume;
54 }
55
56 return read;
57 }
58}