Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classier enums #6760

Merged
merged 7 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions include/AudioEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,27 +109,27 @@ class LMMS_EXPORT AudioEngine : public QObject

struct qualitySettings
{
enum Mode
enum class Mode
{
Mode_Draft,
Mode_HighQuality,
Mode_FinalMix
Draft,
HighQuality,
FinalMix
} ;

enum Interpolation
enum class Interpolation
{
Interpolation_Linear,
Interpolation_SincFastest,
Interpolation_SincMedium,
Interpolation_SincBest
Linear,
SincFastest,
SincMedium,
SincBest
} ;

enum Oversampling
enum class Oversampling
{
Oversampling_None,
Oversampling_2x,
Oversampling_4x,
Oversampling_8x
None,
X2,
X4,
X8
} ;

Interpolation interpolation;
Expand All @@ -139,18 +139,18 @@ class LMMS_EXPORT AudioEngine : public QObject
{
switch (m)
{
case Mode_Draft:
interpolation = Interpolation_Linear;
oversampling = Oversampling_None;
case Mode::Draft:
interpolation = Interpolation::Linear;
oversampling = Oversampling::None;
break;
case Mode_HighQuality:
case Mode::HighQuality:
interpolation =
Interpolation_SincFastest;
oversampling = Oversampling_2x;
Interpolation::SincFastest;
oversampling = Oversampling::X2;
break;
case Mode_FinalMix:
interpolation = Interpolation_SincBest;
oversampling = Oversampling_8x;
case Mode::FinalMix:
interpolation = Interpolation::SincBest;
oversampling = Oversampling::X8;
break;
}
}
Expand All @@ -165,10 +165,10 @@ class LMMS_EXPORT AudioEngine : public QObject
{
switch( oversampling )
{
case Oversampling_None: return 1;
case Oversampling_2x: return 2;
case Oversampling_4x: return 4;
case Oversampling_8x: return 8;
case Oversampling::None: return 1;
case Oversampling::X2: return 2;
case Oversampling::X4: return 4;
case Oversampling::X8: return 8;
}
return 1;
}
Expand All @@ -177,13 +177,13 @@ class LMMS_EXPORT AudioEngine : public QObject
{
switch( interpolation )
{
case Interpolation_Linear:
case Interpolation::Linear:
return SRC_ZERO_ORDER_HOLD;
case Interpolation_SincFastest:
case Interpolation::SincFastest:
return SRC_SINC_FASTEST;
case Interpolation_SincMedium:
case Interpolation::SincMedium:
return SRC_SINC_MEDIUM_QUALITY;
case Interpolation_SincBest:
case Interpolation::SincBest:
return SRC_SINC_BEST_QUALITY;
}
return SRC_LINEAR;
Expand Down Expand Up @@ -255,7 +255,7 @@ class LMMS_EXPORT AudioEngine : public QObject
return m_playHandles;
}

void removePlayHandlesOfTypes(Track * track, const quint8 types);
void removePlayHandlesOfTypes(Track * track, PlayHandle::Types types);


// methods providing information for other classes
Expand Down
8 changes: 4 additions & 4 deletions include/AudioEngineWorkerThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class AudioEngineWorkerThread : public QThread
class JobQueue
{
public:
enum OperationMode
enum class OperationMode
{
Static, // no jobs added while processing queue
Dynamic // jobs can be added while processing queue
Expand All @@ -57,7 +57,7 @@ class AudioEngineWorkerThread : public QThread
m_items(),
m_writeIndex( 0 ),
m_itemsDone( 0 ),
m_opMode( Static )
m_opMode( OperationMode::Static )
{
std::fill(m_items, m_items + JOB_QUEUE_SIZE, nullptr);
}
Expand All @@ -83,7 +83,7 @@ class AudioEngineWorkerThread : public QThread
virtual void quit();

static void resetJobQueue( JobQueue::OperationMode _opMode =
JobQueue::Static )
JobQueue::OperationMode::Static )
{
globalJobQueue.reset( _opMode );
}
Expand All @@ -97,7 +97,7 @@ class AudioEngineWorkerThread : public QThread
// to ThreadableJob objects
template<typename T>
static void fillJobQueue( const T & _vec,
JobQueue::OperationMode _opMode = JobQueue::Static )
JobQueue::OperationMode _opMode = JobQueue::OperationMode::Static )
{
resetJobQueue( _opMode );
for (const auto& job : _vec)
Expand Down
6 changes: 3 additions & 3 deletions include/AutomatableModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject
public:
using AutoModelVector = std::vector<AutomatableModel*>;

enum ScaleType
enum class ScaleType
{
Linear,
Logarithmic,
Expand Down Expand Up @@ -232,11 +232,11 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject
}
void setScaleLogarithmic( bool setToTrue = true )
{
setScaleType( setToTrue ? Logarithmic : Linear );
setScaleType( setToTrue ? ScaleType::Logarithmic : ScaleType::Linear );
}
bool isScaleLogarithmic() const
{
return m_scaleType == Logarithmic;
return m_scaleType == ScaleType::Logarithmic;
}

void setStep( const float step );
Expand Down
14 changes: 7 additions & 7 deletions include/AutomationClip.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ class LMMS_EXPORT AutomationClip : public Clip
{
Q_OBJECT
public:
enum ProgressionTypes
enum class ProgressionType
{
DiscreteProgression,
LinearProgression,
CubicHermiteProgression
Discrete,
Linear,
CubicHermite
} ;

using timeMap = QMap<int, AutomationNode>;
Expand All @@ -76,11 +76,11 @@ class LMMS_EXPORT AutomationClip : public Clip
const objectVector& objects() const;

// progression-type stuff
inline ProgressionTypes progressionType() const
inline ProgressionType progressionType() const
{
return m_progressionType;
}
void setProgressionType( ProgressionTypes _new_progression_type );
void setProgressionType( ProgressionType _new_progression_type );

inline float getTension() const
{
Expand Down Expand Up @@ -214,7 +214,7 @@ public slots:
timeMap m_oldTimeMap; // old values for storing the values before setDragValue() is called.
float m_tension;
bool m_hasAutomation;
ProgressionTypes m_progressionType;
ProgressionType m_progressionType;

bool m_dragging;
bool m_dragKeepOutValue; // Should we keep the current dragged node's outValue?
Expand Down
30 changes: 15 additions & 15 deletions include/AutomationEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ class AutomationEditor : public QWidget, public JournallingObject
return "automationeditor";
}

enum EditModes
enum class EditMode
{
DRAW,
ERASE,
DRAW_OUTVALUES
Draw,
Erase,
DrawOutValues
};

public slots:
Expand Down Expand Up @@ -129,10 +129,10 @@ protected slots:
void horScrolled( int new_pos );
void verScrolled( int new_pos );

void setEditMode(AutomationEditor::EditModes mode);
void setEditMode(AutomationEditor::EditMode mode);
void setEditMode(int mode);

void setProgressionType(AutomationClip::ProgressionTypes type);
void setProgressionType(AutomationClip::ProgressionType type);
void setProgressionType(int type);
void setTension();

Expand All @@ -146,14 +146,14 @@ protected slots:

private:

enum Actions
enum class Action
{
NONE,
MOVE_VALUE,
ERASE_VALUES,
MOVE_OUTVALUE,
RESET_OUTVALUES,
DRAW_LINE
None,
MoveValue,
EraseValues,
MoveOutValue,
ResetOutValues,
DrawLine
} ;

// some constants...
Expand Down Expand Up @@ -201,7 +201,7 @@ protected slots:

TimePos m_currentPosition;

Actions m_action;
Action m_action;

int m_moveXOffset;

Expand All @@ -215,7 +215,7 @@ protected slots:
// Time position (key) of automation node whose outValue is being dragged
int m_draggedOutValueKey;

EditModes m_editMode;
EditMode m_editMode;

bool m_mouseDownLeft;
bool m_mouseDownRight; //true if right click is being held down
Expand Down
21 changes: 11 additions & 10 deletions include/BandLimitedWave.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,15 @@ QDataStream& operator>> ( QDataStream &in, WaveMipMap &waveMipMap );
class LMMS_EXPORT BandLimitedWave
{
public:
enum Waveforms
enum class Waveform
{
BLSaw,
BLSquare,
BLTriangle,
BLMoog,
NumBLWaveforms
Count
};
constexpr static auto NumWaveforms = static_cast<std::size_t>(Waveform::Count);

BandLimitedWave() = default;
virtual ~BandLimitedWave() = default;
Expand Down Expand Up @@ -127,7 +128,7 @@ class LMMS_EXPORT BandLimitedWave
* \param _wavelen The wavelength (length of one cycle, ie. the inverse of frequency) of the wanted oscillation, measured in sample frames
* \param _wave The wanted waveform. Options currently are saw, triangle, square and moog saw.
*/
static inline sample_t oscillate( float _ph, float _wavelen, Waveforms _wave )
static inline sample_t oscillate( float _ph, float _wavelen, Waveform _wave )
{
// get the next higher tlen
int t = 0;
Expand All @@ -139,12 +140,12 @@ class LMMS_EXPORT BandLimitedWave
int lookup = static_cast<int>( lookupf );
const float ip = fraction( lookupf );

const sample_t s1 = s_waveforms[ _wave ].sampleAt( t, lookup );
const sample_t s2 = s_waveforms[ _wave ].sampleAt( t, ( lookup + 1 ) % tlen );
const sample_t s1 = s_waveforms[ static_cast<std::size_t>(_wave) ].sampleAt( t, lookup );
const sample_t s2 = s_waveforms[ static_cast<std::size_t>(_wave) ].sampleAt( t, ( lookup + 1 ) % tlen );

const int lm = lookup == 0 ? tlen - 1 : lookup - 1;
const sample_t s0 = s_waveforms[ _wave ].sampleAt( t, lm );
const sample_t s3 = s_waveforms[ _wave ].sampleAt( t, ( lookup + 2 ) % tlen );
const sample_t s0 = s_waveforms[ static_cast<std::size_t>(_wave) ].sampleAt( t, lm );
const sample_t s3 = s_waveforms[ static_cast<std::size_t>(_wave) ].sampleAt( t, ( lookup + 2 ) % tlen );
const sample_t sr = optimal4pInterpolate( s0, s1, s2, s3, ip );

return sr;
Expand All @@ -153,8 +154,8 @@ class LMMS_EXPORT BandLimitedWave
lookup = lookup << 1;
tlen = tlen << 1;
t += 1;
const sample_t s3 = s_waveforms[ _wave ].sampleAt( t, lookup );
const sample_t s4 = s_waveforms[ _wave ].sampleAt( t, ( lookup + 1 ) % tlen );
const sample_t s3 = s_waveforms[ static_cast<std::size_t>(_wave) ].sampleAt( t, lookup );
const sample_t s4 = s_waveforms[ static_cast<std::size_t>(_wave) ].sampleAt( t, ( lookup + 1 ) % tlen );
const sample_t s34 = linearInterpolate( s3, s4, ip );

const float ip2 = ( ( tlen - _wavelen ) / tlen - 0.5 ) * 2.0;
Expand All @@ -168,7 +169,7 @@ class LMMS_EXPORT BandLimitedWave

static bool s_wavesGenerated;

static std::array<WaveMipMap, NumBLWaveforms> s_waveforms;
static std::array<WaveMipMap, NumWaveforms> s_waveforms;

static QString s_wavetableDir;
};
Expand Down
Loading
Loading