Reduce code duplications
This commit is contained in:
@@ -35,11 +35,12 @@
|
||||
#include "Pattern.h"
|
||||
#include "SerializingObject.h"
|
||||
|
||||
class Groove : public SerializingObject
|
||||
class Groove : public QObject, public SerializingObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Groove();
|
||||
Groove(QObject* parent = nullptr);
|
||||
|
||||
/*
|
||||
* Groove should return true if the note should be played in the curr_time tick,
|
||||
@@ -56,9 +57,10 @@ public:
|
||||
*/
|
||||
virtual int isInTick( MidiTime * _cur_start, fpp_t _frames, f_cnt_t _offset,
|
||||
Note * _n, Pattern * _p );
|
||||
int amount() const {return m_amount;}
|
||||
|
||||
virtual void saveSettings( QDomDocument & _doc, QDomElement & _element );
|
||||
virtual void loadSettings( const QDomElement & _this );
|
||||
virtual void saveSettings( QDomDocument & doc, QDomElement & element );
|
||||
virtual void loadSettings(const QDomElement & element );
|
||||
|
||||
virtual QWidget * instantiateView( QWidget * _parent );
|
||||
|
||||
@@ -66,6 +68,16 @@ public:
|
||||
{
|
||||
return "none";
|
||||
}
|
||||
|
||||
signals:
|
||||
void amountChanged(int newAmount);
|
||||
|
||||
public slots:
|
||||
void setAmount(int amount);
|
||||
|
||||
protected:
|
||||
int m_amount;
|
||||
float m_swingFactor; // = (m_amount / 127)
|
||||
};
|
||||
|
||||
#endif // GROOVE_H
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
/**
|
||||
* A groove thats new
|
||||
*/
|
||||
class GrooveExperiments : public QObject, public Groove
|
||||
class GrooveExperiments : public Groove
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -22,12 +22,9 @@ public:
|
||||
virtual ~GrooveExperiments();
|
||||
|
||||
void init();
|
||||
int amount();
|
||||
|
||||
int isInTick(MidiTime * _cur_start, const fpp_t _frames, const f_cnt_t _offset, Note * _n, Pattern * _p );
|
||||
|
||||
void loadSettings( const QDomElement & _this );
|
||||
void saveSettings( QDomDocument & _doc, QDomElement & _element );
|
||||
inline virtual QString nodeName() const
|
||||
{
|
||||
return "experiment";
|
||||
@@ -37,20 +34,12 @@ public:
|
||||
|
||||
QWidget * instantiateView( QWidget * _parent );
|
||||
|
||||
signals:
|
||||
void shiftAmountChanged(int _newAmount);
|
||||
|
||||
|
||||
public slots:
|
||||
// valid values are from 0 - 127
|
||||
void setAmount(int _amount);
|
||||
void update();
|
||||
|
||||
private:
|
||||
int m_frames_per_tick;
|
||||
int m_shiftAmount;
|
||||
float m_shiftFactor;// = (m_shiftAmount / 127)
|
||||
|
||||
} ;
|
||||
|
||||
class GrooveExperimentsView : public QWidget
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
/**
|
||||
* A groove thatjust latter half of the HydrogenSwing algo.
|
||||
*/
|
||||
class HalfSwing : public QObject, public Groove
|
||||
class HalfSwing : public Groove
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -22,12 +22,9 @@ public:
|
||||
virtual ~HalfSwing();
|
||||
|
||||
void init();
|
||||
int amount();
|
||||
|
||||
int isInTick(MidiTime * _cur_start, const fpp_t _frames, const f_cnt_t _offset, Note * _n, Pattern * _p );
|
||||
|
||||
void loadSettings( const QDomElement & _this );
|
||||
void saveSettings( QDomDocument & _doc, QDomElement & _element );
|
||||
inline virtual QString nodeName() const
|
||||
{
|
||||
return "half";
|
||||
@@ -35,20 +32,12 @@ public:
|
||||
|
||||
QWidget * instantiateView( QWidget * _parent );
|
||||
|
||||
signals:
|
||||
void swingAmountChanged(int _newAmount);
|
||||
|
||||
|
||||
public slots:
|
||||
// valid values are from 0 - 127
|
||||
void setAmount(int _amount);
|
||||
void update();
|
||||
|
||||
private:
|
||||
int m_frames_per_tick;
|
||||
int m_swingAmount;
|
||||
float m_swingFactor;// = (m_swingAmount / 127)
|
||||
|
||||
} ;
|
||||
|
||||
class HalfSwingView : public QWidget
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
/**
|
||||
* A groove that mimics Hydrogen drum machine's swing feature
|
||||
*/
|
||||
class HydrogenSwing : public QObject, public Groove
|
||||
class HydrogenSwing : public Groove
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -22,12 +22,9 @@ public:
|
||||
virtual ~HydrogenSwing();
|
||||
|
||||
void init();
|
||||
int amount();
|
||||
|
||||
int isInTick(MidiTime * _cur_start, const fpp_t _frames, const f_cnt_t _offset, Note * _n, Pattern * _p );
|
||||
|
||||
void loadSettings( const QDomElement & _this );
|
||||
void saveSettings( QDomDocument & _doc, QDomElement & _element );
|
||||
inline virtual QString nodeName() const
|
||||
{
|
||||
return "hydrogen";
|
||||
@@ -37,20 +34,12 @@ public:
|
||||
|
||||
QWidget * instantiateView( QWidget * _parent );
|
||||
|
||||
signals:
|
||||
void swingAmountChanged(int _newAmount);
|
||||
|
||||
|
||||
public slots:
|
||||
// valid values are from 0 - 127
|
||||
void setAmount(int _amount);
|
||||
void update();
|
||||
|
||||
private:
|
||||
int m_frames_per_tick;
|
||||
int m_swingAmount;
|
||||
float m_swingFactor;// = (m_swingAmount / 127)
|
||||
|
||||
} ;
|
||||
|
||||
class HydrogenSwingView : public QWidget
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* A swing groove that adjusts by whole ticks.
|
||||
* Someone might like it, also might be able to save the output to a midi file later.
|
||||
*/
|
||||
class MidiSwing : public QObject, public Groove
|
||||
class MidiSwing : public Groove
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -25,8 +25,6 @@ public:
|
||||
int isInTick(MidiTime * cur_start, const fpp_t _frames, const f_cnt_t _offset, Note * n, Pattern * p );
|
||||
int isInTick(MidiTime * _cur_start, Note * _n, Pattern * _p );
|
||||
|
||||
void loadSettings( const QDomElement & _this );
|
||||
void saveSettings( QDomDocument & _doc, QDomElement & _element );
|
||||
inline virtual QString nodeName() const
|
||||
{
|
||||
return "midi";
|
||||
|
||||
Reference in New Issue
Block a user