Process metronome every MIDI tick (#7483)

This commit is contained in:
saker
2024-09-04 12:58:36 -04:00
committed by GitHub
parent b81f806d63
commit d703f39153
8 changed files with 107 additions and 63 deletions

View File

@@ -289,9 +289,6 @@ public:
void changeQuality(const struct qualitySettings & qs);
inline bool isMetronomeActive() const { return m_metronomeActive; }
inline void setMetronomeActive(bool value = true) { m_metronomeActive = value; }
//! Block until a change in model can be done (i.e. wait for audio thread)
void requestChangeInModel();
void doneChangeInModel();
@@ -352,8 +349,6 @@ private:
void swapBuffers();
void handleMetronome();
void clearInternal();
bool m_renderOnly;
@@ -402,8 +397,6 @@ private:
AudioEngineProfiler m_profiler;
bool m_metronomeActive;
bool m_clearSignal;
std::recursive_mutex m_changeMutex;

43
include/Metronome.h Normal file
View File

@@ -0,0 +1,43 @@
/*
* Metronome.h
*
* Copyright (c) 2024 saker
*
* This file is part of LMMS - https://lmms.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef LMMS_METRONOME_H
#define LMMS_METRONOME_H
#include <cstddef>
namespace lmms {
class Metronome
{
public:
bool active() const { return m_active; }
void setActive(bool active) { m_active = active; }
void processTick(int currentTick, int ticksPerBar, int beatsPerBar, size_t bufferOffset);
private:
bool m_active = false;
};
} // namespace lmms
#endif // LMMS_METRONOME_H

View File

@@ -33,6 +33,7 @@
#include "AudioEngine.h"
#include "Controller.h"
#include "Metronome.h"
#include "lmms_constants.h"
#include "MeterModel.h"
#include "Timeline.h"
@@ -375,6 +376,8 @@ public:
const std::string& syncKey() const noexcept { return m_vstSyncController.sharedMemoryKey(); }
Metronome& metronome() { return m_metronome; }
public slots:
void playSong();
void record();
@@ -448,6 +451,7 @@ private:
void restoreKeymapStates(const QDomElement &element);
void processAutomations(const TrackList& tracks, TimePos timeStart, fpp_t frames);
void processMetronome(size_t bufferOffset);
void setModified(bool value);
@@ -513,6 +517,8 @@ private:
AutomatedValueMap m_oldAutomatedValues;
Metronome m_metronome;
friend class Engine;
friend class gui::SongEditor;
friend class gui::ControllerRackView;