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();