Skip to content

Commit

Permalink
Merge branch 'master' into pin-connector
Browse files Browse the repository at this point in the history
  • Loading branch information
messmerd committed Sep 21, 2024
2 parents 23fd48b + 1825208 commit 089ffb4
Show file tree
Hide file tree
Showing 112 changed files with 873 additions and 1,009 deletions.
20 changes: 7 additions & 13 deletions include/AudioEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ class AudioPort;
class AudioEngineWorkerThread;


const fpp_t MINIMUM_BUFFER_SIZE = 32;
const fpp_t DEFAULT_BUFFER_SIZE = 256;
constexpr fpp_t MINIMUM_BUFFER_SIZE = 32;
constexpr fpp_t DEFAULT_BUFFER_SIZE = 256;
constexpr fpp_t MAXIMUM_BUFFER_SIZE = 4096;

const int BYTES_PER_SAMPLE = sizeof( sample_t );
const int BYTES_PER_INT_SAMPLE = sizeof( int_sample_t );
const int BYTES_PER_FRAME = sizeof( SampleFrame );
constexpr int BYTES_PER_SAMPLE = sizeof(sample_t);
constexpr int BYTES_PER_INT_SAMPLE = sizeof(int_sample_t);
constexpr int BYTES_PER_FRAME = sizeof(SampleFrame);

const float OUTPUT_SAMPLE_MULTIPLIER = 32767.0f;
constexpr float OUTPUT_SAMPLE_MULTIPLIER = 32767.0f;

class LMMS_EXPORT AudioEngine : public QObject
{
Expand Down Expand Up @@ -289,9 +290,6 @@ class LMMS_EXPORT AudioEngine : public QObject

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();
Expand Down Expand Up @@ -352,8 +350,6 @@ class LMMS_EXPORT AudioEngine : public QObject

void swapBuffers();

void handleMetronome();

void clearInternal();

bool m_renderOnly;
Expand Down Expand Up @@ -402,8 +398,6 @@ class LMMS_EXPORT AudioEngine : public QObject

AudioEngineProfiler m_profiler;

bool m_metronomeActive;

bool m_clearSignal;

std::recursive_mutex m_changeMutex;
Expand Down
3 changes: 1 addition & 2 deletions include/AutomationTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ class AutomationTrack : public Track
gui::TrackView * createView( gui::TrackContainerView* ) override;
Clip* createClip(const TimePos & pos) override;

void saveTrackSpecificSettings( QDomDocument & _doc,
QDomElement & _parent ) override;
void saveTrackSpecificSettings(QDomDocument& doc, QDomElement& parent, bool presetMode) override;
void loadTrackSpecificSettings( const QDomElement & _this ) override;

private:
Expand Down
5 changes: 3 additions & 2 deletions include/DummyEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class DummyEffect : public Effect
m_originalPluginData( originalPluginData )
{
setName();
setDontRun(true);
}

~DummyEffect() override = default;
Expand All @@ -107,9 +108,9 @@ class DummyEffect : public Effect
return &m_controls;
}

bool processAudioBuffer( SampleFrame*, const fpp_t ) override
ProcessStatus processImpl(SampleFrame*, const fpp_t) override
{
return false;
return ProcessStatus::Sleep;
}

const QDomElement& originalPluginData() const
Expand Down
40 changes: 31 additions & 9 deletions include/Effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ class LMMS_EXPORT Effect : public Plugin
return "effect";
}


virtual bool processAudioBuffer( SampleFrame* _buf,
const fpp_t _frames ) = 0;
//! Returns true if audio was processed and should continue being processed
bool processAudioBuffer(SampleFrame* buf, const fpp_t frames);

inline ch_cnt_t processorCount() const
{
Expand Down Expand Up @@ -174,14 +173,29 @@ class LMMS_EXPORT Effect : public Plugin


protected:
enum class ProcessStatus
{
//! Unconditionally continue processing
Continue,

//! Calculate the RMS out sum and call `checkGate` to determine whether to stop processing
ContinueIfNotQuiet,

//! Do not continue processing
Sleep
};

/**
Effects should call this at the end of audio processing
* The main audio processing method that runs when plugin is not asleep
*/
virtual ProcessStatus processImpl(SampleFrame* buf, const fpp_t frames) = 0;

/**
* Optional method that runs when plugin is sleeping (not enabled,
* not running, not in the Okay state, or in the Don't Run state)
*/
virtual void processBypassedImpl() {}

If the setting "Keep effects running even without input" is disabled,
after "decay" ms of a signal below "gate", the effect is turned off
and won't be processed again until it receives new audio input
*/
void checkGate( double _out_sum );

gui::PluginView* instantiateView( QWidget * ) override;

Expand Down Expand Up @@ -212,6 +226,14 @@ class LMMS_EXPORT Effect : public Plugin


private:
/**
If the setting "Keep effects running even without input" is disabled,
after "decay" ms of a signal below "gate", the effect is turned off
and won't be processed again until it receives new audio input
*/
void checkGate(double outSum);


EffectChain * m_parent;
void resample( int _i, const SampleFrame* _src_buf,
sample_rate_t _src_sr,
Expand Down
3 changes: 1 addition & 2 deletions include/InstrumentTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ class LMMS_EXPORT InstrumentTrack : public Track, public MidiEventProcessor


// called by track
void saveTrackSpecificSettings( QDomDocument & _doc,
QDomElement & _parent ) override;
void saveTrackSpecificSettings(QDomDocument& doc, QDomElement& parent, bool presetMode) override;
void loadTrackSpecificSettings( const QDomElement & _this ) override;

using Track::setJournalling;
Expand Down
5 changes: 5 additions & 0 deletions include/InstrumentTrackWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "ModelView.h"
#include "SerializingObject.h"
#include "PluginView.h"

class QLabel;
class QLineEdit;
Expand Down Expand Up @@ -67,6 +68,9 @@ class InstrumentTrackWindow : public QWidget, public ModelView,
InstrumentTrackWindow( InstrumentTrackView * _tv );
~InstrumentTrackWindow() override;

void resizeEvent(QResizeEvent* event) override;


// parent for all internal tab-widgets
TabWidget * tabWidgetParent()
{
Expand Down Expand Up @@ -152,6 +156,7 @@ protected slots:
InstrumentSoundShapingView * m_ssView;
InstrumentFunctionNoteStackingView* m_noteStackingView;
InstrumentFunctionArpeggioView* m_arpeggioView;
QWidget* m_instrumentFunctionsView; // container of note stacking and arpeggio
InstrumentMidiIOView * m_midiView;
EffectRackView * m_effectView;
InstrumentTuningView *m_tuningView;
Expand Down
27 changes: 13 additions & 14 deletions plugins/Flanger/Noise.h → include/Metronome.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* noise.h - defination of Noise class.
* Metronome.h
*
* Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
* Copyright (c) 2024 saker
*
* This file is part of LMMS - https://lmms.io
*
Expand All @@ -22,23 +22,22 @@
*
*/

#ifndef NOISE_H
#define NOISE_H

namespace lmms
{
#ifndef LMMS_METRONOME_H
#define LMMS_METRONOME_H

#include <cstddef>

class Noise
namespace lmms {
class Metronome
{
public:
Noise();
float tick();
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:
double inv_randmax;
bool m_active = false;
};


} // namespace lmms

#endif // NOISE_H
#endif // LMMS_METRONOME_H
18 changes: 7 additions & 11 deletions include/MixerChannelView.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <QLineEdit>
#include <QPixmap>
#include <QWidget>
#include <QStackedWidget>

namespace lmms
{
Expand All @@ -59,11 +60,6 @@ namespace lmms::gui
Q_PROPERTY(QColor strokeInnerActive READ strokeInnerActive WRITE setStrokeInnerActive)
Q_PROPERTY(QColor strokeInnerInactive READ strokeInnerInactive WRITE setStrokeInnerInactive)
public:
enum class SendReceiveState
{
None, SendToThis, ReceiveFromThis
};

MixerChannelView(QWidget* parent, MixerView* mixerView, int channelIndex);
void paintEvent(QPaintEvent* event) override;
void contextMenuEvent(QContextMenuEvent*) override;
Expand All @@ -74,9 +70,6 @@ namespace lmms::gui
int channelIndex() const;
void setChannelIndex(int index);

SendReceiveState sendReceiveState() const;
void setSendReceiveState(const SendReceiveState& state);

QBrush backgroundActive() const;
void setBackgroundActive(const QBrush& c);

Expand Down Expand Up @@ -115,19 +108,22 @@ namespace lmms::gui

private:
SendButtonIndicator* m_sendButton;
QLabel* m_receiveArrow;
QStackedWidget* m_receiveArrowOrSendButton;
int m_receiveArrowStackedIndex = -1;
int m_sendButtonStackedIndex = -1;

Knob* m_sendKnob;
LcdWidget* m_channelNumberLcd;
QLineEdit* m_renameLineEdit;
QGraphicsView* m_renameLineEditView;
QLabel* m_sendArrow;
QLabel* m_receiveArrow;
PixmapButton* m_muteButton;
PixmapButton* m_soloButton;
PeakIndicator* m_peakIndicator = nullptr;
Fader* m_fader;
EffectRackView* m_effectRackView;
MixerView* m_mixerView;
SendReceiveState m_sendReceiveState = SendReceiveState::None;
int m_channelIndex = 0;
bool m_inRename = false;

Expand All @@ -141,4 +137,4 @@ namespace lmms::gui
};
} // namespace lmms::gui

#endif
#endif // MIXER_CHANNEL_VIEW_H
3 changes: 1 addition & 2 deletions include/PatternTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ class LMMS_EXPORT PatternTrack : public Track
gui::TrackView * createView( gui::TrackContainerView* tcv ) override;
Clip* createClip(const TimePos & pos) override;

void saveTrackSpecificSettings( QDomDocument & _doc,
QDomElement & _parent ) override;
void saveTrackSpecificSettings(QDomDocument& doc, QDomElement& parent, bool presetMode) override;
void loadTrackSpecificSettings( const QDomElement & _this ) override;

static PatternTrack* findPatternTrack(int pattern_num);
Expand Down
19 changes: 11 additions & 8 deletions include/PluginView.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,26 @@

#include <QWidget>

#include "Plugin.h"
#include "ModelView.h"
#include "Plugin.h"

namespace lmms::gui
{
namespace lmms::gui {

class LMMS_EXPORT PluginView : public QWidget, public ModelView
class LMMS_EXPORT PluginView : public QWidget, public ModelView
{
public:
PluginView( Plugin * _plugin, QWidget * _parent ) :
QWidget( _parent ),
ModelView( _plugin, this )
PluginView(Plugin* _plugin, QWidget* _parent)
: QWidget(_parent)
, ModelView(_plugin, this)
{
}

} ;
void setResizable(bool resizable) { m_isResizable = resizable; }
bool isResizable() { return m_isResizable; }

private:
bool m_isResizable = false;
};

} // namespace lmms::gui

Expand Down
3 changes: 1 addition & 2 deletions include/SampleTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class SampleTrack : public Track
Clip* createClip(const TimePos & pos) override;


void saveTrackSpecificSettings( QDomDocument & _doc,
QDomElement & _parent ) override;
void saveTrackSpecificSettings(QDomDocument& doc, QDomElement& parent, bool presetMode) override;
void loadTrackSpecificSettings( const QDomElement & _this ) override;

inline IntModel * mixerChannelModel()
Expand Down
6 changes: 6 additions & 0 deletions include/Song.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include "AudioEngine.h"
#include "Controller.h"
#include "Metronome.h"
#include "lmms_constants.h"
#include "MeterModel.h"
#include "Timeline.h"
Expand Down Expand Up @@ -375,6 +376,8 @@ class LMMS_EXPORT Song : public TrackContainer

const std::string& syncKey() const noexcept { return m_vstSyncController.sharedMemoryKey(); }

Metronome& metronome() { return m_metronome; }

public slots:
void playSong();
void record();
Expand Down Expand Up @@ -448,6 +451,7 @@ private slots:
void restoreKeymapStates(const QDomElement &element);

void processAutomations(const TrackList& tracks, TimePos timeStart, fpp_t frames);
void processMetronome(size_t bufferOffset);

void setModified(bool value);

Expand Down Expand Up @@ -513,6 +517,8 @@ private slots:

AutomatedValueMap m_oldAutomatedValues;

Metronome m_metronome;

friend class Engine;
friend class gui::SongEditor;
friend class gui::ControllerRackView;
Expand Down
Loading

0 comments on commit 089ffb4

Please sign in to comment.