Skip to content

Commit 7de0b31

Browse files
committed
🔨 Fix erronious audio channel pitches being wrong
1 parent ce65fa8 commit 7de0b31

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/engine/audio/audio_engine.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ void AudioChannel::stop() {
9595
m_active = false;
9696
m_currentFile = nullptr;
9797
m_position = 0;
98+
m_currentSpeed = 1.0f;
99+
m_targetSpeed = 1.0f;
98100
}
99101

100102
void AudioChannel::setVolume(float vol) {
@@ -379,10 +381,12 @@ void AudioEngine::audioCallback(float *buffer, size_t frames) {
379381
}
380382
}
381383

382-
int AudioEngine::findFreeChannel() const {
384+
int AudioEngine::findFreeChannel() {
383385
// Skip channel 0 (reserved for music)
384386
for (size_t i = 1; i < MAX_CHANNELS; ++i) {
385387
if (!m_channels[i].isActive()) {
388+
// Optionally force a stop to ensure clean state
389+
m_channels[i].stop();
386390
return static_cast<int>(i);
387391
}
388392
}

src/engine/audio/audio_engine.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class AudioEngine {
114114

115115
void processCommands();
116116
void mixAudio(float *buffer, size_t frames);
117-
[[nodiscard]] int findFreeChannel() const;
117+
[[nodiscard]] int findFreeChannel();
118118
};
119119

120120
}; // namespace ste

0 commit comments

Comments
 (0)