Skip to content

Commit

Permalink
🐛 Fixed a bug that caused incorrect index calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
AutumnSky1010 committed Dec 30, 2024
1 parent 57bdb9e commit 681a87b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/SoundMaker/Sounds/TrackBaseSound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ public StereoWave GenerateStereoWave()
var pan = (track.Pan + 1) / 2.0f;
for (int i = track.StartIndex; i <= track.EndIndex; i++)
{
left[i] += (short)(trackWave[i - track.StartIndex] * pan / concurrentTracksCount);
right[i] += (short)(trackWave[i - track.StartIndex] * (1 - pan) / concurrentTracksCount);
left[i] += (short)((trackWave[i - track.StartIndex] / concurrentTracksCount) * pan);
right[i] += (short)((trackWave[i - track.StartIndex] / concurrentTracksCount) * (1 - pan));
}
}
}
Expand Down Expand Up @@ -363,8 +363,8 @@ public IEnumerable<StereoWave> GenerateBufferedStereoWave(int startIndex, int bu

for (int seekIndex = startIndex; seekIndex <= maxEndIndex; seekIndex += bufferSize)
{
var right = new short[maxEndIndex + 1];
var left = new short[maxEndIndex + 1];
var right = new short[bufferSize];
var left = new short[bufferSize];
foreach (var (_, tracks) in _tracksTimeMap)
{
foreach (var track in tracks)
Expand All @@ -383,8 +383,8 @@ public IEnumerable<StereoWave> GenerateBufferedStereoWave(int startIndex, int bu
var pan = (track.Pan + 1) / 2.0f;
for (int i = 0; i < trackWave.Length; i++)
{
left[i] += (short)(trackWave[i - track.StartIndex] * pan / concurrentTracksCount);
right[i] += (short)(trackWave[i - track.StartIndex] * (1 - pan) / concurrentTracksCount);
left[i] += (short)((trackWave[i] / concurrentTracksCount) * pan);
right[i] += (short)((trackWave[i] / concurrentTracksCount) * (1 - pan));
}
}
}
Expand Down

0 comments on commit 681a87b

Please sign in to comment.