From b542aea9b39e85d7141e9ad2e2989c461f0bc6b9 Mon Sep 17 00:00:00 2001 From: antpoms <148887171+antpoms@users.noreply.github.com> Date: Mon, 16 Jun 2025 16:34:37 +0200 Subject: [PATCH] =?UTF-8?q?nombre=20fini=20de=20notes=20g=C3=A9n=C3=A9r?= =?UTF-8?q?=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SimpleGame/src/Include/AudioEmitter.hpp | 1 - SimpleGame/src/Source/AudioEmitter.cpp | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/SimpleGame/src/Include/AudioEmitter.hpp b/SimpleGame/src/Include/AudioEmitter.hpp index 09b19cd..4ec424e 100644 --- a/SimpleGame/src/Include/AudioEmitter.hpp +++ b/SimpleGame/src/Include/AudioEmitter.hpp @@ -33,7 +33,6 @@ public: int nextChord(int currentChord); int firstNote(); int nextNote(int currentNote); - int noteSecondaire(int note); float getTimeTempo() const; float getTime() const; float timeBeforeNewGeneration{4.f}; diff --git a/SimpleGame/src/Source/AudioEmitter.cpp b/SimpleGame/src/Source/AudioEmitter.cpp index 741b3d7..114d769 100644 --- a/SimpleGame/src/Source/AudioEmitter.cpp +++ b/SimpleGame/src/Source/AudioEmitter.cpp @@ -280,6 +280,9 @@ int AudioEmitter::nextNote(int currentNote) { */ std::vector> AudioEmitter::generateMusic() { std::vector> result; + if (current_beat >= nbr_melo_total) { + return result; + } result.reserve(16 * nbr_melo_max); float beatDuration = tempo / 60.f; unsigned int sampleRate = 48000; @@ -344,8 +347,10 @@ std::vector> AudioEmitter::generateMusic() { void AudioEmitter::audioUpdate() { system->update(); } void AudioEmitter::audioEnd() { - for (FMOD::Channel *c : activeChannels) { - delete c; + for (int i = 0; i < activeChannels.size(); i += 1) { + if (activeChannels[i]) { + activeChannels[i]->stop(); + } } timer->stop(); system->close();