Files
lmms/plugins/ZynAddSubFx/ZynAddSubFx.h
Michael Gregorius 5c0db46a60 Streamline instrument flags (#7227)
## Instrument flags as a property of an instrument
The instruments flags (single streamed, MIDI based, not bendable) are properties of an instrument that do not change over time. Therefore the flags are made a property of the instrument which is initialized at construction time.

Adjust the constructors of all instruments which overrode the `flags` method to pass their flags into the `Instrument` constructor.

## Add helper methods for flags
Add helper methods for the flags. This makes the code more concise and readable and clients do not need to know the technical details on how to evaluate a flag.

## Remove the flags methods
Remove the flags methods to make it an implementation detail on how the flags are managed.
2024-04-27 17:45:55 +02:00

176 lines
3.5 KiB
C++

/*
* ZynAddSubFx.h - ZynAddSubFX-embedding plugin
*
* Copyright (c) 2008-2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* 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 ZYNADDSUBFX_H
#define ZYNADDSUBFX_H
#include <QMap>
#include <QMutex>
#include "AutomatableModel.h"
#include "Instrument.h"
#include "InstrumentView.h"
#include "RemotePlugin.h"
#include "zynaddsubfx/src/globals.h"
class QPushButton;
namespace lmms
{
class LocalZynAddSubFx;
class NotePlayHandle;
namespace gui
{
class Knob;
class LedCheckBox;
class ZynAddSubFxView;
}
class ZynAddSubFxRemotePlugin : public RemotePlugin
{
Q_OBJECT
public:
ZynAddSubFxRemotePlugin();
bool processMessage( const message & _m ) override;
signals:
void clickedCloseButton();
} ;
class ZynAddSubFxInstrument : public Instrument
{
Q_OBJECT
public:
ZynAddSubFxInstrument( InstrumentTrack * _instrument_track );
~ZynAddSubFxInstrument() override;
void play( sampleFrame * _working_buffer ) override;
bool handleMidiEvent( const MidiEvent& event, const TimePos& time = TimePos(), f_cnt_t offset = 0 ) override;
void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override;
void loadSettings( const QDomElement & _this ) override;
void loadFile( const QString & _file ) override;
QString nodeName() const override;
gui::PluginView* instantiateView( QWidget * _parent ) override;
private slots:
void reloadPlugin();
void updatePitchRange();
void updatePortamento();
void updateFilterFreq();
void updateFilterQ();
void updateBandwidth();
void updateFmGain();
void updateResCenterFreq();
void updateResBandwidth();
private:
void initPlugin();
void sendControlChange( MidiControllers midiCtl, float value );
bool m_hasGUI;
QMutex m_pluginMutex;
LocalZynAddSubFx * m_plugin;
ZynAddSubFxRemotePlugin * m_remotePlugin;
FloatModel m_portamentoModel;
FloatModel m_filterFreqModel;
FloatModel m_filterQModel;
FloatModel m_bandwidthModel;
FloatModel m_fmGainModel;
FloatModel m_resCenterFreqModel;
FloatModel m_resBandwidthModel;
BoolModel m_forwardMidiCcModel;
QMap<int, bool> m_modifiedControllers;
friend class gui::ZynAddSubFxView;
signals:
void settingsChanged();
} ;
namespace gui
{
class ZynAddSubFxView : public InstrumentViewFixedSize
{
Q_OBJECT
public:
ZynAddSubFxView( Instrument * _instrument, QWidget * _parent );
protected:
void dragEnterEvent( QDragEnterEvent * _dee ) override;
void dropEvent( QDropEvent * _de ) override;
private:
void modelChanged() override;
QPushButton * m_toggleUIButton;
Knob * m_portamento;
Knob * m_filterFreq;
Knob * m_filterQ;
Knob * m_bandwidth;
Knob * m_fmGain;
Knob * m_resCenterFreq;
Knob * m_resBandwidth;
LedCheckBox * m_forwardMidiCC;
private slots:
void toggleUI();
} ;
} // namespace gui
} // namespace lmms
#endif