naudio / NAudio

Audio and MIDI library for .NET
MIT License
5.37k stars 1.09k forks source link

Audio Playback Speed Issue with Multiple Buses in WaveMixerStream32 #1128

Open MoeHiro opened 4 months ago

MoeHiro commented 4 months ago

I am using WaveMixerStream32 to manage audio tracks, buses, and a master output. My setup involves mixing multiple audio streams on each track which then feed into buses, with all buses ultimately routing into the Master for output. The system works well when each track is exclusively sent to a single bus. However, problems arise when I implement track sends—routing a track to additional buses for the purpose of applying effects individually on those buses. During playback, audio on the routed track plays back at an accelerated rate, as if it is being processed twice. I've tried to work around this by creating a custom WaveStream where the Read method writes data to a MemoryStream before returning it. This seems to work when the modified audio track and the original track are on the same line, but fails when the track is sent to another line. How can I resolve this issue, or is there a better approach to handle this situation? Reconstructing a new audio track from the source to facilitate the sends does not seem like a wise choice.