nombre fini de notes générées

This commit is contained in:
antpoms 2025-06-16 16:34:37 +02:00
parent e5357049b0
commit b542aea9b3
2 changed files with 7 additions and 3 deletions

View file

@ -33,7 +33,6 @@ public:
int nextChord(int currentChord); int nextChord(int currentChord);
int firstNote(); int firstNote();
int nextNote(int currentNote); int nextNote(int currentNote);
int noteSecondaire(int note);
float getTimeTempo() const; float getTimeTempo() const;
float getTime() const; float getTime() const;
float timeBeforeNewGeneration{4.f}; float timeBeforeNewGeneration{4.f};

View file

@ -280,6 +280,9 @@ int AudioEmitter::nextNote(int currentNote) {
*/ */
std::vector<std::pair<float, int>> AudioEmitter::generateMusic() { std::vector<std::pair<float, int>> AudioEmitter::generateMusic() {
std::vector<std::pair<float, int>> result; std::vector<std::pair<float, int>> result;
if (current_beat >= nbr_melo_total) {
return result;
}
result.reserve(16 * nbr_melo_max); result.reserve(16 * nbr_melo_max);
float beatDuration = tempo / 60.f; float beatDuration = tempo / 60.f;
unsigned int sampleRate = 48000; unsigned int sampleRate = 48000;
@ -344,8 +347,10 @@ std::vector<std::pair<float, int>> AudioEmitter::generateMusic() {
void AudioEmitter::audioUpdate() { system->update(); } void AudioEmitter::audioUpdate() { system->update(); }
void AudioEmitter::audioEnd() { void AudioEmitter::audioEnd() {
for (FMOD::Channel *c : activeChannels) { for (int i = 0; i < activeChannels.size(); i += 1) {
delete c; if (activeChannels[i]) {
activeChannels[i]->stop();
}
} }
timer->stop(); timer->stop();
system->close(); system->close();