[BUG]: Speaker transmitter (seemingly randomly) clearing Queue
Before You Report
- [x] I have searched for existing reports of this bug, and this bug report is unique.
Version
1.1.1
Description
If an audio clip is a multiple of 480, the CurrentPosition will be equal to the length of the sample at the end of reading it. Sometimes this causes the CurrentPosition to not be reset when dequeueing the next clip causing it to skip samples until it encounters one with a longer length.
To Reproduce
Queue multiple samples with a length of 48000 (although I expect any multiple of 480 to work).
Expected Behavior
For the examples below I used an audio file and always keeping the queue at a length of 2, so after clearing the queue it will just continue adding new clips.
In both clips the capybara is spawned when the music starts playing and remains spawned for the same amount of time, the actual time jumps may not be very noticable. (Fixed version is quite a bit louder) [bugged] -> https://youtu.be/mulHwbCaMtI [Fixed] -> https://youtu.be/ojj_PTHWaAg
Additional Information
I've personally fixed it by using the PlaybackBuffer similar to github.com/CedModV2/SCPSLAudioApi.
An easy fix would be to reset the CurrentPosition each time a new sample is read. (Currently, where the first dequeue of the Transmit coroutine is, the CurrentPosition is not reset, causing it to be stuck on its last value)
I can't get the transmitter to work at all, I passed it 50077 samples from 48000 samples per sec .ogg file decoded via NVorbis. I used logs at every step and the samples were fine and then I passed it to .Play(). The log right after play said that it got the samples right (via .CurrentSampleCount), however the Coroutine that starts a second later and logs .CurrentSampleCount and .CurrentRemainingSampleCount every second shows that it immediately goes to .CurrentSampleCount == 0, .CurrentRemainingSampleCount == -323, and IsPlaying == true forever. I don't know if it's a I'm stupid thing or what.