From f10277715f6da1d3055a1ed75dc3b40a5cfac81d Mon Sep 17 00:00:00 2001 From: Dominic Clark Date: Thu, 24 Aug 2023 19:16:02 +0100 Subject: [PATCH] Classier enums (#6760) --- include/AudioEngine.h | 64 ++-- include/AudioEngineWorkerThread.h | 8 +- include/AutomatableModel.h | 6 +- include/AutomationClip.h | 14 +- include/AutomationEditor.h | 30 +- include/BandLimitedWave.h | 21 +- include/BasicFilters.h | 103 +++--- include/Clip.h | 7 - include/ClipView.h | 8 +- include/Controller.h | 27 +- include/CustomTextKnob.h | 2 +- include/DataFile.h | 8 +- include/EnvelopeAndLfoParameters.h | 5 +- include/ExportProjectDialog.h | 2 +- include/FileBrowser.h | 27 +- include/Flags.h | 83 +++++ include/Graph.h | 19 +- include/Instrument.h | 10 +- include/InstrumentFunctions.h | 21 +- include/InstrumentSoundShaping.h | 7 +- include/Knob.h | 16 +- include/LadspaBase.h | 20 +- include/LadspaManager.h | 14 +- include/LedCheckBox.h | 11 +- include/LmmsStyle.h | 30 -- include/Lv2ControlBase.h | 2 +- include/Lv2Manager.h | 6 +- include/Lv2Ports.h | 5 +- include/Lv2Proc.h | 2 +- include/Lv2SubPluginFeatures.h | 2 +- include/MainWindow.h | 2 +- include/MidiClip.h | 8 +- include/MidiPort.h | 9 +- include/MidiPortMenu.h | 4 +- include/Note.h | 44 ++- include/NotePlayHandle.h | 16 +- include/Oscillator.h | 47 +-- include/OutputSettings.h | 19 +- include/Piano.h | 6 +- include/PianoRoll.h | 96 ++--- include/PlayHandle.h | 21 +- include/Plugin.h | 10 +- include/PluginFactory.h | 4 +- include/PluginIssue.h | 40 +-- include/ProjectJournal.h | 2 +- include/ProjectRenderer.h | 21 +- include/ProjectVersion.h | 6 +- include/RenderManager.h | 4 +- include/SampleBuffer.h | 10 +- include/SetupDialog.h | 4 +- include/Song.h | 67 ++-- include/SongEditor.h | 8 +- include/TempoSyncKnob.h | 2 +- include/TempoSyncKnobModel.h | 34 +- include/TimeDisplayWidget.h | 6 +- include/TimeLineWidget.h | 32 +- include/Track.h | 26 +- include/TrackContainer.h | 14 +- include/TrackContainerView.h | 6 - include/TrackContentWidget.h | 2 +- include/TrackView.h | 12 +- include/fft_helpers.h | 12 +- include/lmms_constants.h | 22 +- plugins/Amplifier/Amplifier.cpp | 2 +- plugins/Amplifier/AmplifierControlDialog.cpp | 8 +- .../AudioFileProcessor/AudioFileProcessor.cpp | 46 +-- .../AudioFileProcessor/AudioFileProcessor.h | 28 +- plugins/BassBooster/BassBooster.cpp | 2 +- .../BassBooster/BassBoosterControlDialog.cpp | 6 +- plugins/BitInvader/BitInvader.cpp | 12 +- plugins/Bitcrush/Bitcrush.cpp | 2 +- plugins/Bitcrush/BitcrushControlDialog.cpp | 18 +- plugins/CarlaBase/Carla.cpp | 6 +- plugins/CarlaPatchbay/CarlaPatchbay.cpp | 2 +- plugins/CarlaRack/CarlaRack.cpp | 2 +- plugins/Compressor/Compressor.cpp | 14 +- plugins/Compressor/Compressor.h | 2 +- .../Compressor/CompressorControlDialog.cpp | 36 +- plugins/CrossoverEQ/CrossoverEQ.cpp | 2 +- .../CrossoverEQ/CrossoverEQControlDialog.cpp | 14 +- plugins/Delay/DelayControlsDialog.cpp | 8 +- plugins/Delay/DelayEffect.cpp | 2 +- plugins/Dispersion/Dispersion.cpp | 2 +- .../Dispersion/DispersionControlDialog.cpp | 6 +- plugins/DualFilter/DualFilter.cpp | 6 +- .../DualFilter/DualFilterControlDialog.cpp | 6 +- .../DynamicsProcessor/DynamicsProcessor.cpp | 10 +- .../DynamicsProcessorControlDialog.cpp | 10 +- .../DynamicsProcessorControls.h | 9 +- plugins/Eq/EqControlsDialog.cpp | 4 +- plugins/Eq/EqCurve.cpp | 30 +- plugins/Eq/EqCurve.h | 19 +- plugins/Eq/EqEffect.cpp | 2 +- plugins/Eq/EqParameterWidget.cpp | 16 +- plugins/Flanger/FlangerControlsDialog.cpp | 12 +- plugins/Flanger/FlangerEffect.cpp | 2 +- plugins/FreeBoy/FreeBoy.cpp | 6 +- plugins/GigPlayer/GigPlayer.cpp | 26 +- plugins/GigPlayer/GigPlayer.h | 6 +- plugins/HydrogenImport/HydrogenImport.cpp | 34 +- plugins/Kicker/Kicker.cpp | 12 +- plugins/Kicker/Kicker.h | 2 +- plugins/LadspaBrowser/LadspaBrowser.cpp | 12 +- plugins/LadspaBrowser/LadspaDescription.cpp | 14 +- plugins/LadspaEffect/LadspaControlDialog.cpp | 10 +- plugins/LadspaEffect/LadspaEffect.cpp | 64 ++-- .../LadspaEffect/LadspaSubPluginFeatures.cpp | 10 +- .../LadspaEffect/LadspaSubPluginFeatures.h | 2 +- plugins/Lb302/Lb302.cpp | 94 ++--- plugins/Lb302/Lb302.h | 20 +- plugins/Lv2Effect/Lv2Effect.cpp | 4 +- plugins/Lv2Instrument/Lv2Instrument.cpp | 6 +- plugins/Lv2Instrument/Lv2Instrument.h | 4 +- plugins/MidiExport/MidiExport.cpp | 16 +- plugins/MidiImport/MidiImport.cpp | 12 +- plugins/Monstro/Monstro.cpp | 2 +- plugins/Monstro/Monstro.h | 14 +- plugins/MultitapEcho/MultitapEcho.cpp | 2 +- .../MultitapEchoControlDialog.cpp | 12 +- plugins/Nes/Nes.cpp | 2 +- plugins/Nes/Nes.h | 2 +- plugins/OpulenZ/OpulenZ.cpp | 8 +- plugins/OpulenZ/OpulenZ.h | 2 +- plugins/Organic/Organic.cpp | 26 +- plugins/Patman/Patman.cpp | 32 +- plugins/Patman/Patman.h | 16 +- .../PeakControllerEffect.cpp | 2 +- .../PeakControllerEffectControlDialog.cpp | 12 +- plugins/ReverbSC/ReverbSC.cpp | 2 +- plugins/ReverbSC/ReverbSCControlDialog.cpp | 8 +- plugins/Sf2Player/Sf2Player.cpp | 10 +- plugins/Sf2Player/Sf2Player.h | 2 +- plugins/Sfxr/Sfxr.cpp | 6 +- plugins/Sfxr/Sfxr.h | 5 +- plugins/Sid/SidInstrument.cpp | 30 +- plugins/Sid/SidInstrument.h | 29 +- plugins/SpectrumAnalyzer/Analyzer.cpp | 2 +- plugins/SpectrumAnalyzer/SaControls.cpp | 4 +- plugins/SpectrumAnalyzer/SaControlsDialog.cpp | 16 +- plugins/SpectrumAnalyzer/SaProcessor.cpp | 50 +-- plugins/StereoEnhancer/StereoEnhancer.cpp | 2 +- .../StereoEnhancerControlDialog.cpp | 2 +- plugins/StereoMatrix/StereoMatrix.cpp | 2 +- .../StereoMatrixControlDialog.cpp | 8 +- plugins/Stk/Mallets/Mallets.cpp | 32 +- plugins/TripleOscillator/TripleOscillator.cpp | 10 +- plugins/Vectorscope/VecControlsDialog.cpp | 2 +- plugins/Vectorscope/Vectorscope.cpp | 2 +- plugins/Vestige/Vestige.cpp | 8 +- plugins/Vestige/Vestige.h | 2 +- plugins/Vibed/Vibed.cpp | 18 +- plugins/Vibed/Vibed.h | 2 +- plugins/VstBase/RemoteVstPlugin.cpp | 24 +- plugins/VstBase/VstPlugin.cpp | 16 +- plugins/VstBase/communication.h | 16 +- plugins/VstBase/vst_base.cpp | 2 +- plugins/VstEffect/VstEffect.cpp | 4 +- plugins/VstEffect/VstEffectControlDialog.cpp | 10 + plugins/VstEffect/VstEffectControls.cpp | 12 +- plugins/VstEffect/VstSubPluginFeatures.cpp | 2 +- plugins/VstEffect/VstSubPluginFeatures.h | 2 +- plugins/Watsyn/Watsyn.cpp | 10 +- plugins/Watsyn/Watsyn.h | 4 +- plugins/WaveShaper/WaveShaper.cpp | 2 +- .../WaveShaper/WaveShaperControlDialog.cpp | 8 +- plugins/Xpressive/Xpressive.cpp | 14 +- plugins/ZynAddSubFx/ZynAddSubFx.cpp | 22 +- plugins/ZynAddSubFx/ZynAddSubFx.h | 2 +- src/core/AudioEngine.cpp | 24 +- src/core/AudioEngineWorkerThread.cpp | 2 +- src/core/AutomatableModel.cpp | 30 +- src/core/AutomationClip.cpp | 34 +- src/core/BandLimitedWave.cpp | 42 +-- src/core/ConfigManager.cpp | 4 +- src/core/Controller.cpp | 24 +- src/core/ControllerConnection.cpp | 18 +- src/core/DataFile.cpp | 65 ++-- src/core/EnvelopeAndLfoParameters.cpp | 16 +- src/core/ImportFilter.cpp | 2 +- src/core/InstrumentFunctions.cpp | 38 +- src/core/InstrumentPlayHandle.cpp | 2 +- src/core/InstrumentSoundShaping.cpp | 40 +-- src/core/Ladspa2LMMS.cpp | 10 +- src/core/LadspaControl.cpp | 90 ++--- src/core/LadspaManager.cpp | 8 +- src/core/LfoController.cpp | 23 +- src/core/Mixer.cpp | 14 +- src/core/Note.cpp | 2 +- src/core/NotePlayHandle.cpp | 12 +- src/core/Oscillator.cpp | 277 +++++++-------- src/core/PatternStore.cpp | 8 +- src/core/PeakController.cpp | 2 +- src/core/Piano.cpp | 14 +- src/core/Plugin.cpp | 2 +- src/core/PluginFactory.cpp | 2 +- src/core/PluginIssue.cpp | 38 +- src/core/PresetPreviewPlayHandle.cpp | 6 +- src/core/ProjectJournal.cpp | 6 +- src/core/ProjectRenderer.cpp | 24 +- src/core/RenderManager.cpp | 10 +- src/core/SampleBuffer.cpp | 24 +- src/core/SampleClip.cpp | 8 +- src/core/SamplePlayHandle.cpp | 2 +- src/core/SampleRecordHandle.cpp | 2 +- src/core/Song.cpp | 160 ++++----- src/core/TempoSyncKnobModel.cpp | 36 +- src/core/ToolPlugin.cpp | 2 +- src/core/Track.cpp | 28 +- src/core/TrackContainer.cpp | 12 +- src/core/UpgradeExtendedNoteRange.cpp | 6 +- src/core/audio/AudioFileFlac.cpp | 6 +- src/core/audio/AudioFileMP3.cpp | 6 +- src/core/audio/AudioFileWave.cpp | 8 +- src/core/audio/AudioPort.cpp | 2 +- src/core/fft_helpers.cpp | 10 +- src/core/lv2/Lv2ControlBase.cpp | 2 +- src/core/lv2/Lv2Manager.cpp | 4 +- src/core/lv2/Lv2Ports.cpp | 30 +- src/core/lv2/Lv2Proc.cpp | 24 +- src/core/lv2/Lv2SubPluginFeatures.cpp | 2 +- src/core/main.cpp | 38 +- src/core/midi/MidiAlsaSeq.cpp | 6 +- src/core/midi/MidiController.cpp | 4 +- src/core/midi/MidiPort.cpp | 10 +- src/gui/ControllerView.cpp | 2 +- src/gui/Controls.cpp | 2 +- src/gui/EffectView.cpp | 8 +- src/gui/FileBrowser.cpp | 110 +++--- src/gui/LadspaControlView.cpp | 18 +- src/gui/LfoControllerDialog.cpp | 8 +- src/gui/MainWindow.cpp | 42 +-- src/gui/MicrotunerConfig.cpp | 10 + src/gui/MidiCCRackView.cpp | 2 +- src/gui/MixerLine.cpp | 2 +- src/gui/MixerView.cpp | 14 +- src/gui/PluginBrowser.cpp | 4 +- src/gui/SampleTrackWindow.cpp | 14 +- src/gui/clips/AutomationClipView.cpp | 2 +- src/gui/clips/ClipView.cpp | 102 +++--- src/gui/clips/MidiClipView.cpp | 12 +- src/gui/editors/AutomationEditor.cpp | 108 +++--- src/gui/editors/PatternEditor.cpp | 10 +- src/gui/editors/PianoRoll.cpp | 330 +++++++++--------- src/gui/editors/PositionLine.cpp | 4 +- src/gui/editors/SongEditor.cpp | 40 +-- src/gui/editors/TimeLineWidget.cpp | 56 +-- src/gui/editors/TrackContainerView.cpp | 10 +- src/gui/instrument/EnvelopeAndLfoView.cpp | 49 +-- .../instrument/InstrumentFunctionViews.cpp | 16 +- .../instrument/InstrumentSoundShapingView.cpp | 4 +- src/gui/instrument/InstrumentTrackWindow.cpp | 14 +- src/gui/instrument/PianoView.cpp | 40 +-- src/gui/menus/MidiPortMenu.cpp | 12 +- src/gui/modals/ControllerConnectionDialog.cpp | 6 +- src/gui/modals/EffectSelectDialog.cpp | 2 +- src/gui/modals/ExportProjectDialog.cpp | 32 +- src/gui/modals/SetupDialog.cpp | 4 +- src/gui/tracks/InstrumentTrackView.cpp | 8 +- src/gui/tracks/SampleTrackView.cpp | 4 +- src/gui/tracks/TrackContentWidget.cpp | 12 +- src/gui/tracks/TrackLabelButton.cpp | 2 +- src/gui/tracks/TrackOperationsWidget.cpp | 6 +- src/gui/tracks/TrackView.cpp | 16 +- src/gui/widgets/CustomTextKnob.cpp | 2 +- src/gui/widgets/Graph.cpp | 10 +- src/gui/widgets/Knob.cpp | 40 +-- src/gui/widgets/LedCheckBox.cpp | 12 +- src/gui/widgets/TempoSyncKnob.cpp | 60 ++-- src/gui/widgets/TimeDisplayWidget.cpp | 16 +- src/tracks/AutomationTrack.cpp | 4 +- src/tracks/InstrumentTrack.cpp | 20 +- src/tracks/MidiClip.cpp | 24 +- src/tracks/PatternTrack.cpp | 8 +- src/tracks/SampleTrack.cpp | 6 +- tests/src/core/ProjectVersionTest.cpp | 16 +- tests/src/tracks/AutomationTrackTest.cpp | 22 +- 276 files changed, 2608 insertions(+), 2522 deletions(-) create mode 100644 include/Flags.h diff --git a/include/AudioEngine.h b/include/AudioEngine.h index dec8f2592f2..030c5bce39e 100644 --- a/include/AudioEngine.h +++ b/include/AudioEngine.h @@ -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; @@ -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; } } @@ -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; } @@ -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; @@ -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 diff --git a/include/AudioEngineWorkerThread.h b/include/AudioEngineWorkerThread.h index 16de6ff6fae..b76235aa125 100644 --- a/include/AudioEngineWorkerThread.h +++ b/include/AudioEngineWorkerThread.h @@ -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 @@ -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); } @@ -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 ); } @@ -97,7 +97,7 @@ class AudioEngineWorkerThread : public QThread // to ThreadableJob objects template static void fillJobQueue( const T & _vec, - JobQueue::OperationMode _opMode = JobQueue::Static ) + JobQueue::OperationMode _opMode = JobQueue::OperationMode::Static ) { resetJobQueue( _opMode ); for (const auto& job : _vec) diff --git a/include/AutomatableModel.h b/include/AutomatableModel.h index 292da3becf3..2264a592eda 100644 --- a/include/AutomatableModel.h +++ b/include/AutomatableModel.h @@ -81,7 +81,7 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject public: using AutoModelVector = std::vector; - enum ScaleType + enum class ScaleType { Linear, Logarithmic, @@ -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 ); diff --git a/include/AutomationClip.h b/include/AutomationClip.h index fc6a26d0e13..ceb5611c958 100644 --- a/include/AutomationClip.h +++ b/include/AutomationClip.h @@ -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; @@ -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 { @@ -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? diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index a1c4d694f11..ecefa8b26f1 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -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: @@ -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(); @@ -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... @@ -201,7 +201,7 @@ protected slots: TimePos m_currentPosition; - Actions m_action; + Action m_action; int m_moveXOffset; @@ -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 diff --git a/include/BandLimitedWave.h b/include/BandLimitedWave.h index 2a12c62e3ce..1f402aa6ea0 100644 --- a/include/BandLimitedWave.h +++ b/include/BandLimitedWave.h @@ -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(Waveform::Count); BandLimitedWave() = default; virtual ~BandLimitedWave() = default; @@ -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; @@ -139,12 +140,12 @@ class LMMS_EXPORT BandLimitedWave int lookup = static_cast( 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(_wave) ].sampleAt( t, lookup ); + const sample_t s2 = s_waveforms[ static_cast(_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(_wave) ].sampleAt( t, lm ); + const sample_t s3 = s_waveforms[ static_cast(_wave) ].sampleAt( t, ( lookup + 2 ) % tlen ); const sample_t sr = optimal4pInterpolate( s0, s1, s2, s3, ip ); return sr; @@ -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(_wave) ].sampleAt( t, lookup ); + const sample_t s4 = s_waveforms[ static_cast(_wave) ].sampleAt( t, ( lookup + 1 ) % tlen ); const sample_t s34 = linearInterpolate( s3, s4, ip ); const float ip2 = ( ( tlen - _wavelen ) / tlen - 0.5 ) * 2.0; @@ -168,7 +169,7 @@ class LMMS_EXPORT BandLimitedWave static bool s_wavesGenerated; - static std::array s_waveforms; + static std::array s_waveforms; static QString s_wavetableDir; }; diff --git a/include/BasicFilters.h b/include/BasicFilters.h index c54053c950d..9351cbafbc9 100644 --- a/include/BasicFilters.h +++ b/include/BasicFilters.h @@ -224,7 +224,7 @@ class BasicFilters { MM_OPERATORS public: - enum FilterTypes + enum class FilterType { LowPass, HiPass, @@ -247,8 +247,7 @@ class BasicFilters Highpass_SV, Notch_SV, FastFormant, - Tripole, - NumFilters + Tripole }; static inline float minFreq() @@ -261,20 +260,20 @@ class BasicFilters return( 0.01f ); } - inline void setFilterType( const int _idx ) + inline void setFilterType( const FilterType _idx ) { - m_doubleFilter = _idx == DoubleLowPass || _idx == DoubleMoog; + m_doubleFilter = _idx == FilterType::DoubleLowPass || _idx == FilterType::DoubleMoog; if( !m_doubleFilter ) { - m_type = static_cast( _idx ); + m_type = _idx; return; } // Double lowpass mode, backwards-compat for the goofy // Add-NumFilters to signify doubleFilter stuff - m_type = _idx == DoubleLowPass - ? LowPass - : Moog; + m_type = _idx == FilterType::DoubleLowPass + ? FilterType::LowPass + : FilterType::Moog; if( m_subFilter == nullptr ) { m_subFilter = new BasicFilters( @@ -334,7 +333,7 @@ class BasicFilters sample_t out; switch( m_type ) { - case Moog: + case FilterType::Moog: { sample_t x = _in0 - m_r*m_y4[_chnl]; @@ -364,7 +363,7 @@ class BasicFilters // 3x onepole filters with 4x oversampling and interpolation of oversampled signal: // input signal is linear-interpolated after oversampling, output signal is averaged from oversampled outputs - case Tripole: + case FilterType::Tripole: { out = 0.0f; float ip = 0.0f; @@ -397,8 +396,8 @@ class BasicFilters // and extended to other SV filter types // /* Hal Chamberlin's state variable filter */ - case Lowpass_SV: - case Bandpass_SV: + case FilterType::Lowpass_SV: + case FilterType::Bandpass_SV: { float highpass; @@ -414,12 +413,12 @@ class BasicFilters } /* mix filter output into output buffer */ - return m_type == Lowpass_SV + return m_type == FilterType::Lowpass_SV ? m_delay4[_chnl] : m_delay3[_chnl]; } - case Highpass_SV: + case FilterType::Highpass_SV: { float hp; @@ -433,7 +432,7 @@ class BasicFilters return hp; } - case Notch_SV: + case FilterType::Notch_SV: { float hp1, hp2; @@ -458,7 +457,7 @@ class BasicFilters // can be driven up to self-oscillation (BTW: do not remove the limits!!!). // (C) 1998 ... 2009 S.Fendt. Released under the GPL v2.0 or any later version. - case Lowpass_RC12: + case FilterType::Lowpass_RC12: { sample_t lp, bp, hp, in; for( int n = 4; n != 0; --n ) @@ -482,8 +481,8 @@ class BasicFilters } return lp; } - case Highpass_RC12: - case Bandpass_RC12: + case FilterType::Highpass_RC12: + case FilterType::Bandpass_RC12: { sample_t hp, bp, in; for( int n = 4; n != 0; --n ) @@ -501,10 +500,10 @@ class BasicFilters m_rchp0[_chnl] = hp; m_rcbp0[_chnl] = bp; } - return m_type == Highpass_RC12 ? hp : bp; + return m_type == FilterType::Highpass_RC12 ? hp : bp; } - case Lowpass_RC24: + case FilterType::Lowpass_RC24: { sample_t lp, bp, hp, in; for( int n = 4; n != 0; --n ) @@ -547,8 +546,8 @@ class BasicFilters } return lp; } - case Highpass_RC24: - case Bandpass_RC24: + case FilterType::Highpass_RC24: + case FilterType::Bandpass_RC24: { sample_t hp, bp, in; for( int n = 4; n != 0; --n ) @@ -568,7 +567,7 @@ class BasicFilters m_rcbp0[_chnl] = bp; // second stage gets the output of the first stage as input... - in = m_type == Highpass_RC24 + in = m_type == FilterType::Highpass_RC24 ? hp + m_rcbp1[_chnl] * m_rcq : bp + m_rcbp1[_chnl] * m_rcq; @@ -584,17 +583,17 @@ class BasicFilters m_rchp1[_chnl] = hp; m_rcbp1[_chnl] = bp; } - return m_type == Highpass_RC24 ? hp : bp; + return m_type == FilterType::Highpass_RC24 ? hp : bp; } - case Formantfilter: - case FastFormant: + case FilterType::Formantfilter: + case FilterType::FastFormant: { if (std::abs(_in0) < 1.0e-10f && std::abs(m_vflast[0][_chnl]) < 1.0e-10f) { return 0.0f; } // performance hack - skip processing when the numbers get too small sample_t hp, bp, in; out = 0; - const int os = m_type == FastFormant ? 1 : 4; // no oversampling for fast formant + const int os = m_type == FilterType::FastFormant ? 1 : 4; // no oversampling for fast formant for( int o = 0; o < os; ++o ) { // first formant @@ -681,7 +680,7 @@ class BasicFilters out += bp; } - return m_type == FastFormant ? out * 2.0f : out * 0.5f; + return m_type == FilterType::FastFormant ? out * 2.0f : out * 0.5f; } default: @@ -704,12 +703,12 @@ class BasicFilters // temp coef vars _q = std::max(_q, minQ()); - if( m_type == Lowpass_RC12 || - m_type == Bandpass_RC12 || - m_type == Highpass_RC12 || - m_type == Lowpass_RC24 || - m_type == Bandpass_RC24 || - m_type == Highpass_RC24 ) + if( m_type == FilterType::Lowpass_RC12 || + m_type == FilterType::Bandpass_RC12 || + m_type == FilterType::Highpass_RC12 || + m_type == FilterType::Lowpass_RC24 || + m_type == FilterType::Bandpass_RC24 || + m_type == FilterType::Highpass_RC24 ) { _freq = std::clamp(_freq, 50.0f, 20000.0f); const float sr = m_sampleRatio * 0.25f; @@ -724,8 +723,8 @@ class BasicFilters return; } - if( m_type == Formantfilter || - m_type == FastFormant ) + if( m_type == FilterType::Formantfilter || + m_type == FilterType::FastFormant ) { _freq = std::clamp(_freq, minFreq(), 20000.0f); // limit freq and q for not getting bad noise out of the filter... @@ -750,7 +749,7 @@ class BasicFilters const float f1 = 1.0f / ( linearInterpolate( _f[vowel+0][1], _f[vowel+1][1], fract ) * F_2PI ); // samplerate coeff: depends on oversampling - const float sr = m_type == FastFormant ? m_sampleRatio : m_sampleRatio * 0.25f; + const float sr = m_type == FilterType::FastFormant ? m_sampleRatio : m_sampleRatio * 0.25f; m_vfa[0] = 1.0f - sr / ( f0 + sr ); m_vfb[0] = 1.0f - m_vfa[0]; @@ -761,8 +760,8 @@ class BasicFilters return; } - if( m_type == Moog || - m_type == DoubleMoog ) + if( m_type == FilterType::Moog || + m_type == FilterType::DoubleMoog ) { // [ 0 - 0.5 ] const float f = std::clamp(_freq, minFreq(), 20000.0f) * m_sampleRatio; @@ -780,7 +779,7 @@ class BasicFilters return; } - if( m_type == Tripole ) + if( m_type == FilterType::Tripole ) { const float f = std::clamp(_freq, 20.0f, 20000.0f) * m_sampleRatio * 0.25f; @@ -791,10 +790,10 @@ class BasicFilters return; } - if( m_type == Lowpass_SV || - m_type == Bandpass_SV || - m_type == Highpass_SV || - m_type == Notch_SV ) + if( m_type == FilterType::Lowpass_SV || + m_type == FilterType::Bandpass_SV || + m_type == FilterType::Highpass_SV || + m_type == FilterType::Notch_SV ) { const float f = sinf(std::max(minFreq(), _freq) * m_sampleRatio * F_PI); m_svf1 = std::min(f, 0.825f); @@ -818,38 +817,38 @@ class BasicFilters switch( m_type ) { - case LowPass: + case FilterType::LowPass: { const float b1 = ( 1.0f - tcos ) * a0; const float b0 = b1 * 0.5f; m_biQuad.setCoeffs( a1, a2, b0, b1, b0 ); break; } - case HiPass: + case FilterType::HiPass: { const float b1 = ( -1.0f - tcos ) * a0; const float b0 = b1 * -0.5f; m_biQuad.setCoeffs( a1, a2, b0, b1, b0 ); break; } - case BandPass_CSG: + case FilterType::BandPass_CSG: { const float b0 = tsin * a0; m_biQuad.setCoeffs( a1, a2, b0, 0.0f, -b0 ); break; } - case BandPass_CZPG: + case FilterType::BandPass_CZPG: { const float b0 = alpha * a0; m_biQuad.setCoeffs( a1, a2, b0, 0.0f, -b0 ); break; } - case Notch: + case FilterType::Notch: { m_biQuad.setCoeffs( a1, a2, a0, a1, a0 ); break; } - case AllPass: + case FilterType::AllPass: { m_biQuad.setCoeffs( a1, a2, a2, a1, 1.0f ); break; @@ -898,7 +897,7 @@ class BasicFilters // in/out history for Lowpass_SV (state-variant lowpass) frame m_delay1, m_delay2, m_delay3, m_delay4; - FilterTypes m_type; + FilterType m_type; bool m_doubleFilter; float m_sampleRate; diff --git a/include/Clip.h b/include/Clip.h index 8f4162d966d..96394602fa0 100644 --- a/include/Clip.h +++ b/include/Clip.h @@ -164,13 +164,6 @@ public slots: private: - enum Actions - { - NoAction, - Move, - Resize - } ; - Track * m_track; QString m_name; diff --git a/include/ClipView.h b/include/ClipView.h index 32c5130b984..94225836725 100644 --- a/include/ClipView.h +++ b/include/ClipView.h @@ -140,7 +140,7 @@ public slots: void resetColor(); protected: - enum ContextMenuAction + enum class ContextMenuAction { Remove, Cut, @@ -191,9 +191,9 @@ protected slots: private: - enum Actions + enum class Action { - NoAction, + None, Move, MoveSelection, Resize, @@ -206,7 +206,7 @@ protected slots: static TextFloat * s_textFloat; Clip * m_clip; - Actions m_action; + Action m_action; QPoint m_initialMousePos; QPoint m_initialMouseGlobalPos; QVector m_initialOffsets; diff --git a/include/Controller.h b/include/Controller.h index 3387975b8d1..fe78c55cc0d 100644 --- a/include/Controller.h +++ b/include/Controller.h @@ -51,20 +51,19 @@ class LMMS_EXPORT Controller : public Model, public JournallingObject { Q_OBJECT public: - enum ControllerTypes + enum class ControllerType { - DummyController, - LfoController, - MidiController, - PeakController, + Dummy, + Lfo, + Midi, + Peak, /* - XYController, - EquationController + XY, + Equation */ - NumControllerTypes } ; - Controller( ControllerTypes _type, Model * _parent, + Controller( ControllerType _type, Model * _parent, const QString & _display_name ); ~Controller() override; @@ -83,7 +82,7 @@ class LMMS_EXPORT Controller : public Model, public JournallingObject m_sampleExact = _exact; } - inline ControllerTypes type() const + inline ControllerType type() const { return( m_type ); } @@ -94,8 +93,8 @@ class LMMS_EXPORT Controller : public Model, public JournallingObject { switch( m_type ) { - case LfoController: return( true ); - case PeakController: return( true ); + case ControllerType::Lfo: return( true ); + case ControllerType::Peak: return( true ); default: break; } @@ -112,7 +111,7 @@ class LMMS_EXPORT Controller : public Model, public JournallingObject void loadSettings( const QDomElement & _this ) override; QString nodeName() const override; - static Controller * create( ControllerTypes _tt, Model * _parent ); + static Controller * create( ControllerType _tt, Model * _parent ); static Controller * create( const QDomElement & _this, Model * _parent ); @@ -165,7 +164,7 @@ public slots: int m_connectionCount; QString m_name; - ControllerTypes m_type; + ControllerType m_type; static ControllerVector s_controllers; diff --git a/include/CustomTextKnob.h b/include/CustomTextKnob.h index 19768ec8780..31a58415e6f 100644 --- a/include/CustomTextKnob.h +++ b/include/CustomTextKnob.h @@ -36,7 +36,7 @@ class LMMS_EXPORT CustomTextKnob : public Knob protected: inline void setHintText( const QString & _txt_before, const QString & _txt_after ) {} // inaccessible public: - CustomTextKnob( knobTypes _knob_num, QWidget * _parent = nullptr, const QString & _name = QString(), const QString & _value_text = QString() ); + CustomTextKnob( KnobType _knob_num, QWidget * _parent = nullptr, const QString & _name = QString(), const QString & _value_text = QString() ); CustomTextKnob( QWidget * _parent = nullptr, const QString & _name = QString(), const QString & _value_text = QString() ); //!< default ctor diff --git a/include/DataFile.h b/include/DataFile.h index a91b37f9ba2..137f0156fe2 100644 --- a/include/DataFile.h +++ b/include/DataFile.h @@ -47,9 +47,9 @@ class LMMS_EXPORT DataFile : public QDomDocument using UpgradeMethod = void(DataFile::*)(); public: - enum Types + enum class Type { - UnknownType, + Unknown, SongProject, SongProjectTemplate, InstrumentTrackSettings, @@ -57,10 +57,8 @@ class LMMS_EXPORT DataFile : public QDomDocument ClipboardData, JournalData, EffectSettings, - MidiClip, - TypeCount + MidiClip } ; - using Type = Types; DataFile( const QString& fileName ); DataFile( const QByteArray& data ); diff --git a/include/EnvelopeAndLfoParameters.h b/include/EnvelopeAndLfoParameters.h index 02abd07e3e8..7abc3910e96 100644 --- a/include/EnvelopeAndLfoParameters.h +++ b/include/EnvelopeAndLfoParameters.h @@ -169,7 +169,7 @@ public slots: bool m_bad_lfoShapeData; SampleBuffer m_userWave; - enum LfoShapes + enum class LfoShape { SineWave, TriangleWave, @@ -177,8 +177,9 @@ public slots: SquareWave, UserDefinedWave, RandomWave, - NumLfoShapes + Count } ; + constexpr static auto NumLfoShapes = static_cast(LfoShape::Count); sample_t lfoShapeSample( fpp_t _frame_offset ); void updateLfoShapeData(); diff --git a/include/ExportProjectDialog.h b/include/ExportProjectDialog.h index 56a9fc1f5b3..37f6e0399a0 100644 --- a/include/ExportProjectDialog.h +++ b/include/ExportProjectDialog.h @@ -62,7 +62,7 @@ private slots: QString m_fileExtension; bool m_multiExport; - ProjectRenderer::ExportFileFormats m_ft; + ProjectRenderer::ExportFileFormat m_ft; std::unique_ptr m_renderManager; } ; diff --git a/include/FileBrowser.h b/include/FileBrowser.h index 51103b19f95..3334a73f659 100644 --- a/include/FileBrowser.h +++ b/include/FileBrowser.h @@ -223,20 +223,19 @@ class Directory : public QTreeWidgetItem class FileItem : public QTreeWidgetItem { public: - enum FileTypes + enum class FileType { - ProjectFile, - PresetFile, - SampleFile, - SoundFontFile, - PatchFile, - MidiFile, - VstPluginFile, - UnknownFile, - NumFileTypes + Project, + Preset, + Sample, + SoundFont, + Patch, + Midi, + VstPlugin, + Unknown } ; - enum FileHandling + enum class FileHandling { NotSupported, LoadAsProject, @@ -255,7 +254,7 @@ class FileItem : public QTreeWidgetItem return QFileInfo(m_path, text(0)).absoluteFilePath(); } - inline FileTypes type() const + inline FileType type() const { return( m_type ); } @@ -267,7 +266,7 @@ class FileItem : public QTreeWidgetItem inline bool isTrack() const { - return m_handling == LoadAsPreset || m_handling == LoadByPlugin; + return m_handling == FileHandling::LoadAsPreset || m_handling == FileHandling::LoadByPlugin; } QString extension(); @@ -287,7 +286,7 @@ class FileItem : public QTreeWidgetItem static QPixmap * s_unknownFilePixmap; QString m_path; - FileTypes m_type; + FileType m_type; FileHandling m_handling; } ; diff --git a/include/Flags.h b/include/Flags.h new file mode 100644 index 00000000000..76106dde660 --- /dev/null +++ b/include/Flags.h @@ -0,0 +1,83 @@ +/* + * Flags.h - class to make flags from enums + * + * Copyright (c) 2023 Dominic Clark + * + * 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_FLAGS_H +#define LMMS_FLAGS_H + +#include + +namespace lmms { + +template +class Flags +{ + static_assert(std::is_enum_v, "lmms::Flags can only be used with enum types"); + +public: + using EnumType = T; + using UnderlyingType = std::underlying_type_t; + + constexpr Flags() = default; + + constexpr Flags(T value) : // Intentionally not explicit + m_value{static_cast(value)} + {} + + constexpr explicit Flags(UnderlyingType value) : + m_value{value} + {} + + constexpr auto testAll(Flags flags) const -> bool { return *this & flags == flags; } + constexpr auto testAny(Flags flags) const -> bool { return *this & flags != Flags{}; } + constexpr auto testFlag(EnumType flag) const -> bool { return static_cast(*this & flag); } + + constexpr auto operator~() const -> Flags { return Flags{~m_value}; } + friend constexpr auto operator&(Flags l, Flags r) -> Flags { return Flags{l.m_value & r.m_value}; } + friend constexpr auto operator|(Flags l, Flags r) -> Flags { return Flags{l.m_value | r.m_value}; } + friend constexpr auto operator^(Flags l, Flags r) -> Flags { return Flags{l.m_value ^ r.m_value}; } + friend constexpr auto operator+(Flags l, Flags r) -> Flags { return Flags{l.m_value | r.m_value}; } + friend constexpr auto operator-(Flags l, Flags r) -> Flags { return Flags{l.m_value & ~r.m_value}; } + + constexpr auto operator&=(Flags f) -> Flags& { m_value &= f.m_value; return *this; } + constexpr auto operator|=(Flags f) -> Flags& { m_value |= f.m_value; return *this; } + constexpr auto operator^=(Flags f) -> Flags& { m_value ^= f.m_value; return *this; } + constexpr auto operator+=(Flags f) -> Flags& { m_value |= f.m_value; return *this; } + constexpr auto operator-=(Flags f) -> Flags& { m_value &= ~f.m_value; return *this; } + + constexpr explicit operator UnderlyingType() const { return m_value; } // TODO C++23: explicit(std::is_scoped_enum) + constexpr explicit operator bool() const { return m_value != 0; } + + friend constexpr auto operator==(Flags l, Flags r) -> bool { return l.m_value == r.m_value; } // TODO C++20: = default + friend constexpr auto operator!=(Flags l, Flags r) -> bool { return l.m_value != r.m_value; } // TODO C++20: Remove + +private: + UnderlyingType m_value = 0; +}; + +#define LMMS_DECLARE_OPERATORS_FOR_FLAGS(type) \ +constexpr inline auto operator|(type l, type r) -> ::lmms::Flags { return ::lmms::Flags{l} | ::lmms::Flags{r}; } + +} // namespace lmms + +#endif // LMMS_FLAGS_H diff --git a/include/Graph.h b/include/Graph.h index f62215ac255..0f5f2452486 100644 --- a/include/Graph.h +++ b/include/Graph.h @@ -48,13 +48,12 @@ class LMMS_EXPORT Graph : public QWidget, public ModelView { Q_OBJECT public: - enum graphStyle + enum class Style { - NearestStyle, //!< draw as stairs - LinearStyle, //!< connect each 2 samples with a line, with wrapping - LinearNonCyclicStyle, //!< LinearStyle without wrapping - BarStyle, //!< draw thick bars - NumGraphStyles + Nearest, //!< draw as stairs + Linear, //!< connect each 2 samples with a line, with wrapping + LinearNonCyclic, //!< Linear without wrapping + Bar, //!< draw thick bars }; /** @@ -62,7 +61,7 @@ class LMMS_EXPORT Graph : public QWidget, public ModelView * @param _width Pixel width of widget * @param _height Pixel height of widget */ - Graph( QWidget * _parent, graphStyle _style = Graph::LinearStyle, + Graph( QWidget * _parent, Style _style = Style::Linear, int _width = 132, int _height = 104 ); @@ -78,13 +77,13 @@ class LMMS_EXPORT Graph : public QWidget, public ModelView return castModel(); } - inline graphStyle getGraphStyle() + inline Style getGraphStyle() { return m_graphStyle; } - inline void setGraphStyle( graphStyle _s ) + inline void setGraphStyle( Style _s ) { m_graphStyle = _s; update(); @@ -114,7 +113,7 @@ protected slots: QPixmap m_foreground; QColor m_graphColor; - graphStyle m_graphStyle; + Style m_graphStyle; bool m_mouseDown; int m_lastCursorX; diff --git a/include/Instrument.h b/include/Instrument.h index 1c42c970e1c..f23e0b401f3 100644 --- a/include/Instrument.h +++ b/include/Instrument.h @@ -27,6 +27,8 @@ #define LMMS_INSTRUMENT_H #include + +#include "Flags.h" #include "lmms_export.h" #include "lmms_basics.h" #include "MemoryManager.h" @@ -47,7 +49,7 @@ class LMMS_EXPORT Instrument : public Plugin { MM_OPERATORS public: - enum Flag + enum class Flag { NoFlags = 0x00, IsSingleStreamed = 0x01, /*! Instrument provides a single audio stream for all notes */ @@ -55,7 +57,7 @@ class LMMS_EXPORT Instrument : public Plugin IsNotBendable = 0x04, /*! Instrument can't react to pitch bend changes */ }; - Q_DECLARE_FLAGS(Flags, Flag); + using Flags = lmms::Flags; Instrument(InstrumentTrack * _instrument_track, const Descriptor * _descriptor, @@ -102,7 +104,7 @@ class LMMS_EXPORT Instrument : public Plugin virtual Flags flags() const { - return NoFlags; + return Flag::NoFlags; } // sub-classes can re-implement this for receiving all incoming @@ -149,7 +151,7 @@ class LMMS_EXPORT Instrument : public Plugin } ; -Q_DECLARE_OPERATORS_FOR_FLAGS(Instrument::Flags) +LMMS_DECLARE_OPERATORS_FOR_FLAGS(Instrument::Flag) } // namespace lmms diff --git a/include/InstrumentFunctions.h b/include/InstrumentFunctions.h index 61d625d8339..59c651a68c4 100644 --- a/include/InstrumentFunctions.h +++ b/include/InstrumentFunctions.h @@ -176,14 +176,13 @@ class InstrumentFunctionArpeggio : public Model, public JournallingObject { Q_OBJECT public: - enum ArpDirections + enum class ArpDirection { - ArpDirUp, - ArpDirDown, - ArpDirUpAndDown, - ArpDirDownAndUp, - ArpDirRandom, - NumArpDirections + Up, + Down, + UpAndDown, + DownAndUp, + Random } ; InstrumentFunctionArpeggio( Model * _parent ); @@ -202,11 +201,11 @@ class InstrumentFunctionArpeggio : public Model, public JournallingObject private: - enum ArpModes + enum class ArpMode { - FreeMode, - SortMode, - SyncMode + Free, + Sort, + Sync } ; BoolModel m_arpEnabledModel; diff --git a/include/InstrumentSoundShaping.h b/include/InstrumentSoundShaping.h index 6db3078ecaf..fb5f1e8bd90 100644 --- a/include/InstrumentSoundShaping.h +++ b/include/InstrumentSoundShaping.h @@ -51,13 +51,14 @@ class InstrumentSoundShaping : public Model, public JournallingObject void processAudioBuffer( sampleFrame * _ab, const fpp_t _frames, NotePlayHandle * _n ); - enum Targets + enum class Target { Volume, Cut, Resonance, - NumTargets + Count } ; + constexpr static auto NumTargets = static_cast(Target::Count); f_cnt_t envFrames( const bool _only_vol = false ) const; f_cnt_t releaseFrames() const; @@ -82,7 +83,7 @@ class InstrumentSoundShaping : public Model, public JournallingObject FloatModel m_filterCutModel; FloatModel m_filterResModel; - static const char *const targetNames[InstrumentSoundShaping::NumTargets][3]; + static const char *const targetNames[NumTargets][3]; friend class gui::InstrumentSoundShapingView; diff --git a/include/Knob.h b/include/Knob.h index 289af8cd5ea..85a51e363e8 100644 --- a/include/Knob.h +++ b/include/Knob.h @@ -42,9 +42,9 @@ namespace lmms::gui class SimpleTextFloat; -enum knobTypes +enum class KnobType { - knobDark_28, knobBright_26, knobSmall_17, knobVintage_32, knobStyled + Dark28, Bright26, Small17, Vintage32, Styled } ; @@ -53,7 +53,7 @@ void convertPixmapToGrayScale(QPixmap &pixMap); class LMMS_EXPORT Knob : public QWidget, public FloatModelView { Q_OBJECT - Q_ENUMS( knobTypes ) + Q_ENUMS( KnobType ) Q_PROPERTY(float innerRadius READ innerRadius WRITE setInnerRadius) Q_PROPERTY(float outerRadius READ outerRadius WRITE setOuterRadius) @@ -75,7 +75,7 @@ class LMMS_EXPORT Knob : public QWidget, public FloatModelView mapPropertyFromModel(bool,isVolumeKnob,setVolumeKnob,m_volumeKnob); mapPropertyFromModel(float,volumeRatio,setVolumeRatio,m_volumeRatio); - Q_PROPERTY(knobTypes knobNum READ knobNum WRITE setknobNum) + Q_PROPERTY(KnobType knobNum READ knobNum WRITE setknobNum) Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) @@ -83,7 +83,7 @@ class LMMS_EXPORT Knob : public QWidget, public FloatModelView void onKnobNumUpdated(); //!< to be called when you updated @a m_knobNum public: - Knob( knobTypes _knob_num, QWidget * _parent = nullptr, const QString & _name = QString() ); + Knob( KnobType _knob_num, QWidget * _parent = nullptr, const QString & _name = QString() ); Knob( QWidget * _parent = nullptr, const QString & _name = QString() ); //!< default ctor Knob( const Knob& other ) = delete; @@ -106,8 +106,8 @@ class LMMS_EXPORT Knob : public QWidget, public FloatModelView float outerRadius() const; void setOuterRadius( float r ); - knobTypes knobNum() const; - void setknobNum( knobTypes k ); + KnobType knobNum() const; + void setknobNum( KnobType k ); QPointF centerPoint() const; float centerPointX() const; @@ -206,7 +206,7 @@ private slots: QColor m_textColor; - knobTypes m_knobNum; + KnobType m_knobNum; } ; diff --git a/include/LadspaBase.h b/include/LadspaBase.h index 51c0ca20235..6569c5a309e 100644 --- a/include/LadspaBase.h +++ b/include/LadspaBase.h @@ -35,16 +35,16 @@ namespace lmms class LadspaControl; -enum buffer_rate_t { - CHANNEL_IN, - CHANNEL_OUT, - AUDIO_RATE_INPUT, - AUDIO_RATE_OUTPUT, - CONTROL_RATE_INPUT, - CONTROL_RATE_OUTPUT +enum class BufferRate { + ChannelIn, + ChannelOut, + AudioRateInput, + AudioRateOutput, + ControlRateInput, + ControlRateOutput }; -enum buffer_data_t { TOGGLED, ENUM, INTEGER, FLOATING, TIME, NONE }; +enum class BufferDataType { Toggled, Enum, Integer, Floating, Time, None }; //! This struct is used to hold port descriptions internally //! which where received from the ladspa plugin @@ -54,8 +54,8 @@ struct port_desc_t ch_cnt_t proc; uint16_t port_id; uint16_t control_id; - buffer_rate_t rate; - buffer_data_t data_type; + BufferRate rate; + BufferDataType data_type; float scale; LADSPA_Data max; LADSPA_Data min; diff --git a/include/LadspaManager.h b/include/LadspaManager.h index 8c00d260429..1a336023132 100644 --- a/include/LadspaManager.h +++ b/include/LadspaManager.h @@ -62,14 +62,14 @@ calls using: as the plug-in key. */ -enum LadspaPluginType +enum class LadspaPluginType { - SOURCE, - TRANSFER, - VALID, - INVALID, - SINK, - OTHER + Source, + Transfer, + Valid, + Invalid, + Sink, + Other }; struct LadspaManagerDescription diff --git a/include/LedCheckBox.h b/include/LedCheckBox.h index 95016b87fa5..e3629e143e7 100644 --- a/include/LedCheckBox.h +++ b/include/LedCheckBox.h @@ -38,20 +38,19 @@ class LMMS_EXPORT LedCheckBox : public AutomatableButton { Q_OBJECT public: - enum LedColors + enum class LedColor { Yellow, Green, - Red, - NumColors + Red } ; LedCheckBox( const QString & _txt, QWidget * _parent, const QString & _name = QString(), - LedColors _color = Yellow ); + LedColor _color = LedColor::Yellow ); LedCheckBox( QWidget * _parent, const QString & _name = QString(), - LedColors _color = Yellow ); + LedColor _color = LedColor::Yellow ); ~LedCheckBox() override; @@ -75,7 +74,7 @@ class LMMS_EXPORT LedCheckBox : public AutomatableButton QString m_text; - void initUi( LedColors _color ); //!< to be called by ctors + void initUi( LedColor _color ); //!< to be called by ctors void onTextUpdated(); //!< to be called when you updated @a m_text } ; diff --git a/include/LmmsStyle.h b/include/LmmsStyle.h index b3be03952fe..d17bbed9844 100644 --- a/include/LmmsStyle.h +++ b/include/LmmsStyle.h @@ -36,34 +36,6 @@ namespace lmms::gui class LmmsStyle : public QProxyStyle { public: - enum ColorRole - { - AutomationBarFill, - AutomationBarValue, - AutomationSelectedBarFill, - AutomationCrosshair, - PianoRollStepNote, - PianoRollSelectedNote, - PianoRollDefaultNote, - PianoRollFrozenNote, - PianoRollMutedNote, - PianoRollEditHandle, - PianoRollVolumeLevel, - PianoRollPanningLevel, - PianoRollSelectedLevel, - TimelineForecolor, - StandardGraphLine, - StandardGraphHandle, - StandardGraphHandleBorder, - StandardGraphCrosshair, - TextFloatForecolor, - TextFloatFill, - VisualizationLevelLow, - VisualizationLevelMid, - VisualizationLevelPeak, - NumColorRoles - }; - LmmsStyle(); ~LmmsStyle() override = default; @@ -88,8 +60,6 @@ class LmmsStyle : public QProxyStyle private: QImage colorizeXpm( const char * const * xpm, const QBrush& fill ) const; void hoverColors( bool sunken, bool hover, bool active, QColor& color, QColor& blend ) const; - QColor m_colors[ LmmsStyle::NumColorRoles ]; - }; diff --git a/include/Lv2ControlBase.h b/include/Lv2ControlBase.h index f5cb0cdb414..2d44f0ecf56 100644 --- a/include/Lv2ControlBase.h +++ b/include/Lv2ControlBase.h @@ -74,7 +74,7 @@ class PluginIssue; class LMMS_EXPORT Lv2ControlBase : public LinkedModelGroups { public: - static Plugin::PluginTypes check(const LilvPlugin* m_plugin, + static Plugin::Type check(const LilvPlugin* m_plugin, std::vector &issues); void shutdown(); diff --git a/include/Lv2Manager.h b/include/Lv2Manager.h index 89f6a0efd1f..909dba5607e 100644 --- a/include/Lv2Manager.h +++ b/include/Lv2Manager.h @@ -95,18 +95,18 @@ class Lv2Manager //! use only for std::map internals Lv2Info() : m_plugin(nullptr) {} //! ctor used inside Lv2Manager - Lv2Info(const LilvPlugin* plug, Plugin::PluginTypes type, bool valid) : + Lv2Info(const LilvPlugin* plug, Plugin::Type type, bool valid) : m_plugin(plug), m_type(type), m_valid(valid) {} Lv2Info(Lv2Info&& other) = default; Lv2Info& operator=(Lv2Info&& other) = default; const LilvPlugin* plugin() const { return m_plugin; } - Plugin::PluginTypes type() const { return m_type; } + Plugin::Type type() const { return m_type; } bool isValid() const { return m_valid; } private: const LilvPlugin* m_plugin; - Plugin::PluginTypes m_type; + Plugin::Type m_type; bool m_valid = false; }; diff --git a/include/Lv2Ports.h b/include/Lv2Ports.h index 0f0b02913a2..e4c896ff3e7 100644 --- a/include/Lv2Ports.h +++ b/include/Lv2Ports.h @@ -33,6 +33,7 @@ #include #include +#include "Flags.h" #include "lmms_basics.h" #include "PluginIssue.h" @@ -210,12 +211,12 @@ struct Audio : public VisitablePort struct AtomSeq : public VisitablePort { - enum FlagType + enum class FlagType { None = 0, Midi = 1 }; - unsigned flags = FlagType::None; + Flags flags = FlagType::None; struct Lv2EvbufDeleter { diff --git a/include/Lv2Proc.h b/include/Lv2Proc.h index 1be284ced62..62070def7f6 100644 --- a/include/Lv2Proc.h +++ b/include/Lv2Proc.h @@ -64,7 +64,7 @@ namespace Lv2Ports class Lv2Proc : public LinkedModelGroup { public: - static Plugin::PluginTypes check(const LilvPlugin* plugin, + static Plugin::Type check(const LilvPlugin* plugin, std::vector &issues); /* diff --git a/include/Lv2SubPluginFeatures.h b/include/Lv2SubPluginFeatures.h index 57eab871529..eb0bd990098 100644 --- a/include/Lv2SubPluginFeatures.h +++ b/include/Lv2SubPluginFeatures.h @@ -47,7 +47,7 @@ class LMMS_EXPORT Lv2SubPluginFeatures : public Plugin::Descriptor::SubPluginFea static QString pluginName(const LilvPlugin *plug); public: - Lv2SubPluginFeatures(Plugin::PluginTypes type); + Lv2SubPluginFeatures(Plugin::Type type); void fillDescriptionWidget( QWidget *parent, const Key *k) const override; diff --git a/include/MainWindow.h b/include/MainWindow.h index c4bbb676735..30d52ec3a65 100644 --- a/include/MainWindow.h +++ b/include/MainWindow.h @@ -113,7 +113,7 @@ class MainWindow : public QMainWindow return m_autoSaveTimer.interval(); } - enum SessionState + enum class SessionState { Normal, Recover diff --git a/include/MidiClip.h b/include/MidiClip.h index bbb7d325d86..43b322f8075 100644 --- a/include/MidiClip.h +++ b/include/MidiClip.h @@ -46,7 +46,7 @@ class LMMS_EXPORT MidiClip : public Clip { Q_OBJECT public: - enum MidiClipTypes + enum class Type { BeatClip, MelodyClip @@ -82,7 +82,7 @@ class LMMS_EXPORT MidiClip : public Clip void splitNotes(NoteVector notes, TimePos pos); // clip-type stuff - inline MidiClipTypes type() const + inline Type type() const { return m_clipType; } @@ -129,14 +129,14 @@ protected slots: private: TimePos beatClipLength() const; - void setType( MidiClipTypes _new_clip_type ); + void setType( Type _new_clip_type ); void checkType(); void resizeToFirstTrack(); InstrumentTrack * m_instrumentTrack; - MidiClipTypes m_clipType; + Type m_clipType; // data-stuff NoteVector m_notes; diff --git a/include/MidiPort.h b/include/MidiPort.h index 6f759708e0c..6078f7a9b75 100644 --- a/include/MidiPort.h +++ b/include/MidiPort.h @@ -69,20 +69,19 @@ class MidiPort : public Model, public SerializingObject public: using Map = QMap; - enum Modes + enum class Mode { Disabled, // don't route any MIDI-events (default) Input, // from MIDI-client to MIDI-event-processor Output, // from MIDI-event-processor to MIDI-client Duplex // both directions } ; - using Mode = Modes; MidiPort( const QString& name, MidiClient* client, MidiEventProcessor* eventProcessor, Model* parent = nullptr, - Mode mode = Disabled ); + Mode mode = Mode::Disabled ); ~MidiPort() override; void setName( const QString& name ); @@ -96,12 +95,12 @@ class MidiPort : public Model, public SerializingObject bool isInputEnabled() const { - return mode() == Input || mode() == Duplex; + return mode() == Mode::Input || mode() == Mode::Duplex; } bool isOutputEnabled() const { - return mode() == Output || mode() == Duplex; + return mode() == Mode::Output || mode() == Mode::Duplex; } int realOutputChannel() const diff --git a/include/MidiPortMenu.h b/include/MidiPortMenu.h index 0b3fc1b2fd3..59604969b91 100644 --- a/include/MidiPortMenu.h +++ b/include/MidiPortMenu.h @@ -40,7 +40,7 @@ class MidiPortMenu : public QMenu, public ModelView { Q_OBJECT public: - MidiPortMenu( MidiPort::Modes _mode ); + MidiPortMenu( MidiPort::Mode _mode ); ~MidiPortMenu() override = default; @@ -55,7 +55,7 @@ protected slots: private: void modelChanged() override; - MidiPort::Modes m_mode; + MidiPort::Mode m_mode; } ; diff --git a/include/Note.h b/include/Note.h index a5c60ef8b6f..5e3a1b8a2bd 100644 --- a/include/Note.h +++ b/include/Note.h @@ -42,47 +42,53 @@ namespace lmms class DetuningHelper; -enum Keys +enum class Key : int { - Key_C = 0, - Key_CIS = 1, Key_DES = 1, - Key_D = 2, - Key_DIS = 3, Key_ES = 3, - Key_E = 4, Key_FES = 4, - Key_F = 5, - Key_FIS = 6, Key_GES = 6, - Key_G = 7, - Key_GIS = 8, Key_AS = 8, - Key_A = 9, - Key_AIS = 10, Key_B = 10, - Key_H = 11 + C = 0, + Cis = 1, Des = 1, + D = 2, + Dis = 3, Es = 3, + E = 4, Fes = 4, + F = 5, + Fis = 6, Ges = 6, + G = 7, + Gis = 8, As = 8, + A = 9, + Ais = 10, B = 10, + H = 11 } ; -enum Octaves +enum class Octave : int { Octave_m1, // MIDI standard starts at C-1 Octave_0, Octave_1, Octave_2, Octave_3, - Octave_4, DefaultOctave = Octave_4, + Octave_4, Octave_5, Octave_6, Octave_7, Octave_8, Octave_9, // incomplete octave, MIDI only goes up to G9 - NumOctaves }; const int FirstOctave = -1; const int KeysPerOctave = 12; -const int DefaultKey = DefaultOctave * KeysPerOctave + Key_A; + +constexpr inline auto operator+(Octave octave, Key key) -> int +{ + return static_cast(octave) * KeysPerOctave + static_cast(key); +} + +constexpr auto DefaultOctave = Octave::Octave_4; +const int DefaultKey = DefaultOctave + Key::A; //! Number of physical keys, limited to MIDI range (valid for both MIDI 1.0 and 2.0) const int NumKeys = 128; -const int DefaultMiddleKey = Octave_4 * KeysPerOctave + Key_C; -const int DefaultBaseKey = Octave_4 * KeysPerOctave + Key_A; +const int DefaultMiddleKey = Octave::Octave_4 + Key::C; +const int DefaultBaseKey = Octave::Octave_4 + Key::A; const float DefaultBaseFreq = 440.f; const float MaxDetuning = 4 * 12.0f; diff --git a/include/NotePlayHandle.h b/include/NotePlayHandle.h index 29477705bc3..46b14c4cd44 100644 --- a/include/NotePlayHandle.h +++ b/include/NotePlayHandle.h @@ -56,15 +56,13 @@ class LMMS_EXPORT NotePlayHandle : public PlayHandle, public Note fpp_t m_fadeInLength; // specifies origin of NotePlayHandle - enum Origins + enum class Origin { - OriginMidiClip, /*! playback of a note from a MIDI clip */ - OriginMidiInput, /*! playback of a MIDI note input event */ - OriginNoteStacking, /*! created by note stacking instrument function */ - OriginArpeggio, /*! created by arpeggio instrument function */ - OriginCount + MidiClip, /*! playback of a note from a MIDI clip */ + MidiInput, /*! playback of a MIDI note input event */ + NoteStacking, /*! created by note stacking instrument function */ + Arpeggio, /*! created by arpeggio instrument function */ }; - using Origin = Origins; NotePlayHandle( InstrumentTrack* instrumentTrack, const f_cnt_t offset, @@ -72,7 +70,7 @@ class LMMS_EXPORT NotePlayHandle : public PlayHandle, public Note const Note& noteToPlay, NotePlayHandle* parent = nullptr, int midiEventChannel = -1, - Origin origin = OriginMidiClip ); + Origin origin = Origin::MidiClip ); ~NotePlayHandle() override; void * operator new ( size_t size, void * p ) @@ -349,7 +347,7 @@ class NotePlayHandleManager const Note& noteToPlay, NotePlayHandle* parent = nullptr, int midiEventChannel = -1, - NotePlayHandle::Origin origin = NotePlayHandle::OriginMidiClip ); + NotePlayHandle::Origin origin = NotePlayHandle::Origin::MidiClip ); static void release( NotePlayHandle * nph ); static void extend( int i ); static void free(); diff --git a/include/Oscillator.h b/include/Oscillator.h index 46d858032aa..dab0b948d08 100644 --- a/include/Oscillator.h +++ b/include/Oscillator.h @@ -48,31 +48,34 @@ class LMMS_EXPORT Oscillator { MM_OPERATORS public: - enum WaveShapes + enum class WaveShape { - SineWave, - TriangleWave, - SawWave, - SquareWave, - MoogSawWave, - ExponentialWave, + Sine, + Triangle, + Saw, + Square, + MoogSaw, + Exponential, WhiteNoise, - UserDefinedWave, - NumWaveShapes, //!< Number of all available wave shapes - FirstWaveShapeTable = TriangleWave, //!< First wave shape that has a pre-generated table - NumWaveShapeTables = WhiteNoise - FirstWaveShapeTable, //!< Number of band-limited wave shapes to be generated + UserDefined, + Count //!< Number of all available wave shapes }; + constexpr static auto NumWaveShapes = static_cast(WaveShape::Count); + //! First wave shape that has a pre-generated table + constexpr static auto FirstWaveShapeTable = static_cast(WaveShape::Triangle); + //! Number of band-limited wave shapes to be generated + constexpr static auto NumWaveShapeTables = static_cast(WaveShape::WhiteNoise) - FirstWaveShapeTable; - enum ModulationAlgos + enum class ModulationAlgo { PhaseModulation, AmplitudeModulation, SignalMix, SynchronizedBySubOsc, FrequencyModulation, - NumModulationAlgos + Count } ; - + constexpr static auto NumModulationAlgos = static_cast(ModulationAlgo::Count); Oscillator( const IntModel *wave_shape_model, const IntModel *mod_algo_model, @@ -251,7 +254,7 @@ class LMMS_EXPORT Oscillator bool m_isModulator; /* Multiband WaveTable */ - static sample_t s_waveTables[WaveShapes::NumWaveShapeTables][OscillatorConstants::WAVE_TABLES_PER_WAVEFORM_COUNT][OscillatorConstants::WAVETABLE_LENGTH]; + static sample_t s_waveTables[NumWaveShapeTables][OscillatorConstants::WAVE_TABLES_PER_WAVEFORM_COUNT][OscillatorConstants::WAVETABLE_LENGTH]; static fftwf_plan s_fftPlan; static fftwf_plan s_ifftPlan; static fftwf_complex * s_specBuf; @@ -284,26 +287,26 @@ class LMMS_EXPORT Oscillator const ch_cnt_t _chnl ); inline bool syncOk( float _osc_coeff ); - template + template void updateNoSub( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ); - template + template void updatePM( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ); - template + template void updateAM( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ); - template + template void updateMix( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ); - template + template void updateSync( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ); - template + template void updateFM( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ); - template + template inline sample_t getSample( const float _sample ); inline void recalcPhase(); diff --git a/include/OutputSettings.h b/include/OutputSettings.h index 12242e1bbe5..94de0612c12 100644 --- a/include/OutputSettings.h +++ b/include/OutputSettings.h @@ -35,19 +35,18 @@ namespace lmms class OutputSettings { public: - enum BitDepth + enum class BitDepth { - Depth_16Bit, - Depth_24Bit, - Depth_32Bit, - NumDepths + Depth16Bit, + Depth24Bit, + Depth32Bit }; - enum StereoMode + enum class StereoMode { - StereoMode_Stereo, - StereoMode_JointStereo, - StereoMode_Mono + Stereo, + JointStereo, + Mono }; class BitRateSettings @@ -85,7 +84,7 @@ class OutputSettings OutputSettings( sample_rate_t sampleRate, BitRateSettings const & bitRateSettings, BitDepth bitDepth ) : - OutputSettings(sampleRate, bitRateSettings, bitDepth, StereoMode_Stereo ) + OutputSettings(sampleRate, bitRateSettings, bitDepth, StereoMode::Stereo ) { } diff --git a/include/Piano.h b/include/Piano.h index 96f37484031..698d9c8febc 100644 --- a/include/Piano.h +++ b/include/Piano.h @@ -38,10 +38,10 @@ class MidiEventProcessor; class Piano final : public Model { public: - enum KeyTypes + enum class KeyType { - WhiteKey, - BlackKey + White, + Black } ; Piano(InstrumentTrack* track); diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 03b93d8163e..9f3bbcd7d20 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -104,13 +104,13 @@ class PianoRoll : public QWidget Q_PROPERTY(QBrush blackKeyActiveBackground MEMBER m_blackKeyActiveBackground) Q_PROPERTY(QBrush blackKeyDisabledBackground MEMBER m_blackKeyDisabledBackground) public: - enum EditModes + enum class EditMode { - ModeDraw, - ModeErase, - ModeSelect, - ModeEditDetuning, - ModeEditKnife + Draw, + Erase, + Select, + Detuning, + Knife }; /*! \brief Resets settings to default when e.g. creating a new project */ @@ -153,16 +153,26 @@ class PianoRoll : public QWidget int trackOctaveSize() const; - Song::PlayModes desiredPlayModeForAccompany() const; + Song::PlayMode desiredPlayModeForAccompany() const; int quantization() const; protected: - enum QuantizeActions + enum class QuantizeAction { - QuantizeBoth, - QuantizePos, - QuantizeLength + Both, + Pos, + Length + }; + + enum class SemiToneMarkerAction + { + UnmarkAll, + MarkCurrentSemiTone, + MarkAllOctaveSemiTones, + MarkCurrentScale, + MarkCurrentChord, + CopyAllNotesOnKey }; void keyPressEvent( QKeyEvent * ke ) override; @@ -221,12 +231,12 @@ protected slots: void quantizeChanged(); void noteLengthChanged(); void keyChanged(); - void quantizeNotes(lmms::gui::PianoRoll::QuantizeActions mode = QuantizeBoth); + void quantizeNotes(QuantizeAction mode = QuantizeAction::Both); void updateSemiToneMarkerMenu(); void changeNoteEditMode( int i ); - void markSemiTone(int i, bool fromMenu = true); + void markSemiTone(SemiToneMarkerAction i, bool fromMenu = true); void hideMidiClip( lmms::MidiClip* clip ); @@ -248,46 +258,36 @@ protected slots: private: - enum Actions - { - ActionNone, - ActionMoveNote, - ActionResizeNote, - ActionSelectNotes, - ActionChangeNoteProperty, - ActionResizeNoteEditArea, - ActionKnife - }; - - enum NoteEditMode + enum class Action { - NoteEditVolume, - NoteEditPanning, - NoteEditCount // make sure this one is always last + None, + MoveNote, + ResizeNote, + SelectNotes, + ChangeNoteProperty, + ResizeNoteEditArea, + Knife }; - enum SemiToneMarkerAction + enum class NoteEditMode { - stmaUnmarkAll, - stmaMarkCurrentSemiTone, - stmaMarkAllOctaveSemiTones, - stmaMarkCurrentScale, - stmaMarkCurrentChord, - stmaCopyAllNotesOnKey + Volume, + Panning, + Count // make sure this one is always last }; - enum PianoRollKeyTypes + enum class KeyType { - PR_WHITE_KEY_SMALL, - PR_WHITE_KEY_BIG, - PR_BLACK_KEY + WhiteSmall, + WhiteBig, + Black }; - enum GridMode + enum class GridMode { - gridNudge, - gridSnap - // gridFree + Nudge, + Snap + // Free }; PositionLine * m_positionLine; @@ -346,7 +346,7 @@ protected slots: static QPixmap * s_toolOpen; static QPixmap* s_toolKnife; - static std::array prKeyOrder; + static std::array prKeyOrder; static SimpleTextFloat * s_textFloat; @@ -378,7 +378,7 @@ protected slots: QList m_recordingNotes; Note * m_currentNote; - Actions m_action; + Action m_action; NoteEditMode m_noteEditMode; GridMode m_gridMode; @@ -429,9 +429,9 @@ protected slots: int m_startKey; // first key when drawing int m_lastKey; - EditModes m_editMode; - EditModes m_ctrlMode; // mode they were in before they hit ctrl - EditModes m_knifeMode; // mode they where in before entering knife mode + EditMode m_editMode; + EditMode m_ctrlMode; // mode they were in before they hit ctrl + EditMode m_knifeMode; // mode they where in before entering knife mode bool m_mouseDownRight; //true if right click is being held down diff --git a/include/PlayHandle.h b/include/PlayHandle.h index c64931ac051..8f5d771ed7b 100644 --- a/include/PlayHandle.h +++ b/include/PlayHandle.h @@ -30,7 +30,7 @@ #include "lmms_export.h" - +#include "Flags.h" #include "ThreadableJob.h" #include "lmms_basics.h" @@ -45,19 +45,16 @@ class AudioPort; class LMMS_EXPORT PlayHandle : public ThreadableJob { public: - enum Types + enum class Type { - TypeNotePlayHandle = 0x01, - TypeInstrumentPlayHandle = 0x02, - TypeSamplePlayHandle = 0x04, - TypePresetPreviewHandle = 0x08 + NotePlayHandle = 0x01, + InstrumentPlayHandle = 0x02, + SamplePlayHandle = 0x04, + PresetPreviewHandle = 0x08 } ; - using Type = Types; + using Types = Flags; - enum - { - MaxNumber = 1024 - } ; + constexpr static std::size_t MaxNumber = 1024; PlayHandle( const Type type, f_cnt_t offset = 0 ); @@ -164,6 +161,8 @@ class LMMS_EXPORT PlayHandle : public ThreadableJob using PlayHandleList = QList; using ConstPlayHandleList = QList; +LMMS_DECLARE_OPERATORS_FOR_FLAGS(PlayHandle::Type) + } // namespace lmms #endif // LMMS_PLAY_HANDLE_H diff --git a/include/Plugin.h b/include/Plugin.h index b1982f98c44..439dd95ad16 100644 --- a/include/Plugin.h +++ b/include/Plugin.h @@ -74,7 +74,7 @@ class LMMS_EXPORT Plugin : public Model, public JournallingObject MM_OPERATORS Q_OBJECT public: - enum PluginTypes + enum class Type { Instrument, // instrument being used in channel-track Effect, // effect-plugin for effect-board @@ -97,7 +97,7 @@ class LMMS_EXPORT Plugin : public Model, public JournallingObject const char * description; const char * author; int version; - PluginTypes type; + Type type; const PixmapLoader * logo; const char * supportedFileTypes; //!< csv list of extensions @@ -181,7 +181,7 @@ class LMMS_EXPORT Plugin : public Model, public JournallingObject using KeyList = QList; - SubPluginFeatures( Plugin::PluginTypes type ) : + SubPluginFeatures( Plugin::Type type ) : m_type( type ) { } @@ -227,7 +227,7 @@ class LMMS_EXPORT Plugin : public Model, public JournallingObject } protected: - const Plugin::PluginTypes m_type; + const Plugin::Type m_type; } ; SubPluginFeatures * subPluginFeatures; @@ -250,7 +250,7 @@ class LMMS_EXPORT Plugin : public Model, public JournallingObject const PixmapLoader *logo() const; //! Return plugin type - inline PluginTypes type() const + inline Type type() const { return m_descriptor->type; } diff --git a/include/PluginFactory.h b/include/PluginFactory.h index 10c76e4ee20..7221f2b097b 100644 --- a/include/PluginFactory.h +++ b/include/PluginFactory.h @@ -55,7 +55,7 @@ class LMMS_EXPORT PluginFactory bool isNull() const {return ! library;} }; using PluginInfoList = QList; - using DescriptorMap = QMultiMap; + using DescriptorMap = QMultiMap; PluginFactory(); ~PluginFactory() = default; @@ -68,7 +68,7 @@ class LMMS_EXPORT PluginFactory /// Returns a list of all found plugins' descriptors. Plugin::DescriptorList descriptors() const; - Plugin::DescriptorList descriptors(Plugin::PluginTypes type) const; + Plugin::DescriptorList descriptors(Plugin::Type type) const; struct PluginInfoAndKey { diff --git a/include/PluginIssue.h b/include/PluginIssue.h index 87e895113bc..01a4268ecc9 100644 --- a/include/PluginIssue.h +++ b/include/PluginIssue.h @@ -33,32 +33,32 @@ namespace lmms //! Types of issues that can cause LMMS to not load a plugin //! LMMS Plugins should use this to indicate errors -enum PluginIssueType +enum class PluginIssueType { // port flow & type - unknownPortFlow, - unknownPortType, + UnknownPortFlow, + UnknownPortType, // channel count - tooManyInputChannels, - tooManyOutputChannels, - tooManyMidiInputChannels, - tooManyMidiOutputChannels, - noOutputChannel, + TooManyInputChannels, + TooManyOutputChannels, + TooManyMidiInputChannels, + TooManyMidiOutputChannels, + NoOutputChannel, // port metadata - portHasNoDef, - portHasNoMin, - portHasNoMax, - minGreaterMax, - defaultValueNotInRange, - logScaleMinMissing, - logScaleMaxMissing, - logScaleMinMaxDifferentSigns, + PortHasNoDef, + PortHasNoMin, + PortHasNoMax, + MinGreaterMax, + DefaultValueNotInRange, + LogScaleMinMissing, + LogScaleMaxMissing, + LogScaleMinMaxDifferentSigns, // features - featureNotSupported, //!< plugin requires functionality LMMS can't offer + FeatureNotSupported, //!< plugin requires functionality LMMS can't offer // misc - badPortType, //!< port type not supported - blacklisted, - noIssue + BadPortType, //!< port type not supported + Blacklisted, + NoIssue }; //! Issue type bundled with informational string diff --git a/include/ProjectJournal.h b/include/ProjectJournal.h index a4a26307846..841bbf09435 100644 --- a/include/ProjectJournal.h +++ b/include/ProjectJournal.h @@ -104,7 +104,7 @@ class ProjectJournal struct CheckPoint { - CheckPoint( jo_id_t initID = 0, const DataFile& initData = DataFile( DataFile::JournalData ) ) : + CheckPoint( jo_id_t initID = 0, const DataFile& initData = DataFile( DataFile::Type::JournalData ) ) : joID( initID ), data( initData ) { diff --git a/include/ProjectRenderer.h b/include/ProjectRenderer.h index 95a1f53ed29..14c584a2eb2 100644 --- a/include/ProjectRenderer.h +++ b/include/ProjectRenderer.h @@ -40,20 +40,21 @@ class LMMS_EXPORT ProjectRenderer : public QThread { Q_OBJECT public: - enum ExportFileFormats: int + enum class ExportFileFormat : int { - WaveFile, - FlacFile, - OggFile, - MP3File, - NumFileFormats + Wave, + Flac, + Ogg, + MP3, + Count } ; + constexpr static auto NumFileFormats = static_cast(ExportFileFormat::Count); struct FileEncodeDevice { bool isAvailable() const { return m_getDevInst != nullptr; } - ExportFileFormats m_fileFormat; + ExportFileFormat m_fileFormat; const char * m_description; const char * m_extension; AudioFileDeviceInstantiaton m_getDevInst; @@ -62,7 +63,7 @@ class LMMS_EXPORT ProjectRenderer : public QThread ProjectRenderer( const AudioEngine::qualitySettings & _qs, const OutputSettings & _os, - ExportFileFormats _file_format, + ExportFileFormat _file_format, const QString & _out_file ); ~ProjectRenderer() override = default; @@ -71,10 +72,10 @@ class LMMS_EXPORT ProjectRenderer : public QThread return m_fileDev != nullptr; } - static ExportFileFormats getFileFormatFromExtension( + static ExportFileFormat getFileFormatFromExtension( const QString & _ext ); - static QString getFileExtensionFromFormat( ExportFileFormats fmt ); + static QString getFileExtensionFromFormat( ExportFileFormat fmt ); static const std::array fileEncodeDevices; diff --git a/include/ProjectVersion.h b/include/ProjectVersion.h index d9a459a433a..20b32d1c96f 100644 --- a/include/ProjectVersion.h +++ b/include/ProjectVersion.h @@ -42,11 +42,11 @@ namespace lmms class ProjectVersion { public: - enum CompareType : int { None = 0, Major=1, Minor=2, Release=3, Stage=4, Build=5, All = std::numeric_limits::max() }; + enum class CompareType : int { None = 0, Major=1, Minor=2, Release=3, Stage=4, Build=5, All = std::numeric_limits::max() }; - ProjectVersion(QString version, CompareType c = All); - ProjectVersion(const char * version, CompareType c = All); + ProjectVersion(QString version, CompareType c = CompareType::All); + ProjectVersion(const char * version, CompareType c = CompareType::All); const QString& getVersion() const { return m_version; } int getMajor() const { return m_major; } diff --git a/include/RenderManager.h b/include/RenderManager.h index 43f696f146a..6865227789e 100644 --- a/include/RenderManager.h +++ b/include/RenderManager.h @@ -43,7 +43,7 @@ class RenderManager : public QObject RenderManager( const AudioEngine::qualitySettings & qualitySettings, const OutputSettings & outputSettings, - ProjectRenderer::ExportFileFormats fmt, + ProjectRenderer::ExportFileFormat fmt, QString outputPath); ~RenderManager() override; @@ -73,7 +73,7 @@ private slots: const AudioEngine::qualitySettings m_qualitySettings; const AudioEngine::qualitySettings m_oldQualitySettings; const OutputSettings m_outputSettings; - ProjectRenderer::ExportFileFormats m_format; + ProjectRenderer::ExportFileFormat m_format; QString m_outputPath; std::unique_ptr m_activeRenderer; diff --git a/include/SampleBuffer.h b/include/SampleBuffer.h index e2ed24b8190..3d1013baa01 100644 --- a/include/SampleBuffer.h +++ b/include/SampleBuffer.h @@ -57,10 +57,10 @@ class LMMS_EXPORT SampleBuffer : public QObject, public sharedObject Q_OBJECT MM_OPERATORS public: - enum LoopMode { - LoopOff = 0, - LoopOn, - LoopPingPong + enum class LoopMode { + Off = 0, + On, + PingPong }; class LMMS_EXPORT handleState { @@ -125,7 +125,7 @@ class LMMS_EXPORT SampleBuffer : public QObject, public sharedObject handleState * state, const fpp_t frames, const float freq, - const LoopMode loopMode = LoopOff + const LoopMode loopMode = LoopMode::Off ); void visualize( diff --git a/include/SetupDialog.h b/include/SetupDialog.h index 27a4ce4f9f8..de4cdd9ddbd 100644 --- a/include/SetupDialog.h +++ b/include/SetupDialog.h @@ -53,7 +53,7 @@ class SetupDialog : public QDialog Q_OBJECT public: - enum ConfigTabs + enum class ConfigTab { GeneralSettings, PerformanceSettings, @@ -62,7 +62,7 @@ class SetupDialog : public QDialog PathsSettings }; - SetupDialog(ConfigTabs tab_to_open = GeneralSettings); + SetupDialog(ConfigTab tab_to_open = ConfigTab::GeneralSettings); ~SetupDialog() override; diff --git a/include/Song.h b/include/Song.h index c13fe0e9604..02714d8ac6b 100644 --- a/include/Song.h +++ b/include/Song.h @@ -68,15 +68,16 @@ class LMMS_EXPORT Song : public TrackContainer mapPropertyFromModel( int,masterPitch,setMasterPitch,m_masterPitchModel ); mapPropertyFromModel( int,masterVolume,setMasterVolume, m_masterVolumeModel ); public: - enum PlayModes - { - Mode_None, - Mode_PlaySong, - Mode_PlayPattern, - Mode_PlayMidiClip, - Mode_PlayAutomationClip, - Mode_Count + enum class PlayMode + { + None, + Song, + Pattern, + MidiClip, + AutomationClip, + Count } ; + constexpr static auto PlayModeCount = static_cast(PlayMode::Count); struct SaveOptions { /** @@ -141,36 +142,34 @@ class LMMS_EXPORT Song : public TrackContainer inline int getMilliseconds() const { - return m_elapsedMilliSeconds[m_playMode]; + return getMilliseconds(m_playMode); } - inline int getMilliseconds(PlayModes playMode) const + inline int getMilliseconds(PlayMode playMode) const { - return m_elapsedMilliSeconds[playMode]; + return m_elapsedMilliSeconds[static_cast(playMode)]; } inline void setToTime(TimePos const & pos) { - m_elapsedMilliSeconds[m_playMode] = pos.getTimeInMilliseconds(getTempo()); - m_playPos[m_playMode].setTicks(pos.getTicks()); + setToTime(pos, m_playMode); } - inline void setToTime(TimePos const & pos, PlayModes playMode) + inline void setToTime(TimePos const & pos, PlayMode playMode) { - m_elapsedMilliSeconds[playMode] = pos.getTimeInMilliseconds(getTempo()); - m_playPos[playMode].setTicks(pos.getTicks()); + m_elapsedMilliSeconds[static_cast(playMode)] = pos.getTimeInMilliseconds(getTempo()); + getPlayPos(playMode).setTicks(pos.getTicks()); } inline void setToTimeByTicks(tick_t ticks) { - m_elapsedMilliSeconds[m_playMode] = TimePos::ticksToMilliseconds(ticks, getTempo()); - m_playPos[m_playMode].setTicks(ticks); + setToTimeByTicks(ticks, m_playMode); } - inline void setToTimeByTicks(tick_t ticks, PlayModes playMode) + inline void setToTimeByTicks(tick_t ticks, PlayMode playMode) { - m_elapsedMilliSeconds[playMode] = TimePos::ticksToMilliseconds(ticks, getTempo()); - m_playPos[playMode].setTicks(ticks); + m_elapsedMilliSeconds[static_cast(playMode)] = TimePos::ticksToMilliseconds(ticks, getTempo()); + getPlayPos(playMode).setTicks(ticks); } inline int getBars() const @@ -253,18 +252,18 @@ class LMMS_EXPORT Song : public TrackContainer m_renderBetweenMarkers = renderBetweenMarkers; } - inline PlayModes playMode() const + inline PlayMode playMode() const { return m_playMode; } - inline PlayPos & getPlayPos( PlayModes pm ) + inline PlayPos & getPlayPos( PlayMode pm ) { - return m_playPos[pm]; + return m_playPos[static_cast(pm)]; } - inline const PlayPos & getPlayPos( PlayModes pm ) const + inline const PlayPos & getPlayPos( PlayMode pm ) const { - return m_playPos[pm]; + return m_playPos[static_cast(pm)]; } inline PlayPos & getPlayPos() { @@ -417,21 +416,21 @@ private slots: inline bar_t currentBar() const { - return m_playPos[m_playMode].getBar(); + return getPlayPos(m_playMode).getBar(); } inline tick_t currentTick() const { - return m_playPos[m_playMode].getTicks(); + return getPlayPos(m_playMode).getTicks(); } inline f_cnt_t currentFrame() const { - return m_playPos[m_playMode].getTicks() * Engine::framesPerTick() + - m_playPos[m_playMode].currentFrame(); + return getPlayPos(m_playMode).getTicks() * Engine::framesPerTick() + + getPlayPos(m_playMode).currentFrame(); } - void setPlayPos( tick_t ticks, PlayModes playMode ); + void setPlayPos( tick_t ticks, PlayMode playMode ); void saveControllerStates( QDomDocument & doc, QDomElement & element ); void restoreControllerStates( const QDomElement & element ); @@ -482,14 +481,14 @@ private slots: QHash m_errors; - PlayModes m_playMode; - PlayPos m_playPos[Mode_Count]; + PlayMode m_playMode; + PlayPos m_playPos[PlayModeCount]; bar_t m_length; const MidiClip* m_midiClipToPlay; bool m_loopMidiClip; - double m_elapsedMilliSeconds[Mode_Count]; + double m_elapsedMilliSeconds[PlayModeCount]; tick_t m_elapsedTicks; bar_t m_elapsedBars; diff --git a/include/SongEditor.h b/include/SongEditor.h index 867ff0f14d8..ee9e83f44c3 100644 --- a/include/SongEditor.h +++ b/include/SongEditor.h @@ -57,11 +57,11 @@ class SongEditor : public TrackContainerView { Q_OBJECT public: - enum EditMode + enum class EditMode { - DrawMode, - KnifeMode, - SelectMode + Draw, + Knife, + Select }; SongEditor( Song * song ); diff --git a/include/TempoSyncKnob.h b/include/TempoSyncKnob.h index a8e2eeb7e62..b86320d13d3 100644 --- a/include/TempoSyncKnob.h +++ b/include/TempoSyncKnob.h @@ -41,7 +41,7 @@ class LMMS_EXPORT TempoSyncKnob : public Knob { Q_OBJECT public: - TempoSyncKnob( knobTypes knobNum, QWidget* parent = nullptr, const QString& name = QString() ); + TempoSyncKnob( KnobType knobNum, QWidget* parent = nullptr, const QString& name = QString() ); ~TempoSyncKnob() override; const QString & syncDescription(); diff --git a/include/TempoSyncKnobModel.h b/include/TempoSyncKnobModel.h index 59d7b5dc8e7..5cd2db067fa 100644 --- a/include/TempoSyncKnobModel.h +++ b/include/TempoSyncKnobModel.h @@ -46,17 +46,17 @@ class LMMS_EXPORT TempoSyncKnobModel : public FloatModel Q_OBJECT MODEL_IS_VISITABLE public: - enum TempoSyncMode + enum class SyncMode { - SyncNone, - SyncDoubleWholeNote, - SyncWholeNote, - SyncHalfNote, - SyncQuarterNote, - SyncEighthNote, - SyncSixteenthNote, - SyncThirtysecondNote, - SyncCustom + None, + DoubleWholeNote, + WholeNote, + HalfNote, + QuarterNote, + EighthNote, + SixteenthNote, + ThirtysecondNote, + Custom } ; TempoSyncKnobModel( const float _val, const float _min, @@ -68,12 +68,12 @@ class LMMS_EXPORT TempoSyncKnobModel : public FloatModel void saveSettings( QDomDocument & _doc, QDomElement & _this, const QString& name ) override; void loadSettings( const QDomElement & _this, const QString& name ) override; - TempoSyncMode syncMode() const + SyncMode syncMode() const { return m_tempoSyncMode; } - void setSyncMode( TempoSyncMode _new_mode ); + void setSyncMode( SyncMode _new_mode ); float scale() const { @@ -83,16 +83,16 @@ class LMMS_EXPORT TempoSyncKnobModel : public FloatModel void setScale( float _new_scale ); signals: - void syncModeChanged( lmms::TempoSyncKnobModel::TempoSyncMode _new_mode ); + void syncModeChanged( lmms::TempoSyncKnobModel::SyncMode _new_mode ); void scaleChanged( float _new_scale ); public slots: inline void disableSync() { - setTempoSync( SyncNone ); + setTempoSync( SyncMode::None ); } - void setTempoSync( int _note_type ); + void setTempoSync( SyncMode _note_type ); void setTempoSync( QAction * _item ); @@ -102,8 +102,8 @@ protected slots: private: - TempoSyncMode m_tempoSyncMode; - TempoSyncMode m_tempoLastSyncMode; + SyncMode m_tempoSyncMode; + SyncMode m_tempoLastSyncMode; float m_scale; MeterModel m_custom; diff --git a/include/TimeDisplayWidget.h b/include/TimeDisplayWidget.h index 9e74b57aa4c..287b4ee7e75 100644 --- a/include/TimeDisplayWidget.h +++ b/include/TimeDisplayWidget.h @@ -51,13 +51,11 @@ private slots: private: - enum DisplayModes + enum class DisplayMode { MinutesSeconds, - BarsTicks, - DisplayModeCount + BarsTicks }; - using DisplayMode = DisplayModes; void setDisplayMode( DisplayMode displayMode ); diff --git a/include/TimeLineWidget.h b/include/TimeLineWidget.h index 061a31081ad..2e4ba6a97a4 100644 --- a/include/TimeLineWidget.h +++ b/include/TimeLineWidget.h @@ -55,19 +55,19 @@ class TimeLineWidget : public QWidget, public JournallingObject Q_PROPERTY( QColor activeLoopInnerColor READ getActiveLoopInnerColor WRITE setActiveLoopInnerColor ) Q_PROPERTY( int loopRectangleVerticalPadding READ getLoopRectangleVerticalPadding WRITE setLoopRectangleVerticalPadding ) - enum AutoScrollStates + enum class AutoScrollState { - AutoScrollEnabled, - AutoScrollDisabled + Enabled, + Disabled } ; - enum LoopPointStates + enum class LoopPointState { - LoopPointsDisabled, - LoopPointsEnabled + Disabled, + Enabled } ; - enum BehaviourAtStopStates + enum class BehaviourAtStopState { BackToZero, BackToStart, @@ -76,7 +76,7 @@ class TimeLineWidget : public QWidget, public JournallingObject TimeLineWidget(int xoff, int yoff, float ppb, Song::PlayPos & pos, - const TimePos & begin, Song::PlayModes mode, QWidget * parent); + const TimePos & begin, Song::PlayMode mode, QWidget * parent); ~TimeLineWidget() override; inline QColor const & getBarLineColor() const { return m_barLineColor; } @@ -111,12 +111,12 @@ class TimeLineWidget : public QWidget, public JournallingObject return( m_pos ); } - AutoScrollStates autoScroll() const + AutoScrollState autoScroll() const { return m_autoScroll; } - BehaviourAtStopStates behaviourAtStop() const + BehaviourAtStopState behaviourAtStop() const { return m_behaviourAtStop; } @@ -128,7 +128,7 @@ class TimeLineWidget : public QWidget, public JournallingObject bool loopPointsEnabled() const { - return m_loopPoints == LoopPointsEnabled; + return m_loopPoints == LoopPointState::Enabled; } inline const TimePos & loopBegin() const @@ -220,9 +220,9 @@ public slots: QColor m_barLineColor; QColor m_barNumberColor; - AutoScrollStates m_autoScroll; - LoopPointStates m_loopPoints; - BehaviourAtStopStates m_behaviourAtStop; + AutoScrollState m_autoScroll; + LoopPointState m_loopPoints; + BehaviourAtStopState m_behaviourAtStop; bool m_changedPosition; @@ -232,7 +232,7 @@ public slots: float m_snapSize; Song::PlayPos & m_pos; const TimePos & m_begin; - const Song::PlayModes m_mode; + const Song::PlayMode m_mode; TimePos m_loopPos[2]; TimePos m_savedPos; @@ -242,7 +242,7 @@ public slots: int m_initalXSelect; - enum actions + enum class Action { NoAction, MovePositionMarker, diff --git a/include/Track.h b/include/Track.h index 000d564f7a9..33d1ad23317 100644 --- a/include/Track.h +++ b/include/Track.h @@ -72,29 +72,29 @@ class LMMS_EXPORT Track : public Model, public JournallingObject public: using clipVector = std::vector; - enum TrackTypes + enum class Type { - InstrumentTrack, - PatternTrack, - SampleTrack, - EventTrack, - VideoTrack, - AutomationTrack, - HiddenAutomationTrack, - NumTrackTypes + Instrument, + Pattern, + Sample, + Event, + Video, + Automation, + HiddenAutomation, + Count } ; - Track( TrackTypes type, TrackContainer * tc ); + Track( Type type, TrackContainer * tc ); ~Track() override; - static Track * create( TrackTypes tt, TrackContainer * tc ); + static Track * create( Type tt, TrackContainer * tc ); static Track * create( const QDomElement & element, TrackContainer * tc ); Track * clone(); // pure virtual functions - TrackTypes type() const + Type type() const { return m_type; } @@ -224,7 +224,7 @@ public slots: private: TrackContainer* m_trackContainer; - TrackTypes m_type; + Type m_type; QString m_name; int m_height; diff --git a/include/TrackContainer.h b/include/TrackContainer.h index 8739a9e9f01..01e94df5435 100644 --- a/include/TrackContainer.h +++ b/include/TrackContainer.h @@ -50,10 +50,10 @@ class LMMS_EXPORT TrackContainer : public Model, public JournallingObject Q_OBJECT public: using TrackList = std::vector; - enum TrackContainerTypes + enum class Type { - PatternContainer, - SongContainer + Pattern, + Song } ; TrackContainer(); @@ -63,7 +63,7 @@ class LMMS_EXPORT TrackContainer : public Model, public JournallingObject void loadSettings( const QDomElement & _this ) override; - int countTracks( Track::TrackTypes _tt = Track::NumTrackTypes ) const; + int countTracks( Track::Type _tt = Track::Type::Count ) const; void addTrack( Track * _track ); @@ -85,12 +85,12 @@ class LMMS_EXPORT TrackContainer : public Model, public JournallingObject return "trackcontainer"; } - inline void setType( TrackContainerTypes newType ) + inline void setType( Type newType ) { m_TrackContainerType = newType; } - inline TrackContainerTypes type() const + inline Type type() const { return m_TrackContainerType; } @@ -108,7 +108,7 @@ class LMMS_EXPORT TrackContainer : public Model, public JournallingObject private: TrackList m_tracks; - TrackContainerTypes m_TrackContainerType; + Type m_TrackContainerType; friend class gui::TrackContainerView; diff --git a/include/TrackContainerView.h b/include/TrackContainerView.h index d53291c33d7..82d6f993b08 100644 --- a/include/TrackContainerView.h +++ b/include/TrackContainerView.h @@ -174,12 +174,6 @@ public slots: private: - enum Actions - { - AddTrack, - RemoveTrack - } ; - class scrollArea : public QScrollArea { public: diff --git a/include/TrackContentWidget.h b/include/TrackContentWidget.h index 1a3e14a0e4d..7cf2363231d 100644 --- a/include/TrackContentWidget.h +++ b/include/TrackContentWidget.h @@ -95,7 +95,7 @@ public slots: void changePosition( const lmms::TimePos & newPos = TimePos( -1 ) ); protected: - enum ContextMenuAction + enum class ContextMenuAction { Paste }; diff --git a/include/TrackView.h b/include/TrackView.h index efa4f4a0a53..763705599c5 100644 --- a/include/TrackView.h +++ b/include/TrackView.h @@ -95,7 +95,7 @@ class TrackView : public QWidget, public ModelView, public JournallingObject bool isMovingTrack() const { - return m_action == MoveTrack; + return m_action == Action::Move; } virtual void update(); @@ -139,11 +139,11 @@ public slots: private: - enum Actions + enum class Action { - NoAction, - MoveTrack, - ResizeTrack + None, + Move, + Resize } ; Track * m_track; @@ -153,7 +153,7 @@ public slots: QWidget m_trackSettingsWidget; TrackContentWidget m_trackContentWidget; - Actions m_action; + Action m_action; virtual FadeButton * getActivityIndicator() { diff --git a/include/fft_helpers.h b/include/fft_helpers.h index 2d2a8d19e1e..cd4e5f88db4 100644 --- a/include/fft_helpers.h +++ b/include/fft_helpers.h @@ -44,12 +44,12 @@ const unsigned int FFT_BUFFER_SIZE = 2048; const std::vector FFT_BLOCK_SIZES = {256, 512, 1024, 2048, 4096, 8192, 16384}; // List of FFT window functions supported by precomputeWindow() -enum FFT_WINDOWS +enum class FFTWindow { - RECTANGULAR = 0, - BLACKMAN_HARRIS, - HAMMING, - HANNING + Rectangular = 0, + BlackmanHarris, + Hamming, + Hanning }; @@ -83,7 +83,7 @@ int LMMS_EXPORT notEmpty(const std::vector &spectrum); * * @return -1 on error */ -int LMMS_EXPORT precomputeWindow(float *window, unsigned int length, FFT_WINDOWS type, bool normalized = true); +int LMMS_EXPORT precomputeWindow(float *window, unsigned int length, FFTWindow type, bool normalized = true); /** Compute absolute values of complex_buffer, save to absspec_buffer. diff --git a/include/lmms_constants.h b/include/lmms_constants.h index e6fce9f4d16..c6452d6c619 100644 --- a/include/lmms_constants.h +++ b/include/lmms_constants.h @@ -62,13 +62,13 @@ constexpr unsigned int MaxKeymapCount = 10; //!< number of keyboard mappings per constexpr int LOWEST_LOG_FREQ = 5; // Full range is defined by LOWEST_LOG_FREQ and current sample rate. -enum FREQUENCY_RANGES +enum class FrequencyRange { - FRANGE_FULL = 0, - FRANGE_AUDIBLE, - FRANGE_BASS, - FRANGE_MIDS, - FRANGE_HIGH + Full = 0, + Audible, + Bass, + Mids, + High }; constexpr int FRANGE_AUDIBLE_START = 20; @@ -83,12 +83,12 @@ constexpr int FRANGE_HIGH_END = 20000; // Amplitude ranges (in dBFS). // Reference: full scale sine wave (-1.0 to 1.0) is 0 dB. // Doubling or halving the amplitude produces 3 dB difference. -enum AMPLITUDE_RANGES +enum class AmplitudeRange { - ARANGE_EXTENDED = 0, - ARANGE_AUDIBLE, - ARANGE_LOUD, - ARANGE_SILENT + Extended = 0, + Audible, + Loud, + Silent }; constexpr int ARANGE_EXTENDED_START = -80; diff --git a/plugins/Amplifier/Amplifier.cpp b/plugins/Amplifier/Amplifier.cpp index 9344807c49c..7de8fb18088 100644 --- a/plugins/Amplifier/Amplifier.cpp +++ b/plugins/Amplifier/Amplifier.cpp @@ -41,7 +41,7 @@ Plugin::Descriptor PLUGIN_EXPORT amplifier_plugin_descriptor = QT_TRANSLATE_NOOP( "PluginBrowser", "A native amplifier plugin" ), "Vesa Kivimäki ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, nullptr, diff --git a/plugins/Amplifier/AmplifierControlDialog.cpp b/plugins/Amplifier/AmplifierControlDialog.cpp index 226130fcd3d..ed9e98f29b4 100644 --- a/plugins/Amplifier/AmplifierControlDialog.cpp +++ b/plugins/Amplifier/AmplifierControlDialog.cpp @@ -43,27 +43,27 @@ AmplifierControlDialog::AmplifierControlDialog( AmplifierControls* controls ) : setPalette( pal ); setFixedSize( 100, 110 ); - auto volumeKnob = new Knob(knobBright_26, this); + auto volumeKnob = new Knob(KnobType::Bright26, this); volumeKnob -> move( 16, 10 ); volumeKnob -> setVolumeKnob( true ); volumeKnob->setModel( &controls->m_volumeModel ); volumeKnob->setLabel( tr( "VOL" ) ); volumeKnob->setHintText( tr( "Volume:" ) , "%" ); - auto panKnob = new Knob(knobBright_26, this); + auto panKnob = new Knob(KnobType::Bright26, this); panKnob -> move( 57, 10 ); panKnob->setModel( &controls->m_panModel ); panKnob->setLabel( tr( "PAN" ) ); panKnob->setHintText( tr( "Panning:" ) , "" ); - auto leftKnob = new Knob(knobBright_26, this); + auto leftKnob = new Knob(KnobType::Bright26, this); leftKnob -> move( 16, 65 ); leftKnob -> setVolumeKnob( true ); leftKnob->setModel( &controls->m_leftModel ); leftKnob->setLabel( tr( "LEFT" ) ); leftKnob->setHintText( tr( "Left gain:" ) , "%" ); - auto rightKnob = new Knob(knobBright_26, this); + auto rightKnob = new Knob(KnobType::Bright26, this); rightKnob -> move( 57, 65 ); rightKnob -> setVolumeKnob( true ); rightKnob->setModel( &controls->m_rightModel ); diff --git a/plugins/AudioFileProcessor/AudioFileProcessor.cpp b/plugins/AudioFileProcessor/AudioFileProcessor.cpp index 2243683ce3a..a941e773f25 100644 --- a/plugins/AudioFileProcessor/AudioFileProcessor.cpp +++ b/plugins/AudioFileProcessor/AudioFileProcessor.cpp @@ -64,7 +64,7 @@ Plugin::Descriptor PLUGIN_EXPORT audiofileprocessor_plugin_descriptor = "instrument-track" ), "Tobias Doerffel ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), "wav,ogg,ds,spx,au,voc,aif,aiff,flac,raw", nullptr, @@ -516,7 +516,7 @@ AudioFileProcessorView::AudioFileProcessorView( Instrument * _instrument, m_stutterButton->setToolTip( tr( "Continue sample playback across notes" ) ); - m_ampKnob = new Knob( knobBright_26, this ); + m_ampKnob = new Knob( KnobType::Bright26, this ); m_ampKnob->setVolumeKnob( true ); m_ampKnob->move( 5, 108 ); m_ampKnob->setHintText( tr( "Amplify:" ), "%" ); @@ -567,7 +567,7 @@ void AudioFileProcessorView::dragEnterEvent( QDragEnterEvent * _dee ) QString txt = _dee->mimeData()->data( mimeType( MimeType::StringPair ) ); if( txt.section( ':', 0, 0 ) == QString( "clip_%1" ).arg( - Track::SampleTrack ) ) + static_cast(Track::Type::Sample) ) ) { _dee->acceptProposedAction(); } @@ -619,7 +619,7 @@ void AudioFileProcessorView::dropEvent( QDropEvent * _de ) newWaveView(); return; } - else if( type == QString( "clip_%1" ).arg( Track::SampleTrack ) ) + else if( type == QString( "clip_%1" ).arg( static_cast(Track::Type::Sample) ) ) { DataFile dataFile( value.toUtf8() ); castModel()->setAudioFile( dataFile.content().firstChild().toElement().attribute( "src" ) ); @@ -787,9 +787,9 @@ void AudioFileProcessorWaveView::mousePressEvent( QMouseEvent * _me ) const int end_dist = qAbs( m_endFrameX - x ); const int loop_dist = qAbs( m_loopFrameX - x ); - draggingType dt = sample_loop; int md = loop_dist; - if( start_dist < loop_dist ) { dt = sample_start; md = start_dist; } - else if( end_dist < loop_dist ) { dt = sample_end; md = end_dist; } + DraggingType dt = DraggingType::SampleLoop; int md = loop_dist; + if( start_dist < loop_dist ) { dt = DraggingType::SampleStart; md = start_dist; } + else if( end_dist < loop_dist ) { dt = DraggingType::SampleEnd; md = end_dist; } if( md < 4 ) { @@ -797,7 +797,7 @@ void AudioFileProcessorWaveView::mousePressEvent( QMouseEvent * _me ) } else { - m_draggingType = wave; + m_draggingType = DraggingType::Wave; updateCursor(_me); } } @@ -808,7 +808,7 @@ void AudioFileProcessorWaveView::mousePressEvent( QMouseEvent * _me ) void AudioFileProcessorWaveView::mouseReleaseEvent( QMouseEvent * _me ) { m_isDragging = false; - if( m_draggingType == wave ) + if( m_draggingType == DraggingType::Wave ) { updateCursor(_me); } @@ -828,16 +828,16 @@ void AudioFileProcessorWaveView::mouseMoveEvent( QMouseEvent * _me ) const int step = _me->x() - m_draggingLastPoint.x(); switch( m_draggingType ) { - case sample_start: - slideSamplePointByPx( start, step ); + case DraggingType::SampleStart: + slideSamplePointByPx( Point::Start, step ); break; - case sample_end: - slideSamplePointByPx( end, step ); + case DraggingType::SampleEnd: + slideSamplePointByPx( Point::End, step ); break; - case sample_loop: - slideSamplePointByPx( loop, step ); + case DraggingType::SampleLoop: + slideSamplePointByPx( Point::Loop, step ); break; - case wave: + case DraggingType::Wave: default: if( qAbs( _me->y() - m_draggingLastPoint.y() ) < 2 * qAbs( _me->x() - m_draggingLastPoint.x() ) ) @@ -983,7 +983,7 @@ void AudioFileProcessorWaveView::updateGraph() if( m_to == 1 ) { m_to = m_sampleBuffer.frames() * 0.7; - slideSamplePointToFrames( end, m_to * 0.7 ); + slideSamplePointToFrames( Point::End, m_to * 0.7 ); } if( m_from > m_sampleBuffer.startFrame() ) @@ -1110,7 +1110,7 @@ void AudioFileProcessorWaveView::setKnobs( knob * _start, knob * _end, knob * _l -void AudioFileProcessorWaveView::slideSamplePointByPx( knobType _point, int _px ) +void AudioFileProcessorWaveView::slideSamplePointByPx( Point _point, int _px ) { slideSamplePointByFrames( _point, @@ -1121,18 +1121,18 @@ void AudioFileProcessorWaveView::slideSamplePointByPx( knobType _point, int _px -void AudioFileProcessorWaveView::slideSamplePointByFrames( knobType _point, f_cnt_t _frames, bool _slide_to ) +void AudioFileProcessorWaveView::slideSamplePointByFrames( Point _point, f_cnt_t _frames, bool _slide_to ) { knob * a_knob = m_startKnob; switch( _point ) { - case end: + case Point::End: a_knob = m_endKnob; break; - case loop: + case Point::Loop: a_knob = m_loopKnob; break; - case start: + case Point::Start: break; } if( a_knob == nullptr ) @@ -1196,7 +1196,7 @@ void AudioFileProcessorWaveView::reverse() void AudioFileProcessorWaveView::updateCursor( QMouseEvent * _me ) { - bool const waveIsDragged = m_isDragging && (m_draggingType == wave); + bool const waveIsDragged = m_isDragging && (m_draggingType == DraggingType::Wave); bool const pointerCloseToStartEndOrLoop = (_me != nullptr ) && ( isCloseTo( _me->x(), m_startFrameX ) || isCloseTo( _me->x(), m_endFrameX ) || diff --git a/plugins/AudioFileProcessor/AudioFileProcessor.h b/plugins/AudioFileProcessor/AudioFileProcessor.h index 6c696784a41..5fed10862ff 100644 --- a/plugins/AudioFileProcessor/AudioFileProcessor.h +++ b/plugins/AudioFileProcessor/AudioFileProcessor.h @@ -177,11 +177,11 @@ class AudioFileProcessorWaveView : public QWidget public: - enum knobType + enum class Point { - start, - end, - loop + Start, + End, + Loop } ; class knob : public Knob @@ -192,7 +192,7 @@ class AudioFileProcessorWaveView : public QWidget public: knob( QWidget * _parent ) : - Knob( knobBright_26, _parent ), + Knob( KnobType::Bright26, _parent ), m_waveView( 0 ), m_relatedKnob( 0 ) { @@ -239,12 +239,12 @@ public slots: private: static const int s_padding = 2; - enum draggingType + enum class DraggingType { - wave, - sample_start, - sample_end, - sample_loop + Wave, + SampleStart, + SampleEnd, + SampleLoop } ; SampleBuffer& m_sampleBuffer; @@ -262,7 +262,7 @@ public slots: f_cnt_t m_loopFrameX; bool m_isDragging; QPoint m_draggingLastPoint; - draggingType m_draggingType; + DraggingType m_draggingType; bool m_reversed; f_cnt_t m_framesPlayed; bool m_animation; @@ -276,11 +276,11 @@ public slots: private: void zoom( const bool _out = false ); void slide( int _px ); - void slideSamplePointByPx( knobType _point, int _px ); - void slideSamplePointByFrames( knobType _point, f_cnt_t _frames, bool _slide_to = false ); + void slideSamplePointByPx( Point _point, int _px ); + void slideSamplePointByFrames( Point _point, f_cnt_t _frames, bool _slide_to = false ); void slideSampleByFrames( f_cnt_t _frames ); - void slideSamplePointToFrames( knobType _point, f_cnt_t _frames ) + void slideSamplePointToFrames( Point _point, f_cnt_t _frames ) { slideSamplePointByFrames( _point, _frames, true ); } diff --git a/plugins/BassBooster/BassBooster.cpp b/plugins/BassBooster/BassBooster.cpp index 48e26591193..e6b25b0d141 100644 --- a/plugins/BassBooster/BassBooster.cpp +++ b/plugins/BassBooster/BassBooster.cpp @@ -41,7 +41,7 @@ Plugin::Descriptor PLUGIN_EXPORT bassbooster_plugin_descriptor = QT_TRANSLATE_NOOP( "PluginBrowser", "Boost your bass the fast and simple way" ), "Tobias Doerffel ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, nullptr, diff --git a/plugins/BassBooster/BassBoosterControlDialog.cpp b/plugins/BassBooster/BassBoosterControlDialog.cpp index 21aacb0f25f..9efa07c0d36 100644 --- a/plugins/BassBooster/BassBoosterControlDialog.cpp +++ b/plugins/BassBooster/BassBoosterControlDialog.cpp @@ -50,17 +50,17 @@ BassBoosterControlDialog::BassBoosterControlDialog( BassBoosterControls* control auto l = new QHBoxLayout; - auto freqKnob = new Knob(knobBright_26, this); + auto freqKnob = new Knob(KnobType::Bright26, this); freqKnob->setModel( &controls->m_freqModel ); freqKnob->setLabel( tr( "FREQ" ) ); freqKnob->setHintText( tr( "Frequency:" ) , "Hz" ); - auto gainKnob = new Knob(knobBright_26, this); + auto gainKnob = new Knob(KnobType::Bright26, this); gainKnob->setModel( &controls->m_gainModel ); gainKnob->setLabel( tr( "GAIN" ) ); gainKnob->setHintText( tr( "Gain:" ) , "" ); - auto ratioKnob = new Knob(knobBright_26, this); + auto ratioKnob = new Knob(KnobType::Bright26, this); ratioKnob->setModel( &controls->m_ratioModel ); ratioKnob->setLabel( tr( "RATIO" ) ); ratioKnob->setHintText( tr( "Ratio:" ) , "" ); diff --git a/plugins/BitInvader/BitInvader.cpp b/plugins/BitInvader/BitInvader.cpp index d893835604b..98ef1e97cf1 100644 --- a/plugins/BitInvader/BitInvader.cpp +++ b/plugins/BitInvader/BitInvader.cpp @@ -60,7 +60,7 @@ Plugin::Descriptor PLUGIN_EXPORT bitinvader_plugin_descriptor = "Customizable wavetable synthesizer" ), "Andreas Brandmaier ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), nullptr, nullptr, @@ -345,11 +345,11 @@ BitInvaderView::BitInvaderView( Instrument * _instrument, "artwork" ) ); setPalette( pal ); - m_sampleLengthKnob = new Knob( knobDark_28, this ); + m_sampleLengthKnob = new Knob( KnobType::Dark28, this ); m_sampleLengthKnob->move( 6, 201 ); m_sampleLengthKnob->setHintText( tr( "Sample length" ), "" ); - m_graph = new Graph( this, Graph::NearestStyle, 204, 134 ); + m_graph = new Graph( this, Graph::Style::Nearest, 204, 134 ); m_graph->move(23,59); // 55,120 - 2px border m_graph->setAutoFillBackground( true ); m_graph->setGraphColor( QColor( 255, 255, 255 ) ); @@ -431,12 +431,12 @@ BitInvaderView::BitInvaderView( Instrument * _instrument, m_interpolationToggle = new LedCheckBox( "Interpolation", this, - tr( "Interpolation" ), LedCheckBox::Yellow ); + tr( "Interpolation" ), LedCheckBox::LedColor::Yellow ); m_interpolationToggle->move( 131, 221 ); m_normalizeToggle = new LedCheckBox( "Normalize", this, - tr( "Normalize" ), LedCheckBox::Green ); + tr( "Normalize" ), LedCheckBox::LedColor::Green ); m_normalizeToggle->move( 131, 236 ); @@ -556,7 +556,7 @@ void BitInvaderView::smoothClicked() void BitInvaderView::interpolationToggled( bool value ) { - m_graph->setGraphStyle( value ? Graph::LinearStyle : Graph::NearestStyle); + m_graph->setGraphStyle( value ? Graph::Style::Linear : Graph::Style::Nearest); Engine::getSong()->setModified(); } diff --git a/plugins/Bitcrush/Bitcrush.cpp b/plugins/Bitcrush/Bitcrush.cpp index 963e970db10..8d29186b5e7 100644 --- a/plugins/Bitcrush/Bitcrush.cpp +++ b/plugins/Bitcrush/Bitcrush.cpp @@ -48,7 +48,7 @@ Plugin::Descriptor PLUGIN_EXPORT bitcrush_plugin_descriptor = QT_TRANSLATE_NOOP( "PluginBrowser", "An oversampling bitcrusher" ), "Vesa Kivimäki ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader( "logo" ), nullptr, nullptr, diff --git a/plugins/Bitcrush/BitcrushControlDialog.cpp b/plugins/Bitcrush/BitcrushControlDialog.cpp index f3dc854701d..64c9b636160 100644 --- a/plugins/Bitcrush/BitcrushControlDialog.cpp +++ b/plugins/Bitcrush/BitcrushControlDialog.cpp @@ -53,13 +53,13 @@ BitcrushControlDialog::BitcrushControlDialog( BitcrushControls * controls ) : outLabel->move( 139, 15 ); // input knobs - auto inGain = new Knob(knobBright_26, this); + auto inGain = new Knob(KnobType::Bright26, this); inGain->move( 16, 32 ); inGain->setModel( & controls->m_inGain ); inGain->setLabel( tr( "GAIN" ) ); inGain->setHintText( tr( "Input gain:" ) , " dBFS" ); - auto inNoise = new Knob(knobBright_26, this); + auto inNoise = new Knob(KnobType::Bright26, this); inNoise->move( 14, 76 ); inNoise->setModel( & controls->m_inNoise ); inNoise->setLabel( tr( "NOISE" ) ); @@ -67,13 +67,13 @@ BitcrushControlDialog::BitcrushControlDialog( BitcrushControls * controls ) : // output knobs - auto outGain = new Knob(knobBright_26, this); + auto outGain = new Knob(KnobType::Bright26, this); outGain->move( 138, 32 ); outGain->setModel( & controls->m_outGain ); outGain->setLabel( tr( "GAIN" ) ); outGain->setHintText( tr( "Output gain:" ) , " dBFS" ); - auto outClip = new Knob(knobBright_26, this); + auto outClip = new Knob(KnobType::Bright26, this); outClip->move( 138, 76 ); outClip->setModel( & controls->m_outClip ); outClip->setLabel( tr( "CLIP" ) ); @@ -82,25 +82,25 @@ BitcrushControlDialog::BitcrushControlDialog( BitcrushControls * controls ) : // leds - auto rateEnabled = new LedCheckBox("", this, tr("Rate enabled"), LedCheckBox::Green); + auto rateEnabled = new LedCheckBox("", this, tr("Rate enabled"), LedCheckBox::LedColor::Green); rateEnabled->move( 64, 14 ); rateEnabled->setModel( & controls->m_rateEnabled ); rateEnabled->setToolTip(tr("Enable sample-rate crushing")); - auto depthEnabled = new LedCheckBox("", this, tr("Depth enabled"), LedCheckBox::Green); + auto depthEnabled = new LedCheckBox("", this, tr("Depth enabled"), LedCheckBox::LedColor::Green); depthEnabled->move( 101, 14 ); depthEnabled->setModel( & controls->m_depthEnabled ); depthEnabled->setToolTip(tr("Enable bit-depth crushing")); // rate crushing knobs - auto rate = new Knob(knobBright_26, this); + auto rate = new Knob(KnobType::Bright26, this); rate->move( 59, 32 ); rate->setModel( & controls->m_rate ); rate->setLabel( tr( "FREQ" ) ); rate->setHintText( tr( "Sample rate:" ) , " Hz" ); - auto stereoDiff = new Knob(knobBright_26, this); + auto stereoDiff = new Knob(KnobType::Bright26, this); stereoDiff->move( 72, 76 ); stereoDiff->setModel( & controls->m_stereoDiff ); stereoDiff->setLabel( tr( "STEREO" ) ); @@ -108,7 +108,7 @@ BitcrushControlDialog::BitcrushControlDialog( BitcrushControls * controls ) : // depth crushing knob - auto levels = new Knob(knobBright_26, this); + auto levels = new Knob(KnobType::Bright26, this); levels->move( 92, 32 ); levels->setModel( & controls->m_levels ); levels->setLabel( tr( "QUANT" ) ); diff --git a/plugins/CarlaBase/Carla.cpp b/plugins/CarlaBase/Carla.cpp index ef14b7aa425..faff94b570b 100644 --- a/plugins/CarlaBase/Carla.cpp +++ b/plugins/CarlaBase/Carla.cpp @@ -220,7 +220,7 @@ CarlaInstrument::CarlaInstrument(InstrumentTrack* const instrumentTrack, const D CarlaInstrument::~CarlaInstrument() { - Engine::audioEngine()->removePlayHandlesOfTypes(instrumentTrack(), PlayHandle::TypeNotePlayHandle | PlayHandle::TypeInstrumentPlayHandle); + Engine::audioEngine()->removePlayHandlesOfTypes(instrumentTrack(), PlayHandle::Type::NotePlayHandle | PlayHandle::Type::InstrumentPlayHandle); if (fHost.resourceDir != nullptr) { @@ -345,7 +345,7 @@ intptr_t CarlaInstrument::handleDispatcher(const NativeHostDispatcherOpcode opco Instrument::Flags CarlaInstrument::flags() const { - return IsSingleStreamed|IsMidiBased|IsNotBendable; + return Flag::IsSingleStreamed | Flag::IsMidiBased | Flag::IsNotBendable; } QString CarlaInstrument::nodeName() const @@ -1015,7 +1015,7 @@ void CarlaParamsView::refreshKnobs() for (uint32_t i=0; i < m_carlaInstrument->m_paramModels.count(); ++i) { bool enabled = m_carlaInstrument->m_paramModels[i]->enabled(); - m_knobs.push_back(new Knob(knobDark_28, m_inputScrollAreaWidgetContent)); + m_knobs.push_back(new Knob(KnobType::Dark28, m_inputScrollAreaWidgetContent)); QString name = (*m_carlaInstrument->m_paramModels[i]).displayName(); m_knobs[i]->setHintText(name, ""); m_knobs[i]->setLabel(name); diff --git a/plugins/CarlaPatchbay/CarlaPatchbay.cpp b/plugins/CarlaPatchbay/CarlaPatchbay.cpp index e440d4e3f13..ae22e30d15f 100644 --- a/plugins/CarlaPatchbay/CarlaPatchbay.cpp +++ b/plugins/CarlaPatchbay/CarlaPatchbay.cpp @@ -43,7 +43,7 @@ Plugin::Descriptor PLUGIN_EXPORT carlapatchbay_plugin_descriptor = "Carla Patchbay Instrument" ), "falkTX ", CARLA_VERSION_HEX, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), nullptr, nullptr, diff --git a/plugins/CarlaRack/CarlaRack.cpp b/plugins/CarlaRack/CarlaRack.cpp index 5360baf96ad..8be5e40b3c8 100644 --- a/plugins/CarlaRack/CarlaRack.cpp +++ b/plugins/CarlaRack/CarlaRack.cpp @@ -43,7 +43,7 @@ Plugin::Descriptor PLUGIN_EXPORT carlarack_plugin_descriptor = "Carla Rack Instrument" ), "falkTX ", CARLA_VERSION_HEX, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), nullptr, nullptr, diff --git a/plugins/Compressor/Compressor.cpp b/plugins/Compressor/Compressor.cpp index 92123ffd91f..3c5ad615714 100755 --- a/plugins/Compressor/Compressor.cpp +++ b/plugins/Compressor/Compressor.cpp @@ -43,7 +43,7 @@ Plugin::Descriptor PLUGIN_EXPORT compressor_plugin_descriptor = QT_TRANSLATE_NOOP("PluginBrowser", "A dynamic range compressor."), "Lost Robot ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, nullptr, @@ -442,28 +442,28 @@ bool CompressorEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames) m_gainResult[i] = qMax(m_rangeVal, m_gainResult[i]); } - switch (stereoLink) + switch (static_cast(stereoLink)) { - case Unlinked: + case StereoLinkMode::Unlinked: { break; } - case Maximum: + case StereoLinkMode::Maximum: { m_gainResult[0] = m_gainResult[1] = qMin(m_gainResult[0], m_gainResult[1]); break; } - case Average: + case StereoLinkMode::Average: { m_gainResult[0] = m_gainResult[1] = (m_gainResult[0] + m_gainResult[1]) * 0.5f; break; } - case Minimum: + case StereoLinkMode::Minimum: { m_gainResult[0] = m_gainResult[1] = qMax(m_gainResult[0], m_gainResult[1]); break; } - case Blend: + case StereoLinkMode::Blend: { if (blend > 0)// 0 is unlinked { diff --git a/plugins/Compressor/Compressor.h b/plugins/Compressor/Compressor.h index 121e0b88f18..da6ab52bcde 100755 --- a/plugins/Compressor/Compressor.h +++ b/plugins/Compressor/Compressor.h @@ -79,7 +79,7 @@ private slots: inline int realmod(int k, int n); inline float realfmod(float k, float n); - enum StereoLinkModes { Unlinked, Maximum, Average, Minimum, Blend }; + enum class StereoLinkMode { Unlinked, Maximum, Average, Minimum, Blend }; std::vector m_preLookaheadBuf[2]; int m_preLookaheadBufLoc[2] = {0}; diff --git a/plugins/Compressor/CompressorControlDialog.cpp b/plugins/Compressor/CompressorControlDialog.cpp index 8c6f61bec88..114980a7d96 100755 --- a/plugins/Compressor/CompressorControlDialog.cpp +++ b/plugins/Compressor/CompressorControlDialog.cpp @@ -95,92 +95,92 @@ CompressorControlDialog::CompressorControlDialog(CompressorControls* controls) : m_ratioEnabledLabel->setPixmap(PLUGIN_NAME::getIconPixmap("knob_enabled_large")); m_ratioEnabledLabel->setAttribute(Qt::WA_TransparentForMouseEvents); - m_thresholdKnob = new Knob(knobStyled, this); + m_thresholdKnob = new Knob(KnobType::Styled, this); makeLargeKnob(m_thresholdKnob, tr("Threshold:") , " dBFS"); m_thresholdKnob->setModel(&controls->m_thresholdModel); m_thresholdKnob->setToolTip(tr("Volume at which the compression begins to take place")); - m_ratioKnob = new Knob(knobStyled, this); + m_ratioKnob = new Knob(KnobType::Styled, this); makeLargeKnob(m_ratioKnob, tr("Ratio:") , ":1"); m_ratioKnob->setModel(&controls->m_ratioModel); m_ratioKnob->setToolTip(tr("How far the compressor must turn the volume down after crossing the threshold")); - m_attackKnob = new Knob(knobStyled, this); + m_attackKnob = new Knob(KnobType::Styled, this); makeLargeKnob(m_attackKnob, tr("Attack:") , " ms"); m_attackKnob->setModel(&controls->m_attackModel); m_attackKnob->setToolTip(tr("Speed at which the compressor starts to compress the audio")); - m_releaseKnob = new Knob(knobStyled, this); + m_releaseKnob = new Knob(KnobType::Styled, this); makeLargeKnob(m_releaseKnob, tr("Release:") , " ms"); m_releaseKnob->setModel(&controls->m_releaseModel); m_releaseKnob->setToolTip(tr("Speed at which the compressor ceases to compress the audio")); - m_kneeKnob = new Knob(knobStyled, this); + m_kneeKnob = new Knob(KnobType::Styled, this); makeSmallKnob(m_kneeKnob, tr("Knee:") , " dB"); m_kneeKnob->setModel(&controls->m_kneeModel); m_kneeKnob->setToolTip(tr("Smooth out the gain reduction curve around the threshold")); - m_rangeKnob = new Knob(knobStyled, this); + m_rangeKnob = new Knob(KnobType::Styled, this); makeSmallKnob(m_rangeKnob, tr("Range:") , " dBFS"); m_rangeKnob->setModel(&controls->m_rangeModel); m_rangeKnob->setToolTip(tr("Maximum gain reduction")); - m_lookaheadLengthKnob = new Knob(knobStyled, this); + m_lookaheadLengthKnob = new Knob(KnobType::Styled, this); makeSmallKnob(m_lookaheadLengthKnob, tr("Lookahead Length:") , " ms"); m_lookaheadLengthKnob->setModel(&controls->m_lookaheadLengthModel); m_lookaheadLengthKnob->setToolTip(tr("How long the compressor has to react to the sidechain signal ahead of time")); - m_holdKnob = new Knob(knobStyled, this); + m_holdKnob = new Knob(KnobType::Styled, this); makeSmallKnob(m_holdKnob, tr("Hold:") , " ms"); m_holdKnob->setModel(&controls->m_holdModel); m_holdKnob->setToolTip(tr("Delay between attack and release stages")); - m_rmsKnob = new Knob(knobStyled, this); + m_rmsKnob = new Knob(KnobType::Styled, this); makeSmallKnob(m_rmsKnob, tr("RMS Size:") , ""); m_rmsKnob->setModel(&controls->m_rmsModel); m_rmsKnob->setToolTip(tr("Size of the RMS buffer")); - m_inBalanceKnob = new Knob(knobStyled, this); + m_inBalanceKnob = new Knob(KnobType::Styled, this); makeSmallKnob(m_inBalanceKnob, tr("Input Balance:") , ""); m_inBalanceKnob->setModel(&controls->m_inBalanceModel); m_inBalanceKnob->setToolTip(tr("Bias the input audio to the left/right or mid/side")); - m_outBalanceKnob = new Knob(knobStyled, this); + m_outBalanceKnob = new Knob(KnobType::Styled, this); makeSmallKnob(m_outBalanceKnob, tr("Output Balance:") , ""); m_outBalanceKnob->setModel(&controls->m_outBalanceModel); m_outBalanceKnob->setToolTip(tr("Bias the output audio to the left/right or mid/side")); - m_stereoBalanceKnob = new Knob(knobStyled, this); + m_stereoBalanceKnob = new Knob(KnobType::Styled, this); makeSmallKnob(m_stereoBalanceKnob, tr("Stereo Balance:") , ""); m_stereoBalanceKnob->setModel(&controls->m_stereoBalanceModel); m_stereoBalanceKnob->setToolTip(tr("Bias the sidechain signal to the left/right or mid/side")); - m_blendKnob = new Knob(knobStyled, this); + m_blendKnob = new Knob(KnobType::Styled, this); makeSmallKnob(m_blendKnob, tr("Stereo Link Blend:") , ""); m_blendKnob->setModel(&controls->m_blendModel); m_blendKnob->setToolTip(tr("Blend between unlinked/maximum/average/minimum stereo linking modes")); - m_tiltKnob = new Knob(knobStyled, this); + m_tiltKnob = new Knob(KnobType::Styled, this); makeSmallKnob(m_tiltKnob, tr("Tilt Gain:") , " dB"); m_tiltKnob->setModel(&controls->m_tiltModel); m_tiltKnob->setToolTip(tr("Bias the sidechain signal to the low or high frequencies. -6 db is lowpass, 6 db is highpass.")); - m_tiltFreqKnob = new Knob(knobStyled, this); + m_tiltFreqKnob = new Knob(KnobType::Styled, this); makeSmallKnob(m_tiltFreqKnob, tr("Tilt Frequency:") , " Hz"); m_tiltFreqKnob->setModel(&controls->m_tiltFreqModel); m_tiltFreqKnob->setToolTip(tr("Center frequency of sidechain tilt filter")); - m_mixKnob = new Knob(knobStyled, this); + m_mixKnob = new Knob(KnobType::Styled, this); makeSmallKnob(m_mixKnob, tr("Mix:") , "%"); m_mixKnob->setModel(&controls->m_mixModel); m_mixKnob->setToolTip(tr("Balance between wet and dry signals")); - m_autoAttackKnob = new Knob(knobStyled, this); + m_autoAttackKnob = new Knob(KnobType::Styled, this); makeSmallKnob(m_autoAttackKnob, tr("Auto Attack:") , "%"); m_autoAttackKnob->setModel(&controls->m_autoAttackModel); m_autoAttackKnob->setToolTip(tr("Automatically control attack value depending on crest factor")); - m_autoReleaseKnob = new Knob(knobStyled, this); + m_autoReleaseKnob = new Knob(KnobType::Styled, this); makeSmallKnob(m_autoReleaseKnob, tr("Auto Release:") , "%"); m_autoReleaseKnob->setModel(&controls->m_autoReleaseModel); m_autoReleaseKnob->setToolTip(tr("Automatically control release value depending on crest factor")); diff --git a/plugins/CrossoverEQ/CrossoverEQ.cpp b/plugins/CrossoverEQ/CrossoverEQ.cpp index 641e06b4e4e..c4334677cb4 100644 --- a/plugins/CrossoverEQ/CrossoverEQ.cpp +++ b/plugins/CrossoverEQ/CrossoverEQ.cpp @@ -43,7 +43,7 @@ Plugin::Descriptor PLUGIN_EXPORT crossovereq_plugin_descriptor = QT_TRANSLATE_NOOP( "PluginBrowser", "A 4-band Crossover Equalizer" ), "Vesa Kivimäki ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader( "logo" ), nullptr, nullptr, diff --git a/plugins/CrossoverEQ/CrossoverEQControlDialog.cpp b/plugins/CrossoverEQ/CrossoverEQControlDialog.cpp index ba32e9dfc04..12b560b2370 100644 --- a/plugins/CrossoverEQ/CrossoverEQControlDialog.cpp +++ b/plugins/CrossoverEQ/CrossoverEQControlDialog.cpp @@ -46,19 +46,19 @@ CrossoverEQControlDialog::CrossoverEQControlDialog( CrossoverEQControls * contro setFixedSize( 167, 178 ); // knobs - auto xover12 = new Knob(knobBright_26, this); + auto xover12 = new Knob(KnobType::Bright26, this); xover12->move( 29, 11 ); xover12->setModel( & controls->m_xover12 ); xover12->setLabel( "1/2" ); xover12->setHintText( tr( "Band 1/2 crossover:" ), " Hz" ); - auto xover23 = new Knob(knobBright_26, this); + auto xover23 = new Knob(KnobType::Bright26, this); xover23->move( 69, 11 ); xover23->setModel( & controls->m_xover23 ); xover23->setLabel( "2/3" ); xover23->setHintText( tr( "Band 2/3 crossover:" ), " Hz" ); - auto xover34 = new Knob(knobBright_26, this); + auto xover34 = new Knob(KnobType::Bright26, this); xover34->move( 109, 11 ); xover34->setModel( & controls->m_xover34 ); xover34->setLabel( "3/4" ); @@ -90,22 +90,22 @@ CrossoverEQControlDialog::CrossoverEQControlDialog( CrossoverEQControls * contro gain4->setHintText( tr( "Band 4 gain:" ), " dBFS" ); // leds - auto mute1 = new LedCheckBox("", this, tr("Band 1 mute"), LedCheckBox::Green); + auto mute1 = new LedCheckBox("", this, tr("Band 1 mute"), LedCheckBox::LedColor::Green); mute1->move( 15, 154 ); mute1->setModel( & controls->m_mute1 ); mute1->setToolTip(tr("Mute band 1")); - auto mute2 = new LedCheckBox("", this, tr("Band 2 mute"), LedCheckBox::Green); + auto mute2 = new LedCheckBox("", this, tr("Band 2 mute"), LedCheckBox::LedColor::Green); mute2->move( 55, 154 ); mute2->setModel( & controls->m_mute2 ); mute2->setToolTip(tr("Mute band 2")); - auto mute3 = new LedCheckBox("", this, tr("Band 3 mute"), LedCheckBox::Green); + auto mute3 = new LedCheckBox("", this, tr("Band 3 mute"), LedCheckBox::LedColor::Green); mute3->move( 95, 154 ); mute3->setModel( & controls->m_mute3 ); mute3->setToolTip(tr("Mute band 3")); - auto mute4 = new LedCheckBox("", this, tr("Band 4 mute"), LedCheckBox::Green); + auto mute4 = new LedCheckBox("", this, tr("Band 4 mute"), LedCheckBox::LedColor::Green); mute4->move( 135, 154 ); mute4->setModel( & controls->m_mute4 ); mute4->setToolTip(tr("Mute band 4")); diff --git a/plugins/Delay/DelayControlsDialog.cpp b/plugins/Delay/DelayControlsDialog.cpp index 9a9dea0d4c6..065b3d1e4e5 100644 --- a/plugins/Delay/DelayControlsDialog.cpp +++ b/plugins/Delay/DelayControlsDialog.cpp @@ -44,28 +44,28 @@ DelayControlsDialog::DelayControlsDialog( DelayControls *controls ) : setPalette( pal ); setFixedSize( 300, 208 ); - auto sampleDelayKnob = new TempoSyncKnob(knobBright_26, this); + auto sampleDelayKnob = new TempoSyncKnob(KnobType::Bright26, this); sampleDelayKnob->move( 10,14 ); sampleDelayKnob->setVolumeKnob( false ); sampleDelayKnob->setModel( &controls->m_delayTimeModel ); sampleDelayKnob->setLabel( tr( "DELAY" ) ); sampleDelayKnob->setHintText( tr( "Delay time" ) + " ", " s" ); - auto feedbackKnob = new Knob(knobBright_26, this); + auto feedbackKnob = new Knob(KnobType::Bright26, this); feedbackKnob->move( 11, 58 ); feedbackKnob->setVolumeKnob( true) ; feedbackKnob->setModel( &controls->m_feedbackModel); feedbackKnob->setLabel( tr( "FDBK" ) ); feedbackKnob->setHintText( tr ( "Feedback amount" ) + " " , "" ); - auto lfoFreqKnob = new TempoSyncKnob(knobBright_26, this); + auto lfoFreqKnob = new TempoSyncKnob(KnobType::Bright26, this); lfoFreqKnob->move( 11, 119 ); lfoFreqKnob->setVolumeKnob( false ); lfoFreqKnob->setModel( &controls->m_lfoTimeModel ); lfoFreqKnob->setLabel( tr( "RATE" ) ); lfoFreqKnob->setHintText( tr ( "LFO frequency") + " ", " s" ); - auto lfoAmtKnob = new TempoSyncKnob(knobBright_26, this); + auto lfoAmtKnob = new TempoSyncKnob(KnobType::Bright26, this); lfoAmtKnob->move( 11, 159 ); lfoAmtKnob->setVolumeKnob( false ); lfoAmtKnob->setModel( &controls->m_lfoAmountModel ); diff --git a/plugins/Delay/DelayEffect.cpp b/plugins/Delay/DelayEffect.cpp index 6db2f38e387..05204f355ee 100644 --- a/plugins/Delay/DelayEffect.cpp +++ b/plugins/Delay/DelayEffect.cpp @@ -44,7 +44,7 @@ Plugin::Descriptor PLUGIN_EXPORT delay_plugin_descriptor = QT_TRANSLATE_NOOP( "PluginBrowser", "A native delay plugin" ), "Dave French ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, nullptr, diff --git a/plugins/Dispersion/Dispersion.cpp b/plugins/Dispersion/Dispersion.cpp index 9b98877e554..fb28e1f47a3 100644 --- a/plugins/Dispersion/Dispersion.cpp +++ b/plugins/Dispersion/Dispersion.cpp @@ -40,7 +40,7 @@ Plugin::Descriptor PLUGIN_EXPORT dispersion_plugin_descriptor = QT_TRANSLATE_NOOP("PluginBrowser", "An all-pass filter allowing for extremely high orders."), "Lost Robot ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, nullptr diff --git a/plugins/Dispersion/DispersionControlDialog.cpp b/plugins/Dispersion/DispersionControlDialog.cpp index b9f04baa2d5..2879e7613ef 100644 --- a/plugins/Dispersion/DispersionControlDialog.cpp +++ b/plugins/Dispersion/DispersionControlDialog.cpp @@ -51,19 +51,19 @@ DispersionControlDialog::DispersionControlDialog(DispersionControls* controls) : m_amountBox->setLabel(tr("AMOUNT")); m_amountBox->setToolTip(tr("Number of all-pass filters")); - Knob * freqKnob = new Knob(knobBright_26, this); + Knob * freqKnob = new Knob(KnobType::Bright26, this); freqKnob->move(59, 8); freqKnob->setModel(&controls->m_freqModel); freqKnob->setLabel(tr("FREQ")); freqKnob->setHintText(tr("Frequency:") , " Hz"); - Knob * resoKnob = new Knob(knobBright_26, this); + Knob * resoKnob = new Knob(KnobType::Bright26, this); resoKnob->move(99, 8); resoKnob->setModel(&controls->m_resoModel); resoKnob->setLabel(tr("RESO")); resoKnob->setHintText(tr("Resonance:") , " octaves"); - Knob * feedbackKnob = new Knob(knobBright_26, this); + Knob * feedbackKnob = new Knob(KnobType::Bright26, this); feedbackKnob->move(139, 8); feedbackKnob->setModel(&controls->m_feedbackModel); feedbackKnob->setLabel(tr("FEED")); diff --git a/plugins/DualFilter/DualFilter.cpp b/plugins/DualFilter/DualFilter.cpp index e510109e998..4e66db988a1 100644 --- a/plugins/DualFilter/DualFilter.cpp +++ b/plugins/DualFilter/DualFilter.cpp @@ -43,7 +43,7 @@ Plugin::Descriptor PLUGIN_EXPORT dualfilter_plugin_descriptor = QT_TRANSLATE_NOOP( "PluginBrowser", "A Dual filter plugin" ), "Vesa Kivimäki ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader( "logo" ), nullptr, nullptr, @@ -90,12 +90,12 @@ bool DualFilterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames if( m_dfControls.m_filter1Model.isValueChanged() || m_filter1changed ) { - m_filter1->setFilterType( m_dfControls.m_filter1Model.value() ); + m_filter1->setFilterType( static_cast::FilterType>(m_dfControls.m_filter1Model.value()) ); m_filter1changed = true; } if( m_dfControls.m_filter2Model.isValueChanged() || m_filter2changed ) { - m_filter2->setFilterType( m_dfControls.m_filter2Model.value() ); + m_filter2->setFilterType( static_cast::FilterType>(m_dfControls.m_filter2Model.value()) ); m_filter2changed = true; } diff --git a/plugins/DualFilter/DualFilterControlDialog.cpp b/plugins/DualFilter/DualFilterControlDialog.cpp index 81a8359016c..d316e337213 100644 --- a/plugins/DualFilter/DualFilterControlDialog.cpp +++ b/plugins/DualFilter/DualFilterControlDialog.cpp @@ -36,7 +36,7 @@ namespace lmms::gui #define makeknob( name, x, y, model, label, hint, unit ) \ - Knob * name = new Knob( knobBright_26, this); \ + Knob * name = new Knob( KnobType::Bright26, this); \ (name) -> move( x, y ); \ (name) ->setModel( &controls-> model ); \ (name) ->setLabel( label ); \ @@ -64,8 +64,8 @@ DualFilterControlDialog::DualFilterControlDialog( DualFilterControls* controls ) gain1Knob-> setVolumeKnob( true ); gain2Knob-> setVolumeKnob( true ); - auto enabled1Toggle = new LedCheckBox("", this, tr("Filter 1 enabled"), LedCheckBox::Green); - auto enabled2Toggle = new LedCheckBox("", this, tr("Filter 2 enabled"), LedCheckBox::Green); + auto enabled1Toggle = new LedCheckBox("", this, tr("Filter 1 enabled"), LedCheckBox::LedColor::Green); + auto enabled2Toggle = new LedCheckBox("", this, tr("Filter 2 enabled"), LedCheckBox::LedColor::Green); enabled1Toggle -> move( 12, 11 ); enabled1Toggle -> setModel( &controls -> m_enabled1Model ); diff --git a/plugins/DynamicsProcessor/DynamicsProcessor.cpp b/plugins/DynamicsProcessor/DynamicsProcessor.cpp index 54f1f0c509c..6bdf41eee4e 100644 --- a/plugins/DynamicsProcessor/DynamicsProcessor.cpp +++ b/plugins/DynamicsProcessor/DynamicsProcessor.cpp @@ -47,7 +47,7 @@ Plugin::Descriptor PLUGIN_EXPORT dynamicsprocessor_plugin_descriptor = "plugin for processing dynamics in a flexible way" ), "Vesa Kivimäki ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, nullptr, @@ -167,19 +167,19 @@ bool DynProcEffect::processAudioBuffer( sampleFrame * _buf, } // account for stereo mode - switch( stereoMode ) + switch( static_cast(stereoMode) ) { - case DynProcControls::SM_Maximum: + case DynProcControls::StereoMode::Maximum: { sm_peak[0] = sm_peak[1] = qMax( m_currentPeak[0], m_currentPeak[1] ); break; } - case DynProcControls::SM_Average: + case DynProcControls::StereoMode::Average: { sm_peak[0] = sm_peak[1] = ( m_currentPeak[0] + m_currentPeak[1] ) * 0.5; break; } - case DynProcControls::SM_Unlinked: + case DynProcControls::StereoMode::Unlinked: { sm_peak[0] = m_currentPeak[0]; sm_peak[1] = m_currentPeak[1]; diff --git a/plugins/DynamicsProcessor/DynamicsProcessorControlDialog.cpp b/plugins/DynamicsProcessor/DynamicsProcessorControlDialog.cpp index 4d8758e03d7..bd076b946ba 100644 --- a/plugins/DynamicsProcessor/DynamicsProcessorControlDialog.cpp +++ b/plugins/DynamicsProcessor/DynamicsProcessorControlDialog.cpp @@ -47,7 +47,7 @@ DynProcControlDialog::DynProcControlDialog( setPalette( pal ); setFixedSize( 224, 319 ); - auto waveGraph = new Graph(this, Graph::LinearNonCyclicStyle, 204, 205); + auto waveGraph = new Graph(this, Graph::Style::LinearNonCyclic, 204, 205); waveGraph -> move( 10, 6 ); waveGraph -> setModel( &_controls -> m_wavegraphModel ); waveGraph -> setAutoFillBackground( true ); @@ -58,7 +58,7 @@ DynProcControlDialog::DynProcControlDialog( waveGraph->setGraphColor( QColor( 85, 204, 145 ) ); waveGraph -> setMaximumSize( 204, 205 ); - auto inputKnob = new Knob(knobBright_26, this); + auto inputKnob = new Knob(KnobType::Bright26, this); inputKnob -> setVolumeKnob( true ); inputKnob -> setVolumeRatio( 1.0 ); inputKnob -> move( 26, 223 ); @@ -66,7 +66,7 @@ DynProcControlDialog::DynProcControlDialog( inputKnob->setLabel( tr( "INPUT" ) ); inputKnob->setHintText( tr( "Input gain:" ) , "" ); - auto outputKnob = new Knob(knobBright_26, this); + auto outputKnob = new Knob(KnobType::Bright26, this); outputKnob -> setVolumeKnob( true ); outputKnob -> setVolumeRatio( 1.0 ); outputKnob -> move( 76, 223 ); @@ -74,13 +74,13 @@ DynProcControlDialog::DynProcControlDialog( outputKnob->setLabel( tr( "OUTPUT" ) ); outputKnob->setHintText( tr( "Output gain:" ) , "" ); - auto attackKnob = new Knob(knobBright_26, this); + auto attackKnob = new Knob(KnobType::Bright26, this); attackKnob -> move( 24, 268 ); attackKnob->setModel( &_controls->m_attackModel ); attackKnob->setLabel( tr( "ATTACK" ) ); attackKnob->setHintText( tr( "Peak attack time:" ) , "ms" ); - auto releaseKnob = new Knob(knobBright_26, this); + auto releaseKnob = new Knob(KnobType::Bright26, this); releaseKnob -> move( 74, 268 ); releaseKnob->setModel( &_controls->m_releaseModel ); releaseKnob->setLabel( tr( "RELEASE" ) ); diff --git a/plugins/DynamicsProcessor/DynamicsProcessorControls.h b/plugins/DynamicsProcessor/DynamicsProcessorControls.h index cbe109eaf25..8fb66fee382 100644 --- a/plugins/DynamicsProcessor/DynamicsProcessorControls.h +++ b/plugins/DynamicsProcessor/DynamicsProcessorControls.h @@ -41,12 +41,11 @@ class DynProcControls : public EffectControls { Q_OBJECT public: - enum StereoModes + enum class StereoMode { - SM_Maximum, - SM_Average, - SM_Unlinked, - NumStereoModes + Maximum, + Average, + Unlinked }; DynProcControls( DynProcEffect * _eff ); ~DynProcControls() override = default; diff --git a/plugins/Eq/EqControlsDialog.cpp b/plugins/Eq/EqControlsDialog.cpp index 6535b61f345..a26fa0db918 100644 --- a/plugins/Eq/EqControlsDialog.cpp +++ b/plugins/Eq/EqControlsDialog.cpp @@ -106,14 +106,14 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) : distance = 81; for( int i = 0; i < m_parameterWidget->bandCount() ; i++ ) { - auto resKnob = new Knob(knobBright_26, this); + auto resKnob = new Knob(KnobType::Bright26, this); resKnob->move( distance, 440 ); resKnob->setVolumeKnob(false); resKnob->setModel( m_parameterWidget->getBandModels( i )->res ); if(i > 1 && i < 6) { resKnob->setHintText( tr( "Bandwidth: " ) , tr( " Octave" ) ); } else { resKnob->setHintText( tr( "Resonance : " ) , "" ); } - auto freqKnob = new Knob(knobBright_26, this); + auto freqKnob = new Knob(KnobType::Bright26, this); freqKnob->move( distance, 396 ); freqKnob->setVolumeKnob( false ); freqKnob->setModel( m_parameterWidget->getBandModels( i )->freq ); diff --git a/plugins/Eq/EqCurve.cpp b/plugins/Eq/EqCurve.cpp index b9fa3f51988..10213bfa92f 100644 --- a/plugins/Eq/EqCurve.cpp +++ b/plugins/Eq/EqCurve.cpp @@ -137,7 +137,7 @@ void EqHandle::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QRectF textRect2 = QRectF ( rectX+1, rectY+1, 80, 30 ); QString freq = QString::number( xPixelToFreq( EqHandle::x(), m_width ) ); QString res; - if ( getType() != para ) + if ( getType() != EqHandleType::Para ) { res = tr( "Reso: ") + QString::number( getResonance() ); } @@ -171,11 +171,11 @@ QPainterPath EqHandle::getCurvePath() float y = m_heigth * 0.5; for ( float x = 0 ; x < m_width; x++ ) { - if ( m_type == highpass ) y = getLowCutCurve( x ); - if ( m_type == lowshelf ) y = getLowShelfCurve( x ); - if ( m_type == para ) y = getPeakCurve( x ); - if ( m_type == highshelf ) y = getHighShelfCurve( x ); - if ( m_type == lowpass ) y = getHighCutCurve( x ); + if ( m_type == EqHandleType::HighPass ) y = getLowCutCurve( x ); + if ( m_type == EqHandleType::LowShelf ) y = getLowShelfCurve( x ); + if ( m_type == EqHandleType::Para ) y = getPeakCurve( x ); + if ( m_type == EqHandleType::HighShelf ) y = getHighShelfCurve( x ); + if ( m_type == EqHandleType::LowPass ) y = getHighCutCurve( x ); if ( x == 0 ) path.moveTo( x, y ); // sets the begin of Path path.lineTo( x, y ); } @@ -410,7 +410,7 @@ int EqHandle::getNum() -void EqHandle::setType( int t ) +void EqHandle::setType( EqHandleType t ) { EqHandle::m_type = t; } @@ -442,7 +442,7 @@ void EqHandle::setMouseHover( bool d ) -int EqHandle::getType() +EqHandleType EqHandle::getType() { return m_type; } @@ -569,7 +569,7 @@ void EqHandle::mouseReleaseEvent( QGraphicsSceneMouseEvent *event ) void EqHandle::wheelEvent( QGraphicsSceneWheelEvent *wevent ) { float highestBandwich; - if( m_type != para ) + if( m_type != EqHandleType::Para ) { highestBandwich = 10; } @@ -631,7 +631,7 @@ QVariant EqHandle::itemChange( QGraphicsItem::GraphicsItemChange change, const Q if( change == ItemPositionChange ) { // pass filter don't move in y direction - if ( m_type == highpass || m_type == lowpass ) + if ( m_type == EqHandleType::HighPass || m_type == EqHandleType::LowPass ) { float newX = value.toPointF().x(); if( newX < 0 ) @@ -714,23 +714,23 @@ void EqCurve::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, { for ( int x = 0; x < m_width ; x=x+1 ) { - if ( m_handle->at( thatHandle )->getType() == highpass ) + if ( m_handle->at( thatHandle )->getType() == EqHandleType::HighPass ) { mainCurve[x]= ( mainCurve[x] + ( m_handle->at( thatHandle )->getLowCutCurve( x ) * ( activeHandles ) ) - ( ( activeHandles * ( m_heigth/2 ) ) - m_heigth ) ); } - if ( m_handle->at(thatHandle)->getType() == lowshelf ) + if ( m_handle->at(thatHandle)->getType() == EqHandleType::LowShelf ) { mainCurve[x]= ( mainCurve[x] + ( m_handle->at( thatHandle )->getLowShelfCurve( x ) * ( activeHandles ) ) - ( ( activeHandles * ( m_heigth/2 ) ) - m_heigth ) ); } - if ( m_handle->at( thatHandle )->getType() == para ) + if ( m_handle->at( thatHandle )->getType() == EqHandleType::Para ) { mainCurve[x]= ( mainCurve[x] + ( m_handle->at( thatHandle )->getPeakCurve( x ) * ( activeHandles ) ) - ( ( activeHandles * ( m_heigth/2 ) ) - m_heigth ) ); } - if ( m_handle->at( thatHandle )->getType() == highshelf ) + if ( m_handle->at( thatHandle )->getType() == EqHandleType::HighShelf ) { mainCurve[x]= ( mainCurve[x] + ( m_handle->at( thatHandle )->getHighShelfCurve( x ) * ( activeHandles ) ) - ( ( activeHandles * ( m_heigth/2 ) ) - m_heigth ) ); } - if ( m_handle->at(thatHandle)->getType() == lowpass ) + if ( m_handle->at(thatHandle)->getType() == EqHandleType::LowPass ) { mainCurve[x]= ( mainCurve[x] + ( m_handle->at( thatHandle )->getHighCutCurve( x ) * ( activeHandles ) ) - ( ( activeHandles * ( m_heigth/2 ) ) - m_heigth ) ); } diff --git a/plugins/Eq/EqCurve.h b/plugins/Eq/EqCurve.h index e01e30841ef..27236aabb72 100644 --- a/plugins/Eq/EqCurve.h +++ b/plugins/Eq/EqCurve.h @@ -32,12 +32,12 @@ namespace lmms::gui { -enum{ - highpass=1, - lowshelf, - para, - highshelf, - lowpass +enum class EqHandleType { + HighPass=1, + LowShelf, + Para, + HighShelf, + LowPass }; @@ -64,8 +64,8 @@ class EqHandle : public QGraphicsObject float getHighCutCurve( float x ); float getResonance(); int getNum(); - int getType(); - void setType( int t ); + EqHandleType getType(); + void setType( EqHandleType t ); void setResonance( float r ); bool isMouseHover(); void setMouseHover( bool d ); @@ -104,7 +104,8 @@ class EqHandle : public QGraphicsObject bool m_lp24; bool m_lp48; bool m_mouseHover; - int m_type, m_numb; + EqHandleType m_type; + int m_numb; float m_width, m_heigth; float m_resonance; bool m_mousePressed; diff --git a/plugins/Eq/EqEffect.cpp b/plugins/Eq/EqEffect.cpp index eb168a9f9b5..8a795414429 100644 --- a/plugins/Eq/EqEffect.cpp +++ b/plugins/Eq/EqEffect.cpp @@ -44,7 +44,7 @@ Plugin::Descriptor PLUGIN_EXPORT eq_plugin_descriptor = QT_TRANSLATE_NOOP( "PluginBrowser", "A native eq plugin" ), "Dave French ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, nullptr, diff --git a/plugins/Eq/EqParameterWidget.cpp b/plugins/Eq/EqParameterWidget.cpp index fb60322a13a..b48f0f31760 100644 --- a/plugins/Eq/EqParameterWidget.cpp +++ b/plugins/Eq/EqParameterWidget.cpp @@ -164,35 +164,35 @@ void EqParameterWidget::changeHandle( int i ) switch ( i ) { case 0 : - m_handleList->at( i )->setType( highpass ); + m_handleList->at( i )->setType( EqHandleType::HighPass ); m_handleList->at( i )->setPos( x, m_displayHeigth / 2 ); break; case 1: - m_handleList->at( i )->setType( lowshelf ); + m_handleList->at( i )->setType( EqHandleType::LowShelf ); m_handleList->at( i )->setPos( x, y ); break; case 2: - m_handleList->at( i )->setType( para ); + m_handleList->at( i )->setType( EqHandleType::Para ); m_handleList->at( i )->setPos( x, y ); break; case 3: - m_handleList->at( i )->setType( para ); + m_handleList->at( i )->setType( EqHandleType::Para ); m_handleList->at( i )->setPos( x, y ); break; case 4: - m_handleList->at( i )->setType( para ); + m_handleList->at( i )->setType( EqHandleType::Para ); m_handleList->at( i )->setPos( x, y ); break; case 5: - m_handleList->at( i )->setType( para ); + m_handleList->at( i )->setType( EqHandleType::Para ); m_handleList->at( i )->setPos( x, y ); break; case 6: - m_handleList->at( i )->setType( highshelf ); + m_handleList->at( i )->setType( EqHandleType::HighShelf ); m_handleList->at( i )->setPos( x, y ); break; case 7: - m_handleList->at( i )->setType( lowpass ); + m_handleList->at( i )->setType( EqHandleType::LowPass ); m_handleList->at( i )->setPos( QPointF( x, m_displayHeigth / 2 ) ); break; } diff --git a/plugins/Flanger/FlangerControlsDialog.cpp b/plugins/Flanger/FlangerControlsDialog.cpp index f35aabfd444..3ac5dc9c638 100644 --- a/plugins/Flanger/FlangerControlsDialog.cpp +++ b/plugins/Flanger/FlangerControlsDialog.cpp @@ -42,42 +42,42 @@ FlangerControlsDialog::FlangerControlsDialog( FlangerControls *controls ) : setPalette( pal ); setFixedSize( 233, 75 ); - auto delayKnob = new Knob(knobBright_26, this); + auto delayKnob = new Knob(KnobType::Bright26, this); delayKnob->move( 10,10 ); delayKnob->setVolumeKnob( false ); delayKnob->setModel( &controls->m_delayTimeModel ); delayKnob->setLabel( tr( "DELAY" ) ); delayKnob->setHintText( tr( "Delay time:" ) + " ", "s" ); - auto lfoFreqKnob = new TempoSyncKnob(knobBright_26, this); + auto lfoFreqKnob = new TempoSyncKnob(KnobType::Bright26, this); lfoFreqKnob->move( 48,10 ); lfoFreqKnob->setVolumeKnob( false ); lfoFreqKnob->setModel( &controls->m_lfoFrequencyModel ); lfoFreqKnob->setLabel( tr( "RATE" ) ); lfoFreqKnob->setHintText( tr( "Period:" ) , " Sec" ); - auto lfoAmtKnob = new Knob(knobBright_26, this); + auto lfoAmtKnob = new Knob(KnobType::Bright26, this); lfoAmtKnob->move( 85,10 ); lfoAmtKnob->setVolumeKnob( false ); lfoAmtKnob->setModel( &controls->m_lfoAmountModel ); lfoAmtKnob->setLabel( tr( "AMNT" ) ); lfoAmtKnob->setHintText( tr( "Amount:" ) , "" ); - auto lfoPhaseKnob = new Knob(knobBright_26, this); + auto lfoPhaseKnob = new Knob(KnobType::Bright26, this); lfoPhaseKnob->move( 123,10 ); lfoPhaseKnob->setVolumeKnob( false ); lfoPhaseKnob->setModel( &controls->m_lfoPhaseModel ); lfoPhaseKnob->setLabel( tr( "PHASE" ) ); lfoPhaseKnob->setHintText( tr( "Phase:" ) , " degrees" ); - auto feedbackKnob = new Knob(knobBright_26, this); + auto feedbackKnob = new Knob(KnobType::Bright26, this); feedbackKnob->move( 160,10 ); feedbackKnob->setVolumeKnob( true) ; feedbackKnob->setModel( &controls->m_feedbackModel ); feedbackKnob->setLabel( tr( "FDBK" ) ); feedbackKnob->setHintText( tr( "Feedback amount:" ) , "" ); - auto whiteNoiseKnob = new Knob(knobBright_26, this); + auto whiteNoiseKnob = new Knob(KnobType::Bright26, this); whiteNoiseKnob->move( 196,10 ); whiteNoiseKnob->setVolumeKnob( true) ; whiteNoiseKnob->setModel( &controls->m_whiteNoiseAmountModel ); diff --git a/plugins/Flanger/FlangerEffect.cpp b/plugins/Flanger/FlangerEffect.cpp index 9f7200f0ea6..60b5df67b1f 100644 --- a/plugins/Flanger/FlangerEffect.cpp +++ b/plugins/Flanger/FlangerEffect.cpp @@ -45,7 +45,7 @@ Plugin::Descriptor PLUGIN_EXPORT flanger_plugin_descriptor = QT_TRANSLATE_NOOP( "PluginBrowser", "A native flanger plugin" ), "Dave French ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, nullptr, diff --git a/plugins/FreeBoy/FreeBoy.cpp b/plugins/FreeBoy/FreeBoy.cpp index c26cd79c4e4..6450253ee45 100644 --- a/plugins/FreeBoy/FreeBoy.cpp +++ b/plugins/FreeBoy/FreeBoy.cpp @@ -63,7 +63,7 @@ Plugin::Descriptor PLUGIN_EXPORT freeboy_plugin_descriptor = "Attila Herman " "Csaba Hruska ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), nullptr, } ; @@ -446,7 +446,7 @@ class FreeBoyKnob : public Knob { public: FreeBoyKnob( QWidget * _parent ) : - Knob( knobStyled, _parent ) + Knob( KnobType::Styled, _parent ) { setFixedSize( 30, 30 ); setCenterPointX( 15.0 ); @@ -677,7 +677,7 @@ FreeBoyInstrumentView::FreeBoyInstrumentView( Instrument * _instrument, m_graph = new Graph( this ); - m_graph->setGraphStyle( Graph::NearestStyle ); + m_graph->setGraphStyle( Graph::Style::Nearest ); m_graph->setGraphColor( QColor(0x4E, 0x83, 0x2B) ); m_graph->move( 37, 199 ); m_graph->resize(208, 47); diff --git a/plugins/GigPlayer/GigPlayer.cpp b/plugins/GigPlayer/GigPlayer.cpp index 42d64cf07c2..c2e155a20c5 100644 --- a/plugins/GigPlayer/GigPlayer.cpp +++ b/plugins/GigPlayer/GigPlayer.cpp @@ -69,7 +69,7 @@ Plugin::Descriptor PLUGIN_EXPORT gigplayer_plugin_descriptor = QT_TRANSLATE_NOOP( "PluginBrowser", "Player for GIG files" ), "Garrett Wilson ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), "gig", nullptr, @@ -108,8 +108,8 @@ GigInstrument::GigInstrument( InstrumentTrack * _instrument_track ) : GigInstrument::~GigInstrument() { Engine::audioEngine()->removePlayHandlesOfTypes( instrumentTrack(), - PlayHandle::TypeNotePlayHandle - | PlayHandle::TypeInstrumentPlayHandle ); + PlayHandle::Type::NotePlayHandle + | PlayHandle::Type::InstrumentPlayHandle ); freeInstance(); } @@ -341,16 +341,16 @@ void GigInstrument::play( sampleFrame * _working_buffer ) for( QList::iterator it = m_notes.begin(); it != m_notes.end(); ++it ) { // Process notes in the KeyUp state, adding release samples if desired - if( it->state == KeyUp ) + if( it->state == GigState::KeyUp ) { // If there are no samples, we're done if( it->samples.empty() ) { - it->state = Completed; + it->state = GigState::Completed; } else { - it->state = PlayingKeyUp; + it->state = GigState::PlayingKeyUp; // Notify each sample that the key has been released for (auto& sample : it->samples) @@ -366,9 +366,9 @@ void GigInstrument::play( sampleFrame * _working_buffer ) } } // Process notes in the KeyDown state, adding samples for the notes - else if( it->state == KeyDown ) + else if( it->state == GigState::KeyDown ) { - it->state = PlayingKeyDown; + it->state = GigState::PlayingKeyDown; addSamples( *it, false ); } @@ -393,7 +393,7 @@ void GigInstrument::play( sampleFrame * _working_buffer ) } // Delete ended notes (either in the completed state or all the samples ended) - if( it->state == Completed || it->samples.empty() ) + if( it->state == GigState::Completed || it->samples.empty() ) { it = m_notes.erase( it ); @@ -408,7 +408,7 @@ void GigInstrument::play( sampleFrame * _working_buffer ) for (auto& note : m_notes) { // Only process the notes if we're in a playing state - if (!(note.state == PlayingKeyDown || note.state == PlayingKeyUp )) + if (!(note.state == GigState::PlayingKeyDown || note.state == GigState::PlayingKeyUp )) { continue; } @@ -680,9 +680,9 @@ void GigInstrument::deleteNotePluginData( NotePlayHandle * _n ) for (auto& note : m_notes) { // Find the note by matching pointers to the plugin data - if (note.handle == pluginData && (note.state == KeyDown || note.state == PlayingKeyDown)) + if (note.handle == pluginData && (note.state == GigState::KeyDown || note.state == GigState::PlayingKeyDown)) { - note.state = KeyUp; + note.state = GigState::KeyUp; } } @@ -906,7 +906,7 @@ class gigKnob : public Knob { public: gigKnob( QWidget * _parent ) : - Knob( knobBright_26, _parent ) + Knob( KnobType::Bright26, _parent ) { setFixedSize( 31, 38 ); } diff --git a/plugins/GigPlayer/GigPlayer.h b/plugins/GigPlayer/GigPlayer.h index 20058424b15..e5039f109be 100644 --- a/plugins/GigPlayer/GigPlayer.h +++ b/plugins/GigPlayer/GigPlayer.h @@ -187,7 +187,7 @@ class GigSample // What portion of a note are we in? -enum GigState +enum class GigState { // We just pressed the key KeyDown, @@ -224,7 +224,7 @@ class GigNote GigNote( int midiNote, int velocity, float frequency, GIGPluginData * handle ) : midiNote( midiNote ), velocity( velocity ), - release( false ), isRelease( false ), state( KeyDown ), + release( false ), isRelease( false ), state( GigState::KeyDown ), frequency( frequency ), handle( handle ) { } @@ -268,7 +268,7 @@ class GigInstrument : public Instrument Flags flags() const override { - return IsSingleStreamed|IsNotBendable; + return Flag::IsSingleStreamed | Flag::IsNotBendable; } gui::PluginView* instantiateView( QWidget * _parent ) override; diff --git a/plugins/HydrogenImport/HydrogenImport.cpp b/plugins/HydrogenImport/HydrogenImport.cpp index d8f76071a86..144a2f5e75e 100644 --- a/plugins/HydrogenImport/HydrogenImport.cpp +++ b/plugins/HydrogenImport/HydrogenImport.cpp @@ -30,7 +30,7 @@ Plugin::Descriptor PLUGIN_EXPORT hydrogenimport_plugin_descriptor = "Filter for importing Hydrogen files into LMMS" ), "frank mather", 0x0100, - Plugin::ImportFilter, + Plugin::Type::ImportFilter, nullptr, nullptr, nullptr, @@ -42,7 +42,7 @@ QString filename; class NoteKey { public: - enum Key { + enum class Key { C = 0, Cs, D, @@ -59,7 +59,7 @@ class NoteKey static int stringToNoteKey( const QString& str ) { - int m_key = NoteKey::C; + auto m_key = Key::C; QString sKey = str.left( str.length() - 1 ); @@ -74,54 +74,54 @@ class NoteKey if ( sKey == "C" ) { - m_key = NoteKey::C; + m_key = Key::C; } else if ( sKey == "Cs" ) { - m_key = NoteKey::Cs; + m_key = Key::Cs; } else if ( sKey == "D" ) { - m_key = NoteKey::D; + m_key = Key::D; } else if ( sKey == "Ef" ) { - m_key = NoteKey::Ef; + m_key = Key::Ef; } else if ( sKey == "E" ) { - m_key = NoteKey::E; + m_key = Key::E; } else if ( sKey == "F" ) { - m_key = NoteKey::F; + m_key = Key::F; } else if ( sKey == "Fs" ) { - m_key = NoteKey::Fs; + m_key = Key::Fs; } else if ( sKey == "G" ) { - m_key = NoteKey::G; + m_key = Key::G; } else if ( sKey == "Af" ) { - m_key = NoteKey::Af; + m_key = Key::Af; } else if ( sKey == "A" ) { - m_key = NoteKey::A; + m_key = Key::A; } else if ( sKey == "Bf" ) { - m_key = NoteKey::Bf; + m_key = Key::Bf; } else if ( sKey == "B" ) { - m_key = NoteKey::B; + m_key = Key::B; } // Hydrogen records MIDI notes from C-1 to B5, and exports them as a number ranging from -3 to 3 - return m_key + ((nOctave + 3) * 12); + return static_cast(m_key) + ((nOctave + 3) * 12); } }; @@ -218,7 +218,7 @@ bool HydrogenImport::readSong() if ( nLayer == 0 ) { drum_track[sId] = static_cast( - Track::create(Track::InstrumentTrack, Engine::patternStore()) + Track::create(Track::Type::Instrument, Engine::patternStore()) ); drum_track[sId]->volumeModel()->setValue( fVolume * 100 ); drum_track[sId]->panningModel()->setValue( ( fPan_R - fPan_L ) * 100 ); diff --git a/plugins/Kicker/Kicker.cpp b/plugins/Kicker/Kicker.cpp index 29f7dc8f14d..ef1d623c1a1 100644 --- a/plugins/Kicker/Kicker.cpp +++ b/plugins/Kicker/Kicker.cpp @@ -54,7 +54,7 @@ Plugin::Descriptor PLUGIN_EXPORT kicker_plugin_descriptor = "Versatile drum synthesizer" ), "Tobias Doerffel ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), nullptr, nullptr, @@ -226,7 +226,7 @@ class KickerKnob : public Knob { public: KickerKnob( QWidget * _parent ) : - Knob( knobStyled, _parent ) + Knob( KnobType::Styled, _parent ) { setFixedSize( 29, 29 ); setObjectName( "smallKnob" ); @@ -238,7 +238,7 @@ class KickerEnvKnob : public TempoSyncKnob { public: KickerEnvKnob( QWidget * _parent ) : - TempoSyncKnob( knobStyled, _parent ) + TempoSyncKnob( KnobType::Styled, _parent ) { setFixedSize( 29, 29 ); setObjectName( "smallKnob" ); @@ -250,7 +250,7 @@ class KickerLargeKnob : public Knob { public: KickerLargeKnob( QWidget * _parent ) : - Knob( knobStyled, _parent ) + Knob( KnobType::Styled, _parent ) { setFixedSize( 34, 34 ); setObjectName( "largeKnob" ); @@ -315,10 +315,10 @@ KickerInstrumentView::KickerInstrumentView( Instrument * _instrument, m_distEndKnob->setHintText( tr( "End distortion:" ), "" ); m_distEndKnob->move( COL5, ROW2 ); - m_startNoteToggle = new LedCheckBox( "", this, "", LedCheckBox::Green ); + m_startNoteToggle = new LedCheckBox( "", this, "", LedCheckBox::LedColor::Green ); m_startNoteToggle->move( COL1 + 8, LED_ROW ); - m_endNoteToggle = new LedCheckBox( "", this, "", LedCheckBox::Green ); + m_endNoteToggle = new LedCheckBox( "", this, "", LedCheckBox::LedColor::Green ); m_endNoteToggle->move( END_COL + 8, LED_ROW ); setAutoFillBackground( true ); diff --git a/plugins/Kicker/Kicker.h b/plugins/Kicker/Kicker.h index cef732adb62..b5d065598c5 100644 --- a/plugins/Kicker/Kicker.h +++ b/plugins/Kicker/Kicker.h @@ -66,7 +66,7 @@ class KickerInstrument : public Instrument Flags flags() const override { - return IsNotBendable; + return Flag::IsNotBendable; } f_cnt_t desiredReleaseFrames() const override diff --git a/plugins/LadspaBrowser/LadspaBrowser.cpp b/plugins/LadspaBrowser/LadspaBrowser.cpp index 09f83ab4e5f..31be6405649 100644 --- a/plugins/LadspaBrowser/LadspaBrowser.cpp +++ b/plugins/LadspaBrowser/LadspaBrowser.cpp @@ -56,7 +56,7 @@ Plugin::Descriptor PLUGIN_EXPORT ladspabrowser_plugin_descriptor = "List installed LADSPA plugins" ), "Danny McRae ", 0x0100, - Plugin::Tool, + Plugin::Type::Tool, new PluginPixmapLoader("logo"), nullptr, nullptr, @@ -107,12 +107,12 @@ LadspaBrowserView::LadspaBrowserView( ToolPlugin * _tool ) : auto ws = new QWidget(this); ws->setFixedSize( 500, 480 ); - QWidget * available = createTab( ws, tr( "Available Effects" ), VALID ); + QWidget * available = createTab( ws, tr( "Available Effects" ), LadspaPluginType::Valid ); QWidget * unavailable = createTab( ws, tr( "Unavailable Effects" ), - INVALID ); - QWidget * instruments = createTab( ws, tr( "Instruments" ), SOURCE ); - QWidget * analysis = createTab( ws, tr( "Analysis Tools" ), SINK ); - QWidget * other = createTab( ws, tr( "Don't know" ), OTHER ); + LadspaPluginType::Invalid ); + QWidget * instruments = createTab( ws, tr( "Instruments" ), LadspaPluginType::Source ); + QWidget * analysis = createTab( ws, tr( "Analysis Tools" ), LadspaPluginType::Sink ); + QWidget * other = createTab( ws, tr( "Don't know" ), LadspaPluginType::Other ); m_tabBar->addTab( available, tr( "Available Effects" ), diff --git a/plugins/LadspaBrowser/LadspaDescription.cpp b/plugins/LadspaBrowser/LadspaDescription.cpp index 004505d6639..fbcd6c25dba 100644 --- a/plugins/LadspaBrowser/LadspaDescription.cpp +++ b/plugins/LadspaBrowser/LadspaDescription.cpp @@ -49,22 +49,22 @@ LadspaDescription::LadspaDescription( QWidget * _parent, l_sortable_plugin_t plugins; switch( _type ) { - case SOURCE: + case LadspaPluginType::Source: plugins = manager->getInstruments(); break; - case TRANSFER: + case LadspaPluginType::Transfer: plugins = manager->getValidEffects(); break; - case VALID: + case LadspaPluginType::Valid: plugins = manager->getValidEffects(); break; - case INVALID: + case LadspaPluginType::Invalid: plugins = manager->getInvalidEffects(); break; - case SINK: + case LadspaPluginType::Sink: plugins = manager->getAnalysisTools(); break; - case OTHER: + case LadspaPluginType::Other: plugins = manager->getOthers(); break; default: @@ -75,7 +75,7 @@ LadspaDescription::LadspaDescription( QWidget * _parent, for (const auto& plugin : plugins) { ch_cnt_t audioDeviceChannels = Engine::audioEngine()->audioDev()->channels(); - if (_type != VALID || manager->getDescription(plugin.second)->inputChannels <= audioDeviceChannels) + if (_type != LadspaPluginType::Valid || manager->getDescription(plugin.second)->inputChannels <= audioDeviceChannels) { pluginNames.push_back(plugin.first); m_pluginKeys.push_back(plugin.second); diff --git a/plugins/LadspaEffect/LadspaControlDialog.cpp b/plugins/LadspaEffect/LadspaControlDialog.cpp index 571dbd454da..2a5437fb128 100644 --- a/plugins/LadspaEffect/LadspaControlDialog.cpp +++ b/plugins/LadspaEffect/LadspaControlDialog.cpp @@ -86,7 +86,7 @@ void LadspaControlDialog::updateEffectView( LadspaControls * _ctl ) control_list_t & controls = _ctl->m_controls[proc]; int row = 0; int col = 0; - buffer_data_t last_port = NONE; + BufferDataType last_port = BufferDataType::None; QGroupBox * grouper; if( _ctl->m_processors > 1 ) @@ -108,10 +108,10 @@ void LadspaControlDialog::updateEffectView( LadspaControls * _ctl ) { if (control->port()->proc == proc) { - buffer_data_t this_port = control->port()->data_type; - if( last_port != NONE && - ( this_port == TOGGLED || this_port == ENUM ) && - ( last_port != TOGGLED && last_port != ENUM ) ) + BufferDataType this_port = control->port()->data_type; + if( last_port != BufferDataType::None && + ( this_port == BufferDataType::Toggled || this_port == BufferDataType::Enum ) && + ( last_port != BufferDataType::Toggled && last_port != BufferDataType::Enum ) ) { ++row; col = 0; diff --git a/plugins/LadspaEffect/LadspaEffect.cpp b/plugins/LadspaEffect/LadspaEffect.cpp index e5d1c5d69c5..cc754a82962 100644 --- a/plugins/LadspaEffect/LadspaEffect.cpp +++ b/plugins/LadspaEffect/LadspaEffect.cpp @@ -60,10 +60,10 @@ Plugin::Descriptor PLUGIN_EXPORT ladspaeffect_plugin_descriptor = "inside LMMS." ), "Danny McRae ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, - new LadspaSubPluginFeatures( Plugin::Effect ) + new LadspaSubPluginFeatures( Plugin::Type::Effect ) } ; } @@ -106,7 +106,7 @@ LadspaEffect::~LadspaEffect() void LadspaEffect::changeSampleRate() { - DataFile dataFile( DataFile::EffectSettings ); + DataFile dataFile( DataFile::Type::EffectSettings ); m_controls->saveState( dataFile, dataFile.content() ); LadspaControls * controls = m_controls; @@ -163,7 +163,7 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, port_desc_t * pp = m_ports.at( proc ).at( port ); switch( pp->rate ) { - case CHANNEL_IN: + case BufferRate::ChannelIn: for( fpp_t frame = 0; frame < frames; ++frame ) { @@ -172,7 +172,7 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, } ++channel; break; - case AUDIO_RATE_INPUT: + case BufferRate::AudioRateInput: { ValueBuffer * vb = pp->control->valueBuffer(); if( vb ) @@ -195,7 +195,7 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, } break; } - case CONTROL_RATE_INPUT: + case BufferRate::ControlRateInput: if( pp->control == nullptr ) { break; @@ -205,9 +205,9 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, pp->buffer[0] = pp->value; break; - case CHANNEL_OUT: - case AUDIO_RATE_OUTPUT: - case CONTROL_RATE_OUTPUT: + case BufferRate::ChannelOut: + case BufferRate::AudioRateOutput: + case BufferRate::ControlRateOutput: break; default: break; @@ -234,11 +234,11 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, port_desc_t * pp = m_ports.at( proc ).at( port ); switch( pp->rate ) { - case CHANNEL_IN: - case AUDIO_RATE_INPUT: - case CONTROL_RATE_INPUT: + case BufferRate::ChannelIn: + case BufferRate::AudioRateInput: + case BufferRate::ControlRateInput: break; - case CHANNEL_OUT: + case BufferRate::ChannelOut: for( fpp_t frame = 0; frame < frames; ++frame ) { @@ -247,8 +247,8 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, } ++channel; break; - case AUDIO_RATE_OUTPUT: - case CONTROL_RATE_OUTPUT: + case BufferRate::AudioRateOutput: + case BufferRate::ControlRateOutput: break; default: break; @@ -325,7 +325,7 @@ void LadspaEffect::pluginInstantiation() if( p->name.toUpper().contains( "IN" ) && manager->isPortInput( m_key, port ) ) { - p->rate = CHANNEL_IN; + p->rate = BufferRate::ChannelIn; p->buffer = MM_ALLOC( Engine::audioEngine()->framesPerPeriod() ); inbuf[ inputch ] = p->buffer; inputch++; @@ -333,7 +333,7 @@ void LadspaEffect::pluginInstantiation() else if( p->name.toUpper().contains( "OUT" ) && manager->isPortOutput( m_key, port ) ) { - p->rate = CHANNEL_OUT; + p->rate = BufferRate::ChannelOut; if( ! m_inPlaceBroken && inbuf[ outputch ] ) { p->buffer = inbuf[ outputch ]; @@ -347,12 +347,12 @@ void LadspaEffect::pluginInstantiation() } else if( manager->isPortInput( m_key, port ) ) { - p->rate = AUDIO_RATE_INPUT; + p->rate = BufferRate::AudioRateInput; p->buffer = MM_ALLOC( Engine::audioEngine()->framesPerPeriod() ); } else { - p->rate = AUDIO_RATE_OUTPUT; + p->rate = BufferRate::AudioRateOutput; p->buffer = MM_ALLOC( Engine::audioEngine()->framesPerPeriod() ); } } @@ -362,30 +362,30 @@ void LadspaEffect::pluginInstantiation() if( manager->isPortInput( m_key, port ) ) { - p->rate = CONTROL_RATE_INPUT; + p->rate = BufferRate::ControlRateInput; } else { - p->rate = CONTROL_RATE_OUTPUT; + p->rate = BufferRate::ControlRateOutput; } } p->scale = 1.0f; if( manager->isEnum( m_key, port ) ) { - p->data_type = ENUM; + p->data_type = BufferDataType::Enum; } else if( manager->isPortToggled( m_key, port ) ) { - p->data_type = TOGGLED; + p->data_type = BufferDataType::Toggled; } else if( manager->isInteger( m_key, port ) ) { - p->data_type = INTEGER; + p->data_type = BufferDataType::Integer; } else if( p->name.toUpper().contains( "(SECONDS)" ) ) { - p->data_type = TIME; + p->data_type = BufferDataType::Time; p->scale = 1000.0f; int loc = p->name.toUpper().indexOf( "(SECONDS)" ); @@ -393,20 +393,20 @@ void LadspaEffect::pluginInstantiation() } else if( p->name.toUpper().contains( "(S)" ) ) { - p->data_type = TIME; + p->data_type = BufferDataType::Time; p->scale = 1000.0f; int loc = p->name.toUpper().indexOf( "(S)" ); p->name.replace( loc, 3, "(ms)" ); } else if( p->name.toUpper().contains( "(MS)" ) ) { - p->data_type = TIME; + p->data_type = BufferDataType::Time; int loc = p->name.toUpper().indexOf( "(MS)" ); p->name.replace( loc, 4, "(ms)" ); } else { - p->data_type = FLOATING; + p->data_type = BufferDataType::Floating; } // Get the range and default values. @@ -438,7 +438,7 @@ void LadspaEffect::pluginInstantiation() p->def = manager->getDefaultSetting( m_key, port ); if( p->def == NOHINT ) { - if( p->data_type != TOGGLED ) + if( p->data_type != BufferDataType::Toggled ) { p->def = ( p->min + p->max ) / 2.0f; } @@ -465,8 +465,8 @@ void LadspaEffect::pluginInstantiation() // For convenience, keep a separate list of the ports that are used // to control the processors. - if( p->rate == AUDIO_RATE_INPUT || - p->rate == CONTROL_RATE_INPUT ) + if( p->rate == BufferRate::AudioRateInput || + p->rate == BufferRate::ControlRateInput ) { p->control_id = m_portControls.count(); m_portControls.append( p ); @@ -555,7 +555,7 @@ void LadspaEffect::pluginDestruction() for( int port = 0; port < m_portCount; port++ ) { port_desc_t * pp = m_ports.at( proc ).at( port ); - if( m_inPlaceBroken || pp->rate != CHANNEL_OUT ) + if( m_inPlaceBroken || pp->rate != BufferRate::ChannelOut ) { if( pp->buffer) MM_FREE( pp->buffer ); } diff --git a/plugins/LadspaEffect/LadspaSubPluginFeatures.cpp b/plugins/LadspaEffect/LadspaSubPluginFeatures.cpp index 1522d7187e2..46a211f9f75 100644 --- a/plugins/LadspaEffect/LadspaSubPluginFeatures.cpp +++ b/plugins/LadspaEffect/LadspaSubPluginFeatures.cpp @@ -39,7 +39,7 @@ namespace lmms { -LadspaSubPluginFeatures::LadspaSubPluginFeatures( Plugin::PluginTypes _type ) : +LadspaSubPluginFeatures::LadspaSubPluginFeatures( Plugin::Type _type ) : SubPluginFeatures( _type ) { } @@ -137,17 +137,17 @@ void LadspaSubPluginFeatures::listSubPluginKeys( l_sortable_plugin_t plugins; switch( m_type ) { - case Plugin::Instrument: + case Plugin::Type::Instrument: plugins = lm->getInstruments(); break; - case Plugin::Effect: + case Plugin::Type::Effect: plugins = lm->getValidEffects(); //plugins += lm->getInvalidEffects(); break; - case Plugin::Tool: + case Plugin::Type::Tool: plugins = lm->getAnalysisTools(); break; - case Plugin::Other: + case Plugin::Type::Other: plugins = lm->getOthers(); break; default: diff --git a/plugins/LadspaEffect/LadspaSubPluginFeatures.h b/plugins/LadspaEffect/LadspaSubPluginFeatures.h index c65dce9fe25..7747127b855 100644 --- a/plugins/LadspaEffect/LadspaSubPluginFeatures.h +++ b/plugins/LadspaEffect/LadspaSubPluginFeatures.h @@ -38,7 +38,7 @@ namespace lmms class LadspaSubPluginFeatures : public Plugin::Descriptor::SubPluginFeatures { public: - LadspaSubPluginFeatures( Plugin::PluginTypes _type ); + LadspaSubPluginFeatures( Plugin::Type _type ); QString displayName(const Key& k) const override; void fillDescriptionWidget( QWidget * _parent, diff --git a/plugins/Lb302/Lb302.cpp b/plugins/Lb302/Lb302.cpp index c0e477dccd1..b8fff2c0b8a 100644 --- a/plugins/Lb302/Lb302.cpp +++ b/plugins/Lb302/Lb302.cpp @@ -86,7 +86,7 @@ Plugin::Descriptor PLUGIN_EXPORT lb302_plugin_descriptor = "Incomplete monophonic imitation TB-303" ), "Paul Giblock ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), nullptr, nullptr, @@ -290,7 +290,7 @@ Lb302Synth::Lb302Synth( InstrumentTrack * _instrumentTrack ) : vca_decay(0.99897516), vca_a0(0.5), vca_a(0.), - vca_mode(never_played) + vca_mode(VcaMode::NeverPlayed) { connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), @@ -332,7 +332,7 @@ Lb302Synth::Lb302Synth( InstrumentTrack * _instrumentTrack ) : vcf_envpos = ENVINC; - vco_shape = BL_SAWTOOTH; + vco_shape = VcoShape::BLSawtooth; vcfs[0] = new Lb302FilterIIR2(&fs); vcfs[1] = new Lb302Filter3Pole(&fs); @@ -469,7 +469,7 @@ int Lb302Synth::process(sampleFrame *outbuf, const int size) if( release_frame == 0 || ! m_playingNote ) { - vca_mode = decay; + vca_mode = VcaMode::Decay; } if( new_freq ) @@ -493,7 +493,7 @@ int Lb302Synth::process(sampleFrame *outbuf, const int size) // start decay if we're past release if( i >= release_frame ) { - vca_mode = decay; + vca_mode = VcaMode::Decay; } // update vcf @@ -523,43 +523,43 @@ int Lb302Synth::process(sampleFrame *outbuf, const int size) vco_c -= 1.0; switch(int(rint(wave_shape.value()))) { - case 0: vco_shape = SAWTOOTH; break; - case 1: vco_shape = TRIANGLE; break; - case 2: vco_shape = SQUARE; break; - case 3: vco_shape = ROUND_SQUARE; break; - case 4: vco_shape = MOOG; break; - case 5: vco_shape = SINE; break; - case 6: vco_shape = EXPONENTIAL; break; - case 7: vco_shape = WHITE_NOISE; break; - case 8: vco_shape = BL_SAWTOOTH; break; - case 9: vco_shape = BL_SQUARE; break; - case 10: vco_shape = BL_TRIANGLE; break; - case 11: vco_shape = BL_MOOG; break; - default: vco_shape = SAWTOOTH; break; + case 0: vco_shape = VcoShape::Sawtooth; break; + case 1: vco_shape = VcoShape::Triangle; break; + case 2: vco_shape = VcoShape::Square; break; + case 3: vco_shape = VcoShape::RoundSquare; break; + case 4: vco_shape = VcoShape::Moog; break; + case 5: vco_shape = VcoShape::Sine; break; + case 6: vco_shape = VcoShape::Exponential; break; + case 7: vco_shape = VcoShape::WhiteNoise; break; + case 8: vco_shape = VcoShape::BLSawtooth; break; + case 9: vco_shape = VcoShape::BLSquare; break; + case 10: vco_shape = VcoShape::BLTriangle; break; + case 11: vco_shape = VcoShape::BLMoog; break; + default: vco_shape = VcoShape::Sawtooth; break; } // add vco_shape_param the changes the shape of each curve. // merge sawtooths with triangle and square with round square? switch (vco_shape) { - case SAWTOOTH: // p0: curviness of line + case VcoShape::Sawtooth: // p0: curviness of line vco_k = vco_c; // Is this sawtooth backwards? break; - case TRIANGLE: // p0: duty rev.saw<->triangle<->saw p1: curviness + case VcoShape::Triangle: // p0: duty rev.saw<->triangle<->saw p1: curviness vco_k = (vco_c*2.0)+0.5; if (vco_k>0.5) vco_k = 1.0- vco_k; break; - case SQUARE: // p0: slope of top + case VcoShape::Square: // p0: slope of top vco_k = (vco_c<0)?0.5:-0.5; break; - case ROUND_SQUARE: // p0: width of round + case VcoShape::RoundSquare: // p0: width of round vco_k = (vco_c<0)?(sqrtf(1-(vco_c*vco_c*4))-0.5):-0.5; break; - case MOOG: // Maybe the fall should be exponential/sinsoidal instead of quadric. + case VcoShape::Moog: // Maybe the fall should be exponential/sinsoidal instead of quadric. // [-0.5, 0]: Rise, [0,0.25]: Slope down, [0.25,0.5]: Low vco_k = (vco_c*2.0)+0.5; if (vco_k>1.0) { @@ -572,33 +572,33 @@ int Lb302Synth::process(sampleFrame *outbuf, const int size) vco_k *= 2.0; // MOOG wave gets filtered away break; - case SINE: + case VcoShape::Sine: // [-0.5, 0.5] : [-pi, pi] vco_k = 0.5f * Oscillator::sinSample( vco_c ); break; - case EXPONENTIAL: + case VcoShape::Exponential: vco_k = 0.5 * Oscillator::expSample( vco_c ); break; - case WHITE_NOISE: + case VcoShape::WhiteNoise: vco_k = 0.5 * Oscillator::noiseSample( vco_c ); break; - case BL_SAWTOOTH: - vco_k = BandLimitedWave::oscillate( vco_c + 0.5f, BandLimitedWave::pdToLen( vco_inc ), BandLimitedWave::BLSaw ) * 0.5f; + case VcoShape::BLSawtooth: + vco_k = BandLimitedWave::oscillate( vco_c + 0.5f, BandLimitedWave::pdToLen( vco_inc ), BandLimitedWave::Waveform::BLSaw ) * 0.5f; break; - case BL_SQUARE: - vco_k = BandLimitedWave::oscillate( vco_c + 0.5f, BandLimitedWave::pdToLen( vco_inc ), BandLimitedWave::BLSquare ) * 0.5f; + case VcoShape::BLSquare: + vco_k = BandLimitedWave::oscillate( vco_c + 0.5f, BandLimitedWave::pdToLen( vco_inc ), BandLimitedWave::Waveform::BLSquare ) * 0.5f; break; - case BL_TRIANGLE: - vco_k = BandLimitedWave::oscillate( vco_c + 0.5f, BandLimitedWave::pdToLen( vco_inc ), BandLimitedWave::BLTriangle ) * 0.5f; + case VcoShape::BLTriangle: + vco_k = BandLimitedWave::oscillate( vco_c + 0.5f, BandLimitedWave::pdToLen( vco_inc ), BandLimitedWave::Waveform::BLTriangle ) * 0.5f; break; - case BL_MOOG: - vco_k = BandLimitedWave::oscillate( vco_c + 0.5f, BandLimitedWave::pdToLen( vco_inc ), BandLimitedWave::BLMoog ); + case VcoShape::BLMoog: + vco_k = BandLimitedWave::oscillate( vco_c + 0.5f, BandLimitedWave::pdToLen( vco_inc ), BandLimitedWave::Waveform::BLMoog ); break; } @@ -633,18 +633,18 @@ int Lb302Synth::process(sampleFrame *outbuf, const int size) } // Handle Envelope - if(vca_mode==attack) { + if(vca_mode==VcaMode::Attack) { vca_a+=(vca_a0-vca_a)*vca_attack; if(sample_cnt>=0.5*Engine::audioEngine()->processingSampleRate()) - vca_mode = idle; + vca_mode = VcaMode::Idle; } - else if(vca_mode == decay) { + else if(vca_mode == VcaMode::Decay) { vca_a *= vca_decay; // the following line actually speeds up processing if(vca_a < (1/65536.0)) { vca_a = 0; - vca_mode = never_played; + vca_mode = VcaMode::NeverPlayed; } } @@ -666,15 +666,15 @@ void Lb302Synth::initNote( Lb302Note *n) // Always reset vca on non-dead notes, and // Only reset vca on decaying(decayed) and never-played - if(n->dead == 0 || (vca_mode == decay || vca_mode == never_played)) { + if(n->dead == 0 || (vca_mode == VcaMode::Decay || vca_mode == VcaMode::NeverPlayed)) { //printf(" good\n"); sample_cnt = 0; - vca_mode = attack; + vca_mode = VcaMode::Attack; // LB303: //vca_a = 0; } else { - vca_mode = idle; + vca_mode = VcaMode::Idle; } initSlide(); @@ -819,22 +819,22 @@ Lb302SynthView::Lb302SynthView( Instrument * _instrument, QWidget * _parent ) : InstrumentViewFixedSize( _instrument, _parent ) { // GUI - m_vcfCutKnob = new Knob( knobBright_26, this ); + m_vcfCutKnob = new Knob( KnobType::Bright26, this ); m_vcfCutKnob->move( 75, 130 ); m_vcfCutKnob->setHintText( tr( "Cutoff Freq:" ), "" ); m_vcfCutKnob->setLabel( "" ); - m_vcfResKnob = new Knob( knobBright_26, this ); + m_vcfResKnob = new Knob( KnobType::Bright26, this ); m_vcfResKnob->move( 120, 130 ); m_vcfResKnob->setHintText( tr( "Resonance:" ), "" ); m_vcfResKnob->setLabel( "" ); - m_vcfModKnob = new Knob( knobBright_26, this ); + m_vcfModKnob = new Knob( KnobType::Bright26, this ); m_vcfModKnob->move( 165, 130 ); m_vcfModKnob->setHintText( tr( "Env Mod:" ), "" ); m_vcfModKnob->setLabel( "" ); - m_vcfDecKnob = new Knob( knobBright_26, this ); + m_vcfDecKnob = new Knob( KnobType::Bright26, this ); m_vcfDecKnob->move( 210, 130 ); m_vcfDecKnob->setHintText( tr( "Decay:" ), "" ); m_vcfDecKnob->setLabel( "" ); @@ -855,12 +855,12 @@ Lb302SynthView::Lb302SynthView( Instrument * _instrument, QWidget * _parent ) : tr( "303-es-que, 24dB/octave, 3 pole filter" ) ); - m_slideDecKnob = new Knob( knobBright_26, this ); + m_slideDecKnob = new Knob( KnobType::Bright26, this ); m_slideDecKnob->move( 210, 75 ); m_slideDecKnob->setHintText( tr( "Slide Decay:" ), "" ); m_slideDecKnob->setLabel( ""); - m_distKnob = new Knob( knobBright_26, this ); + m_distKnob = new Knob( KnobType::Bright26, this ); m_distKnob->move( 210, 190 ); m_distKnob->setHintText( tr( "DIST:" ), "" ); m_distKnob->setLabel( tr( "")); diff --git a/plugins/Lb302/Lb302.h b/plugins/Lb302/Lb302.h index 3abece98ff3..237a3f3f8be 100644 --- a/plugins/Lb302/Lb302.h +++ b/plugins/Lb302/Lb302.h @@ -165,7 +165,7 @@ class Lb302Synth : public Instrument Flags flags() const override { - return IsSingleStreamed; + return Flag::IsSingleStreamed; } f_cnt_t desiredReleaseFrames() const override @@ -213,9 +213,9 @@ public slots: vco_slideinc, //* Slide base to use in next node. Nonzero=slide next note vco_slidebase; //* The base vco_inc while sliding. - enum vco_shape_t { SAWTOOTH, SQUARE, TRIANGLE, MOOG, ROUND_SQUARE, SINE, EXPONENTIAL, WHITE_NOISE, - BL_SAWTOOTH, BL_SQUARE, BL_TRIANGLE, BL_MOOG }; - vco_shape_t vco_shape; + enum class VcoShape { Sawtooth, Square, Triangle, Moog, RoundSquare, Sine, Exponential, WhiteNoise, + BLSawtooth, BLSquare, BLTriangle, BLMoog }; + VcoShape vco_shape; // Filters (just keep both loaded and switch) Lb302Filter* vcfs[NUM_FILTERS]; @@ -235,14 +235,14 @@ public slots: vca_a; // Amplifier coefficient. // Envelope State - enum VCA_Mode + enum class VcaMode { - attack = 0, - decay = 1, - idle = 2, - never_played = 3 + Attack = 0, + Decay = 1, + Idle = 2, + NeverPlayed = 3 }; - VCA_Mode vca_mode; + VcaMode vca_mode; // My hacks int sample_cnt; diff --git a/plugins/Lv2Effect/Lv2Effect.cpp b/plugins/Lv2Effect/Lv2Effect.cpp index ec2dc1f4814..9c21b3f2a4f 100644 --- a/plugins/Lv2Effect/Lv2Effect.cpp +++ b/plugins/Lv2Effect/Lv2Effect.cpp @@ -46,10 +46,10 @@ Plugin::Descriptor PLUGIN_EXPORT lv2effect_plugin_descriptor = "plugin for using arbitrary LV2-effects inside LMMS."), "Johannes Lorenz ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, - new Lv2SubPluginFeatures(Plugin::Effect) + new Lv2SubPluginFeatures(Plugin::Type::Effect) }; } diff --git a/plugins/Lv2Instrument/Lv2Instrument.cpp b/plugins/Lv2Instrument/Lv2Instrument.cpp index 05244584466..1e45f4e919e 100644 --- a/plugins/Lv2Instrument/Lv2Instrument.cpp +++ b/plugins/Lv2Instrument/Lv2Instrument.cpp @@ -55,10 +55,10 @@ Plugin::Descriptor PLUGIN_EXPORT lv2instrument_plugin_descriptor = "plugin for using arbitrary LV2 instruments inside LMMS."), "Johannes Lorenz ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader("logo"), nullptr, - new Lv2SubPluginFeatures(Plugin::Instrument) + new Lv2SubPluginFeatures(Plugin::Type::Instrument) }; } @@ -97,7 +97,7 @@ Lv2Instrument::Lv2Instrument(InstrumentTrack *instrumentTrackArg, Lv2Instrument::~Lv2Instrument() { Engine::audioEngine()->removePlayHandlesOfTypes(instrumentTrack(), - PlayHandle::TypeNotePlayHandle | PlayHandle::TypeInstrumentPlayHandle); + PlayHandle::Type::NotePlayHandle | PlayHandle::Type::InstrumentPlayHandle); } diff --git a/plugins/Lv2Instrument/Lv2Instrument.h b/plugins/Lv2Instrument/Lv2Instrument.h index 7b521e1b070..2cd73632da2 100644 --- a/plugins/Lv2Instrument/Lv2Instrument.h +++ b/plugins/Lv2Instrument/Lv2Instrument.h @@ -89,9 +89,9 @@ class Lv2Instrument : public Instrument, public Lv2ControlBase Flags flags() const override { #ifdef LV2_INSTRUMENT_USE_MIDI - return IsSingleStreamed | IsMidiBased; + return Flag::IsSingleStreamed | Flag::IsMidiBased; #else - return IsSingleStreamed; + return Flag::IsSingleStreamed; #endif } gui::PluginView* instantiateView(QWidget *parent) override; diff --git a/plugins/MidiExport/MidiExport.cpp b/plugins/MidiExport/MidiExport.cpp index 0d18d8ae156..df968e36ab3 100644 --- a/plugins/MidiExport/MidiExport.cpp +++ b/plugins/MidiExport/MidiExport.cpp @@ -51,7 +51,7 @@ Plugin::Descriptor PLUGIN_EXPORT midiexport_plugin_descriptor = "Mohamed Abdel Maksoud and " "Hyunjin Song ", 0x0100, - Plugin::ExportFilter, + Plugin::Type::ExportFilter, nullptr, nullptr, nullptr, @@ -84,8 +84,8 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, auto buffer = std::array{}; uint32_t size; - for (const Track* track : tracks) if (track->type() == Track::InstrumentTrack) nTracks++; - for (const Track* track : patternStoreTracks) if (track->type() == Track::InstrumentTrack) nTracks++; + for (const Track* track : tracks) if (track->type() == Track::Type::Instrument) nTracks++; + for (const Track* track : patternStoreTracks) if (track->type() == Track::Type::Instrument) nTracks++; // midi header MidiFile::MIDIHeader header(nTracks); @@ -97,10 +97,10 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, // midi tracks for (Track* track : tracks) { - DataFile dataFile(DataFile::SongProject); + DataFile dataFile(DataFile::Type::SongProject); MTrack mtrack; - if (track->type() == Track::InstrumentTrack) + if (track->type() == Track::Type::Instrument) { mtrack.addName(track->name().toStdString(), 0); @@ -143,7 +143,7 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, midiout.writeRawData((char *)buffer.data(), size); } - if (track->type() == Track::PatternTrack) + if (track->type() == Track::Type::Pattern) { patternTrack = dynamic_cast(track); element = patternTrack->saveState(dataFile, dataFile.content()); @@ -169,7 +169,7 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, // for each instrument in the pattern editor for (Track* track : patternStoreTracks) { - DataFile dataFile(DataFile::SongProject); + DataFile dataFile(DataFile::Type::SongProject); MTrack mtrack; // begin at the first pattern track (first pattern) @@ -177,7 +177,7 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, std::vector> st; - if (track->type() != Track::InstrumentTrack) continue; + if (track->type() != Track::Type::Instrument) continue; mtrack.addName(track->name().toStdString(), 0); //mtrack.addProgramChange(0, 0); diff --git a/plugins/MidiImport/MidiImport.cpp b/plugins/MidiImport/MidiImport.cpp index 6836060f3fa..785cd079af0 100644 --- a/plugins/MidiImport/MidiImport.cpp +++ b/plugins/MidiImport/MidiImport.cpp @@ -71,7 +71,7 @@ Plugin::Descriptor PLUGIN_EXPORT midiimport_plugin_descriptor = "Filter for importing MIDI-files into LMMS" ), "Tobias Doerffel ", 0x0100, - Plugin::ImportFilter, + Plugin::Type::ImportFilter, nullptr, nullptr, nullptr, @@ -165,7 +165,7 @@ class smfMidiCC // in the main thread. This should probably be // removed if that ever changes. qApp->processEvents(); - at = dynamic_cast( Track::create( Track::AutomationTrack, tc ) ); + at = dynamic_cast( Track::create( Track::Type::Automation, tc ) ); } if( tn != "") { at->setName( tn ); @@ -227,7 +227,7 @@ class smfMidiChannel if( !it ) { // Keep LMMS responsive qApp->processEvents(); - it = dynamic_cast( Track::create( Track::InstrumentTrack, tc ) ); + it = dynamic_cast( Track::create( Track::Type::Instrument, tc ) ); #ifdef LMMS_HAVE_FLUIDSYNTH it_inst = it->loadInstrument( "sf2player" ); @@ -328,9 +328,9 @@ bool MidiImport::readSMF( TrackContainer* tc ) // NOTE: unordered_map::operator[] creates a new element if none exists MeterModel & timeSigMM = Engine::getSong()->getTimeSigModel(); - auto nt = dynamic_cast(Track::create(Track::AutomationTrack, Engine::getSong())); + auto nt = dynamic_cast(Track::create(Track::Type::Automation, Engine::getSong())); nt->setName(tr("MIDI Time Signature Numerator")); - auto dt = dynamic_cast(Track::create(Track::AutomationTrack, Engine::getSong())); + auto dt = dynamic_cast(Track::create(Track::Type::Automation, Engine::getSong())); dt->setName(tr("MIDI Time Signature Denominator")); auto timeSigNumeratorPat = new AutomationClip(nt); timeSigNumeratorPat->setDisplayName(tr("Numerator")); @@ -358,7 +358,7 @@ bool MidiImport::readSMF( TrackContainer* tc ) pd.setValue( 2 ); // Tempo stuff - auto tt = dynamic_cast(Track::create(Track::AutomationTrack, Engine::getSong())); + auto tt = dynamic_cast(Track::create(Track::Type::Automation, Engine::getSong())); tt->setName(tr("Tempo")); auto tap = new AutomationClip(tt); tap->setDisplayName(tr("Tempo")); diff --git a/plugins/Monstro/Monstro.cpp b/plugins/Monstro/Monstro.cpp index 10dbf5b1fa4..f588d6b786d 100644 --- a/plugins/Monstro/Monstro.cpp +++ b/plugins/Monstro/Monstro.cpp @@ -53,7 +53,7 @@ Plugin::Descriptor PLUGIN_EXPORT monstro_plugin_descriptor = "Monstrous 3-oscillator synth with modulation matrix" ), "Vesa Kivimäki ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), nullptr, nullptr, diff --git a/plugins/Monstro/Monstro.h b/plugins/Monstro/Monstro.h index 319b7e000f9..21efedaf314 100644 --- a/plugins/Monstro/Monstro.h +++ b/plugins/Monstro/Monstro.h @@ -43,14 +43,14 @@ // #define makeknob( name, x, y, hint, unit, oname ) \ - name = new Knob( knobStyled, view ); \ + name = new Knob( KnobType::Styled, view ); \ name ->move( x, y ); \ name ->setHintText( hint, unit ); \ name ->setObjectName( oname ); \ name ->setFixedSize( 20, 20 ); #define maketsknob( name, x, y, hint, unit, oname ) \ - name = new TempoSyncKnob( knobStyled, view ); \ + name = new TempoSyncKnob( KnobType::Styled, view ); \ name ->move( x, y ); \ name ->setHintText( hint, unit ); \ name ->setObjectName( oname ); \ @@ -211,19 +211,19 @@ class MonstroSynth break; case WAVE_TRI: //return Oscillator::triangleSample( _ph ); - return BandLimitedWave::oscillate( _ph, _wavelen, BandLimitedWave::BLTriangle ); + return BandLimitedWave::oscillate( _ph, _wavelen, BandLimitedWave::Waveform::BLTriangle ); break; case WAVE_SAW: //return Oscillator::sawSample( _ph ); - return BandLimitedWave::oscillate( _ph, _wavelen, BandLimitedWave::BLSaw ); + return BandLimitedWave::oscillate( _ph, _wavelen, BandLimitedWave::Waveform::BLSaw ); break; case WAVE_RAMP: //return Oscillator::sawSample( _ph ) * -1.0; - return BandLimitedWave::oscillate( _ph, _wavelen, BandLimitedWave::BLSaw ) * -1.0; + return BandLimitedWave::oscillate( _ph, _wavelen, BandLimitedWave::Waveform::BLSaw ) * -1.0; break; case WAVE_SQR: //return Oscillator::squareSample( _ph ); - return BandLimitedWave::oscillate( _ph, _wavelen, BandLimitedWave::BLSquare ); + return BandLimitedWave::oscillate( _ph, _wavelen, BandLimitedWave::Waveform::BLSquare ); break; case WAVE_SQRSOFT: { @@ -236,7 +236,7 @@ class MonstroSynth } case WAVE_MOOG: //return Oscillator::moogSawSample( _ph ); - return BandLimitedWave::oscillate( _ph, _wavelen, BandLimitedWave::BLMoog ); + return BandLimitedWave::oscillate( _ph, _wavelen, BandLimitedWave::Waveform::BLMoog ); break; case WAVE_SINABS: return qAbs( Oscillator::sinSample( _ph ) ); diff --git a/plugins/MultitapEcho/MultitapEcho.cpp b/plugins/MultitapEcho/MultitapEcho.cpp index 05c3f30fe38..4f5e9fdf8b3 100644 --- a/plugins/MultitapEcho/MultitapEcho.cpp +++ b/plugins/MultitapEcho/MultitapEcho.cpp @@ -41,7 +41,7 @@ Plugin::Descriptor PLUGIN_EXPORT multitapecho_plugin_descriptor = QT_TRANSLATE_NOOP( "PluginBrowser", "A multitap echo delay plugin" ), "Vesa Kivimäki ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader( "logo" ), nullptr, nullptr, diff --git a/plugins/MultitapEcho/MultitapEchoControlDialog.cpp b/plugins/MultitapEcho/MultitapEchoControlDialog.cpp index dbf428e5f42..e89137bf0b7 100644 --- a/plugins/MultitapEcho/MultitapEchoControlDialog.cpp +++ b/plugins/MultitapEcho/MultitapEchoControlDialog.cpp @@ -48,8 +48,8 @@ MultitapEchoControlDialog::MultitapEchoControlDialog( MultitapEchoControls * con // graph widgets - auto ampGraph = new Graph(this, Graph::BarStyle, 204, 105); - auto lpGraph = new Graph(this, Graph::BarStyle, 204, 105); + auto ampGraph = new Graph(this, Graph::Style::Bar, 204, 105); + auto lpGraph = new Graph(this, Graph::Style::Bar, 204, 105); ampGraph->move( 30, 10 ); lpGraph->move( 30, 125 ); @@ -78,26 +78,26 @@ MultitapEchoControlDialog::MultitapEchoControlDialog( MultitapEchoControls * con // knobs - auto stepLength = new TempoSyncKnob(knobBright_26, this); + auto stepLength = new TempoSyncKnob(KnobType::Bright26, this); stepLength->move( 100, 245 ); stepLength->setModel( & controls->m_stepLength ); stepLength->setLabel( tr( "Length" ) ); stepLength->setHintText( tr( "Step length:" ) , " ms" ); - auto dryGain = new Knob(knobBright_26, this); + auto dryGain = new Knob(KnobType::Bright26, this); dryGain->move( 150, 245 ); dryGain->setModel( & controls->m_dryGain ); dryGain->setLabel( tr( "Dry" ) ); dryGain->setHintText( tr( "Dry gain:" ) , " dBFS" ); - auto stages = new Knob(knobBright_26, this); + auto stages = new Knob(KnobType::Bright26, this); stages->move( 200, 245 ); stages->setModel( & controls->m_stages ); stages->setLabel( tr( "Stages" ) ); stages->setHintText( tr( "Low-pass stages:" ) , "x" ); // switch led - auto swapInputs = new LedCheckBox("Swap inputs", this, tr("Swap inputs"), LedCheckBox::Green); + auto swapInputs = new LedCheckBox("Swap inputs", this, tr("Swap inputs"), LedCheckBox::LedColor::Green); swapInputs->move( 20, 275 ); swapInputs->setModel( & controls->m_swapInputs ); swapInputs->setToolTip(tr("Swap left and right input channels for reflections")); diff --git a/plugins/Nes/Nes.cpp b/plugins/Nes/Nes.cpp index 4260bca1ad4..a530ac19b3b 100644 --- a/plugins/Nes/Nes.cpp +++ b/plugins/Nes/Nes.cpp @@ -51,7 +51,7 @@ Plugin::Descriptor PLUGIN_EXPORT nes_plugin_descriptor = "A NES-like synthesizer" ), "Vesa Kivimäki ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), nullptr, nullptr, diff --git a/plugins/Nes/Nes.h b/plugins/Nes/Nes.h index 91e5e556c51..3ddf0fc9a0d 100644 --- a/plugins/Nes/Nes.h +++ b/plugins/Nes/Nes.h @@ -35,7 +35,7 @@ #define makeknob( name, x, y, hint, unit, oname ) \ - name = new Knob( knobStyled, this ); \ + name = new Knob( KnobType::Styled, this ); \ name ->move( x, y ); \ name ->setHintText( hint, unit ); \ name ->setObjectName( oname ); \ diff --git a/plugins/OpulenZ/OpulenZ.cpp b/plugins/OpulenZ/OpulenZ.cpp index 3a18c1e3fd4..64f60999576 100644 --- a/plugins/OpulenZ/OpulenZ.cpp +++ b/plugins/OpulenZ/OpulenZ.cpp @@ -73,7 +73,7 @@ Plugin::Descriptor PLUGIN_EXPORT opulenz_plugin_descriptor = "2-operator FM Synth" ), "Raine M. Ekman ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), "sbi", nullptr, @@ -222,8 +222,8 @@ OpulenzInstrument::OpulenzInstrument( InstrumentTrack * _instrument_track ) : OpulenzInstrument::~OpulenzInstrument() { delete theEmulator; Engine::audioEngine()->removePlayHandlesOfTypes( instrumentTrack(), - PlayHandle::TypeNotePlayHandle - | PlayHandle::TypeInstrumentPlayHandle ); + PlayHandle::Type::NotePlayHandle + | PlayHandle::Type::InstrumentPlayHandle ); delete [] renderbuffer; } @@ -686,7 +686,7 @@ OpulenzInstrumentView::OpulenzInstrumentView( Instrument * _instrument, { #define KNOB_GEN(knobname, hinttext, hintunit,xpos,ypos) \ - knobname = new Knob( knobStyled, this );\ + knobname = new Knob( KnobType::Styled, this );\ knobname->setHintText( tr(hinttext), hintunit );\ knobname->setFixedSize(22,22);\ knobname->setCenterPointX(11.0);\ diff --git a/plugins/OpulenZ/OpulenZ.h b/plugins/OpulenZ/OpulenZ.h index 1f999252fa7..a3e11a6c0fc 100644 --- a/plugins/OpulenZ/OpulenZ.h +++ b/plugins/OpulenZ/OpulenZ.h @@ -66,7 +66,7 @@ class OpulenzInstrument : public Instrument Flags flags() const override { - return IsSingleStreamed | IsMidiBased; + return Flag::IsSingleStreamed | Flag::IsMidiBased; } bool handleMidiEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset = 0 ) override; diff --git a/plugins/Organic/Organic.cpp b/plugins/Organic/Organic.cpp index 476b249612a..f8a2b0d135c 100644 --- a/plugins/Organic/Organic.cpp +++ b/plugins/Organic/Organic.cpp @@ -52,7 +52,7 @@ Plugin::Descriptor PLUGIN_EXPORT organic_plugin_descriptor = "Additive Synthesizer for organ-like sounds" ), "Andreas Brandmaier ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), nullptr, nullptr, @@ -74,7 +74,9 @@ float * OrganicInstrument::s_harmonics = nullptr; OrganicInstrument::OrganicInstrument( InstrumentTrack * _instrument_track ) : Instrument( _instrument_track, &organic_plugin_descriptor ), - m_modulationAlgo( Oscillator::SignalMix, Oscillator::SignalMix, Oscillator::SignalMix), + m_modulationAlgo(static_cast(Oscillator::ModulationAlgo::SignalMix), + static_cast(Oscillator::ModulationAlgo::SignalMix), + static_cast(Oscillator::ModulationAlgo::SignalMix)), m_fx1Model( 0.0f, 0.0f, 0.99f, 0.01f , this, tr( "Distortion" ) ), m_volModel( 100.0f, 0.0f, 200.0f, 1.0f, this, tr( "Volume" ) ) { @@ -403,7 +405,7 @@ class OrganicKnob : public Knob { public: OrganicKnob( QWidget * _parent ) : - Knob( knobStyled, _parent ) + Knob( KnobType::Styled, _parent ) { setFixedSize( 21, 21 ); } @@ -506,7 +508,7 @@ void OrganicInstrumentView::modelChanged() oscKnob->setHintText( tr( "Osc %1 waveform:" ).arg( i + 1 ), QString() ); // setup volume-knob - auto volKnob = new Knob(knobStyled, this); + auto volKnob = new Knob(KnobType::Styled, this); volKnob->setVolumeKnob( true ); volKnob->move( x + i * colWidth, y + rowHeight*1 ); volKnob->setFixedSize( 21, 21 ); @@ -560,7 +562,7 @@ void OrganicInstrumentView::updateKnobHint() OscillatorObject::OscillatorObject( Model * _parent, int _index ) : Model( _parent ), - m_waveShape( Oscillator::SineWave, 0, Oscillator::NumWaveShapes-1, this ), + m_waveShape( static_cast(Oscillator::WaveShape::Sine), 0, Oscillator::NumWaveShapes-1, this ), m_oscModel( 0.0f, 0.0f, 5.0f, 1.0f, this, tr( "Osc %1 waveform" ).arg( _index + 1 ) ), m_harmModel( static_cast( _index ), 0.0f, 17.0f, 1.0f, @@ -582,15 +584,15 @@ void OscillatorObject::oscButtonChanged() static auto shapes = std::array { - Oscillator::SineWave, - Oscillator::SawWave, - Oscillator::SquareWave, - Oscillator::TriangleWave, - Oscillator::MoogSawWave, - Oscillator::ExponentialWave + Oscillator::WaveShape::Sine, + Oscillator::WaveShape::Saw, + Oscillator::WaveShape::Square, + Oscillator::WaveShape::Triangle, + Oscillator::WaveShape::MoogSaw, + Oscillator::WaveShape::Exponential } ; - m_waveShape.setValue( shapes[(int)roundf( m_oscModel.value() )] ); + m_waveShape.setValue( static_cast(shapes[(int)roundf( m_oscModel.value() )]) ); } diff --git a/plugins/Patman/Patman.cpp b/plugins/Patman/Patman.cpp index 7bcd46dcb9b..a2b829940a4 100644 --- a/plugins/Patman/Patman.cpp +++ b/plugins/Patman/Patman.cpp @@ -61,7 +61,7 @@ Plugin::Descriptor PLUGIN_EXPORT patman_plugin_descriptor = "GUS-compatible patch instrument" ), "Javier Serrano Polo ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), "pat", nullptr, @@ -154,7 +154,7 @@ void PatmanInstrument::playNote( NotePlayHandle * _n, hdata->sample->frequency(); if( hdata->sample->play( _working_buffer + offset, hdata->state, frames, - play_freq, m_loopedModel.value() ? SampleBuffer::LoopOn : SampleBuffer::LoopOff ) ) + play_freq, m_loopedModel.value() ? SampleBuffer::LoopMode::On : SampleBuffer::LoopMode::Off ) ) { applyRelease( _working_buffer, _n ); instrumentTrack()->processAudioBuffer( _working_buffer, @@ -201,8 +201,8 @@ void PatmanInstrument::setFile( const QString & _patch_file, bool _rename ) // named it self m_patchFile = PathUtil::toShortestRelative( _patch_file ); - LoadErrors error = loadPatch( PathUtil::toAbsolute( _patch_file ) ); - if( error ) + LoadError error = loadPatch( PathUtil::toAbsolute( _patch_file ) ); + if( error != LoadError::OK ) { printf("Load error\n"); } @@ -213,7 +213,7 @@ void PatmanInstrument::setFile( const QString & _patch_file, bool _rename ) -PatmanInstrument::LoadErrors PatmanInstrument::loadPatch( +PatmanInstrument::LoadError PatmanInstrument::loadPatch( const QString & _filename ) { unloadCurrentPatch(); @@ -222,7 +222,7 @@ PatmanInstrument::LoadErrors PatmanInstrument::loadPatch( if( !fd ) { perror( "fopen" ); - return( LoadOpen ); + return( LoadError::Open ); } auto header = std::array{}; @@ -232,19 +232,19 @@ PatmanInstrument::LoadErrors PatmanInstrument::loadPatch( && memcmp(header.data(), "GF1PATCH100\0ID#000002", 22))) { fclose( fd ); - return( LoadNotGUS ); + return( LoadError::NotGUS ); } if( header[82] != 1 && header[82] != 0 ) { fclose( fd ); - return( LoadInstruments ); + return( LoadError::Instruments ); } if( header[151] != 1 && header[151] != 0 ) { fclose( fd ); - return( LoadLayers ); + return( LoadError::Layers ); } int sample_count = header[198]; @@ -256,14 +256,14 @@ PatmanInstrument::LoadErrors PatmanInstrument::loadPatch( if ( fseek( fd, x, SEEK_CUR ) == -1 ) \ { \ fclose( fd ); \ - return( LoadIO ); \ + return( LoadError::IO ); \ } #define READ_SHORT( x ) \ if ( fread( &tmpshort, 2, 1, fd ) != 1 ) \ { \ fclose( fd ); \ - return( LoadIO ); \ + return( LoadError::IO ); \ } \ x = (unsigned short)swap16IfBE( tmpshort ); @@ -271,7 +271,7 @@ PatmanInstrument::LoadErrors PatmanInstrument::loadPatch( if ( fread( &x, 4, 1, fd ) != 1 ) \ { \ fclose( fd ); \ - return( LoadIO ); \ + return( LoadError::IO ); \ } \ x = (unsigned)swap32IfBE( x ); @@ -295,7 +295,7 @@ PatmanInstrument::LoadErrors PatmanInstrument::loadPatch( if ( fread( &modes, 1, 1, fd ) != 1 ) { fclose( fd ); - return( LoadIO ); + return( LoadError::IO ); } // skip scale frequency, scale factor, reserved space SKIP_BYTES( 2 + 2 + 36 ); @@ -313,7 +313,7 @@ PatmanInstrument::LoadErrors PatmanInstrument::loadPatch( { delete[] wave_samples; fclose( fd ); - return( LoadIO ); + return( LoadError::IO ); } sample = swap16IfBE( sample ); if( modes & MODES_UNSIGNED ) @@ -337,7 +337,7 @@ PatmanInstrument::LoadErrors PatmanInstrument::loadPatch( { delete[] wave_samples; fclose( fd ); - return( LoadIO ); + return( LoadError::IO ); } if( modes & MODES_UNSIGNED ) { @@ -374,7 +374,7 @@ PatmanInstrument::LoadErrors PatmanInstrument::loadPatch( delete[] data; } fclose( fd ); - return( LoadOK ); + return( LoadError::OK ); } diff --git a/plugins/Patman/Patman.h b/plugins/Patman/Patman.h index acdf4f7efa1..3a15db5f362 100644 --- a/plugins/Patman/Patman.h +++ b/plugins/Patman/Patman.h @@ -98,17 +98,17 @@ public slots: BoolModel m_tunedModel; - enum LoadErrors + enum class LoadError { - LoadOK, - LoadOpen, - LoadNotGUS, - LoadInstruments, - LoadLayers, - LoadIO + OK, + Open, + NotGUS, + Instruments, + Layers, + IO } ; - LoadErrors loadPatch( const QString & _filename ); + LoadError loadPatch( const QString & _filename ); void unloadCurrentPatch(); void selectSample( NotePlayHandle * _n ); diff --git a/plugins/PeakControllerEffect/PeakControllerEffect.cpp b/plugins/PeakControllerEffect/PeakControllerEffect.cpp index bd99631b78b..7aff6f8033e 100644 --- a/plugins/PeakControllerEffect/PeakControllerEffect.cpp +++ b/plugins/PeakControllerEffect/PeakControllerEffect.cpp @@ -48,7 +48,7 @@ Plugin::Descriptor PLUGIN_EXPORT peakcontrollereffect_plugin_descriptor = "Plugin for controlling knobs with sound peaks" ), "Paul Giblock ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, nullptr, diff --git a/plugins/PeakControllerEffect/PeakControllerEffectControlDialog.cpp b/plugins/PeakControllerEffect/PeakControllerEffectControlDialog.cpp index 69566a86c27..e44d5bcc246 100644 --- a/plugins/PeakControllerEffect/PeakControllerEffectControlDialog.cpp +++ b/plugins/PeakControllerEffect/PeakControllerEffectControlDialog.cpp @@ -49,32 +49,32 @@ PeakControllerEffectControlDialog::PeakControllerEffectControlDialog( setPalette( pal ); setFixedSize( 240, 80 ); - m_baseKnob = new Knob( knobBright_26, this ); + m_baseKnob = new Knob( KnobType::Bright26, this ); m_baseKnob->setLabel( tr( "BASE" ) ); m_baseKnob->setModel( &_controls->m_baseModel ); m_baseKnob->setHintText( tr( "Base:" ) , "" ); - m_amountKnob = new Knob( knobBright_26, this ); + m_amountKnob = new Knob( KnobType::Bright26, this ); m_amountKnob->setLabel( tr( "AMNT" ) ); m_amountKnob->setModel( &_controls->m_amountModel ); m_amountKnob->setHintText( tr( "Modulation amount:" ) , "" ); - m_amountMultKnob = new Knob( knobBright_26, this ); + m_amountMultKnob = new Knob( KnobType::Bright26, this ); m_amountMultKnob->setLabel( tr( "MULT" ) ); m_amountMultKnob->setModel( &_controls->m_amountMultModel ); m_amountMultKnob->setHintText( tr( "Amount multiplicator:" ) , "" ); - m_attackKnob = new Knob( knobBright_26, this ); + m_attackKnob = new Knob( KnobType::Bright26, this ); m_attackKnob->setLabel( tr( "ATCK" ) ); m_attackKnob->setModel( &_controls->m_attackModel ); m_attackKnob->setHintText( tr( "Attack:" ) , "" ); - m_decayKnob = new Knob( knobBright_26, this ); + m_decayKnob = new Knob( KnobType::Bright26, this ); m_decayKnob->setLabel( tr( "DCAY" ) ); m_decayKnob->setModel( &_controls->m_decayModel ); m_decayKnob->setHintText( tr( "Release:" ) , "" ); - m_tresholdKnob = new Knob( knobBright_26, this ); + m_tresholdKnob = new Knob( KnobType::Bright26, this ); m_tresholdKnob->setLabel( tr( "TRSH" ) ); m_tresholdKnob->setModel( &_controls->m_tresholdModel ); m_tresholdKnob->setHintText( tr( "Treshold:" ) , "" ); diff --git a/plugins/ReverbSC/ReverbSC.cpp b/plugins/ReverbSC/ReverbSC.cpp index e8dec8fd731..9006f8c9f21 100644 --- a/plugins/ReverbSC/ReverbSC.cpp +++ b/plugins/ReverbSC/ReverbSC.cpp @@ -42,7 +42,7 @@ Plugin::Descriptor PLUGIN_EXPORT reverbsc_plugin_descriptor = QT_TRANSLATE_NOOP( "PluginBrowser", "Reverb algorithm by Sean Costello" ), "Paul Batchelor", 0x0123, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader( "logo" ), nullptr, nullptr, diff --git a/plugins/ReverbSC/ReverbSCControlDialog.cpp b/plugins/ReverbSC/ReverbSCControlDialog.cpp index c9ddef38406..615d3823e60 100644 --- a/plugins/ReverbSC/ReverbSCControlDialog.cpp +++ b/plugins/ReverbSC/ReverbSCControlDialog.cpp @@ -42,25 +42,25 @@ ReverbSCControlDialog::ReverbSCControlDialog( ReverbSCControls* controls ) : setPalette( pal ); setFixedSize( 185, 55 ); - auto inputGainKnob = new Knob(knobBright_26, this); + auto inputGainKnob = new Knob(KnobType::Bright26, this); inputGainKnob -> move( 16, 10 ); inputGainKnob->setModel( &controls->m_inputGainModel ); inputGainKnob->setLabel( tr( "Input" ) ); inputGainKnob->setHintText( tr( "Input gain:" ) , "dB" ); - auto sizeKnob = new Knob(knobBright_26, this); + auto sizeKnob = new Knob(KnobType::Bright26, this); sizeKnob -> move( 57, 10 ); sizeKnob->setModel( &controls->m_sizeModel ); sizeKnob->setLabel( tr( "Size" ) ); sizeKnob->setHintText( tr( "Size:" ) , "" ); - auto colorKnob = new Knob(knobBright_26, this); + auto colorKnob = new Knob(KnobType::Bright26, this); colorKnob -> move( 98, 10 ); colorKnob->setModel( &controls->m_colorModel ); colorKnob->setLabel( tr( "Color" ) ); colorKnob->setHintText( tr( "Color:" ) , "" ); - auto outputGainKnob = new Knob(knobBright_26, this); + auto outputGainKnob = new Knob(KnobType::Bright26, this); outputGainKnob -> move( 139, 10 ); outputGainKnob->setModel( &controls->m_outputGainModel ); outputGainKnob->setLabel( tr( "Output" ) ); diff --git a/plugins/Sf2Player/Sf2Player.cpp b/plugins/Sf2Player/Sf2Player.cpp index ef4f884cad3..1f0cb7c59e2 100644 --- a/plugins/Sf2Player/Sf2Player.cpp +++ b/plugins/Sf2Player/Sf2Player.cpp @@ -63,7 +63,7 @@ Plugin::Descriptor PLUGIN_EXPORT sf2player_plugin_descriptor = QT_TRANSLATE_NOOP( "PluginBrowser", "Player for SoundFont files" ), "Paul Giblock ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), "sf2,sf3", nullptr, @@ -200,8 +200,8 @@ Sf2Instrument::Sf2Instrument( InstrumentTrack * _instrument_track ) : Sf2Instrument::~Sf2Instrument() { Engine::audioEngine()->removePlayHandlesOfTypes( instrumentTrack(), - PlayHandle::TypeNotePlayHandle - | PlayHandle::TypeInstrumentPlayHandle ); + PlayHandle::Type::NotePlayHandle + | PlayHandle::Type::InstrumentPlayHandle ); freeFont(); delete_fluid_synth( m_synth ); delete_fluid_settings( m_settings ); @@ -616,7 +616,7 @@ void Sf2Instrument::reloadSynth() m_synthMutex.lock(); if( Engine::audioEngine()->currentQualitySettings().interpolation >= - AudioEngine::qualitySettings::Interpolation_SincFastest ) + AudioEngine::qualitySettings::Interpolation::SincFastest ) { fluid_synth_set_interp_method( m_synth, -1, FLUID_INTERP_7THORDER ); } @@ -936,7 +936,7 @@ class Sf2Knob : public Knob { public: Sf2Knob( QWidget * _parent ) : - Knob( knobStyled, _parent ) + Knob( KnobType::Styled, _parent ) { setFixedSize( 31, 38 ); } diff --git a/plugins/Sf2Player/Sf2Player.h b/plugins/Sf2Player/Sf2Player.h index 5a88d0f953a..bd7fa1b8161 100644 --- a/plugins/Sf2Player/Sf2Player.h +++ b/plugins/Sf2Player/Sf2Player.h @@ -88,7 +88,7 @@ class Sf2Instrument : public Instrument Flags flags() const override { - return IsSingleStreamed; + return Flag::IsSingleStreamed; } gui::PluginView* instantiateView( QWidget * _parent ) override; diff --git a/plugins/Sfxr/Sfxr.cpp b/plugins/Sfxr/Sfxr.cpp index 33f5885216f..fc39ea0fa28 100644 --- a/plugins/Sfxr/Sfxr.cpp +++ b/plugins/Sfxr/Sfxr.cpp @@ -67,7 +67,7 @@ Plugin::Descriptor PLUGIN_EXPORT sfxr_plugin_descriptor = "LMMS port of sfxr" ), "Wong Cho Ching", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), nullptr, nullptr, @@ -350,7 +350,7 @@ SfxrInstrument::SfxrInstrument( InstrumentTrack * _instrument_track ) : m_lpFilResoModel(0.0f, this, "LP Filter Resonance"), m_hpFilCutModel(0.0f, this, "HP Filter Cutoff"), m_hpFilCutSweepModel(0.0f, this, "HP Filter Cutoff Sweep"), - m_waveFormModel( SQR_WAVE, 0, WAVES_NUM-1, this, tr( "Wave" ) ) + m_waveFormModel( static_cast(SfxrWave::Square), 0, NumSfxrWaves-1, this, tr( "Wave" ) ) { } @@ -549,7 +549,7 @@ class SfxrKnob : public Knob { public: SfxrKnob( QWidget * _parent ) : - Knob( knobStyled, _parent ) + Knob( KnobType::Styled, _parent ) { setFixedSize( 20, 20 ); setCenterPointX( 10.0 ); diff --git a/plugins/Sfxr/Sfxr.h b/plugins/Sfxr/Sfxr.h index 632ccfebd72..edec0ba6f00 100644 --- a/plugins/Sfxr/Sfxr.h +++ b/plugins/Sfxr/Sfxr.h @@ -37,10 +37,11 @@ namespace lmms { -enum SfxrWaves +enum class SfxrWave { - SQR_WAVE, SAW_WAVE, SINE_WAVE, NOISE_WAVE, WAVES_NUM + Square, Saw, Sine, Noise, Count }; +constexpr auto NumSfxrWaves = static_cast(SfxrWave::Count); const int WAVEFORM_BASE_X = 20; const int WAVEFORM_BASE_Y = 15; diff --git a/plugins/Sid/SidInstrument.cpp b/plugins/Sid/SidInstrument.cpp index 3b41d8972a3..f663c3b6977 100644 --- a/plugins/Sid/SidInstrument.cpp +++ b/plugins/Sid/SidInstrument.cpp @@ -83,7 +83,7 @@ Plugin::Descriptor PLUGIN_EXPORT sid_plugin_descriptor = "Csaba Hruska " "Attila Herman ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), nullptr, nullptr, @@ -105,7 +105,7 @@ VoiceObject::VoiceObject( Model * _parent, int _idx ) : tr( "Voice %1 release" ).arg( _idx+1 ) ), m_coarseModel( 0.0f, -24.0, 24.0, 1.0f, this, tr( "Voice %1 coarse detuning" ).arg( _idx+1 ) ), - m_waveFormModel( TriangleWave, 0, NumWaveShapes-1, this, + m_waveFormModel( static_cast(WaveForm::Triangle), 0, NumWaveShapes-1, this, tr( "Voice %1 wave shape" ).arg( _idx+1 ) ), m_syncModel( false, this, tr( "Voice %1 sync" ).arg( _idx+1 ) ), @@ -121,12 +121,12 @@ SidInstrument::SidInstrument( InstrumentTrack * _instrument_track ) : // filter m_filterFCModel( 1024.0f, 0.0f, 2047.0f, 1.0f, this, tr( "Cutoff frequency" ) ), m_filterResonanceModel( 8.0f, 0.0f, 15.0f, 1.0f, this, tr( "Resonance" ) ), - m_filterModeModel( LowPass, 0, NumFilterTypes-1, this, tr( "Filter type" )), + m_filterModeModel( static_cast(FilterType::LowPass), 0, NumFilterTypes-1, this, tr( "Filter type" )), // misc m_voice3OffModel( false, this, tr( "Voice 3 off" ) ), m_volumeModel( 15.0f, 0.0f, 15.0f, 1.0f, this, tr( "Volume" ) ), - m_chipModel( sidMOS8580, 0, NumChipModels-1, this, tr( "Chip model" ) ) + m_chipModel( static_cast(ChipModel::MOS8580), 0, NumChipModels-1, this, tr( "Chip model" ) ) { for( int i = 0; i < 3; ++i ) { @@ -323,7 +323,7 @@ void SidInstrument::playNote( NotePlayHandle * _n, reg = 0x00; } - if( (ChipModel)m_chipModel.value() == sidMOS6581 ) + if( (ChipModel)m_chipModel.value() == ChipModel::MOS6581 ) { sid->set_chip_model( MOS6581 ); } @@ -360,13 +360,13 @@ void SidInstrument::playNote( NotePlayHandle * _n, data8 += m_voice[i]->m_syncModel.value()?2:0; data8 += m_voice[i]->m_ringModModel.value()?4:0; data8 += m_voice[i]->m_testModel.value()?8:0; - switch( m_voice[i]->m_waveFormModel.value() ) + switch( static_cast(m_voice[i]->m_waveFormModel.value()) ) { default: break; - case VoiceObject::NoiseWave: data8 += 128; break; - case VoiceObject::SquareWave: data8 += 64; break; - case VoiceObject::SawWave: data8 += 32; break; - case VoiceObject::TriangleWave: data8 += 16; break; + case VoiceObject::WaveForm::Noise: data8 += 128; break; + case VoiceObject::WaveForm::Square: data8 += 64; break; + case VoiceObject::WaveForm::Saw: data8 += 32; break; + case VoiceObject::WaveForm::Triangle: data8 += 16; break; } sidreg[base+4] = data8&0x00FF; // ad @@ -406,12 +406,12 @@ void SidInstrument::playNote( NotePlayHandle * _n, data8 = data16&0x000F; data8 += m_voice3OffModel.value()?128:0; - switch( m_filterModeModel.value() ) + switch( static_cast(m_filterModeModel.value()) ) { default: break; - case LowPass: data8 += 16; break; - case BandPass: data8 += 32; break; - case HighPass: data8 += 64; break; + case FilterType::LowPass: data8 += 16; break; + case FilterType::BandPass: data8 += 32; break; + case FilterType::HighPass: data8 += 64; break; } sidreg[24] = data8&0x00FF; @@ -459,7 +459,7 @@ class sidKnob : public Knob { public: sidKnob( QWidget * _parent ) : - Knob( knobStyled, _parent ) + Knob( KnobType::Styled, _parent ) { setFixedSize( 16, 16 ); setCenterPointX( 7.5 ); diff --git a/plugins/Sid/SidInstrument.h b/plugins/Sid/SidInstrument.h index 203e52e7b6e..53efa8942f7 100644 --- a/plugins/Sid/SidInstrument.h +++ b/plugins/Sid/SidInstrument.h @@ -50,13 +50,15 @@ class VoiceObject : public Model Q_OBJECT MM_OPERATORS public: - enum WaveForm { - SquareWave = 0, - TriangleWave, - SawWave, - NoiseWave, - NumWaveShapes + enum class WaveForm { + Square = 0, + Triangle, + Saw, + Noise, + Count }; + constexpr static auto NumWaveShapes = static_cast(WaveForm::Count); + VoiceObject( Model * _parent, int _idx ); ~VoiceObject() override = default; @@ -82,19 +84,20 @@ class SidInstrument : public Instrument { Q_OBJECT public: - enum FilerType { + enum class FilterType { HighPass = 0, BandPass, LowPass, - NumFilterTypes + Count }; + constexpr static auto NumFilterTypes = static_cast(FilterType::Count); - enum ChipModel { - sidMOS6581 = 0, - sidMOS8580, - NumChipModels + enum class ChipModel { + MOS6581 = 0, + MOS8580, + Count }; - + constexpr static auto NumChipModels = static_cast(ChipModel::Count); SidInstrument( InstrumentTrack * _instrument_track ); ~SidInstrument() override = default; diff --git a/plugins/SpectrumAnalyzer/Analyzer.cpp b/plugins/SpectrumAnalyzer/Analyzer.cpp index de4ac8c681c..0bbada7db55 100644 --- a/plugins/SpectrumAnalyzer/Analyzer.cpp +++ b/plugins/SpectrumAnalyzer/Analyzer.cpp @@ -48,7 +48,7 @@ extern "C" { QT_TRANSLATE_NOOP("PluginBrowser", "A graphical spectrum analyzer."), "Martin Pavelek ", 0x0112, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, nullptr, diff --git a/plugins/SpectrumAnalyzer/SaControls.cpp b/plugins/SpectrumAnalyzer/SaControls.cpp index 1ebfcdca346..d14176ed3b3 100644 --- a/plugins/SpectrumAnalyzer/SaControls.cpp +++ b/plugins/SpectrumAnalyzer/SaControls.cpp @@ -66,7 +66,7 @@ SaControls::SaControls(Analyzer *effect) : m_zeroPaddingModel(2.0f, 0.0f, 4.0f, 1.0f, this, tr("FFT zero padding")) { // Frequency and amplitude ranges; order must match - // FREQUENCY_RANGES and AMPLITUDE_RANGES defined in SaControls.h + // FrequencyRange and AmplitudeRange defined in SaControls.h m_freqRangeModel.addItem(tr("Full (auto)")); m_freqRangeModel.addItem(tr("Audible")); m_freqRangeModel.addItem(tr("Bass")); @@ -99,7 +99,7 @@ SaControls::SaControls(Analyzer *effect) : } m_blockSizeModel.setValue(m_blockSizeModel.findText("2048")); - // Window type order must match FFT_WINDOWS defined in fft_helpers.h + // Window type order must match FFTWindow defined in fft_helpers.h m_windowModel.addItem(tr("Rectangular (Off)")); m_windowModel.addItem(tr("Blackman-Harris (Default)")); m_windowModel.addItem(tr("Hamming")); diff --git a/plugins/SpectrumAnalyzer/SaControlsDialog.cpp b/plugins/SpectrumAnalyzer/SaControlsDialog.cpp index c4fc431b1af..eb09c793a9f 100644 --- a/plugins/SpectrumAnalyzer/SaControlsDialog.cpp +++ b/plugins/SpectrumAnalyzer/SaControlsDialog.cpp @@ -236,7 +236,7 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) controls_layout->setStretchFactor(advanced_widget, 10); // Peak envelope resolution - auto envelopeResolutionKnob = new Knob(knobSmall_17, this); + auto envelopeResolutionKnob = new Knob(KnobType::Small17, this); envelopeResolutionKnob->setModel(&controls->m_envelopeResolutionModel); envelopeResolutionKnob->setLabel(tr("Envelope res.")); envelopeResolutionKnob->setToolTip(tr("Increase envelope resolution for better details, decrease for better GUI performance.")); @@ -244,7 +244,7 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) advanced_layout->addWidget(envelopeResolutionKnob, 0, 0, 1, 1, Qt::AlignCenter); // Spectrum graph resolution - auto spectrumResolutionKnob = new Knob(knobSmall_17, this); + auto spectrumResolutionKnob = new Knob(KnobType::Small17, this); spectrumResolutionKnob->setModel(&controls->m_spectrumResolutionModel); spectrumResolutionKnob->setLabel(tr("Spectrum res.")); spectrumResolutionKnob->setToolTip(tr("Increase spectrum resolution for better details, decrease for better GUI performance.")); @@ -252,7 +252,7 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) advanced_layout->addWidget(spectrumResolutionKnob, 1, 0, 1, 1, Qt::AlignCenter); // Peak falloff speed - auto peakDecayFactorKnob = new Knob(knobSmall_17, this); + auto peakDecayFactorKnob = new Knob(KnobType::Small17, this); peakDecayFactorKnob->setModel(&controls->m_peakDecayFactorModel); peakDecayFactorKnob->setLabel(tr("Falloff factor")); peakDecayFactorKnob->setToolTip(tr("Decrease to make peaks fall faster.")); @@ -260,7 +260,7 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) advanced_layout->addWidget(peakDecayFactorKnob, 0, 1, 1, 1, Qt::AlignCenter); // Averaging weight - auto averagingWeightKnob = new Knob(knobSmall_17, this); + auto averagingWeightKnob = new Knob(KnobType::Small17, this); averagingWeightKnob->setModel(&controls->m_averagingWeightModel); averagingWeightKnob->setLabel(tr("Averaging weight")); averagingWeightKnob->setToolTip(tr("Decrease to make averaging slower and smoother.")); @@ -268,7 +268,7 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) advanced_layout->addWidget(averagingWeightKnob, 1, 1, 1, 1, Qt::AlignCenter); // Waterfall history size - auto waterfallHeightKnob = new Knob(knobSmall_17, this); + auto waterfallHeightKnob = new Knob(KnobType::Small17, this); waterfallHeightKnob->setModel(&controls->m_waterfallHeightModel); waterfallHeightKnob->setLabel(tr("Waterfall height")); waterfallHeightKnob->setToolTip(tr("Increase to get slower scrolling, decrease to see fast transitions better. Warning: medium CPU usage.")); @@ -278,7 +278,7 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) connect(&controls->m_waterfallHeightModel, &FloatModel::dataChanged, [=] {processor->reallocateBuffers();}); // Waterfall gamma correction - auto waterfallGammaKnob = new Knob(knobSmall_17, this); + auto waterfallGammaKnob = new Knob(KnobType::Small17, this); waterfallGammaKnob->setModel(&controls->m_waterfallGammaModel); waterfallGammaKnob->setLabel(tr("Waterfall gamma")); waterfallGammaKnob->setToolTip(tr("Decrease to see very weak signals, increase to get better contrast.")); @@ -286,7 +286,7 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) advanced_layout->addWidget(waterfallGammaKnob, 1, 2, 1, 1, Qt::AlignCenter); // FFT window overlap - auto windowOverlapKnob = new Knob(knobSmall_17, this); + auto windowOverlapKnob = new Knob(KnobType::Small17, this); windowOverlapKnob->setModel(&controls->m_windowOverlapModel); windowOverlapKnob->setLabel(tr("Window overlap")); windowOverlapKnob->setToolTip(tr("Increase to prevent missing fast transitions arriving near FFT window edges. Warning: high CPU usage.")); @@ -294,7 +294,7 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) advanced_layout->addWidget(windowOverlapKnob, 0, 3, 1, 1, Qt::AlignCenter); // FFT zero padding - auto zeroPaddingKnob = new Knob(knobSmall_17, this); + auto zeroPaddingKnob = new Knob(KnobType::Small17, this); zeroPaddingKnob->setModel(&controls->m_zeroPaddingModel); zeroPaddingKnob->setLabel(tr("Zero padding")); zeroPaddingKnob->setToolTip(tr("Increase to get smoother-looking spectrum. Warning: high CPU usage.")); diff --git a/plugins/SpectrumAnalyzer/SaProcessor.cpp b/plugins/SpectrumAnalyzer/SaProcessor.cpp index d7a1dd5fb1a..a79d52bdc08 100644 --- a/plugins/SpectrumAnalyzer/SaProcessor.cpp +++ b/plugins/SpectrumAnalyzer/SaProcessor.cpp @@ -58,7 +58,7 @@ SaProcessor::SaProcessor(const SaControls *controls) : m_reallocating(false) { m_fftWindow.resize(m_inBlockSize, 1.0); - precomputeWindow(m_fftWindow.data(), m_inBlockSize, BLACKMAN_HARRIS); + precomputeWindow(m_fftWindow.data(), m_inBlockSize, FFTWindow::BlackmanHarris); m_bufferL.resize(m_inBlockSize, 0); m_bufferR.resize(m_inBlockSize, 0); @@ -402,7 +402,7 @@ void SaProcessor::reallocateBuffers() // allocate new space, create new plan and resize containers m_fftWindow.resize(new_in_size, 1.0); - precomputeWindow(m_fftWindow.data(), new_in_size, (FFT_WINDOWS) m_controls->m_windowModel.value()); + precomputeWindow(m_fftWindow.data(), new_in_size, (FFTWindow) m_controls->m_windowModel.value()); m_bufferL.resize(new_in_size, 0); m_bufferR.resize(new_in_size, 0); m_filteredBufferL.resize(new_fft_size, 0); @@ -448,7 +448,7 @@ void SaProcessor::rebuildWindow() { // computation is done in fft_helpers QMutexLocker lock(&m_dataAccess); - precomputeWindow(m_fftWindow.data(), m_inBlockSize, (FFT_WINDOWS) m_controls->m_windowModel.value()); + precomputeWindow(m_fftWindow.data(), m_inBlockSize, (FFTWindow) m_controls->m_windowModel.value()); } @@ -545,28 +545,28 @@ float SaProcessor::binBandwidth() const float SaProcessor::getFreqRangeMin(bool linear) const { - switch (m_controls->m_freqRangeModel.value()) + switch (static_cast(m_controls->m_freqRangeModel.value())) { - case FRANGE_AUDIBLE: return FRANGE_AUDIBLE_START; - case FRANGE_BASS: return FRANGE_BASS_START; - case FRANGE_MIDS: return FRANGE_MIDS_START; - case FRANGE_HIGH: return FRANGE_HIGH_START; + case FrequencyRange::Audible: return FRANGE_AUDIBLE_START; + case FrequencyRange::Bass: return FRANGE_BASS_START; + case FrequencyRange::Mids: return FRANGE_MIDS_START; + case FrequencyRange::High: return FRANGE_HIGH_START; default: - case FRANGE_FULL: return linear ? 0 : LOWEST_LOG_FREQ; + case FrequencyRange::Full: return linear ? 0 : LOWEST_LOG_FREQ; } } float SaProcessor::getFreqRangeMax() const { - switch (m_controls->m_freqRangeModel.value()) + switch (static_cast(m_controls->m_freqRangeModel.value())) { - case FRANGE_AUDIBLE: return FRANGE_AUDIBLE_END; - case FRANGE_BASS: return FRANGE_BASS_END; - case FRANGE_MIDS: return FRANGE_MIDS_END; - case FRANGE_HIGH: return FRANGE_HIGH_END; + case FrequencyRange::Audible: return FRANGE_AUDIBLE_END; + case FrequencyRange::Bass: return FRANGE_BASS_END; + case FrequencyRange::Mids: return FRANGE_MIDS_END; + case FrequencyRange::High: return FRANGE_HIGH_END; default: - case FRANGE_FULL: return getNyquistFreq(); + case FrequencyRange::Full: return getNyquistFreq(); } } @@ -619,26 +619,26 @@ float SaProcessor::getAmpRangeMin(bool linear) const { // return very low limit to make sure zero gets included at linear grid if (linear) {return -900;} - switch (m_controls->m_ampRangeModel.value()) + switch (static_cast(m_controls->m_ampRangeModel.value())) { - case ARANGE_EXTENDED: return ARANGE_EXTENDED_START; - case ARANGE_SILENT: return ARANGE_SILENT_START; - case ARANGE_LOUD: return ARANGE_LOUD_START; + case AmplitudeRange::Extended: return ARANGE_EXTENDED_START; + case AmplitudeRange::Silent: return ARANGE_SILENT_START; + case AmplitudeRange::Loud: return ARANGE_LOUD_START; default: - case ARANGE_AUDIBLE: return ARANGE_AUDIBLE_START; + case AmplitudeRange::Audible: return ARANGE_AUDIBLE_START; } } float SaProcessor::getAmpRangeMax() const { - switch (m_controls->m_ampRangeModel.value()) + switch (static_cast(m_controls->m_ampRangeModel.value())) { - case ARANGE_EXTENDED: return ARANGE_EXTENDED_END; - case ARANGE_SILENT: return ARANGE_SILENT_END; - case ARANGE_LOUD: return ARANGE_LOUD_END; + case AmplitudeRange::Extended: return ARANGE_EXTENDED_END; + case AmplitudeRange::Silent: return ARANGE_SILENT_END; + case AmplitudeRange::Loud: return ARANGE_LOUD_END; default: - case ARANGE_AUDIBLE: return ARANGE_AUDIBLE_END; + case AmplitudeRange::Audible: return ARANGE_AUDIBLE_END; } } diff --git a/plugins/StereoEnhancer/StereoEnhancer.cpp b/plugins/StereoEnhancer/StereoEnhancer.cpp index 01e55f2dee5..a7937a2ec1d 100644 --- a/plugins/StereoEnhancer/StereoEnhancer.cpp +++ b/plugins/StereoEnhancer/StereoEnhancer.cpp @@ -43,7 +43,7 @@ Plugin::Descriptor PLUGIN_EXPORT stereoenhancer_plugin_descriptor = "Plugin for enhancing stereo separation of a stereo input file" ), "Lou Herard ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, nullptr, diff --git a/plugins/StereoEnhancer/StereoEnhancerControlDialog.cpp b/plugins/StereoEnhancer/StereoEnhancerControlDialog.cpp index 3f784170616..05c78616e56 100644 --- a/plugins/StereoEnhancer/StereoEnhancerControlDialog.cpp +++ b/plugins/StereoEnhancer/StereoEnhancerControlDialog.cpp @@ -40,7 +40,7 @@ StereoEnhancerControlDialog::StereoEnhancerControlDialog( { auto l = new QHBoxLayout(this); - auto widthKnob = new Knob(knobBright_26, this); + auto widthKnob = new Knob(KnobType::Bright26, this); widthKnob->setModel( &_controls->m_widthModel ); widthKnob->setLabel( tr( "WIDTH" ) ); widthKnob->setHintText( tr( "Width:" ) , " samples" ); diff --git a/plugins/StereoMatrix/StereoMatrix.cpp b/plugins/StereoMatrix/StereoMatrix.cpp index 2dff69b77f6..b96d2e10791 100644 --- a/plugins/StereoMatrix/StereoMatrix.cpp +++ b/plugins/StereoMatrix/StereoMatrix.cpp @@ -43,7 +43,7 @@ Plugin::Descriptor PLUGIN_EXPORT stereomatrix_plugin_descriptor = "Plugin for freely manipulating stereo output" ), "Paul Giblock ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, nullptr, diff --git a/plugins/StereoMatrix/StereoMatrixControlDialog.cpp b/plugins/StereoMatrix/StereoMatrixControlDialog.cpp index 06ff2a03b33..da9a3aa9e02 100644 --- a/plugins/StereoMatrix/StereoMatrixControlDialog.cpp +++ b/plugins/StereoMatrix/StereoMatrixControlDialog.cpp @@ -48,22 +48,22 @@ StereoMatrixControlDialog::StereoMatrixControlDialog( PLUGIN_NAME::getIconPixmap( "artwork" ) ); setPalette( pal ); - auto llKnob = new Knob(knobBright_26, this); + auto llKnob = new Knob(KnobType::Bright26, this); llKnob->setModel( &_controls->m_llModel ); llKnob->setHintText( tr( "Left to Left Vol:" ) , "" ); llKnob->move( 10, 79 ); - auto lrKnob = new Knob(knobBright_26, this); + auto lrKnob = new Knob(KnobType::Bright26, this); lrKnob->setModel( &_controls->m_lrModel ); lrKnob->setHintText( tr( "Left to Right Vol:" ) , "" ); lrKnob->move( 48, 79 ); - auto rlKnob = new Knob(knobBright_26, this); + auto rlKnob = new Knob(KnobType::Bright26, this); rlKnob->setModel( &_controls->m_rlModel ); rlKnob->setHintText( tr( "Right to Left Vol:" ) , "" ); rlKnob->move( 85, 79 ); - auto rrKnob = new Knob(knobBright_26, this); + auto rrKnob = new Knob(KnobType::Bright26, this); rrKnob->setModel( &_controls->m_rrModel ); rrKnob->setHintText( tr( "Right to Right Vol:" ) , "" ); rrKnob->move( 123, 79 ); diff --git a/plugins/Stk/Mallets/Mallets.cpp b/plugins/Stk/Mallets/Mallets.cpp index be144e76405..4fb077de5bc 100644 --- a/plugins/Stk/Mallets/Mallets.cpp +++ b/plugins/Stk/Mallets/Mallets.cpp @@ -59,7 +59,7 @@ Plugin::Descriptor PLUGIN_EXPORT malletsstk_plugin_descriptor = "Tuneful things to bang on" ), "Danny McRae ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), nullptr, nullptr, @@ -409,7 +409,7 @@ MalletsInstrumentView::MalletsInstrumentView( MalletsInstrument * _instrument, connect( &_instrument->m_presetsModel, SIGNAL( dataChanged() ), this, SLOT( changePreset() ) ); - m_spreadKnob = new Knob( knobVintage_32, this ); + m_spreadKnob = new Knob( KnobType::Vintage32, this ); m_spreadKnob->setLabel( tr( "Spread" ) ); m_spreadKnob->move( 190, 140 ); m_spreadKnob->setHintText( tr( "Spread:" ), "" ); @@ -445,27 +445,27 @@ QWidget * MalletsInstrumentView::setupModalBarControls( QWidget * _parent ) auto widget = new QWidget(_parent); widget->setFixedSize( 250, 250 ); - m_hardnessKnob = new Knob( knobVintage_32, widget ); + m_hardnessKnob = new Knob( KnobType::Vintage32, widget ); m_hardnessKnob->setLabel( tr( "Hardness" ) ); m_hardnessKnob->move( 30, 90 ); m_hardnessKnob->setHintText( tr( "Hardness:" ), "" ); - m_positionKnob = new Knob( knobVintage_32, widget ); + m_positionKnob = new Knob( KnobType::Vintage32, widget ); m_positionKnob->setLabel( tr( "Position" ) ); m_positionKnob->move( 110, 90 ); m_positionKnob->setHintText( tr( "Position:" ), "" ); - m_vibratoGainKnob = new Knob( knobVintage_32, widget ); + m_vibratoGainKnob = new Knob( KnobType::Vintage32, widget ); m_vibratoGainKnob->setLabel( tr( "Vibrato gain" ) ); m_vibratoGainKnob->move( 30, 140 ); m_vibratoGainKnob->setHintText( tr( "Vibrato gain:" ), "" ); - m_vibratoFreqKnob = new Knob( knobVintage_32, widget ); + m_vibratoFreqKnob = new Knob( KnobType::Vintage32, widget ); m_vibratoFreqKnob->setLabel( tr( "Vibrato frequency" ) ); m_vibratoFreqKnob->move( 110, 140 ); m_vibratoFreqKnob->setHintText( tr( "Vibrato frequency:" ), "" ); - m_stickKnob = new Knob( knobVintage_32, widget ); + m_stickKnob = new Knob( KnobType::Vintage32, widget ); m_stickKnob->setLabel( tr( "Stick mix" ) ); m_stickKnob->move( 190, 90 ); m_stickKnob->setHintText( tr( "Stick mix:" ), "" ); @@ -481,27 +481,27 @@ QWidget * MalletsInstrumentView::setupTubeBellControls( QWidget * _parent ) auto widget = new QWidget(_parent); widget->setFixedSize( 250, 250 ); - m_modulatorKnob = new Knob( knobVintage_32, widget ); + m_modulatorKnob = new Knob( KnobType::Vintage32, widget ); m_modulatorKnob->setLabel( tr( "Modulator" ) ); m_modulatorKnob->move( 30, 90 ); m_modulatorKnob->setHintText( tr( "Modulator:" ), "" ); - m_crossfadeKnob = new Knob( knobVintage_32, widget ); + m_crossfadeKnob = new Knob( KnobType::Vintage32, widget ); m_crossfadeKnob->setLabel( tr( "Crossfade" ) ); m_crossfadeKnob->move( 110, 90 ); m_crossfadeKnob->setHintText( tr( "Crossfade:" ), "" ); - m_lfoSpeedKnob = new Knob( knobVintage_32, widget ); + m_lfoSpeedKnob = new Knob( KnobType::Vintage32, widget ); m_lfoSpeedKnob->setLabel( tr( "LFO speed" ) ); m_lfoSpeedKnob->move( 30, 140 ); m_lfoSpeedKnob->setHintText( tr( "LFO speed:" ), "" ); - m_lfoDepthKnob = new Knob( knobVintage_32, widget ); + m_lfoDepthKnob = new Knob( KnobType::Vintage32, widget ); m_lfoDepthKnob->setLabel( tr( "LFO depth" ) ); m_lfoDepthKnob->move( 110, 140 ); m_lfoDepthKnob->setHintText( tr( "LFO depth:" ), "" ); - m_adsrKnob = new Knob( knobVintage_32, widget ); + m_adsrKnob = new Knob( KnobType::Vintage32, widget ); m_adsrKnob->setLabel( tr( "ADSR" ) ); m_adsrKnob->move( 190, 90 ); m_adsrKnob->setHintText( tr( "ADSR:" ), "" ); @@ -521,22 +521,22 @@ QWidget * MalletsInstrumentView::setupBandedWGControls( QWidget * _parent ) /* m_strikeLED = new LedCheckBox( tr( "Bowed" ), widget ); m_strikeLED->move( 138, 25 );*/ - m_pressureKnob = new Knob( knobVintage_32, widget ); + m_pressureKnob = new Knob( KnobType::Vintage32, widget ); m_pressureKnob->setLabel( tr( "Pressure" ) ); m_pressureKnob->move( 30, 90 ); m_pressureKnob->setHintText( tr( "Pressure:" ), "" ); -/* m_motionKnob = new Knob( knobVintage_32, widget ); +/* m_motionKnob = new Knob( KnobType::Vintage32, widget ); m_motionKnob->setLabel( tr( "Motion" ) ); m_motionKnob->move( 110, 90 ); m_motionKnob->setHintText( tr( "Motion:" ), "" );*/ - m_velocityKnob = new Knob( knobVintage_32, widget ); + m_velocityKnob = new Knob( KnobType::Vintage32, widget ); m_velocityKnob->setLabel( tr( "Speed" ) ); m_velocityKnob->move( 30, 140 ); m_velocityKnob->setHintText( tr( "Speed:" ), "" ); -/* m_vibratoKnob = new Knob( knobVintage_32, widget, tr( "Vibrato" ) ); +/* m_vibratoKnob = new Knob( KnobType::Vintage32, widget, tr( "Vibrato" ) ); m_vibratoKnob->setLabel( tr( "Vibrato" ) ); m_vibratoKnob->move( 110, 140 ); m_vibratoKnob->setHintText( tr( "Vibrato:" ), "" );*/ diff --git a/plugins/TripleOscillator/TripleOscillator.cpp b/plugins/TripleOscillator/TripleOscillator.cpp index c6624754106..f2340d3d609 100644 --- a/plugins/TripleOscillator/TripleOscillator.cpp +++ b/plugins/TripleOscillator/TripleOscillator.cpp @@ -57,7 +57,7 @@ Plugin::Descriptor PLUGIN_EXPORT tripleoscillator_plugin_descriptor = "in several ways" ), "Tobias Doerffel ", 0x0110, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), nullptr, nullptr, @@ -84,10 +84,10 @@ OscillatorObject::OscillatorObject( Model * _parent, int _idx ) : tr( "Osc %1 phase-offset" ).arg( _idx+1 ) ), m_stereoPhaseDetuningModel( 0.0f, 0.0f, 360.0f, 1.0f, this, tr( "Osc %1 stereo phase-detuning" ).arg( _idx+1 ) ), - m_waveShapeModel( Oscillator::SineWave, 0, + m_waveShapeModel( static_cast(Oscillator::WaveShape::Sine), 0, Oscillator::NumWaveShapes-1, this, tr( "Osc %1 wave shape" ).arg( _idx+1 ) ), - m_modulationAlgoModel( Oscillator::SignalMix, 0, + m_modulationAlgoModel( static_cast(Oscillator::ModulationAlgo::SignalMix), 0, Oscillator::NumModulationAlgos-1, this, tr( "Modulation type %1" ).arg( _idx+1 ) ), m_useWaveTableModel(true), @@ -426,7 +426,7 @@ class TripleOscKnob : public Knob { public: TripleOscKnob( QWidget * _parent ) : - Knob( knobStyled, _parent ) + Knob( KnobType::Styled, _parent ) { setFixedSize( 28, 35 ); } @@ -554,7 +554,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, int knob_y = osc_y + i * osc_h; // setup volume-knob - auto vk = new Knob(knobStyled, this); + auto vk = new Knob(KnobType::Styled, this); vk->setVolumeKnob( true ); vk->setFixedSize( 28, 35 ); vk->move( 6, knob_y ); diff --git a/plugins/Vectorscope/VecControlsDialog.cpp b/plugins/Vectorscope/VecControlsDialog.cpp index 97898fe7070..9aa2cfd8d1f 100644 --- a/plugins/Vectorscope/VecControlsDialog.cpp +++ b/plugins/Vectorscope/VecControlsDialog.cpp @@ -79,7 +79,7 @@ VecControlsDialog::VecControlsDialog(VecControls *controls) : config_layout->addStretch(); // Persistence knob - auto persistenceKnob = new Knob(knobSmall_17, this); + auto persistenceKnob = new Knob(KnobType::Small17, this); persistenceKnob->setModel(&controls->m_persistenceModel); persistenceKnob->setLabel(tr("Persist.")); persistenceKnob->setToolTip(tr("Trace persistence: higher amount means the trace will stay bright for longer time.")); diff --git a/plugins/Vectorscope/Vectorscope.cpp b/plugins/Vectorscope/Vectorscope.cpp index b9880691c64..f843fc86d7b 100644 --- a/plugins/Vectorscope/Vectorscope.cpp +++ b/plugins/Vectorscope/Vectorscope.cpp @@ -39,7 +39,7 @@ extern "C" { QT_TRANSLATE_NOOP("PluginBrowser", "A stereo field visualizer."), "Martin Pavelek ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, nullptr, diff --git a/plugins/Vestige/Vestige.cpp b/plugins/Vestige/Vestige.cpp index eab3693b8b2..dd8e9cbef3b 100644 --- a/plugins/Vestige/Vestige.cpp +++ b/plugins/Vestige/Vestige.cpp @@ -77,7 +77,7 @@ Plugin::Descriptor Q_DECL_EXPORT vestige_plugin_descriptor = "VST-host for using VST(i)-plugins within LMMS" ), "Tobias Doerffel ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), #ifdef LMMS_BUILD_LINUX "dll,so", @@ -185,8 +185,8 @@ VestigeInstrument::~VestigeInstrument() } Engine::audioEngine()->removePlayHandlesOfTypes( instrumentTrack(), - PlayHandle::TypeNotePlayHandle - | PlayHandle::TypeInstrumentPlayHandle ); + PlayHandle::Type::NotePlayHandle + | PlayHandle::Type::InstrumentPlayHandle ); closePlugin(); } @@ -1004,7 +1004,7 @@ ManageVestigeInstrumentView::ManageVestigeInstrumentView( Instrument * _instrume sprintf(paramStr.data(), "param%d", i); s_dumpValues = dump[paramStr.data()].split(":"); - vstKnobs[ i ] = new CustomTextKnob( knobBright_26, this, s_dumpValues.at( 1 ) ); + vstKnobs[ i ] = new CustomTextKnob( KnobType::Bright26, this, s_dumpValues.at( 1 ) ); vstKnobs[ i ]->setDescription( s_dumpValues.at( 1 ) + ":" ); vstKnobs[ i ]->setLabel( s_dumpValues.at( 1 ).left( 15 ) ); diff --git a/plugins/Vestige/Vestige.h b/plugins/Vestige/Vestige.h index 0a36c492402..f740913ead5 100644 --- a/plugins/Vestige/Vestige.h +++ b/plugins/Vestige/Vestige.h @@ -72,7 +72,7 @@ class VestigeInstrument : public Instrument virtual Flags flags() const { - return IsSingleStreamed | IsMidiBased; + return Flag::IsSingleStreamed | Flag::IsMidiBased; } virtual bool handleMidiEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset = 0 ); diff --git a/plugins/Vibed/Vibed.cpp b/plugins/Vibed/Vibed.cpp index 014ab1429af..3ed51fe79d7 100644 --- a/plugins/Vibed/Vibed.cpp +++ b/plugins/Vibed/Vibed.cpp @@ -56,7 +56,7 @@ Plugin::Descriptor PLUGIN_EXPORT vibedstrings_plugin_descriptor = QT_TRANSLATE_NOOP("PluginBrowser", "Vibrating string modeler"), "Danny McRae ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader("logo"), nullptr, nullptr @@ -272,14 +272,14 @@ namespace gui VibedView::VibedView(Instrument* instrument, QWidget* parent) : InstrumentViewFixedSize(instrument, parent), - m_volumeKnob(knobBright_26, this), - m_stiffnessKnob(knobBright_26, this), - m_pickKnob(knobBright_26, this), - m_pickupKnob(knobBright_26, this), - m_panKnob(knobBright_26, this), - m_detuneKnob(knobBright_26, this), - m_randomKnob(knobBright_26, this), - m_lengthKnob(knobBright_26, this), + m_volumeKnob(KnobType::Bright26, this), + m_stiffnessKnob(KnobType::Bright26, this), + m_pickKnob(KnobType::Bright26, this), + m_pickupKnob(KnobType::Bright26, this), + m_panKnob(KnobType::Bright26, this), + m_detuneKnob(KnobType::Bright26, this), + m_randomKnob(KnobType::Bright26, this), + m_lengthKnob(KnobType::Bright26, this), m_graph(this), m_impulse("", this), m_power("", this, tr("Enable waveform")), diff --git a/plugins/Vibed/Vibed.h b/plugins/Vibed/Vibed.h index 308ae64d521..18d334c4d5a 100644 --- a/plugins/Vibed/Vibed.h +++ b/plugins/Vibed/Vibed.h @@ -65,7 +65,7 @@ class Vibed : public Instrument QString nodeName() const override; - Flags flags() const override { return IsNotBendable; } + Flags flags() const override { return Flag::IsNotBendable; } gui::PluginView* instantiateView(QWidget* parent) override; diff --git a/plugins/VstBase/RemoteVstPlugin.cpp b/plugins/VstBase/RemoteVstPlugin.cpp index aaa88f6c8b6..0ec60bea4fe 100644 --- a/plugins/VstBase/RemoteVstPlugin.cpp +++ b/plugins/VstBase/RemoteVstPlugin.cpp @@ -127,7 +127,7 @@ struct ERect using namespace std; -static lmms::VstHostLanguages hlang = lmms::LanguageEnglish; +static lmms::VstHostLanguage hlang = lmms::VstHostLanguage::English; static bool EMBED = false; static bool EMBED_X11 = false; @@ -390,7 +390,7 @@ class RemoteVstPlugin : public RemotePluginClient #endif private: - enum GuiThreadMessages + enum class GuiThreadMessage { None, ProcessPluginMessage, @@ -628,7 +628,7 @@ bool RemoteVstPlugin::processMessage( const message & _m ) break; case IdVstSetLanguage: - hlang = static_cast( _m.getInt() ); + hlang = static_cast( _m.getInt() ); break; case IdVstGetParameterDump: @@ -1763,7 +1763,7 @@ intptr_t RemoteVstPlugin::hostCallback( AEffect * _effect, int32_t _opcode, // call application idle routine (this will // call effEditIdle for all open editors too) #ifndef NATIVE_LINUX_VST - PostMessage( __MessageHwnd, WM_USER, GiveIdle, 0 ); + PostMessage( __MessageHwnd, WM_USER, static_cast(GuiThreadMessage::GiveIdle), 0 ); #else __plugin->sendX11Idle(); #endif @@ -2066,7 +2066,7 @@ intptr_t RemoteVstPlugin::hostCallback( AEffect * _effect, int32_t _opcode, case audioMasterGetLanguage: SHOW_CALLBACK( "amc: audioMasterGetLanguage\n" ); - return hlang; + return static_cast(hlang); case audioMasterGetDirectory: SHOW_CALLBACK( "amc: audioMasterGetDirectory\n" ); @@ -2077,7 +2077,7 @@ intptr_t RemoteVstPlugin::hostCallback( AEffect * _effect, int32_t _opcode, SHOW_CALLBACK( "amc: audioMasterUpdateDisplay\n" ); // something has changed, update 'multi-fx' display #ifndef NATIVE_LINUX_VST - PostMessage( __MessageHwnd, WM_USER, GiveIdle, 0 ); + PostMessage( __MessageHwnd, WM_USER, static_cast(GuiThreadMessage::GiveIdle), 0 ); #else __plugin->sendX11Idle(); #endif @@ -2234,7 +2234,7 @@ void * RemoteVstPlugin::processingThread(void * _param) #ifndef NATIVE_LINUX_VST PostMessage( __MessageHwnd, WM_USER, - ProcessPluginMessage, + static_cast(GuiThreadMessage::ProcessPluginMessage), (LPARAM) new message( m ) ); #else _this->queueMessage( m ); @@ -2244,7 +2244,7 @@ void * RemoteVstPlugin::processingThread(void * _param) // notify GUI thread about shutdown #ifndef NATIVE_LINUX_VST - PostMessage( __MessageHwnd, WM_USER, ClosePlugin, 0 ); + PostMessage( __MessageHwnd, WM_USER, static_cast(GuiThreadMessage::ClosePlugin), 0 ); return 0; #else @@ -2349,9 +2349,9 @@ LRESULT CALLBACK RemoteVstPlugin::wndProc( HWND hwnd, UINT uMsg, } else if( uMsg == WM_USER ) { - switch( wParam ) + switch( static_cast(wParam) ) { - case ProcessPluginMessage: + case GuiThreadMessage::ProcessPluginMessage: { message * m = (message *) lParam; __plugin->queueMessage( *m ); @@ -2363,11 +2363,11 @@ LRESULT CALLBACK RemoteVstPlugin::wndProc( HWND hwnd, UINT uMsg, return 0; } - case GiveIdle: + case GuiThreadMessage::GiveIdle: __plugin->idle(); return 0; - case ClosePlugin: + case GuiThreadMessage::ClosePlugin: PostQuitMessage(0); return 0; diff --git a/plugins/VstBase/VstPlugin.cpp b/plugins/VstBase/VstPlugin.cpp index c3fe17d7206..b23ae39bf97 100644 --- a/plugins/VstBase/VstPlugin.cpp +++ b/plugins/VstBase/VstPlugin.cpp @@ -216,18 +216,18 @@ void VstPlugin::tryLoad( const QString &remoteVstPluginExecutable ) lock(); - VstHostLanguages hlang = LanguageEnglish; + VstHostLanguage hlang = VstHostLanguage::English; switch( QLocale::system().language() ) { - case QLocale::French: hlang = LanguageFrench; break; - case QLocale::German: hlang = LanguageGerman; break; - case QLocale::Italian: hlang = LanguageItalian; break; - case QLocale::Japanese: hlang = LanguageJapanese; break; - case QLocale::Korean: hlang = LanguageKorean; break; - case QLocale::Spanish: hlang = LanguageSpanish; break; + case QLocale::French: hlang = VstHostLanguage::French; break; + case QLocale::German: hlang = VstHostLanguage::German; break; + case QLocale::Italian: hlang = VstHostLanguage::Italian; break; + case QLocale::Japanese: hlang = VstHostLanguage::Japanese; break; + case QLocale::Korean: hlang = VstHostLanguage::Korean; break; + case QLocale::Spanish: hlang = VstHostLanguage::Spanish; break; default: break; } - sendMessage( message( IdVstSetLanguage ).addInt( hlang ) ); + sendMessage( message( IdVstSetLanguage ).addInt( static_cast(hlang) ) ); sendMessage( message( IdVstLoadPlugin ).addString( QSTR_TO_STDSTR( m_plugin ) ) ); waitForInitDone(); diff --git a/plugins/VstBase/communication.h b/plugins/VstBase/communication.h index 1f32dd1354d..50351d38e5d 100644 --- a/plugins/VstBase/communication.h +++ b/plugins/VstBase/communication.h @@ -40,15 +40,15 @@ struct VstParameterDumpItem -enum VstHostLanguages +enum class VstHostLanguage { - LanguageEnglish = 1, - LanguageGerman, - LanguageFrench, - LanguageItalian, - LanguageSpanish, - LanguageJapanese, - LanguageKorean + English = 1, + German, + French, + Italian, + Spanish, + Japanese, + Korean } ; diff --git a/plugins/VstBase/vst_base.cpp b/plugins/VstBase/vst_base.cpp index 80cb9d73629..154dca97576 100644 --- a/plugins/VstBase/vst_base.cpp +++ b/plugins/VstBase/vst_base.cpp @@ -41,7 +41,7 @@ Plugin::Descriptor VSTBASE_EXPORT vstbase_plugin_descriptor = "library for all LMMS plugins dealing with VST-plugins", "Tobias Doerffel ", 0x0100, - Plugin::Library, + Plugin::Type::Library, nullptr, nullptr, } ; diff --git a/plugins/VstEffect/VstEffect.cpp b/plugins/VstEffect/VstEffect.cpp index c3e40cfa73c..bdbdea8060c 100644 --- a/plugins/VstEffect/VstEffect.cpp +++ b/plugins/VstEffect/VstEffect.cpp @@ -49,10 +49,10 @@ Plugin::Descriptor PLUGIN_EXPORT vsteffect_plugin_descriptor = "plugin for using arbitrary VST effects inside LMMS." ), "Tobias Doerffel ", 0x0200, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, - new VstSubPluginFeatures( Plugin::Effect ) + new VstSubPluginFeatures( Plugin::Type::Effect ) } ; } diff --git a/plugins/VstEffect/VstEffectControlDialog.cpp b/plugins/VstEffect/VstEffectControlDialog.cpp index 52160af57fd..5bee94155d9 100644 --- a/plugins/VstEffect/VstEffectControlDialog.cpp +++ b/plugins/VstEffect/VstEffectControlDialog.cpp @@ -48,6 +48,16 @@ VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) : m_plugin( nullptr ), tbLabel( nullptr ) { +#if QT_VERSION < 0x50C00 + // Workaround for a bug in Qt versions below 5.12, + // where argument-dependent-lookup fails for QFlags operators + // declared inside a namepsace. + // This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h + // See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348 + + using ::operator|; +#endif + auto l = new QGridLayout(this); l->setContentsMargins( 10, 10, 10, 10 ); l->setVerticalSpacing( 2 ); diff --git a/plugins/VstEffect/VstEffectControls.cpp b/plugins/VstEffect/VstEffectControls.cpp index e73530a0924..cf0c831a6b8 100644 --- a/plugins/VstEffect/VstEffectControls.cpp +++ b/plugins/VstEffect/VstEffectControls.cpp @@ -316,6 +316,16 @@ namespace gui ManageVSTEffectView::ManageVSTEffectView( VstEffect * _eff, VstEffectControls * m_vi ) : m_effect( _eff ) { +#if QT_VERSION < 0x50C00 + // Workaround for a bug in Qt versions below 5.12, + // where argument-dependent-lookup fails for QFlags operators + // declared inside a namepsace. + // This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h + // See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348 + + using ::operator|; +#endif + m_vi2 = m_vi; widget = new QWidget(); m_vi->m_scrollArea = new QScrollArea( widget ); @@ -379,7 +389,7 @@ ManageVSTEffectView::ManageVSTEffectView( VstEffect * _eff, VstEffectControls * sprintf(paramStr.data(), "param%d", i); s_dumpValues = dump[paramStr.data()].split(":"); - vstKnobs[ i ] = new CustomTextKnob( knobBright_26, widget, s_dumpValues.at( 1 ) ); + vstKnobs[ i ] = new CustomTextKnob( KnobType::Bright26, widget, s_dumpValues.at( 1 ) ); vstKnobs[ i ]->setDescription( s_dumpValues.at( 1 ) + ":" ); vstKnobs[ i ]->setLabel( s_dumpValues.at( 1 ).left( 15 ) ); diff --git a/plugins/VstEffect/VstSubPluginFeatures.cpp b/plugins/VstEffect/VstSubPluginFeatures.cpp index e60fee0c1d6..f929b5526bb 100644 --- a/plugins/VstEffect/VstSubPluginFeatures.cpp +++ b/plugins/VstEffect/VstSubPluginFeatures.cpp @@ -34,7 +34,7 @@ namespace lmms { -VstSubPluginFeatures::VstSubPluginFeatures( Plugin::PluginTypes _type ) : +VstSubPluginFeatures::VstSubPluginFeatures( Plugin::Type _type ) : SubPluginFeatures( _type ) { } diff --git a/plugins/VstEffect/VstSubPluginFeatures.h b/plugins/VstEffect/VstSubPluginFeatures.h index c5dc87d14dd..a5673dfb7d3 100644 --- a/plugins/VstEffect/VstSubPluginFeatures.h +++ b/plugins/VstEffect/VstSubPluginFeatures.h @@ -38,7 +38,7 @@ namespace lmms class VstSubPluginFeatures : public Plugin::Descriptor::SubPluginFeatures { public: - VstSubPluginFeatures( Plugin::PluginTypes _type ); + VstSubPluginFeatures( Plugin::Type _type ); void fillDescriptionWidget( QWidget * _parent, const Key * _key ) const override; diff --git a/plugins/Watsyn/Watsyn.cpp b/plugins/Watsyn/Watsyn.cpp index 7916eb45f11..7603a9c1be6 100644 --- a/plugins/Watsyn/Watsyn.cpp +++ b/plugins/Watsyn/Watsyn.cpp @@ -52,7 +52,7 @@ Plugin::Descriptor PLUGIN_EXPORT watsyn_plugin_descriptor = "4-oscillator modulatable wavetable synth" ), "Vesa Kivimäki ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), nullptr, nullptr, @@ -816,7 +816,7 @@ WatsynView::WatsynView( Instrument * _instrument, pal = QPalette(); pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap("wavegraph") ); // a1 graph - a1_graph = new Graph( this, Graph::LinearStyle, 224, 105 ); + a1_graph = new Graph( this, Graph::Style::Linear, 224, 105 ); a1_graph->move( 4, 141 ); a1_graph->setAutoFillBackground( true ); a1_graph->setGraphColor( QColor( 0x43, 0xb2, 0xff ) ); @@ -824,7 +824,7 @@ WatsynView::WatsynView( Instrument * _instrument, a1_graph->setPalette( pal ); // a2 graph - a2_graph = new Graph( this, Graph::LinearStyle, 224, 105 ); + a2_graph = new Graph( this, Graph::Style::Linear, 224, 105 ); a2_graph->move( 4, 141 ); a2_graph->setAutoFillBackground( true ); a2_graph->setGraphColor( QColor( 0x43, 0xb2, 0xff ) ); @@ -832,7 +832,7 @@ WatsynView::WatsynView( Instrument * _instrument, a2_graph->setPalette( pal ); // b1 graph - b1_graph = new Graph( this, Graph::LinearStyle, 224, 105 ); + b1_graph = new Graph( this, Graph::Style::Linear, 224, 105 ); b1_graph->move( 4, 141 ); b1_graph->setAutoFillBackground( true ); b1_graph->setGraphColor( QColor( 0xfc, 0x54, 0x31 ) ); @@ -840,7 +840,7 @@ WatsynView::WatsynView( Instrument * _instrument, b1_graph->setPalette( pal ); // b2 graph - b2_graph = new Graph( this, Graph::LinearStyle, 224, 105 ); + b2_graph = new Graph( this, Graph::Style::Linear, 224, 105 ); b2_graph->move( 4, 141 ); b2_graph->setAutoFillBackground( true ); b2_graph->setGraphColor( QColor( 0xfc, 0x54, 0x31 ) ); diff --git a/plugins/Watsyn/Watsyn.h b/plugins/Watsyn/Watsyn.h index 3c69be06f1a..3a736e1621f 100644 --- a/plugins/Watsyn/Watsyn.h +++ b/plugins/Watsyn/Watsyn.h @@ -39,14 +39,14 @@ namespace lmms #define makeknob( name, x, y, hint, unit, oname ) \ - name = new Knob( knobStyled, this ); \ + name = new Knob( KnobType::Styled, this ); \ name ->move( x, y ); \ name ->setHintText( hint, unit ); \ name ->setObjectName( oname ); \ name ->setFixedSize( 19, 19 ); #define maketsknob( name, x, y, hint, unit, oname ) \ - name = new TempoSyncKnob( knobStyled, this ); \ + name = new TempoSyncKnob( KnobType::Styled, this ); \ name ->move( x, y ); \ name ->setHintText( hint, unit ); \ name ->setObjectName( oname ); \ diff --git a/plugins/WaveShaper/WaveShaper.cpp b/plugins/WaveShaper/WaveShaper.cpp index 94845e6726e..acd5a933b07 100644 --- a/plugins/WaveShaper/WaveShaper.cpp +++ b/plugins/WaveShaper/WaveShaper.cpp @@ -46,7 +46,7 @@ Plugin::Descriptor PLUGIN_EXPORT waveshaper_plugin_descriptor = "plugin for waveshaping" ), "Vesa Kivimäki ", 0x0100, - Plugin::Effect, + Plugin::Type::Effect, new PluginPixmapLoader("logo"), nullptr, nullptr, diff --git a/plugins/WaveShaper/WaveShaperControlDialog.cpp b/plugins/WaveShaper/WaveShaperControlDialog.cpp index 5ef061fdb58..045f84763f6 100644 --- a/plugins/WaveShaper/WaveShaperControlDialog.cpp +++ b/plugins/WaveShaper/WaveShaperControlDialog.cpp @@ -48,7 +48,7 @@ WaveShaperControlDialog::WaveShaperControlDialog( setPalette( pal ); setFixedSize( 224, 274 ); - auto waveGraph = new Graph(this, Graph::LinearNonCyclicStyle, 204, 205); + auto waveGraph = new Graph(this, Graph::Style::LinearNonCyclic, 204, 205); waveGraph -> move( 10, 6 ); waveGraph -> setModel( &_controls -> m_wavegraphModel ); waveGraph -> setAutoFillBackground( true ); @@ -59,7 +59,7 @@ WaveShaperControlDialog::WaveShaperControlDialog( waveGraph->setGraphColor( QColor( 85, 204, 145 ) ); waveGraph -> setMaximumSize( 204, 205 ); - auto inputKnob = new Knob(knobBright_26, this); + auto inputKnob = new Knob(KnobType::Bright26, this); inputKnob -> setVolumeKnob( true ); inputKnob -> setVolumeRatio( 1.0 ); inputKnob -> move( 26, 225 ); @@ -67,7 +67,7 @@ WaveShaperControlDialog::WaveShaperControlDialog( inputKnob->setLabel( tr( "INPUT" ) ); inputKnob->setHintText( tr( "Input gain:" ) , "" ); - auto outputKnob = new Knob(knobBright_26, this); + auto outputKnob = new Knob(KnobType::Bright26, this); outputKnob -> setVolumeKnob( true ); outputKnob -> setVolumeRatio( 1.0 ); outputKnob -> move( 76, 225 ); @@ -103,7 +103,7 @@ WaveShaperControlDialog::WaveShaperControlDialog( subOneButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "sub1_inactive" ) ); subOneButton->setToolTip(tr("Decrease wavegraph amplitude by 1 dB")); - auto clipInputToggle = new LedCheckBox("Clip input", this, tr("Clip input"), LedCheckBox::Green); + auto clipInputToggle = new LedCheckBox("Clip input", this, tr("Clip input"), LedCheckBox::LedColor::Green); clipInputToggle -> move( 131, 252 ); clipInputToggle -> setModel( &_controls -> m_clipModel ); clipInputToggle->setToolTip(tr("Clip input signal to 0 dB")); diff --git a/plugins/Xpressive/Xpressive.cpp b/plugins/Xpressive/Xpressive.cpp index 3cc5564e655..b1a17a1ce76 100644 --- a/plugins/Xpressive/Xpressive.cpp +++ b/plugins/Xpressive/Xpressive.cpp @@ -57,7 +57,7 @@ extern "C" { Plugin::Descriptor PLUGIN_EXPORT xpressive_plugin_descriptor = { LMMS_STRINGIFY( PLUGIN_NAME), "Xpressive", QT_TRANSLATE_NOOP("PluginBrowser", "Mathematical expression parser"), "Orr Dvori", 0x0100, - Plugin::Instrument, new PluginPixmapLoader("logo"), nullptr, nullptr }; + Plugin::Type::Instrument, new PluginPixmapLoader("logo"), nullptr, nullptr }; } @@ -291,11 +291,11 @@ class XpressiveKnob: public Knob { setLineWidth(3); } XpressiveKnob(QWidget * _parent, const QString & _name) : - Knob(knobStyled, _parent,_name) { + Knob(KnobType::Styled, _parent,_name) { setStyle(); } XpressiveKnob(QWidget * _parent) : - Knob(knobStyled, _parent) { + Knob(KnobType::Styled, _parent) { setStyle(); } @@ -325,7 +325,7 @@ XpressiveView::XpressiveView(Instrument * _instrument, QWidget * _parent) : pal.setBrush(backgroundRole(), PLUGIN_NAME::getIconPixmap("artwork")); setPalette(pal); - m_graph = new Graph(this, Graph::LinearStyle, 180, 81); + m_graph = new Graph(this, Graph::Style::Linear, 180, 81); m_graph->move(3, BASE_START + 1); m_graph->setAutoFillBackground(true); m_graph->setGraphColor(QColor(255, 255, 255)); @@ -447,11 +447,11 @@ XpressiveView::XpressiveView(Instrument * _instrument, QWidget * _parent) : m_waveInterpolate = new LedCheckBox("Interpolate", this, tr("WaveInterpolate"), - LedCheckBox::Green); + LedCheckBox::LedColor::Green); m_waveInterpolate->move(2, 230); m_expressionValidToggle = new LedCheckBox("", this, tr("ExpressionValid"), - LedCheckBox::Red); + LedCheckBox::LedColor::Red); m_expressionValidToggle->move(168, EXPR_TEXT_Y+EXPR_TEXT_H-2); m_expressionValidToggle->setEnabled( false ); @@ -485,7 +485,7 @@ XpressiveView::XpressiveView(Instrument * _instrument, QWidget * _parent) : - m_smoothKnob=new Knob(knobStyled, this, "Smoothness"); + m_smoothKnob=new Knob(KnobType::Styled, this, "Smoothness"); m_smoothKnob->setFixedSize(25, 25); m_smoothKnob->setCenterPointX(12.5); m_smoothKnob->setCenterPointY(12.5); diff --git a/plugins/ZynAddSubFx/ZynAddSubFx.cpp b/plugins/ZynAddSubFx/ZynAddSubFx.cpp index d3d23c65f43..2ec86459281 100644 --- a/plugins/ZynAddSubFx/ZynAddSubFx.cpp +++ b/plugins/ZynAddSubFx/ZynAddSubFx.cpp @@ -66,7 +66,7 @@ Plugin::Descriptor PLUGIN_EXPORT zynaddsubfx_plugin_descriptor = "Embedded ZynAddSubFX" ), "Tobias Doerffel ", 0x0100, - Plugin::Instrument, + Plugin::Type::Instrument, new PluginPixmapLoader( "logo" ), "xiz", nullptr, @@ -151,8 +151,8 @@ ZynAddSubFxInstrument::ZynAddSubFxInstrument( ZynAddSubFxInstrument::~ZynAddSubFxInstrument() { Engine::audioEngine()->removePlayHandlesOfTypes( instrumentTrack(), - PlayHandle::TypeNotePlayHandle - | PlayHandle::TypeInstrumentPlayHandle ); + PlayHandle::Type::NotePlayHandle + | PlayHandle::Type::InstrumentPlayHandle ); m_pluginMutex.lock(); delete m_plugin; @@ -380,7 +380,7 @@ bool ZynAddSubFxInstrument::handleMidiEvent( const MidiEvent& event, const TimeP void ZynAddSubFxInstrument::reloadPlugin() { // save state of current plugin instance - DataFile m( DataFile::InstrumentTrackSettings ); + DataFile m( DataFile::Type::InstrumentTrackSettings ); saveSettings( m, m.content() ); // init plugin (will delete current one and create a new instance) @@ -508,31 +508,31 @@ ZynAddSubFxView::ZynAddSubFxView( Instrument * _instrument, QWidget * _parent ) l->setVerticalSpacing( 16 ); l->setHorizontalSpacing( 10 ); - m_portamento = new Knob( knobBright_26, this ); + m_portamento = new Knob( KnobType::Bright26, this ); m_portamento->setHintText( tr( "Portamento:" ), "" ); m_portamento->setLabel( tr( "PORT" ) ); - m_filterFreq = new Knob( knobBright_26, this ); + m_filterFreq = new Knob( KnobType::Bright26, this ); m_filterFreq->setHintText( tr( "Filter frequency:" ), "" ); m_filterFreq->setLabel( tr( "FREQ" ) ); - m_filterQ = new Knob( knobBright_26, this ); + m_filterQ = new Knob( KnobType::Bright26, this ); m_filterQ->setHintText( tr( "Filter resonance:" ), "" ); m_filterQ->setLabel( tr( "RES" ) ); - m_bandwidth = new Knob( knobBright_26, this ); + m_bandwidth = new Knob( KnobType::Bright26, this ); m_bandwidth->setHintText( tr( "Bandwidth:" ), "" ); m_bandwidth->setLabel( tr( "BW" ) ); - m_fmGain = new Knob( knobBright_26, this ); + m_fmGain = new Knob( KnobType::Bright26, this ); m_fmGain->setHintText( tr( "FM gain:" ), "" ); m_fmGain->setLabel( tr( "FM GAIN" ) ); - m_resCenterFreq = new Knob( knobBright_26, this ); + m_resCenterFreq = new Knob( KnobType::Bright26, this ); m_resCenterFreq->setHintText( tr( "Resonance center frequency:" ), "" ); m_resCenterFreq->setLabel( tr( "RES CF" ) ); - m_resBandwidth = new Knob( knobBright_26, this ); + m_resBandwidth = new Knob( KnobType::Bright26, this ); m_resBandwidth->setHintText( tr( "Resonance bandwidth:" ), "" ); m_resBandwidth->setLabel( tr( "RES BW" ) ); diff --git a/plugins/ZynAddSubFx/ZynAddSubFx.h b/plugins/ZynAddSubFx/ZynAddSubFx.h index 996c187ee45..a391203f382 100644 --- a/plugins/ZynAddSubFx/ZynAddSubFx.h +++ b/plugins/ZynAddSubFx/ZynAddSubFx.h @@ -88,7 +88,7 @@ class ZynAddSubFxInstrument : public Instrument Flags flags() const override { - return IsSingleStreamed | IsMidiBased; + return Flag::IsSingleStreamed | Flag::IsMidiBased; } gui::PluginView* instantiateView( QWidget * _parent ) override; diff --git a/src/core/AudioEngine.cpp b/src/core/AudioEngine.cpp index 59c7f2cd217..21a9a3598bc 100644 --- a/src/core/AudioEngine.cpp +++ b/src/core/AudioEngine.cpp @@ -81,7 +81,7 @@ AudioEngine::AudioEngine( bool renderOnly ) : m_workers(), m_numWorkers( QThread::idealThreadCount()-1 ), m_newPlayHandles( PlayHandle::MaxNumber ), - m_qualitySettings( qualitySettings::Mode_Draft ), + m_qualitySettings( qualitySettings::Mode::Draft ), m_masterGain( 1.0f ), m_isProcessing( false ), m_audioDev( nullptr ), @@ -357,7 +357,7 @@ const surroundSampleFrame * AudioEngine::renderNextBuffer() if( it != m_playHandles.end() ) { ( *it )->audioPort()->removePlayHandle( ( *it ) ); - if( ( *it )->type() == PlayHandle::TypeNotePlayHandle ) + if( ( *it )->type() == PlayHandle::Type::NotePlayHandle ) { NotePlayHandleManager::release( (NotePlayHandle*) *it ); } @@ -405,7 +405,7 @@ const surroundSampleFrame * AudioEngine::renderNextBuffer() if( ( *it )->isFinished() ) { ( *it )->audioPort()->removePlayHandle( ( *it ) ); - if( ( *it )->type() == PlayHandle::TypeNotePlayHandle ) + if( ( *it )->type() == PlayHandle::Type::NotePlayHandle ) { NotePlayHandleManager::release( (NotePlayHandle*) *it ); } @@ -464,12 +464,12 @@ void AudioEngine::handleMetronome() static tick_t lastMetroTicks = -1; Song * song = Engine::getSong(); - Song::PlayModes currentPlayMode = song->playMode(); + Song::PlayMode currentPlayMode = song->playMode(); bool metronomeSupported = - currentPlayMode == Song::Mode_PlayMidiClip - || currentPlayMode == Song::Mode_PlaySong - || currentPlayMode == Song::Mode_PlayPattern; + currentPlayMode == Song::PlayMode::MidiClip + || currentPlayMode == Song::PlayMode::Song + || currentPlayMode == Song::PlayMode::Pattern; if (!metronomeSupported || !m_metronomeActive || song->isExporting()) { @@ -534,7 +534,7 @@ void AudioEngine::clearInternal() // TODO: m_midiClient->noteOffAll(); for (auto ph : m_playHandles) { - if (ph->type() != PlayHandle::TypeInstrumentPlayHandle) + if (ph->type() != PlayHandle::Type::InstrumentPlayHandle) { m_playHandlesToRemove.push_back(ph); } @@ -681,7 +681,7 @@ bool AudioEngine::addPlayHandle( PlayHandle* handle ) return true; } - if( handle->type() == PlayHandle::TypeNotePlayHandle ) + if( handle->type() == PlayHandle::Type::NotePlayHandle ) { NotePlayHandleManager::release( (NotePlayHandle*)handle ); } @@ -732,7 +732,7 @@ void AudioEngine::removePlayHandle(PlayHandle * ph) // (See tobydox's 2008 commit 4583e48) if ( removedFromList ) { - if (ph->type() == PlayHandle::TypeNotePlayHandle) + if (ph->type() == PlayHandle::Type::NotePlayHandle) { NotePlayHandleManager::release(dynamic_cast(ph)); } @@ -749,7 +749,7 @@ void AudioEngine::removePlayHandle(PlayHandle * ph) -void AudioEngine::removePlayHandlesOfTypes(Track * track, const quint8 types) +void AudioEngine::removePlayHandlesOfTypes(Track * track, PlayHandle::Types types) { requestChangeInModel(); PlayHandleList::Iterator it = m_playHandles.begin(); @@ -758,7 +758,7 @@ void AudioEngine::removePlayHandlesOfTypes(Track * track, const quint8 types) if ((*it)->isFromTrack(track) && ((*it)->type() & types)) { ( *it )->audioPort()->removePlayHandle( ( *it ) ); - if( ( *it )->type() == PlayHandle::TypeNotePlayHandle ) + if( ( *it )->type() == PlayHandle::Type::NotePlayHandle ) { NotePlayHandleManager::release( (NotePlayHandle*) *it ); } diff --git a/src/core/AudioEngineWorkerThread.cpp b/src/core/AudioEngineWorkerThread.cpp index 129b3accf77..528841c7128 100644 --- a/src/core/AudioEngineWorkerThread.cpp +++ b/src/core/AudioEngineWorkerThread.cpp @@ -91,7 +91,7 @@ void AudioEngineWorkerThread::JobQueue::run() } } // always exit loop if we're not in dynamic mode - processedJob = processedJob && ( m_opMode == Dynamic ); + processedJob = processedJob && ( m_opMode == OperationMode::Dynamic ); } } diff --git a/src/core/AutomatableModel.cpp b/src/core/AutomatableModel.cpp index c25e813cb9e..e46a864f897 100644 --- a/src/core/AutomatableModel.cpp +++ b/src/core/AutomatableModel.cpp @@ -44,7 +44,7 @@ AutomatableModel::AutomatableModel( const float val, const float min, const float max, const float step, Model* parent, const QString & displayName, bool defaultConstructed ) : Model( parent, displayName, defaultConstructed ), - m_scaleType( Linear ), + m_scaleType( ScaleType::Linear ), m_minValue( min ), m_maxValue( max ), m_step( step ), @@ -105,7 +105,7 @@ void AutomatableModel::saveSettings( QDomDocument& doc, QDomElement& element, co { bool mustQuote = mustQuoteName(name); - if( isAutomated() || m_scaleType != Linear ) + if( isAutomated() || m_scaleType != ScaleType::Linear ) { // automation needs tuple of data (name, id, value) // scale type also needs an extra value @@ -114,7 +114,7 @@ void AutomatableModel::saveSettings( QDomDocument& doc, QDomElement& element, co QDomElement me = doc.createElement( mustQuote ? QString("automatablemodel") : name ); me.setAttribute( "id", ProjectJournal::idToSave( id() ) ); me.setAttribute( "value", m_value ); - me.setAttribute( "scale_type", m_scaleType == Logarithmic ? "log" : "linear" ); + me.setAttribute( "scale_type", m_scaleType == ScaleType::Logarithmic ? "log" : "linear" ); if(mustQuote) { me.setAttribute( "nodename", name ); } @@ -140,11 +140,11 @@ void AutomatableModel::saveSettings( QDomDocument& doc, QDomElement& element, co // the discardMIDIConnections option is true. auto controllerType = m_controllerConnection ? m_controllerConnection->getController()->type() - : Controller::DummyController; + : Controller::ControllerType::Dummy; bool skipMidiController = Engine::getSong()->isSavingProject() && Engine::getSong()->getSaveOptions().discardMIDIConnections.value(); - if (m_controllerConnection && controllerType != Controller::DummyController - && !(skipMidiController && controllerType == Controller::MidiController)) + if (m_controllerConnection && controllerType != Controller::ControllerType::Dummy + && !(skipMidiController && controllerType == Controller::ControllerType::Midi)) { QDomElement controllerElement; @@ -264,18 +264,18 @@ void AutomatableModel::loadSettings( const QDomElement& element, const QString& { if( nodeElement.attribute( "scale_type" ) == "linear" ) { - setScaleType( Linear ); + setScaleType( ScaleType::Linear ); } else if( nodeElement.attribute( "scale_type" ) == "log" ) { - setScaleType( Logarithmic ); + setScaleType( ScaleType::Logarithmic ); } } } else { - setScaleType( Linear ); + setScaleType( ScaleType::Linear ); if( element.hasAttribute( name ) ) // attribute => read the element's value from the attribute list @@ -335,7 +335,7 @@ template T AutomatableModel::logToLinearScale( T value ) const float AutomatableModel::scaledValue( float value ) const { - return m_scaleType == Linear + return m_scaleType == ScaleType::Linear ? value : logToLinearScale( ( value - minValue() ) / m_range ); } @@ -343,7 +343,7 @@ float AutomatableModel::scaledValue( float value ) const float AutomatableModel::inverseScaledValue( float value ) const { - return m_scaleType == Linear + return m_scaleType == ScaleType::Linear ? value : lmms::linearToLogScale( minValue(), maxValue(), value ); } @@ -571,10 +571,10 @@ float AutomatableModel::controllerValue( int frameOffset ) const float v = 0; switch(m_scaleType) { - case Linear: + case ScaleType::Linear: v = minValue() + ( range() * controllerConnection()->currentValue( frameOffset ) ); break; - case Logarithmic: + case ScaleType::Logarithmic: v = logToLinearScale( controllerConnection()->currentValue( frameOffset )); break; @@ -623,13 +623,13 @@ ValueBuffer * AutomatableModel::valueBuffer() float * nvalues = m_valueBuffer.values(); switch( m_scaleType ) { - case Linear: + case ScaleType::Linear: for( int i = 0; i < m_valueBuffer.length(); i++ ) { nvalues[i] = minValue() + ( range() * values[i] ); } break; - case Logarithmic: + case ScaleType::Logarithmic: for( int i = 0; i < m_valueBuffer.length(); i++ ) { nvalues[i] = logToLinearScale( values[i] ); diff --git a/src/core/AutomationClip.cpp b/src/core/AutomationClip.cpp index e55fc5c1ef3..906cb148c82 100644 --- a/src/core/AutomationClip.cpp +++ b/src/core/AutomationClip.cpp @@ -53,7 +53,7 @@ AutomationClip::AutomationClip( AutomationTrack * _auto_track ) : m_autoTrack( _auto_track ), m_objects(), m_tension( 1.0 ), - m_progressionType( DiscreteProgression ), + m_progressionType( ProgressionType::Discrete ), m_dragging( false ), m_isRecording( false ), m_lastRecordedValue( 0 ) @@ -63,11 +63,11 @@ AutomationClip::AutomationClip( AutomationTrack * _auto_track ) : { switch( getTrack()->trackContainer()->type() ) { - case TrackContainer::PatternContainer: + case TrackContainer::Type::Pattern: setAutoResize( true ); break; - case TrackContainer::SongContainer: + case TrackContainer::Type::Song: // move down default: setAutoResize( false ); @@ -104,11 +104,11 @@ AutomationClip::AutomationClip( const AutomationClip & _clip_to_copy ) : if (!getTrack()){ return; } switch( getTrack()->trackContainer()->type() ) { - case TrackContainer::PatternContainer: + case TrackContainer::Type::Pattern: setAutoResize( true ); break; - case TrackContainer::SongContainer: + case TrackContainer::Type::Song: // move down default: setAutoResize( false ); @@ -147,13 +147,13 @@ bool AutomationClip::addObject( AutomatableModel * _obj, bool _search_dup ) void AutomationClip::setProgressionType( - ProgressionTypes _new_progression_type ) + ProgressionType _new_progression_type ) { QMutexLocker m(&m_clipMutex); - if ( _new_progression_type == DiscreteProgression || - _new_progression_type == LinearProgression || - _new_progression_type == CubicHermiteProgression ) + if ( _new_progression_type == ProgressionType::Discrete || + _new_progression_type == ProgressionType::Linear || + _new_progression_type == ProgressionType::CubicHermite ) { m_progressionType = _new_progression_type; emit dataChanged(); @@ -560,11 +560,11 @@ float AutomationClip::valueAt( timeMap::const_iterator v, int offset ) const // value if we do if (offset == 0) { return INVAL(v); } - if (m_progressionType == DiscreteProgression) + if (m_progressionType == ProgressionType::Discrete) { return OUTVAL(v); } - else if( m_progressionType == LinearProgression ) + else if( m_progressionType == ProgressionType::Linear ) { float slope = (INVAL(v + 1) - OUTVAL(v)) @@ -572,7 +572,7 @@ float AutomationClip::valueAt( timeMap::const_iterator v, int offset ) const return OUTVAL(v) + offset * slope; } - else /* CubicHermiteProgression */ + else /* ProgressionType::CubicHermite */ { // Implements a Cubic Hermite spline as explained at: // http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Unit_interval_.280.2C_1.29 @@ -767,7 +767,7 @@ void AutomationClip::saveSettings( QDomDocument & _doc, QDomElement & _this ) _this.setAttribute( "pos", startPosition() ); _this.setAttribute( "len", length() ); _this.setAttribute( "name", name() ); - _this.setAttribute( "prog", QString::number( progressionType() ) ); + _this.setAttribute( "prog", QString::number( static_cast(progressionType()) ) ); _this.setAttribute( "tens", QString::number( getTension() ) ); _this.setAttribute( "mute", QString::number( isMuted() ) ); @@ -808,7 +808,7 @@ void AutomationClip::loadSettings( const QDomElement & _this ) movePosition( _this.attribute( "pos" ).toInt() ); setName( _this.attribute( "name" ) ); - setProgressionType( static_cast( _this.attribute( + setProgressionType( static_cast( _this.attribute( "prog" ).toInt() ) ); setTension( _this.attribute( "tens" ) ); setMuted(_this.attribute( "mute", QString::number( false ) ).toInt() ); @@ -891,7 +891,7 @@ bool AutomationClip::isAutomated( const AutomatableModel * _m ) auto l = combineAllTracks(); for (const auto track : l) { - if (track->type() == Track::AutomationTrack || track->type() == Track::HiddenAutomationTrack) + if (track->type() == Track::Type::Automation || track->type() == Track::Type::HiddenAutomation) { for (const auto& clip : track->getClips()) { @@ -926,7 +926,7 @@ std::vector AutomationClip::clipsForModel(const AutomatableMod for (const auto track : l) { // we want only automation tracks... - if (track->type() == Track::AutomationTrack || track->type() == Track::HiddenAutomationTrack ) + if (track->type() == Track::Type::Automation || track->type() == Track::Type::HiddenAutomation ) { // go through all the clips... for (const auto& trackClip : track->getClips()) @@ -985,7 +985,7 @@ void AutomationClip::resolveAllIDs() auto l = combineAllTracks(); for (const auto& track : l) { - if (track->type() == Track::AutomationTrack || track->type() == Track::HiddenAutomationTrack) + if (track->type() == Track::Type::Automation || track->type() == Track::Type::HiddenAutomation) { for (const auto& clip : track->getClips()) { diff --git a/src/core/BandLimitedWave.cpp b/src/core/BandLimitedWave.cpp index a92b22e21ea..cb09dc5b8f5 100644 --- a/src/core/BandLimitedWave.cpp +++ b/src/core/BandLimitedWave.cpp @@ -30,7 +30,7 @@ namespace lmms { -std::array BandLimitedWave::s_waveforms = { }; +std::array BandLimitedWave::s_waveforms = { }; bool BandLimitedWave::s_wavesGenerated = false; QString BandLimitedWave::s_wavetableDir = ""; @@ -84,7 +84,7 @@ void BandLimitedWave::generateWaves() { saw_file.open( QIODevice::ReadOnly ); QDataStream in( &saw_file ); - in >> s_waveforms[ BandLimitedWave::BLSaw ]; + in >> s_waveforms[static_cast(BandLimitedWave::Waveform::BLSaw)]; saw_file.close(); } else @@ -108,14 +108,14 @@ void BandLimitedWave::generateWaves() s += amp * /*a2 **/sin( static_cast( ph * harm ) / static_cast( len ) * F_2PI ); harm++; } while( hlen > 2.0 ); - s_waveforms[ BandLimitedWave::BLSaw ].setSampleAt( i, ph, s ); + s_waveforms[static_cast(BandLimitedWave::Waveform::BLSaw)].setSampleAt( i, ph, s ); max = std::max(max, std::abs(s)); } // normalize for( int ph = 0; ph < len; ph++ ) { - sample_t s = s_waveforms[ BandLimitedWave::BLSaw ].sampleAt( i, ph ) / max; - s_waveforms[ BandLimitedWave::BLSaw ].setSampleAt( i, ph, s ); + sample_t s = s_waveforms[static_cast(BandLimitedWave::Waveform::BLSaw)].sampleAt( i, ph ) / max; + s_waveforms[static_cast(BandLimitedWave::Waveform::BLSaw)].setSampleAt( i, ph, s ); } } } @@ -126,7 +126,7 @@ void BandLimitedWave::generateWaves() { sqr_file.open( QIODevice::ReadOnly ); QDataStream in( &sqr_file ); - in >> s_waveforms[ BandLimitedWave::BLSquare ]; + in >> s_waveforms[static_cast(BandLimitedWave::Waveform::BLSquare)]; sqr_file.close(); } else @@ -150,14 +150,14 @@ void BandLimitedWave::generateWaves() s += amp * /*a2 **/ sin( static_cast( ph * harm ) / static_cast( len ) * F_2PI ); harm += 2; } while( hlen > 2.0 ); - s_waveforms[ BandLimitedWave::BLSquare ].setSampleAt( i, ph, s ); + s_waveforms[static_cast(BandLimitedWave::Waveform::BLSquare)].setSampleAt( i, ph, s ); max = std::max(max, std::abs(s)); } // normalize for( int ph = 0; ph < len; ph++ ) { - sample_t s = s_waveforms[ BandLimitedWave::BLSquare ].sampleAt( i, ph ) / max; - s_waveforms[ BandLimitedWave::BLSquare ].setSampleAt( i, ph, s ); + sample_t s = s_waveforms[static_cast(BandLimitedWave::Waveform::BLSquare)].sampleAt( i, ph ) / max; + s_waveforms[static_cast(BandLimitedWave::Waveform::BLSquare)].setSampleAt( i, ph, s ); } } } @@ -167,7 +167,7 @@ void BandLimitedWave::generateWaves() { tri_file.open( QIODevice::ReadOnly ); QDataStream in( &tri_file ); - in >> s_waveforms[ BandLimitedWave::BLTriangle ]; + in >> s_waveforms[static_cast(BandLimitedWave::Waveform::BLTriangle)]; tri_file.close(); } else @@ -192,14 +192,14 @@ void BandLimitedWave::generateWaves() ( ( harm + 1 ) % 4 == 0 ? 0.5 : 0.0 ) ) * F_2PI ); harm += 2; } while( hlen > 2.0 ); - s_waveforms[ BandLimitedWave::BLTriangle ].setSampleAt( i, ph, s ); + s_waveforms[static_cast(BandLimitedWave::Waveform::BLTriangle)].setSampleAt( i, ph, s ); max = std::max(max, std::abs(s)); } // normalize for( int ph = 0; ph < len; ph++ ) { - sample_t s = s_waveforms[ BandLimitedWave::BLTriangle ].sampleAt( i, ph ) / max; - s_waveforms[ BandLimitedWave::BLTriangle ].setSampleAt( i, ph, s ); + sample_t s = s_waveforms[static_cast(BandLimitedWave::Waveform::BLTriangle)].sampleAt( i, ph ) / max; + s_waveforms[static_cast(BandLimitedWave::Waveform::BLTriangle)].setSampleAt( i, ph, s ); } } } @@ -210,7 +210,7 @@ void BandLimitedWave::generateWaves() { moog_file.open( QIODevice::ReadOnly ); QDataStream in( &moog_file ); - in >> s_waveforms[ BandLimitedWave::BLMoog ]; + in >> s_waveforms[static_cast(BandLimitedWave::Waveform::BLMoog)]; moog_file.close(); } else @@ -222,9 +222,9 @@ void BandLimitedWave::generateWaves() for( int ph = 0; ph < len; ph++ ) { const int sawph = ( ph + static_cast( len * 0.75 ) ) % len; - const sample_t saw = s_waveforms[ BandLimitedWave::BLSaw ].sampleAt( i, sawph ); - const sample_t tri = s_waveforms[ BandLimitedWave::BLTriangle ].sampleAt( i, ph ); - s_waveforms[ BandLimitedWave::BLMoog ].setSampleAt( i, ph, ( saw + tri ) * 0.5f ); + const sample_t saw = s_waveforms[static_cast(BandLimitedWave::Waveform::BLSaw)].sampleAt( i, sawph ); + const sample_t tri = s_waveforms[static_cast(BandLimitedWave::Waveform::BLTriangle)].sampleAt( i, ph ); + s_waveforms[static_cast(BandLimitedWave::Waveform::BLMoog)].setSampleAt( i, ph, ( saw + tri ) * 0.5f ); } } } @@ -252,22 +252,22 @@ QFile moogfile( "path-to-wavetables/moog.bin" ); sawfile.open( QIODevice::WriteOnly ); QDataStream sawout( &sawfile ); -sawout << s_waveforms[ BandLimitedWave::BLSaw ]; +sawout << s_waveforms[static_cast(BandLimitedWave::Waveform::BLSaw)]; sawfile.close(); sqrfile.open( QIODevice::WriteOnly ); QDataStream sqrout( &sqrfile ); -sqrout << s_waveforms[ BandLimitedWave::BLSquare ]; +sqrout << s_waveforms[static_cast(BandLimitedWave::Waveform::BLSquare)]; sqrfile.close(); trifile.open( QIODevice::WriteOnly ); QDataStream triout( &trifile ); -triout << s_waveforms[ BandLimitedWave::BLTriangle ]; +triout << s_waveforms[static_cast(BandLimitedWave::Waveform::BLTriangle)]; trifile.close(); moogfile.open( QIODevice::WriteOnly ); QDataStream moogout( &moogfile ); -moogout << s_waveforms[ BandLimitedWave::BLMoog ]; +moogout << s_waveforms[static_cast(BandLimitedWave::Waveform::BLMoog)]; moogfile.close(); */ diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index 05574ae3532..61d84770a13 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -173,7 +173,7 @@ void ConfigManager::upgrade() ProjectVersion createdWith = m_version; // Don't use old themes as they break the UI (i.e. 0.4 != 1.0, etc) - if (createdWith.setCompareType(ProjectVersion::Minor) != LMMS_VERSION) + if (createdWith.setCompareType(ProjectVersion::CompareType::Minor) != LMMS_VERSION) { m_themeDir = defaultThemeDir(); } @@ -707,7 +707,7 @@ unsigned int ConfigManager::legacyConfigVersion() { ProjectVersion createdWith = m_version; - createdWith.setCompareType(ProjectVersion::Build); + createdWith.setCompareType(ProjectVersion::CompareType::Build); if( createdWith < "1.1.90" ) { diff --git a/src/core/Controller.cpp b/src/core/Controller.cpp index e7031f20cbb..3e1b596b8ca 100644 --- a/src/core/Controller.cpp +++ b/src/core/Controller.cpp @@ -44,7 +44,7 @@ std::vector Controller::s_controllers; -Controller::Controller( ControllerTypes _type, Model * _parent, +Controller::Controller( ControllerType _type, Model * _parent, const QString & _display_name ) : Model( _parent, _display_name ), JournallingObject(), @@ -53,7 +53,7 @@ Controller::Controller( ControllerTypes _type, Model * _parent, m_connectionCount( 0 ), m_type( _type ) { - if( _type != DummyController && _type != MidiController ) + if( _type != ControllerType::Dummy && _type != ControllerType::Midi ) { s_controllers.push_back(this); // Determine which name to use @@ -182,30 +182,30 @@ void Controller::resetFrameCounter() -Controller * Controller::create( ControllerTypes _ct, Model * _parent ) +Controller * Controller::create( ControllerType _ct, Model * _parent ) { static Controller * dummy = nullptr; Controller * c = nullptr; switch( _ct ) { - case Controller::DummyController: + case ControllerType::Dummy: if (!dummy) - dummy = new Controller( DummyController, nullptr, + dummy = new Controller( ControllerType::Dummy, nullptr, QString() ); c = dummy; break; - case Controller::LfoController: + case ControllerType::Lfo: c = new class LfoController( _parent ); break; - case Controller::PeakController: + case ControllerType::Peak: //Already instantiated in EffectChain::loadSettings() Q_ASSERT( false ); break; - case Controller::MidiController: + case ControllerType::Midi: c = new class MidiController( _parent ); break; @@ -221,14 +221,14 @@ Controller * Controller::create( ControllerTypes _ct, Model * _parent ) Controller * Controller::create( const QDomElement & _this, Model * _parent ) { Controller * c; - if( _this.attribute( "type" ).toInt() == Controller::PeakController ) + if( static_cast(_this.attribute( "type" ).toInt()) == ControllerType::Peak ) { c = PeakController::getControllerBySetting( _this ); } else { c = create( - static_cast( _this.attribute( "type" ).toInt() ), + static_cast( _this.attribute( "type" ).toInt() ), _parent ); } @@ -269,7 +269,7 @@ bool Controller::hasModel( const Model * m ) const void Controller::saveSettings( QDomDocument & _doc, QDomElement & _this ) { - _this.setAttribute( "type", type() ); + _this.setAttribute( "type", static_cast(type()) ); _this.setAttribute( "name", name() ); } @@ -277,7 +277,7 @@ void Controller::saveSettings( QDomDocument & _doc, QDomElement & _this ) void Controller::loadSettings( const QDomElement & _this ) { - if( _this.attribute( "type" ).toInt() != type() ) + if( static_cast(_this.attribute( "type" ).toInt()) != type() ) { qWarning( "controller-type does not match controller-type of " "settings-node!\n" ); diff --git a/src/core/ControllerConnection.cpp b/src/core/ControllerConnection.cpp index a4477c563f2..fea907942af 100644 --- a/src/core/ControllerConnection.cpp +++ b/src/core/ControllerConnection.cpp @@ -50,7 +50,7 @@ ControllerConnection::ControllerConnection(Controller * _controller) : } else { - m_controller = Controller::create( Controller::DummyController, + m_controller = Controller::create( Controller::ControllerType::Dummy, nullptr ); } s_connections.push_back(this); @@ -60,7 +60,7 @@ ControllerConnection::ControllerConnection(Controller * _controller) : ControllerConnection::ControllerConnection( int _controllerId ) : - m_controller( Controller::create( Controller::DummyController, nullptr ) ), + m_controller( Controller::create( Controller::ControllerType::Dummy, nullptr ) ), m_controllerId( _controllerId ), m_ownsController( false ) { @@ -72,7 +72,7 @@ ControllerConnection::ControllerConnection( int _controllerId ) : ControllerConnection::~ControllerConnection() { - if( m_controller && m_controller->type() != Controller::DummyController ) + if( m_controller && m_controller->type() != Controller::ControllerType::Dummy ) { m_controller->removeConnection( this ); } @@ -104,14 +104,14 @@ void ControllerConnection::setController( Controller * _controller ) m_controller = nullptr; } - if( m_controller && m_controller->type() != Controller::DummyController ) + if( m_controller && m_controller->type() != Controller::ControllerType::Dummy ) { m_controller->removeConnection( this ); } if( !_controller ) { - m_controller = Controller::create( Controller::DummyController, nullptr ); + m_controller = Controller::create( Controller::ControllerType::Dummy, nullptr ); } else { @@ -119,7 +119,7 @@ void ControllerConnection::setController( Controller * _controller ) } m_controllerId = -1; - if( _controller->type() != Controller::DummyController ) + if( _controller->type() != Controller::ControllerType::Dummy ) { _controller->addConnection( this ); QObject::connect( _controller, SIGNAL(valueChanged()), @@ -127,7 +127,7 @@ void ControllerConnection::setController( Controller * _controller ) } m_ownsController = - (_controller->type() == Controller::MidiController); + (_controller->type() == Controller::ControllerType::Midi); // If we don't own the controller, allow deletion of controller // to delete the connection @@ -168,7 +168,7 @@ void ControllerConnection::finalizeConnections() c->setController( Engine::getSong()-> controllers().at( c->m_controllerId ) ); } - else if (c->getController()->type() == Controller::DummyController) + else if (c->getController()->type() == Controller::ControllerType::Dummy) { delete c; --i; @@ -228,7 +228,7 @@ void ControllerConnection::loadSettings( const QDomElement & _this ) } else { - m_controller = Controller::create( Controller::DummyController, nullptr ); + m_controller = Controller::create( Controller::ControllerType::Dummy, nullptr ); } } } diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index 2361b19267f..6ad2f8526d8 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -26,6 +26,7 @@ #include "DataFile.h" +#include #include #include @@ -98,17 +99,16 @@ namespace QString m_name; }; - const auto s_types = std::array - { - TypeDescStruct{ DataFile::UnknownType, "unknown" }, - TypeDescStruct{ DataFile::SongProject, "song" }, - TypeDescStruct{ DataFile::SongProjectTemplate, "songtemplate" }, - TypeDescStruct{ DataFile::InstrumentTrackSettings, "instrumenttracksettings" }, - TypeDescStruct{ DataFile::DragNDropData, "dnddata" }, - TypeDescStruct{ DataFile::ClipboardData, "clipboard-data" }, - TypeDescStruct{ DataFile::JournalData, "journaldata" }, - TypeDescStruct{ DataFile::EffectSettings, "effectsettings" }, - TypeDescStruct{ DataFile::MidiClip, "midiclip" } + const auto s_types = std::array{ + TypeDescStruct{ DataFile::Type::Unknown, "unknown" }, + TypeDescStruct{ DataFile::Type::SongProject, "song" }, + TypeDescStruct{ DataFile::Type::SongProjectTemplate, "songtemplate" }, + TypeDescStruct{ DataFile::Type::InstrumentTrackSettings, "instrumenttracksettings" }, + TypeDescStruct{ DataFile::Type::DragNDropData, "dnddata" }, + TypeDescStruct{ DataFile::Type::ClipboardData, "clipboard-data" }, + TypeDescStruct{ DataFile::Type::JournalData, "journaldata" }, + TypeDescStruct{ DataFile::Type::EffectSettings, "effectsettings" }, + TypeDescStruct{ DataFile::Type::MidiClip, "midiclip" } }; } @@ -214,7 +214,7 @@ bool DataFile::validate( QString extension ) return true; } break; - case Type::UnknownType: + case Type::Unknown: if (! ( extension == "mmp" || extension == "mpt" || extension == "mmpz" || extension == "xpf" || extension == "xml" || ( extension == "xiz" && ! getPluginFactory()->pluginSupportingExtension(extension).isNull()) || @@ -251,7 +251,7 @@ QString DataFile::nameWithExtension( const QString & _fn ) const switch( type() ) { - case SongProject: + case Type::SongProject: if( extension != "mmp" && extension != "mpt" && extension != "mmpz" ) @@ -264,13 +264,13 @@ QString DataFile::nameWithExtension( const QString & _fn ) const return _fn + ".mmp"; } break; - case SongProjectTemplate: + case Type::SongProjectTemplate: if( extension != "mpt" ) { return _fn + ".mpt"; } break; - case InstrumentTrackSettings: + case Type::InstrumentTrackSettings: if( extension != "xpf" ) { return _fn + ".xpf"; @@ -286,8 +286,8 @@ QString DataFile::nameWithExtension( const QString & _fn ) const void DataFile::write( QTextStream & _strm ) { - if( type() == SongProject || type() == SongProjectTemplate - || type() == InstrumentTrackSettings ) + if( type() == Type::SongProject || type() == Type::SongProjectTemplate + || type() == Type::InstrumentTrackSettings ) { cleanMetaNodes( documentElement() ); } @@ -585,21 +585,17 @@ bool DataFile::hasLocalPlugins(QDomElement parent /* = QDomElement()*/, bool fir DataFile::Type DataFile::type( const QString& typeName ) { - for( int i = 0; i < TypeCount; ++i ) - { - if( s_types[i].m_name == typeName ) - { - return static_cast( i ); - } - } + const auto it = std::find_if(s_types.begin(), s_types.end(), + [&typeName](const TypeDescStruct& type) { return type.m_name == typeName; }); + if (it != s_types.end()) { return it->m_type; } // compat code if( typeName == "channelsettings" ) { - return DataFile::InstrumentTrackSettings; + return Type::InstrumentTrackSettings; } - return UnknownType; + return Type::Unknown; } @@ -607,12 +603,7 @@ DataFile::Type DataFile::type( const QString& typeName ) QString DataFile::typeName( Type type ) { - if( type >= UnknownType && type < TypeCount ) - { - return s_types[type].m_name; - } - - return s_types[UnknownType].m_name; + return s_types[static_cast(type)].m_name; } @@ -1760,8 +1751,8 @@ void DataFile::upgrade_bbTcoRename() for (int i = 0; !elements.item(i).isNull(); ++i) { auto e = elements.item(i).toElement(); - static_assert(Track::PatternTrack == 1, "Must be type=1 for backwards compatibility"); - if (e.attribute("type").toInt() == Track::PatternTrack) + static_assert(Track::Type::Pattern == static_cast(1), "Must be type=1 for backwards compatibility"); + if (static_cast(e.attribute("type").toInt()) == Track::Type::Pattern) { e.setAttribute("name", e.attribute("name").replace("Beat/Bassline", "Pattern")); } @@ -1789,7 +1780,7 @@ void DataFile::upgrade() documentElement().setAttribute( "creator", "LMMS" ); documentElement().setAttribute( "creatorversion", LMMS_VERSION ); - if( type() == SongProject || type() == SongProjectTemplate ) + if( type() == Type::SongProject || type() == Type::SongProjectTemplate ) { // Time-signature if ( !m_head.hasAttribute( "timesig_numerator" ) ) @@ -1867,8 +1858,8 @@ void DataFile::loadData( const QByteArray & _data, const QString & _sourceFile ) ProjectVersion createdWith = root.attribute("creatorversion"); ProjectVersion openedWith = LMMS_VERSION; - if (createdWith.setCompareType(ProjectVersion::Minor) - != openedWith.setCompareType(ProjectVersion::Minor) + if (createdWith.setCompareType(ProjectVersion::CompareType::Minor) + != openedWith.setCompareType(ProjectVersion::CompareType::Minor) && gui::getGUI() != nullptr && root.attribute("type") == "song" ){ auto projectType = _sourceFile.endsWith(".mpt") ? diff --git a/src/core/EnvelopeAndLfoParameters.cpp b/src/core/EnvelopeAndLfoParameters.cpp index a3f41b5aa19..0a9673c8e2c 100644 --- a/src/core/EnvelopeAndLfoParameters.cpp +++ b/src/core/EnvelopeAndLfoParameters.cpp @@ -113,7 +113,7 @@ EnvelopeAndLfoParameters::EnvelopeAndLfoParameters( SECS_PER_LFO_OSCILLATION * 1000.0, this, tr( "LFO frequency" ) ), m_lfoAmountModel( 0.0, -1.0, 1.0, 0.005, this, tr( "LFO mod amount" ) ), - m_lfoWaveModel( SineWave, 0, NumLfoShapes, this, tr( "LFO wave shape" ) ), + m_lfoWaveModel( static_cast(LfoShape::SineWave), 0, NumLfoShapes, this, tr( "LFO wave shape" ) ), m_x100Model( false, this, tr( "LFO frequency x 100" ) ), m_controlEnvAmountModel( false, this, tr( "Modulate env amount" ) ), m_lfoFrame( 0 ), @@ -209,28 +209,28 @@ inline sample_t EnvelopeAndLfoParameters::lfoShapeSample( fpp_t _frame_offset ) const float phase = frame / static_cast( m_lfoOscillationFrames ); sample_t shape_sample; - switch( m_lfoWaveModel.value() ) + switch( static_cast(m_lfoWaveModel.value()) ) { - case TriangleWave: + case LfoShape::TriangleWave: shape_sample = Oscillator::triangleSample( phase ); break; - case SquareWave: + case LfoShape::SquareWave: shape_sample = Oscillator::squareSample( phase ); break; - case SawWave: + case LfoShape::SawWave: shape_sample = Oscillator::sawSample( phase ); break; - case UserDefinedWave: + case LfoShape::UserDefinedWave: shape_sample = m_userWave.userWaveSample( phase ); break; - case RandomWave: + case LfoShape::RandomWave: if( frame == 0 ) { m_random = Oscillator::noiseSample( 0.0f ); } shape_sample = m_random; break; - case SineWave: + case LfoShape::SineWave: default: shape_sample = Oscillator::sinSample( phase ); break; diff --git a/src/core/ImportFilter.cpp b/src/core/ImportFilter.cpp index 35c34078e13..bc43b0c6c49 100644 --- a/src/core/ImportFilter.cpp +++ b/src/core/ImportFilter.cpp @@ -61,7 +61,7 @@ void ImportFilter::import( const QString & _file_to_import, const bool j = Engine::projectJournal()->isJournalling(); Engine::projectJournal()->setJournalling( false ); - for (const Plugin::Descriptor* desc : getPluginFactory()->descriptors(Plugin::ImportFilter)) + for (const Plugin::Descriptor* desc : getPluginFactory()->descriptors(Plugin::Type::ImportFilter)) { unique_ptr p(Plugin::instantiate( desc->name, nullptr, s.data() )); if( dynamic_cast( p.get() ) != nullptr && diff --git a/src/core/InstrumentFunctions.cpp b/src/core/InstrumentFunctions.cpp index d2fea9dbd01..431afd2fe5c 100644 --- a/src/core/InstrumentFunctions.cpp +++ b/src/core/InstrumentFunctions.cpp @@ -234,7 +234,7 @@ void InstrumentFunctionNoteStacking::processNote( NotePlayHandle * _n ) // at the same time we only add sub-notes if nothing of the note was // played yet, because otherwise we would add chord-subnotes every // time an audio-buffer is rendered... - if( ( _n->origin() == NotePlayHandle::OriginArpeggio || ( _n->hasParent() == false && _n->instrumentTrack()->isArpeggioEnabled() == false ) ) && + if( ( _n->origin() == NotePlayHandle::Origin::Arpeggio || ( _n->hasParent() == false && _n->instrumentTrack()->isArpeggioEnabled() == false ) ) && _n->totalFramesPlayed() == 0 && m_chordsEnabledModel.value() == true && ! _n->isReleased() ) { @@ -263,7 +263,7 @@ void InstrumentFunctionNoteStacking::processNote( NotePlayHandle * _n ) // different Engine::audioEngine()->addPlayHandle( NotePlayHandleManager::acquire( _n->instrumentTrack(), _n->offset(), _n->frames(), note_copy, - _n, -1, NotePlayHandle::OriginNoteStacking ) + _n, -1, NotePlayHandle::Origin::NoteStacking ) ); } } @@ -321,7 +321,7 @@ InstrumentFunctionArpeggio::InstrumentFunctionArpeggio( Model * _parent ) : m_arpDirectionModel.addItem( tr( "Up and down" ), std::make_unique( "arp_up_and_down" ) ); m_arpDirectionModel.addItem( tr( "Down and up" ), std::make_unique( "arp_up_and_down" ) ); m_arpDirectionModel.addItem( tr( "Random" ), std::make_unique( "arp_random" ) ); - m_arpDirectionModel.setInitValue( ArpDirUp ); + m_arpDirectionModel.setInitValue( static_cast(ArpDirection::Up) ); m_arpModeModel.addItem( tr( "Free" ), std::make_unique( "arp_free" ) ); m_arpModeModel.addItem( tr( "Sort" ), std::make_unique( "arp_sort" ) ); @@ -336,8 +336,8 @@ InstrumentFunctionArpeggio::InstrumentFunctionArpeggio( Model * _parent ) : void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) { const int base_note_key = _n->key(); - if( _n->origin() == NotePlayHandle::OriginArpeggio || - _n->origin() == NotePlayHandle::OriginNoteStacking || + if( _n->origin() == NotePlayHandle::Origin::Arpeggio || + _n->origin() == NotePlayHandle::Origin::NoteStacking || !m_arpEnabledModel.value() || _n->isReleased() ) { @@ -351,7 +351,7 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) ConstNotePlayHandleList cnphv = NotePlayHandle::nphsOfInstrumentTrack( _n->instrumentTrack() ); - if( m_arpModeModel.value() != FreeMode && cnphv.size() == 0 ) + if( static_cast(m_arpModeModel.value()) != ArpMode::Free && cnphv.size() == 0 ) { // maybe we're playing only a preset-preview-note? cnphv = PresetPreviewPlayHandle::nphsOfInstrumentTrack( _n->instrumentTrack() ); @@ -375,11 +375,11 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) // used for calculating remaining frames for arp-note, we have to add // arp_frames-1, otherwise the first arp-note will not be setup // correctly... -> arp_frames frames silence at the start of every note! - int cur_frame = ( ( m_arpModeModel.value() != FreeMode ) ? + int cur_frame = ( ( static_cast(m_arpModeModel.value()) != ArpMode::Free ) ? cnphv.first()->totalFramesPlayed() : _n->totalFramesPlayed() ) + arp_frames - 1; // used for loop - f_cnt_t frames_processed = ( m_arpModeModel.value() != FreeMode ) ? cnphv.first()->noteOffset() : _n->noteOffset(); + f_cnt_t frames_processed = ( static_cast(m_arpModeModel.value()) != ArpMode::Free ) ? cnphv.first()->noteOffset() : _n->noteOffset(); while( frames_processed < Engine::audioEngine()->framesPerPeriod() ) { @@ -397,7 +397,7 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) // in sorted mode: is it our turn or do we have to be quiet for // now? - if( m_arpModeModel.value() == SortMode && + if( static_cast(m_arpModeModel.value()) == ArpMode::Sort && ( ( cur_frame / arp_frames ) % total_range ) / range != (f_cnt_t) _n->index() ) { // update counters @@ -418,7 +418,7 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) } } - int dir = m_arpDirectionModel.value(); + auto dir = static_cast(m_arpDirectionModel.value()); // Miss notes randomly. We intercept int dir and abuse it // after need. :) @@ -427,22 +427,22 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) { if( 100 * ( (float) rand() / (float)( RAND_MAX + 1.0f ) ) < m_arpMissModel.value() ) { - dir = ArpDirRandom; + dir = ArpDirection::Random; } } int cur_arp_idx = 0; // process according to arpeggio-direction... - if( dir == ArpDirUp ) + if( dir == ArpDirection::Up ) { cur_arp_idx = ( cur_frame / arp_frames ) % range; } - else if( dir == ArpDirDown ) + else if( dir == ArpDirection::Down ) { cur_arp_idx = range - ( cur_frame / arp_frames ) % range - 1; } - else if( dir == ArpDirUpAndDown && range > 1 ) + else if( dir == ArpDirection::UpAndDown && range > 1 ) { // imagine, we had to play the arp once up and then // once down -> makes 2 * range possible notes... @@ -456,9 +456,9 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) cur_arp_idx = range - cur_arp_idx % ( range - 1 ) - 1; } } - else if( dir == ArpDirDownAndUp && range > 1 ) + else if( dir == ArpDirection::DownAndUp && range > 1 ) { - // copied from ArpDirUpAndDown above + // copied from ArpDirection::UpAndDown above cur_arp_idx = ( cur_frame / arp_frames ) % ( range * 2 - 2 ); // if greater than range, we have to play down... // looks like the code for arp_dir==DOWN... :) @@ -469,7 +469,7 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) // inverts direction cur_arp_idx = range - cur_arp_idx - 1; } - else if( dir == ArpDirRandom ) + else if( dir == ArpDirection::Random ) { // just pick a random chord-index cur_arp_idx = (int)( range * ( (float) rand() / (float) RAND_MAX ) ); @@ -479,7 +479,7 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) cur_arp_idx = static_cast(cur_arp_idx / m_arpRepeatsModel.value()); // Cycle notes - if( m_arpCycleModel.value() && dir != ArpDirRandom ) + if( m_arpCycleModel.value() && dir != ArpDirection::Random ) { cur_arp_idx *= m_arpCycleModel.value() + 1; cur_arp_idx %= static_cast( range / m_arpRepeatsModel.value() ); @@ -507,7 +507,7 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) gated_frames, Note( TimePos( 0 ), TimePos( 0 ), sub_note_key, _n->getVolume(), _n->getPanning(), _n->detuning() ), - _n, -1, NotePlayHandle::OriginArpeggio ) + _n, -1, NotePlayHandle::Origin::Arpeggio ) ); // update counters diff --git a/src/core/InstrumentPlayHandle.cpp b/src/core/InstrumentPlayHandle.cpp index 8c272cd475e..e1a9d9d65fd 100644 --- a/src/core/InstrumentPlayHandle.cpp +++ b/src/core/InstrumentPlayHandle.cpp @@ -31,7 +31,7 @@ namespace lmms InstrumentPlayHandle::InstrumentPlayHandle( Instrument * instrument, InstrumentTrack* instrumentTrack ) : - PlayHandle( TypeInstrumentPlayHandle ), + PlayHandle( Type::InstrumentPlayHandle ), m_instrument( instrument ) { setAudioPort( instrumentTrack->audioPort() ); diff --git a/src/core/InstrumentSoundShaping.cpp b/src/core/InstrumentSoundShaping.cpp index 4aeea453a45..07c3bbf7c0f 100644 --- a/src/core/InstrumentSoundShaping.cpp +++ b/src/core/InstrumentSoundShaping.cpp @@ -69,7 +69,7 @@ InstrumentSoundShaping::InstrumentSoundShaping( for( int i = 0; i < NumTargets; ++i ) { float value_for_zero_amount = 0.0; - if( i == Volume ) + if( static_cast(i) == Target::Volume ) { value_for_zero_amount = 1.0; } @@ -119,7 +119,7 @@ float InstrumentSoundShaping::volumeLevel( NotePlayHandle* n, const f_cnt_t fram } float level; - m_envLfoParameters[Volume]->fillLevel( &level, frame, envReleaseBegin, 1 ); + m_envLfoParameters[static_cast(Target::Volume)]->fillLevel( &level, frame, envReleaseBegin, 1 ); return level; } @@ -160,22 +160,22 @@ void InstrumentSoundShaping::processAudioBuffer( sampleFrame* buffer, { n->m_filter = std::make_unique>( Engine::audioEngine()->processingSampleRate() ); } - n->m_filter->setFilterType( m_filterModel.value() ); + n->m_filter->setFilterType( static_cast::FilterType>(m_filterModel.value()) ); - if( m_envLfoParameters[Cut]->isUsed() ) + if( m_envLfoParameters[static_cast(Target::Cut)]->isUsed() ) { - m_envLfoParameters[Cut]->fillLevel( cutBuffer.data(), envTotalFrames, envReleaseBegin, frames ); + m_envLfoParameters[static_cast(Target::Cut)]->fillLevel( cutBuffer.data(), envTotalFrames, envReleaseBegin, frames ); } - if( m_envLfoParameters[Resonance]->isUsed() ) + if( m_envLfoParameters[static_cast(Target::Resonance)]->isUsed() ) { - m_envLfoParameters[Resonance]->fillLevel( resBuffer.data(), envTotalFrames, envReleaseBegin, frames ); + m_envLfoParameters[static_cast(Target::Resonance)]->fillLevel( resBuffer.data(), envTotalFrames, envReleaseBegin, frames ); } const float fcv = m_filterCutModel.value(); const float frv = m_filterResModel.value(); - if( m_envLfoParameters[Cut]->isUsed() && - m_envLfoParameters[Resonance]->isUsed() ) + if( m_envLfoParameters[static_cast(Target::Cut)]->isUsed() && + m_envLfoParameters[static_cast(Target::Resonance)]->isUsed() ) { for( fpp_t frame = 0; frame < frames; ++frame ) { @@ -196,7 +196,7 @@ void InstrumentSoundShaping::processAudioBuffer( sampleFrame* buffer, buffer[frame][1] = n->m_filter->update( buffer[frame][1], 1 ); } } - else if( m_envLfoParameters[Cut]->isUsed() ) + else if( m_envLfoParameters[static_cast(Target::Cut)]->isUsed() ) { for( fpp_t frame = 0; frame < frames; ++frame ) { @@ -213,7 +213,7 @@ void InstrumentSoundShaping::processAudioBuffer( sampleFrame* buffer, buffer[frame][1] = n->m_filter->update( buffer[frame][1], 1 ); } } - else if( m_envLfoParameters[Resonance]->isUsed() ) + else if( m_envLfoParameters[static_cast(Target::Resonance)]->isUsed() ) { for( fpp_t frame = 0; frame < frames; ++frame ) { @@ -241,10 +241,10 @@ void InstrumentSoundShaping::processAudioBuffer( sampleFrame* buffer, } } - if( m_envLfoParameters[Volume]->isUsed() ) + if( m_envLfoParameters[static_cast(Target::Volume)]->isUsed() ) { QVarLengthArray volBuffer(frames); - m_envLfoParameters[Volume]->fillLevel( volBuffer.data(), envTotalFrames, envReleaseBegin, frames ); + m_envLfoParameters[static_cast(Target::Volume)]->fillLevel( volBuffer.data(), envTotalFrames, envReleaseBegin, frames ); for( fpp_t frame = 0; frame < frames; ++frame ) { @@ -255,7 +255,7 @@ void InstrumentSoundShaping::processAudioBuffer( sampleFrame* buffer, } } -/* else if( m_envLfoParameters[Volume]->isUsed() == false && m_envLfoParameters[PANNING]->isUsed() ) +/* else if( m_envLfoParameters[static_cast(Target::Volume)]->isUsed() == false && m_envLfoParameters[PANNING]->isUsed() ) { // only use panning-envelope... for( fpp_t frame = 0; frame < frames; ++frame ) @@ -275,11 +275,11 @@ void InstrumentSoundShaping::processAudioBuffer( sampleFrame* buffer, f_cnt_t InstrumentSoundShaping::envFrames( const bool _only_vol ) const { - f_cnt_t ret_val = m_envLfoParameters[Volume]->PAHD_Frames(); + f_cnt_t ret_val = m_envLfoParameters[static_cast(Target::Volume)]->PAHD_Frames(); if( _only_vol == false ) { - for( int i = Volume+1; i < NumTargets; ++i ) + for( int i = static_cast(Target::Volume)+1; i < NumTargets; ++i ) { if( m_envLfoParameters[i]->isUsed() && m_envLfoParameters[i]->PAHD_Frames() > ret_val ) @@ -303,17 +303,17 @@ f_cnt_t InstrumentSoundShaping::releaseFrames() const f_cnt_t ret_val = m_instrumentTrack->instrument()->desiredReleaseFrames(); - if( m_instrumentTrack->instrument()->flags().testFlag( Instrument::IsSingleStreamed ) ) + if( m_instrumentTrack->instrument()->flags().testFlag( Instrument::Flag::IsSingleStreamed ) ) { return ret_val; } - if( m_envLfoParameters[Volume]->isUsed() ) + if( m_envLfoParameters[static_cast(Target::Volume)]->isUsed() ) { - return m_envLfoParameters[Volume]->releaseFrames(); + return m_envLfoParameters[static_cast(Target::Volume)]->releaseFrames(); } - for( int i = Volume+1; i < NumTargets; ++i ) + for( int i = static_cast(Target::Volume)+1; i < NumTargets; ++i ) { if( m_envLfoParameters[i]->isUsed() ) { diff --git a/src/core/Ladspa2LMMS.cpp b/src/core/Ladspa2LMMS.cpp index 24dfc76f1a4..440b052f86a 100644 --- a/src/core/Ladspa2LMMS.cpp +++ b/src/core/Ladspa2LMMS.cpp @@ -40,12 +40,12 @@ Ladspa2LMMS::Ladspa2LMMS() ladspa_key_t key = plugin.second; LadspaManagerDescription * desc = getDescription( key ); - if( desc->type == SOURCE ) + if( desc->type == LadspaPluginType::Source ) { m_instruments.append( qMakePair( getName( key ), key ) ); } - else if( desc->type == TRANSFER && + else if( desc->type == LadspaPluginType::Transfer && ( desc->inputChannels == desc->outputChannels && ( desc->inputChannels == 1 || desc->inputChannels == 2 || @@ -55,7 +55,7 @@ Ladspa2LMMS::Ladspa2LMMS() m_validEffects.append( qMakePair( getName( key ), key ) ); } - else if( desc->type == TRANSFER && + else if( desc->type == LadspaPluginType::Transfer && ( desc->inputChannels != desc->outputChannels || ( desc->inputChannels != 1 && desc->inputChannels != 2 && @@ -65,12 +65,12 @@ Ladspa2LMMS::Ladspa2LMMS() m_invalidEffects.append( qMakePair( getName( key ), key ) ); } - else if( desc->type == SINK ) + else if( desc->type == LadspaPluginType::Sink ) { m_analysisTools.append( qMakePair( getName( key ), key ) ); } - else if( desc->type == OTHER ) + else if( desc->type == LadspaPluginType::Other ) { m_otherPlugins.append( qMakePair( getName( key ), key ) ); diff --git a/src/core/LadspaControl.cpp b/src/core/LadspaControl.cpp index 7e8e9262332..3282a0c7a0e 100644 --- a/src/core/LadspaControl.cpp +++ b/src/core/LadspaControl.cpp @@ -53,7 +53,7 @@ LadspaControl::LadspaControl( Model * _parent, port_desc_t * _port, switch( m_port->data_type ) { - case TOGGLED: + case BufferDataType::Toggled: m_toggledModel.setInitValue( static_cast( m_port->def ) ); connect( &m_toggledModel, SIGNAL(dataChanged()), @@ -66,8 +66,8 @@ LadspaControl::LadspaControl( Model * _parent, port_desc_t * _port, m_toggledModel.setScaleLogarithmic( m_port->suggests_logscale ); break; - case INTEGER: - case ENUM: + case BufferDataType::Integer: + case BufferDataType::Enum: m_knobModel.setRange( static_cast( m_port->max ), static_cast( m_port->min ), 1 + static_cast( m_port->max - @@ -80,7 +80,7 @@ LadspaControl::LadspaControl( Model * _parent, port_desc_t * _port, m_knobModel.setScaleLogarithmic( m_port->suggests_logscale ); break; - case FLOATING: + case BufferDataType::Floating: m_knobModel.setRange( m_port->min, m_port->max, ( m_port->max - m_port->min ) / ( m_port->name.toUpper() == "GAIN" @@ -93,7 +93,7 @@ LadspaControl::LadspaControl( Model * _parent, port_desc_t * _port, m_knobModel.setScaleLogarithmic( m_port->suggests_logscale ); break; - case TIME: + case BufferDataType::Time: m_tempoSyncKnobModel.setRange( m_port->min, m_port->max, ( m_port->max - m_port->min ) / 800.0f ); @@ -116,13 +116,13 @@ LADSPA_Data LadspaControl::value() { switch( m_port->data_type ) { - case TOGGLED: + case BufferDataType::Toggled: return static_cast( m_toggledModel.value() ); - case INTEGER: - case ENUM: - case FLOATING: + case BufferDataType::Integer: + case BufferDataType::Enum: + case BufferDataType::Floating: return static_cast( m_knobModel.value() ); - case TIME: + case BufferDataType::Time: return static_cast( m_tempoSyncKnobModel.value() ); default: qWarning( "LadspaControl::value(): BAD BAD BAD\n" ); @@ -137,13 +137,13 @@ ValueBuffer * LadspaControl::valueBuffer() { switch( m_port->data_type ) { - case TOGGLED: - case INTEGER: - case ENUM: + case BufferDataType::Toggled: + case BufferDataType::Integer: + case BufferDataType::Enum: return nullptr; - case FLOATING: + case BufferDataType::Floating: return m_knobModel.valueBuffer(); - case TIME: + case BufferDataType::Time: return m_tempoSyncKnobModel.valueBuffer(); default: qWarning( "LadspaControl::valueBuffer(): BAD BAD BAD\n" ); @@ -159,17 +159,17 @@ void LadspaControl::setValue( LADSPA_Data _value ) { switch( m_port->data_type ) { - case TOGGLED: + case BufferDataType::Toggled: m_toggledModel.setValue( static_cast( _value ) ); break; - case INTEGER: - case ENUM: + case BufferDataType::Integer: + case BufferDataType::Enum: m_knobModel.setValue( static_cast( _value ) ); break; - case FLOATING: + case BufferDataType::Floating: m_knobModel.setValue( static_cast( _value ) ); break; - case TIME: + case BufferDataType::Time: m_tempoSyncKnobModel.setValue( static_cast( _value ) ); break; @@ -194,15 +194,15 @@ void LadspaControl::saveSettings( QDomDocument& doc, } switch( m_port->data_type ) { - case TOGGLED: + case BufferDataType::Toggled: m_toggledModel.saveSettings( doc, e, "data" ); break; - case INTEGER: - case ENUM: - case FLOATING: + case BufferDataType::Integer: + case BufferDataType::Enum: + case BufferDataType::Floating: m_knobModel.saveSettings( doc, e, "data" ); break; - case TIME: + case BufferDataType::Time: m_tempoSyncKnobModel.saveSettings( doc, e, "data" ); break; default: @@ -230,15 +230,15 @@ void LadspaControl::loadSettings( const QDomElement& parent, const QString& name m_linkEnabledModel.setValue(m_linkEnabledModel.initValue()); switch( m_port->data_type ) { - case TOGGLED: + case BufferDataType::Toggled: m_toggledModel.setValue(m_toggledModel.initValue()); break; - case INTEGER: - case ENUM: - case FLOATING: + case BufferDataType::Integer: + case BufferDataType::Enum: + case BufferDataType::Floating: m_knobModel.setValue(m_knobModel.initValue()); break; - case TIME: + case BufferDataType::Time: m_tempoSyncKnobModel.setValue(m_tempoSyncKnobModel.initValue()); break; default: @@ -265,15 +265,15 @@ void LadspaControl::loadSettings( const QDomElement& parent, const QString& name switch( m_port->data_type ) { - case TOGGLED: + case BufferDataType::Toggled: m_toggledModel.loadSettings( e, dataModelName ); break; - case INTEGER: - case ENUM: - case FLOATING: + case BufferDataType::Integer: + case BufferDataType::Enum: + case BufferDataType::Floating: m_knobModel.loadSettings( e, dataModelName ); break; - case TIME: + case BufferDataType::Time: m_tempoSyncKnobModel.loadSettings( e, dataModelName ); break; default: @@ -290,15 +290,15 @@ void LadspaControl::linkControls( LadspaControl * _control ) { switch( m_port->data_type ) { - case TOGGLED: + case BufferDataType::Toggled: BoolModel::linkModels( &m_toggledModel, _control->toggledModel() ); break; - case INTEGER: - case ENUM: - case FLOATING: + case BufferDataType::Integer: + case BufferDataType::Enum: + case BufferDataType::Floating: FloatModel::linkModels( &m_knobModel, _control->knobModel() ); break; - case TIME: + case BufferDataType::Time: TempoSyncKnobModel::linkModels( &m_tempoSyncKnobModel, _control->tempoSyncKnobModel() ); break; @@ -341,15 +341,15 @@ void LadspaControl::unlinkControls( LadspaControl * _control ) { switch( m_port->data_type ) { - case TOGGLED: + case BufferDataType::Toggled: BoolModel::unlinkModels( &m_toggledModel, _control->toggledModel() ); break; - case INTEGER: - case ENUM: - case FLOATING: + case BufferDataType::Integer: + case BufferDataType::Enum: + case BufferDataType::Floating: FloatModel::unlinkModels( &m_knobModel, _control->knobModel() ); break; - case TIME: + case BufferDataType::Time: TempoSyncKnobModel::unlinkModels( &m_tempoSyncKnobModel, _control->tempoSyncKnobModel() ); break; diff --git a/src/core/LadspaManager.cpp b/src/core/LadspaManager.cpp index 8c3ab8f9744..064c928efd2 100644 --- a/src/core/LadspaManager.cpp +++ b/src/core/LadspaManager.cpp @@ -159,21 +159,21 @@ void LadspaManager::addPlugins( if( plugIn->inputChannels == 0 && plugIn->outputChannels > 0 ) { - plugIn->type = SOURCE; + plugIn->type = LadspaPluginType::Source; } else if( plugIn->inputChannels > 0 && plugIn->outputChannels > 0 ) { - plugIn->type = TRANSFER; + plugIn->type = LadspaPluginType::Transfer; } else if( plugIn->inputChannels > 0 && plugIn->outputChannels == 0 ) { - plugIn->type = SINK; + plugIn->type = LadspaPluginType::Sink; } else { - plugIn->type = OTHER; + plugIn->type = LadspaPluginType::Other; } m_ladspaManagerMap[key] = plugIn; diff --git a/src/core/LfoController.cpp b/src/core/LfoController.cpp index c0fe65855ef..23621b84727 100644 --- a/src/core/LfoController.cpp +++ b/src/core/LfoController.cpp @@ -36,12 +36,12 @@ namespace lmms LfoController::LfoController( Model * _parent ) : - Controller( Controller::LfoController, _parent, tr( "LFO Controller" ) ), + Controller( ControllerType::Lfo, _parent, tr( "LFO Controller" ) ), m_baseModel( 0.5, 0.0, 1.0, 0.001, this, tr( "Base value" ) ), m_speedModel( 2.0, 0.01, 20.0, 0.0001, 20000.0, this, tr( "Oscillator speed" ) ), m_amountModel( 1.0, -1.0, 1.0, 0.005, this, tr( "Oscillator amount" ) ), m_phaseModel( 0.0, 0.0, 360.0, 4.0, this, tr( "Oscillator phase" ) ), - m_waveModel( Oscillator::SineWave, 0, Oscillator::NumWaveShapes, + m_waveModel( static_cast(Oscillator::WaveShape::Sine), 0, Oscillator::NumWaveShapes, this, tr( "Oscillator waveform" ) ), m_multiplierModel( 0, 0, 2, this, tr( "Frequency Multiplier" ) ), m_duration( 1000 ), @@ -149,30 +149,31 @@ void LfoController::updateDuration() void LfoController::updateSampleFunction() { - switch( m_waveModel.value() ) + switch( static_cast(m_waveModel.value()) ) { - case Oscillator::SineWave: + case Oscillator::WaveShape::Sine: + default: m_sampleFunction = &Oscillator::sinSample; break; - case Oscillator::TriangleWave: + case Oscillator::WaveShape::Triangle: m_sampleFunction = &Oscillator::triangleSample; break; - case Oscillator::SawWave: + case Oscillator::WaveShape::Saw: m_sampleFunction = &Oscillator::sawSample; break; - case Oscillator::SquareWave: + case Oscillator::WaveShape::Square: m_sampleFunction = &Oscillator::squareSample; break; - case Oscillator::MoogSawWave: + case Oscillator::WaveShape::MoogSaw: m_sampleFunction = &Oscillator::moogSawSample; break; - case Oscillator::ExponentialWave: + case Oscillator::WaveShape::Exponential: m_sampleFunction = &Oscillator::expSample; break; - case Oscillator::WhiteNoise: + case Oscillator::WaveShape::WhiteNoise: m_sampleFunction = &Oscillator::noiseSample; break; - case Oscillator::UserDefinedWave: + case Oscillator::WaveShape::UserDefined: m_sampleFunction = nullptr; /*TODO: If C++11 is allowed, should change the type of m_sampleFunction be std::function diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index 5edd88a0a34..e14660e1fa3 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -301,7 +301,7 @@ void Mixer::deleteChannel( int index ) for( Track* t : tracks ) { - if( t->type() == Track::InstrumentTrack ) + if( t->type() == Track::Type::Instrument ) { auto inst = dynamic_cast(t); int val = inst->mixerChannelModel()->value(0); @@ -317,7 +317,7 @@ void Mixer::deleteChannel( int index ) inst->mixerChannelModel()->setValue(val-1); } } - else if( t->type() == Track::SampleTrack ) + else if( t->type() == Track::Type::Sample ) { auto strk = dynamic_cast(t); int val = strk->mixerChannelModel()->value(0); @@ -401,7 +401,7 @@ void Mixer::moveChannelLeft( int index ) { for (const auto& track : trackList) { - if (track->type() == Track::InstrumentTrack) + if (track->type() == Track::Type::Instrument) { auto inst = (InstrumentTrack*)track; int val = inst->mixerChannelModel()->value(0); @@ -414,7 +414,7 @@ void Mixer::moveChannelLeft( int index ) inst->mixerChannelModel()->setValue(a); } } - else if (track->type() == Track::SampleTrack) + else if (track->type() == Track::Type::Sample) { auto strk = (SampleTrack*)track; int val = strk->mixerChannelModel()->value(0); @@ -630,7 +630,7 @@ void Mixer::masterMix( sampleFrame * _buf ) // also instantly add all muted channels as they don't need to care // about their senders, and can just increment the deps of their // recipients right away. - AudioEngineWorkerThread::resetJobQueue( AudioEngineWorkerThread::JobQueue::Dynamic ); + AudioEngineWorkerThread::resetJobQueue( AudioEngineWorkerThread::JobQueue::OperationMode::Dynamic ); for( MixerChannel * ch : m_mixerChannels ) { ch->m_muted = ch->m_muteModel.value(); @@ -863,7 +863,7 @@ bool Mixer::isChannelInUse(int index) for (const auto t : tracks) { - if (t->type() == Track::InstrumentTrack) + if (t->type() == Track::Type::Instrument) { auto inst = dynamic_cast(t); if (inst->mixerChannelModel()->value() == index) @@ -871,7 +871,7 @@ bool Mixer::isChannelInUse(int index) return true; } } - else if (t->type() == Track::SampleTrack) + else if (t->type() == Track::Type::Sample) { auto strack = dynamic_cast(t); if (strack->mixerChannelModel()->value() == index) diff --git a/src/core/Note.cpp b/src/core/Note.cpp index 1198abdec36..a4ad61412f4 100644 --- a/src/core/Note.cpp +++ b/src/core/Note.cpp @@ -216,7 +216,7 @@ void Note::createDetuning() m_detuning = new DetuningHelper; (void) m_detuning->automationClip(); m_detuning->setRange( -MaxDetuning, MaxDetuning, 0.5f ); - m_detuning->automationClip()->setProgressionType( AutomationClip::LinearProgression ); + m_detuning->automationClip()->setProgressionType( AutomationClip::ProgressionType::Linear ); } } diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index 31f7e81cb15..70007ebf187 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -53,7 +53,7 @@ NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack, NotePlayHandle *parent, int midiEventChannel, Origin origin ) : - PlayHandle( TypeNotePlayHandle, _offset ), + PlayHandle( Type::NotePlayHandle, _offset ), Note( n.length(), n.pos(), n.key(), n.getVolume(), n.getPanning(), n.detuning() ), m_pluginData( nullptr ), m_instrumentTrack( instrumentTrack ), @@ -104,12 +104,12 @@ NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack, setFrames( _frames ); // inform attached components about new MIDI note (used for recording in Piano Roll) - if( m_origin == OriginMidiInput ) + if( m_origin == Origin::MidiInput ) { m_instrumentTrack->midiNoteOn( *this ); } - if(m_instrumentTrack->instrument() && m_instrumentTrack->instrument()->flags() & Instrument::IsSingleStreamed ) + if(m_instrumentTrack->instrument() && m_instrumentTrack->instrument()->flags() & Instrument::Flag::IsSingleStreamed ) { setUsesBuffer( false ); } @@ -400,7 +400,7 @@ void NotePlayHandle::noteOff( const f_cnt_t _s ) // inform attached components about MIDI finished (used for recording in Piano Roll) if (!instrumentTrack()->isSustainPedalPressed()) { - if( m_origin == OriginMidiInput ) + if( m_origin == Origin::MidiInput ) { setLength( TimePos( static_cast( totalFramesPlayed() / Engine::framesPerTick() ) ) ); m_instrumentTrack->midiNoteOff( *this ); @@ -575,8 +575,8 @@ void NotePlayHandle::processTimePos( const TimePos& time ) void NotePlayHandle::resize( const bpm_t _new_tempo ) { - if (origin() == OriginMidiInput || - (origin() == OriginNoteStacking && m_parent->origin() == OriginMidiInput)) + if (origin() == Origin::MidiInput || + (origin() == Origin::NoteStacking && m_parent->origin() == Origin::MidiInput)) { // Don't resize notes from MIDI input - they should continue to play // until the key is released, and their large duration can cause diff --git a/src/core/Oscillator.cpp b/src/core/Oscillator.cpp index 189dede6e8d..06033b63edb 100644 --- a/src/core/Oscillator.cpp +++ b/src/core/Oscillator.cpp @@ -90,21 +90,22 @@ void Oscillator::update(sampleFrame* ab, const fpp_t frames, const ch_cnt_t chnl m_isModulator = modulator; if (m_subOsc != nullptr) { - switch (m_modulationAlgoModel->value()) + switch (static_cast(m_modulationAlgoModel->value())) { - case PhaseModulation: + case ModulationAlgo::PhaseModulation: updatePM(ab, frames, chnl); break; - case AmplitudeModulation: + case ModulationAlgo::AmplitudeModulation: updateAM(ab, frames, chnl); break; - case SignalMix: + case ModulationAlgo::SignalMix: + default: updateMix(ab, frames, chnl); break; - case SynchronizedBySubOsc: + case ModulationAlgo::SynchronizedBySubOsc: updateSync(ab, frames, chnl); break; - case FrequencyModulation: + case ModulationAlgo::FrequencyModulation: updateFM(ab, frames, chnl); } } @@ -199,7 +200,7 @@ void Oscillator::generateAntiAliasUserWaveTable(SampleBuffer *sampleBuffer) sample_t Oscillator::s_waveTables - [Oscillator::WaveShapes::NumWaveShapeTables] + [Oscillator::NumWaveShapeTables] [OscillatorConstants::WAVE_TABLES_PER_WAVEFORM_COUNT] [OscillatorConstants::WAVETABLE_LENGTH]; fftwf_plan Oscillator::s_fftPlan; @@ -235,9 +236,9 @@ void Oscillator::generateWaveTables() // Start from the table that contains the least number of bands, and re-use each table in the following // iteration, adding more bands in each step and avoiding repeated computation of earlier bands. using generator_t = void (*)(int, sample_t*, int); - auto simpleGen = [](WaveShapes shape, generator_t generator) + auto simpleGen = [](WaveShape shape, generator_t generator) { - const int shapeID = shape - FirstWaveShapeTable; + const int shapeID = static_cast(shape) - FirstWaveShapeTable; int lastBands = 0; // Clear the first wave table @@ -273,7 +274,7 @@ void Oscillator::generateWaveTables() Oscillator::s_sampleBuffer[i] = moogSawSample((float)i / (float)OscillatorConstants::WAVETABLE_LENGTH); } fftwf_execute(s_fftPlan); - generateFromFFT(OscillatorConstants::MAX_FREQ / freqFromWaveTableBand(i), s_waveTables[WaveShapes::MoogSawWave - FirstWaveShapeTable][i]); + generateFromFFT(OscillatorConstants::MAX_FREQ / freqFromWaveTableBand(i), s_waveTables[static_cast(WaveShape::MoogSaw) - FirstWaveShapeTable][i]); } // Generate exponential tables @@ -284,7 +285,7 @@ void Oscillator::generateWaveTables() s_sampleBuffer[i] = expSample((float)i / (float)OscillatorConstants::WAVETABLE_LENGTH); } fftwf_execute(s_fftPlan); - generateFromFFT(OscillatorConstants::MAX_FREQ / freqFromWaveTableBand(i), s_waveTables[WaveShapes::ExponentialWave - FirstWaveShapeTable][i]); + generateFromFFT(OscillatorConstants::MAX_FREQ / freqFromWaveTableBand(i), s_waveTables[static_cast(WaveShape::Exponential) - FirstWaveShapeTable][i]); } }; @@ -292,18 +293,18 @@ void Oscillator::generateWaveTables() // but since threading is not essential in this case, it is easier and more reliable to simply generate // the wavetables serially. Remove the the check and #else branch once std::thread is well supported. #if !defined(__MINGW32__) && !defined(__MINGW64__) - std::thread sawThread(simpleGen, WaveShapes::SawWave, generateSawWaveTable); - std::thread squareThread(simpleGen, WaveShapes::SquareWave, generateSquareWaveTable); - std::thread triangleThread(simpleGen, WaveShapes::TriangleWave, generateTriangleWaveTable); + std::thread sawThread(simpleGen, WaveShape::Saw, generateSawWaveTable); + std::thread squareThread(simpleGen, WaveShape::Square, generateSquareWaveTable); + std::thread triangleThread(simpleGen, WaveShape::Triangle, generateTriangleWaveTable); std::thread fftThread(fftGen); sawThread.join(); squareThread.join(); triangleThread.join(); fftThread.join(); #else - simpleGen(WaveShapes::SawWave, generateSawWaveTable); - simpleGen(WaveShapes::SquareWave, generateSquareWaveTable); - simpleGen(WaveShapes::TriangleWave, generateTriangleWaveTable); + simpleGen(WaveShape::Saw, generateSawWaveTable); + simpleGen(WaveShape::Square, generateSquareWaveTable); + simpleGen(WaveShape::Triangle, generateTriangleWaveTable); fftGen(); #endif } @@ -314,32 +315,32 @@ void Oscillator::generateWaveTables() void Oscillator::updateNoSub( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { - switch( m_waveShapeModel->value() ) + switch( static_cast(m_waveShapeModel->value()) ) { - case SineWave: + case WaveShape::Sine: default: - updateNoSub( _ab, _frames, _chnl ); + updateNoSub( _ab, _frames, _chnl ); break; - case TriangleWave: - updateNoSub( _ab, _frames, _chnl ); + case WaveShape::Triangle: + updateNoSub( _ab, _frames, _chnl ); break; - case SawWave: - updateNoSub( _ab, _frames, _chnl ); + case WaveShape::Saw: + updateNoSub( _ab, _frames, _chnl ); break; - case SquareWave: - updateNoSub( _ab, _frames, _chnl ); + case WaveShape::Square: + updateNoSub( _ab, _frames, _chnl ); break; - case MoogSawWave: - updateNoSub( _ab, _frames, _chnl ); + case WaveShape::MoogSaw: + updateNoSub( _ab, _frames, _chnl ); break; - case ExponentialWave: - updateNoSub( _ab, _frames, _chnl ); + case WaveShape::Exponential: + updateNoSub( _ab, _frames, _chnl ); break; - case WhiteNoise: - updateNoSub( _ab, _frames, _chnl ); + case WaveShape::WhiteNoise: + updateNoSub( _ab, _frames, _chnl ); break; - case UserDefinedWave: - updateNoSub( _ab, _frames, _chnl ); + case WaveShape::UserDefined: + updateNoSub( _ab, _frames, _chnl ); break; } } @@ -350,32 +351,32 @@ void Oscillator::updateNoSub( sampleFrame * _ab, const fpp_t _frames, void Oscillator::updatePM( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { - switch( m_waveShapeModel->value() ) + switch( static_cast(m_waveShapeModel->value()) ) { - case SineWave: + case WaveShape::Sine: default: - updatePM( _ab, _frames, _chnl ); + updatePM( _ab, _frames, _chnl ); break; - case TriangleWave: - updatePM( _ab, _frames, _chnl ); + case WaveShape::Triangle: + updatePM( _ab, _frames, _chnl ); break; - case SawWave: - updatePM( _ab, _frames, _chnl ); + case WaveShape::Saw: + updatePM( _ab, _frames, _chnl ); break; - case SquareWave: - updatePM( _ab, _frames, _chnl ); + case WaveShape::Square: + updatePM( _ab, _frames, _chnl ); break; - case MoogSawWave: - updatePM( _ab, _frames, _chnl ); + case WaveShape::MoogSaw: + updatePM( _ab, _frames, _chnl ); break; - case ExponentialWave: - updatePM( _ab, _frames, _chnl ); + case WaveShape::Exponential: + updatePM( _ab, _frames, _chnl ); break; - case WhiteNoise: - updatePM( _ab, _frames, _chnl ); + case WaveShape::WhiteNoise: + updatePM( _ab, _frames, _chnl ); break; - case UserDefinedWave: - updatePM( _ab, _frames, _chnl ); + case WaveShape::UserDefined: + updatePM( _ab, _frames, _chnl ); break; } } @@ -386,32 +387,32 @@ void Oscillator::updatePM( sampleFrame * _ab, const fpp_t _frames, void Oscillator::updateAM( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { - switch( m_waveShapeModel->value() ) + switch( static_cast(m_waveShapeModel->value()) ) { - case SineWave: + case WaveShape::Sine: default: - updateAM( _ab, _frames, _chnl ); + updateAM( _ab, _frames, _chnl ); break; - case TriangleWave: - updateAM( _ab, _frames, _chnl ); + case WaveShape::Triangle: + updateAM( _ab, _frames, _chnl ); break; - case SawWave: - updateAM( _ab, _frames, _chnl ); + case WaveShape::Saw: + updateAM( _ab, _frames, _chnl ); break; - case SquareWave: - updateAM( _ab, _frames, _chnl ); + case WaveShape::Square: + updateAM( _ab, _frames, _chnl ); break; - case MoogSawWave: - updateAM( _ab, _frames, _chnl ); + case WaveShape::MoogSaw: + updateAM( _ab, _frames, _chnl ); break; - case ExponentialWave: - updateAM( _ab, _frames, _chnl ); + case WaveShape::Exponential: + updateAM( _ab, _frames, _chnl ); break; - case WhiteNoise: - updateAM( _ab, _frames, _chnl ); + case WaveShape::WhiteNoise: + updateAM( _ab, _frames, _chnl ); break; - case UserDefinedWave: - updateAM( _ab, _frames, _chnl ); + case WaveShape::UserDefined: + updateAM( _ab, _frames, _chnl ); break; } } @@ -422,32 +423,32 @@ void Oscillator::updateAM( sampleFrame * _ab, const fpp_t _frames, void Oscillator::updateMix( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { - switch( m_waveShapeModel->value() ) + switch( static_cast(m_waveShapeModel->value()) ) { - case SineWave: + case WaveShape::Sine: default: - updateMix( _ab, _frames, _chnl ); + updateMix( _ab, _frames, _chnl ); break; - case TriangleWave: - updateMix( _ab, _frames, _chnl ); + case WaveShape::Triangle: + updateMix( _ab, _frames, _chnl ); break; - case SawWave: - updateMix( _ab, _frames, _chnl ); + case WaveShape::Saw: + updateMix( _ab, _frames, _chnl ); break; - case SquareWave: - updateMix( _ab, _frames, _chnl ); + case WaveShape::Square: + updateMix( _ab, _frames, _chnl ); break; - case MoogSawWave: - updateMix( _ab, _frames, _chnl ); + case WaveShape::MoogSaw: + updateMix( _ab, _frames, _chnl ); break; - case ExponentialWave: - updateMix( _ab, _frames, _chnl ); + case WaveShape::Exponential: + updateMix( _ab, _frames, _chnl ); break; - case WhiteNoise: - updateMix( _ab, _frames, _chnl ); + case WaveShape::WhiteNoise: + updateMix( _ab, _frames, _chnl ); break; - case UserDefinedWave: - updateMix( _ab, _frames, _chnl ); + case WaveShape::UserDefined: + updateMix( _ab, _frames, _chnl ); break; } } @@ -458,32 +459,32 @@ void Oscillator::updateMix( sampleFrame * _ab, const fpp_t _frames, void Oscillator::updateSync( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { - switch( m_waveShapeModel->value() ) + switch( static_cast(m_waveShapeModel->value()) ) { - case SineWave: + case WaveShape::Sine: default: - updateSync( _ab, _frames, _chnl ); + updateSync( _ab, _frames, _chnl ); break; - case TriangleWave: - updateSync( _ab, _frames, _chnl ); + case WaveShape::Triangle: + updateSync( _ab, _frames, _chnl ); break; - case SawWave: - updateSync( _ab, _frames, _chnl ); + case WaveShape::Saw: + updateSync( _ab, _frames, _chnl ); break; - case SquareWave: - updateSync( _ab, _frames, _chnl ); + case WaveShape::Square: + updateSync( _ab, _frames, _chnl ); break; - case MoogSawWave: - updateSync( _ab, _frames, _chnl ); + case WaveShape::MoogSaw: + updateSync( _ab, _frames, _chnl ); break; - case ExponentialWave: - updateSync( _ab, _frames, _chnl ); + case WaveShape::Exponential: + updateSync( _ab, _frames, _chnl ); break; - case WhiteNoise: - updateSync( _ab, _frames, _chnl ); + case WaveShape::WhiteNoise: + updateSync( _ab, _frames, _chnl ); break; - case UserDefinedWave: - updateSync( _ab, _frames, _chnl ); + case WaveShape::UserDefined: + updateSync( _ab, _frames, _chnl ); break; } } @@ -494,32 +495,32 @@ void Oscillator::updateSync( sampleFrame * _ab, const fpp_t _frames, void Oscillator::updateFM( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { - switch( m_waveShapeModel->value() ) + switch( static_cast(m_waveShapeModel->value()) ) { - case SineWave: + case WaveShape::Sine: default: - updateFM( _ab, _frames, _chnl ); + updateFM( _ab, _frames, _chnl ); break; - case TriangleWave: - updateFM( _ab, _frames, _chnl ); + case WaveShape::Triangle: + updateFM( _ab, _frames, _chnl ); break; - case SawWave: - updateFM( _ab, _frames, _chnl ); + case WaveShape::Saw: + updateFM( _ab, _frames, _chnl ); break; - case SquareWave: - updateFM( _ab, _frames, _chnl ); + case WaveShape::Square: + updateFM( _ab, _frames, _chnl ); break; - case MoogSawWave: - updateFM( _ab, _frames, _chnl ); + case WaveShape::MoogSaw: + updateFM( _ab, _frames, _chnl ); break; - case ExponentialWave: - updateFM( _ab, _frames, _chnl ); + case WaveShape::Exponential: + updateFM( _ab, _frames, _chnl ); break; - case WhiteNoise: - updateFM( _ab, _frames, _chnl ); + case WaveShape::WhiteNoise: + updateFM( _ab, _frames, _chnl ); break; - case UserDefinedWave: - updateFM( _ab, _frames, _chnl ); + case WaveShape::UserDefined: + updateFM( _ab, _frames, _chnl ); break; } } @@ -568,7 +569,7 @@ float Oscillator::syncInit( sampleFrame * _ab, const fpp_t _frames, // if we have no sub-osc, we can't do any modulation... just get our samples -template +template void Oscillator::updateNoSub( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { @@ -586,7 +587,7 @@ void Oscillator::updateNoSub( sampleFrame * _ab, const fpp_t _frames, // do pm by using sub-osc as modulator -template +template void Oscillator::updatePM( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { @@ -607,7 +608,7 @@ void Oscillator::updatePM( sampleFrame * _ab, const fpp_t _frames, // do am by using sub-osc as modulator -template +template void Oscillator::updateAM( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { @@ -626,7 +627,7 @@ void Oscillator::updateAM( sampleFrame * _ab, const fpp_t _frames, // do mix by using sub-osc as mix-sample -template +template void Oscillator::updateMix( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { @@ -646,7 +647,7 @@ void Oscillator::updateMix( sampleFrame * _ab, const fpp_t _frames, // sync with sub-osc (every time sub-osc starts new period, we also start new // period) -template +template void Oscillator::updateSync( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { @@ -669,7 +670,7 @@ void Oscillator::updateSync( sampleFrame * _ab, const fpp_t _frames, // do fm by using sub-osc as modulator -template +template void Oscillator::updateFM( sampleFrame * _ab, const fpp_t _frames, const ch_cnt_t _chnl ) { @@ -690,7 +691,7 @@ void Oscillator::updateFM( sampleFrame * _ab, const fpp_t _frames, template<> -inline sample_t Oscillator::getSample(const float sample) +inline sample_t Oscillator::getSample(const float sample) { const float current_freq = m_freq * m_detuning_div_samplerate * Engine::audioEngine()->processingSampleRate(); @@ -708,12 +709,12 @@ inline sample_t Oscillator::getSample(const float sample) template<> -inline sample_t Oscillator::getSample( +inline sample_t Oscillator::getSample( const float _sample ) { if (m_useWaveTable && !m_isModulator) { - return wtSample(s_waveTables[WaveShapes::TriangleWave - FirstWaveShapeTable],_sample); + return wtSample(s_waveTables[static_cast(WaveShape::Triangle) - FirstWaveShapeTable],_sample); } else { @@ -725,12 +726,12 @@ inline sample_t Oscillator::getSample( template<> -inline sample_t Oscillator::getSample( +inline sample_t Oscillator::getSample( const float _sample ) { if (m_useWaveTable && !m_isModulator) { - return wtSample(s_waveTables[WaveShapes::SawWave - FirstWaveShapeTable], _sample); + return wtSample(s_waveTables[static_cast(WaveShape::Saw) - FirstWaveShapeTable], _sample); } else { @@ -742,12 +743,12 @@ inline sample_t Oscillator::getSample( template<> -inline sample_t Oscillator::getSample( +inline sample_t Oscillator::getSample( const float _sample ) { if (m_useWaveTable && !m_isModulator) { - return wtSample(s_waveTables[WaveShapes::SquareWave - FirstWaveShapeTable], _sample); + return wtSample(s_waveTables[static_cast(WaveShape::Square) - FirstWaveShapeTable], _sample); } else { @@ -759,12 +760,12 @@ inline sample_t Oscillator::getSample( template<> -inline sample_t Oscillator::getSample( +inline sample_t Oscillator::getSample( const float _sample ) { if (m_useWaveTable && !m_isModulator) { - return wtSample(s_waveTables[WaveShapes::MoogSawWave - FirstWaveShapeTable], _sample); + return wtSample(s_waveTables[static_cast(WaveShape::MoogSaw) - FirstWaveShapeTable], _sample); } else { @@ -776,12 +777,12 @@ inline sample_t Oscillator::getSample( template<> -inline sample_t Oscillator::getSample( +inline sample_t Oscillator::getSample( const float _sample ) { if (m_useWaveTable && !m_isModulator) { - return wtSample(s_waveTables[WaveShapes::ExponentialWave - FirstWaveShapeTable], _sample); + return wtSample(s_waveTables[static_cast(WaveShape::Exponential) - FirstWaveShapeTable], _sample); } else { @@ -793,7 +794,7 @@ inline sample_t Oscillator::getSample( template<> -inline sample_t Oscillator::getSample( +inline sample_t Oscillator::getSample( const float _sample ) { return( noiseSample( _sample ) ); @@ -803,7 +804,7 @@ inline sample_t Oscillator::getSample( template<> -inline sample_t Oscillator::getSample( +inline sample_t Oscillator::getSample( const float _sample ) { if (m_useWaveTable && !m_isModulator) diff --git a/src/core/PatternStore.cpp b/src/core/PatternStore.cpp index 3d0b60acf19..c5a3521398a 100644 --- a/src/core/PatternStore.cpp +++ b/src/core/PatternStore.cpp @@ -44,7 +44,7 @@ PatternStore::PatternStore() : // not change upon setCurrentPattern()-call connect(&m_patternComboBoxModel, SIGNAL(dataUnchanged()), this, SLOT(currentPatternChanged())); - setType(PatternContainer); + setType(Type::Pattern); } @@ -109,7 +109,7 @@ bar_t PatternStore::lengthOfPattern(int pattern) const int PatternStore::numOfPatterns() const { - return Engine::getSong()->countTracks(Track::PatternTrack); + return Engine::getSong()->countTracks(Track::Type::Pattern); } @@ -174,7 +174,7 @@ void PatternStore::fixIncorrectPositions() void PatternStore::play() { - if (Engine::getSong()->playMode() != Song::Mode_PlayPattern) + if (Engine::getSong()->playMode() != Song::PlayMode::Pattern) { Engine::getSong()->playPattern(); } @@ -218,7 +218,7 @@ void PatternStore::currentPatternChanged() TrackList tl = Engine::getSong()->tracks(); for (Track * t : tl) { - if (t->type() == Track::PatternTrack) + if (t->type() == Track::Type::Pattern) { t->dataChanged(); } diff --git a/src/core/PeakController.cpp b/src/core/PeakController.cpp index af0e7e69dc2..cfcd3765c43 100644 --- a/src/core/PeakController.cpp +++ b/src/core/PeakController.cpp @@ -46,7 +46,7 @@ bool PeakController::m_buggedFile; PeakController::PeakController( Model * _parent, PeakControllerEffect * _peak_effect ) : - Controller( Controller::PeakController, _parent, tr( "Peak Controller" ) ), + Controller( ControllerType::Peak, _parent, tr( "Peak Controller" ) ), m_peakEffect( _peak_effect ), m_currentSample( 0.0f ) { diff --git a/src/core/Piano.cpp b/src/core/Piano.cpp index 82323526e8e..0ddbf5c6090 100644 --- a/src/core/Piano.cpp +++ b/src/core/Piano.cpp @@ -49,12 +49,12 @@ namespace lmms */ static const auto KEY_ORDER = std::array { -// C CIS D DIS - Piano::WhiteKey, Piano::BlackKey, Piano::WhiteKey, Piano::BlackKey, -// E F FIS G - Piano::WhiteKey, Piano::WhiteKey, Piano::BlackKey, Piano::WhiteKey, -// GIS A AIS B - Piano::BlackKey, Piano::WhiteKey, Piano::BlackKey, Piano::WhiteKey +// C CIS D DIS + Piano::KeyType::White, Piano::KeyType::Black, Piano::KeyType::White, Piano::KeyType::Black, +// E F FIS G + Piano::KeyType::White, Piano::KeyType::White, Piano::KeyType::Black, Piano::KeyType::White, +// GIS A AIS B + Piano::KeyType::Black, Piano::KeyType::White, Piano::KeyType::Black, Piano::KeyType::White } ; @@ -127,7 +127,7 @@ bool Piano::isBlackKey(int key) { int keyCode = key % KeysPerOctave; - return KEY_ORDER[keyCode] == Piano::BlackKey; + return KEY_ORDER[keyCode] == Piano::KeyType::Black; } diff --git a/src/core/Plugin.cpp b/src/core/Plugin.cpp index edc183c23f3..97391450187 100644 --- a/src/core/Plugin.cpp +++ b/src/core/Plugin.cpp @@ -50,7 +50,7 @@ static Plugin::Descriptor dummyPluginDescriptor = QT_TRANSLATE_NOOP( "PluginBrowser", "no description" ), "Tobias Doerffel ", 0x0100, - Plugin::Undefined, + Plugin::Type::Undefined, &dummyLoader, nullptr } ; diff --git a/src/core/PluginFactory.cpp b/src/core/PluginFactory.cpp index 3790a7ec97d..ec0f4ec4e7d 100644 --- a/src/core/PluginFactory.cpp +++ b/src/core/PluginFactory.cpp @@ -109,7 +109,7 @@ Plugin::DescriptorList PluginFactory::descriptors() const return m_descriptors.values(); } -Plugin::DescriptorList PluginFactory::descriptors(Plugin::PluginTypes type) const +Plugin::DescriptorList PluginFactory::descriptors(Plugin::Type type) const { return m_descriptors.values(type); } diff --git a/src/core/PluginIssue.cpp b/src/core/PluginIssue.cpp index f8ae06bc71d..c9cf3400faa 100644 --- a/src/core/PluginIssue.cpp +++ b/src/core/PluginIssue.cpp @@ -34,43 +34,43 @@ const char *PluginIssue::msgFor(const PluginIssueType &it) { switch (it) { - case unknownPortFlow: + case PluginIssueType::UnknownPortFlow: return "unknown port flow for mandatory port"; - case unknownPortType: + case PluginIssueType::UnknownPortType: return "unknown port type for mandatory port"; - case tooManyInputChannels: + case PluginIssueType::TooManyInputChannels: return "too many audio input channels"; - case tooManyOutputChannels: + case PluginIssueType::TooManyOutputChannels: return "too many audio output channels"; - case tooManyMidiInputChannels: + case PluginIssueType::TooManyMidiInputChannels: return "too many MIDI input channels"; - case tooManyMidiOutputChannels: + case PluginIssueType::TooManyMidiOutputChannels: return "too many MIDI output channels"; - case noOutputChannel: + case PluginIssueType::NoOutputChannel: return "no audio output channel"; - case portHasNoDef: + case PluginIssueType::PortHasNoDef: return "port is missing default value"; - case portHasNoMin: + case PluginIssueType::PortHasNoMin: return "port is missing min value"; - case portHasNoMax: + case PluginIssueType::PortHasNoMax: return "port is missing max value"; - case minGreaterMax: + case PluginIssueType::MinGreaterMax: return "port minimum is greater than maximum"; - case defaultValueNotInRange: + case PluginIssueType::DefaultValueNotInRange: return "default value is not in range [min, max]"; - case logScaleMinMissing: + case PluginIssueType::LogScaleMinMissing: return "logscale requires minimum value"; - case logScaleMaxMissing: + case PluginIssueType::LogScaleMaxMissing: return "logscale requires maximum value"; - case logScaleMinMaxDifferentSigns: + case PluginIssueType::LogScaleMinMaxDifferentSigns: return "logscale with min < 0 < max"; - case featureNotSupported: + case PluginIssueType::FeatureNotSupported: return "required feature not supported"; - case badPortType: + case PluginIssueType::BadPortType: return "unsupported port type"; - case blacklisted: + case PluginIssueType::Blacklisted: return "blacklisted plugin"; - case noIssue: + case PluginIssueType::NoIssue: return nullptr; } return nullptr; diff --git a/src/core/PresetPreviewPlayHandle.cpp b/src/core/PresetPreviewPlayHandle.cpp index 6a5b8642455..0930de0de22 100644 --- a/src/core/PresetPreviewPlayHandle.cpp +++ b/src/core/PresetPreviewPlayHandle.cpp @@ -48,7 +48,7 @@ class PreviewTrackContainer : public TrackContainer m_dataMutex() { setJournalling( false ); - m_previewInstrumentTrack = dynamic_cast( Track::create( Track::InstrumentTrack, this ) ); + m_previewInstrumentTrack = dynamic_cast( Track::create( Track::Type::Instrument, this ) ); m_previewInstrumentTrack->setJournalling( false ); m_previewInstrumentTrack->setPreviewMode( true ); } @@ -116,7 +116,7 @@ PreviewTrackContainer * PresetPreviewPlayHandle::s_previewTC; PresetPreviewPlayHandle::PresetPreviewPlayHandle( const QString & _preset_file, bool _load_by_plugin, DataFile *dataFile ) : - PlayHandle( TypePresetPreviewHandle ), + PlayHandle( Type::PresetPreviewHandle ), m_previewNote(nullptr) { setUsesBuffer( false ); @@ -169,7 +169,7 @@ PresetPreviewPlayHandle::PresetPreviewPlayHandle( const QString & _preset_file, // make sure, our preset-preview-track does not appear in any MIDI- // devices list, so just disable receiving/sending MIDI-events at all s_previewTC->previewInstrumentTrack()-> - midiPort()->setMode( MidiPort::Disabled ); + midiPort()->setMode( MidiPort::Mode::Disabled ); Engine::audioEngine()->requestChangeInModel(); // create note-play-handle for it diff --git a/src/core/ProjectJournal.cpp b/src/core/ProjectJournal.cpp index bc1fee5c05d..fc77c98e65d 100644 --- a/src/core/ProjectJournal.cpp +++ b/src/core/ProjectJournal.cpp @@ -58,7 +58,7 @@ void ProjectJournal::undo() if( jo ) { - DataFile curState( DataFile::JournalData ); + DataFile curState( DataFile::Type::JournalData ); jo->saveState( curState, curState.content() ); m_redoCheckPoints.push( CheckPoint( c.joID, curState ) ); @@ -83,7 +83,7 @@ void ProjectJournal::redo() if( jo ) { - DataFile curState( DataFile::JournalData ); + DataFile curState( DataFile::Type::JournalData ); jo->saveState( curState, curState.content() ); m_undoCheckPoints.push( CheckPoint( c.joID, curState ) ); @@ -115,7 +115,7 @@ void ProjectJournal::addJournalCheckPoint( JournallingObject *jo ) { m_redoCheckPoints.clear(); - DataFile dataFile( DataFile::JournalData ); + DataFile dataFile( DataFile::Type::JournalData ); jo->saveState( dataFile, dataFile.content() ); m_undoCheckPoints.push( CheckPoint( jo->id(), dataFile ) ); diff --git a/src/core/ProjectRenderer.cpp b/src/core/ProjectRenderer.cpp index da6c729c813..3f101330aeb 100644 --- a/src/core/ProjectRenderer.cpp +++ b/src/core/ProjectRenderer.cpp @@ -42,15 +42,15 @@ namespace lmms const std::array ProjectRenderer::fileEncodeDevices { - FileEncodeDevice{ ProjectRenderer::WaveFile, + FileEncodeDevice{ ProjectRenderer::ExportFileFormat::Wave, QT_TRANSLATE_NOOP( "ProjectRenderer", "WAV (*.wav)" ), ".wav", &AudioFileWave::getInst }, - FileEncodeDevice{ ProjectRenderer::FlacFile, + FileEncodeDevice{ ProjectRenderer::ExportFileFormat::Flac, QT_TRANSLATE_NOOP("ProjectRenderer", "FLAC (*.flac)"), ".flac", &AudioFileFlac::getInst }, - FileEncodeDevice{ ProjectRenderer::OggFile, + FileEncodeDevice{ ProjectRenderer::ExportFileFormat::Ogg, QT_TRANSLATE_NOOP( "ProjectRenderer", "OGG (*.ogg)" ), ".ogg", #ifdef LMMS_HAVE_OGGVORBIS @@ -59,7 +59,7 @@ const std::array ProjectRenderer::fileEnco nullptr #endif }, - FileEncodeDevice{ ProjectRenderer::MP3File, + FileEncodeDevice{ ProjectRenderer::ExportFileFormat::MP3, QT_TRANSLATE_NOOP( "ProjectRenderer", "MP3 (*.mp3)" ), ".mp3", #ifdef LMMS_HAVE_MP3LAME @@ -71,7 +71,7 @@ const std::array ProjectRenderer::fileEnco // Insert your own file-encoder infos here. // Maybe one day the user can add own encoders inside the program. - FileEncodeDevice{ ProjectRenderer::NumFileFormats, nullptr, nullptr, nullptr } + FileEncodeDevice{ ProjectRenderer::ExportFileFormat::Count, nullptr, nullptr, nullptr } } ; @@ -80,7 +80,7 @@ const std::array ProjectRenderer::fileEnco ProjectRenderer::ProjectRenderer( const AudioEngine::qualitySettings & qualitySettings, const OutputSettings & outputSettings, - ExportFileFormats exportFileFormat, + ExportFileFormat exportFileFormat, const QString & outputFilename ) : QThread( Engine::audioEngine() ), m_fileDev( nullptr ), @@ -88,7 +88,7 @@ ProjectRenderer::ProjectRenderer( const AudioEngine::qualitySettings & qualitySe m_progress( 0 ), m_abort( false ) { - AudioFileDeviceInstantiaton audioEncoderFactory = fileEncodeDevices[exportFileFormat].m_getDevInst; + AudioFileDeviceInstantiaton audioEncoderFactory = fileEncodeDevices[static_cast(exportFileFormat)].m_getDevInst; if (audioEncoderFactory) { @@ -110,11 +110,11 @@ ProjectRenderer::ProjectRenderer( const AudioEngine::qualitySettings & qualitySe // Little help function for getting file format from a file extension // (only for registered file-encoders). -ProjectRenderer::ExportFileFormats ProjectRenderer::getFileFormatFromExtension( +ProjectRenderer::ExportFileFormat ProjectRenderer::getFileFormatFromExtension( const QString & _ext ) { int idx = 0; - while( fileEncodeDevices[idx].m_fileFormat != NumFileFormats ) + while( fileEncodeDevices[idx].m_fileFormat != ExportFileFormat::Count ) { if( QString( fileEncodeDevices[idx].m_extension ) == _ext ) { @@ -123,16 +123,16 @@ ProjectRenderer::ExportFileFormats ProjectRenderer::getFileFormatFromExtension( ++idx; } - return( WaveFile ); // Default. + return( ExportFileFormat::Wave ); // Default. } QString ProjectRenderer::getFileExtensionFromFormat( - ExportFileFormats fmt ) + ExportFileFormat fmt ) { - return fileEncodeDevices[fmt].m_extension; + return fileEncodeDevices[static_cast(fmt)].m_extension; } diff --git a/src/core/RenderManager.cpp b/src/core/RenderManager.cpp index 8c031b9706f..969cad15bed 100644 --- a/src/core/RenderManager.cpp +++ b/src/core/RenderManager.cpp @@ -37,7 +37,7 @@ namespace lmms RenderManager::RenderManager( const AudioEngine::qualitySettings & qualitySettings, const OutputSettings & outputSettings, - ProjectRenderer::ExportFileFormats fmt, + ProjectRenderer::ExportFileFormat fmt, QString outputPath) : m_qualitySettings(qualitySettings), m_oldQualitySettings( Engine::audioEngine()->currentQualitySettings() ), @@ -102,11 +102,11 @@ void RenderManager::renderTracks() // find all currently unnmuted tracks -- we want to render these. for (const auto& tk : tl) { - Track::TrackTypes type = tk->type(); + Track::Type type = tk->type(); // Don't render automation tracks if ( tk->isMuted() == false && - ( type == Track::InstrumentTrack || type == Track::SampleTrack ) ) + ( type == Track::Type::Instrument || type == Track::Type::Sample ) ) { m_unmuted.push_back(tk); } @@ -115,11 +115,11 @@ void RenderManager::renderTracks() const TrackContainer::TrackList t2 = Engine::patternStore()->tracks(); for (const auto& tk : t2) { - Track::TrackTypes type = tk->type(); + Track::Type type = tk->type(); // Don't render automation tracks if ( tk->isMuted() == false && - ( type == Track::InstrumentTrack || type == Track::SampleTrack ) ) + ( type == Track::Type::Instrument || type == Track::Type::Sample ) ) { m_unmuted.push_back(tk); } diff --git a/src/core/SampleBuffer.cpp b/src/core/SampleBuffer.cpp index 2f35b23a846..775db125b75 100644 --- a/src/core/SampleBuffer.cpp +++ b/src/core/SampleBuffer.cpp @@ -738,7 +738,7 @@ bool SampleBuffer::play( // this holds the index of the first frame to play f_cnt_t playFrame = std::max(state->m_frameIndex, startFrame); - if (loopMode == LoopOff) + if (loopMode == LoopMode::Off) { if (playFrame >= endFrame || (endFrame - playFrame) / freqFactor == 0) { @@ -746,7 +746,7 @@ bool SampleBuffer::play( return false; } } - else if (loopMode == LoopOn) + else if (loopMode == LoopMode::On) { playFrame = getLoopedIndex(playFrame, loopStartFrame, loopEndFrame); } @@ -786,14 +786,14 @@ bool SampleBuffer::play( // Advance switch (loopMode) { - case LoopOff: + case LoopMode::Off: playFrame += srcData.input_frames_used; break; - case LoopOn: + case LoopMode::On: playFrame += srcData.input_frames_used; playFrame = getLoopedIndex(playFrame, loopStartFrame, loopEndFrame); break; - case LoopPingPong: + case LoopMode::PingPong: { f_cnt_t left = srcData.input_frames_used; if (state->isBackwards()) @@ -825,14 +825,14 @@ bool SampleBuffer::play( // Advance switch (loopMode) { - case LoopOff: + case LoopMode::Off: playFrame += frames; break; - case LoopOn: + case LoopMode::On: playFrame += frames; playFrame = getLoopedIndex(playFrame, loopStartFrame, loopEndFrame); break; - case LoopPingPong: + case LoopMode::PingPong: { f_cnt_t left = frames; if (state->isBackwards()) @@ -883,14 +883,14 @@ sampleFrame * SampleBuffer::getSampleFragment( f_cnt_t end ) const { - if (loopMode == LoopOff) + if (loopMode == LoopMode::Off) { if (index + frames <= end) { return m_data + index; } } - else if (loopMode == LoopOn) + else if (loopMode == LoopMode::On) { if (index + frames <= loopEnd) { @@ -907,13 +907,13 @@ sampleFrame * SampleBuffer::getSampleFragment( *tmp = MM_ALLOC( frames); - if (loopMode == LoopOff) + if (loopMode == LoopMode::Off) { f_cnt_t available = end - index; memcpy(*tmp, m_data + index, available * BYTES_PER_FRAME); memset(*tmp + available, 0, (frames - available) * BYTES_PER_FRAME); } - else if (loopMode == LoopOn) + else if (loopMode == LoopMode::On) { f_cnt_t copied = std::min(frames, loopEnd - index); memcpy(*tmp, m_data + index, copied * BYTES_PER_FRAME); diff --git a/src/core/SampleClip.cpp b/src/core/SampleClip.cpp index 87d6351bc59..592a6382741 100644 --- a/src/core/SampleClip.cpp +++ b/src/core/SampleClip.cpp @@ -53,7 +53,7 @@ SampleClip::SampleClip( Track * _track ) : this, SLOT(updateLength())); //care about positionmarker - gui::TimeLineWidget* timeLine = Engine::getSong()->getPlayPos( Engine::getSong()->Mode_PlaySong ).m_timeLine; + gui::TimeLineWidget* timeLine = Engine::getSong()->getPlayPos( Song::PlayMode::Song ).m_timeLine; if( timeLine ) { connect( timeLine, SIGNAL(positionMarkerMoved()), this, SLOT(playbackPositionChanged())); @@ -74,11 +74,11 @@ SampleClip::SampleClip( Track * _track ) : switch( getTrack()->trackContainer()->type() ) { - case TrackContainer::PatternContainer: + case TrackContainer::Type::Pattern: setAutoResize( true ); break; - case TrackContainer::SongContainer: + case TrackContainer::Type::Song: // move down default: setAutoResize( false ); @@ -179,7 +179,7 @@ void SampleClip::toggleRecord() void SampleClip::playbackPositionChanged() { - Engine::audioEngine()->removePlayHandlesOfTypes( getTrack(), PlayHandle::TypeSamplePlayHandle ); + Engine::audioEngine()->removePlayHandlesOfTypes( getTrack(), PlayHandle::Type::SamplePlayHandle ); auto st = dynamic_cast(getTrack()); st->setPlayingClips( false ); } diff --git a/src/core/SamplePlayHandle.cpp b/src/core/SamplePlayHandle.cpp index 77658e1d896..ea27146cb07 100644 --- a/src/core/SamplePlayHandle.cpp +++ b/src/core/SamplePlayHandle.cpp @@ -36,7 +36,7 @@ namespace lmms SamplePlayHandle::SamplePlayHandle( SampleBuffer* sampleBuffer , bool ownAudioPort ) : - PlayHandle( TypeSamplePlayHandle ), + PlayHandle( Type::SamplePlayHandle ), m_sampleBuffer( sharedObject::ref( sampleBuffer ) ), m_doneMayReturnTrue( true ), m_frame( 0 ), diff --git a/src/core/SampleRecordHandle.cpp b/src/core/SampleRecordHandle.cpp index edebd27fd71..10e970b8f3e 100644 --- a/src/core/SampleRecordHandle.cpp +++ b/src/core/SampleRecordHandle.cpp @@ -37,7 +37,7 @@ namespace lmms SampleRecordHandle::SampleRecordHandle( SampleClip* clip ) : - PlayHandle( TypeSamplePlayHandle ), + PlayHandle( Type::SamplePlayHandle ), m_framesRecorded( 0 ), m_minLength( clip->length() ), m_track( clip->getTrack() ), diff --git a/src/core/Song.cpp b/src/core/Song.cpp index 6f4c5212e80..e8073f225f9 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -68,7 +68,7 @@ tick_t TimePos::s_ticksPerBar = DefaultTicksPerBar; Song::Song() : TrackContainer(), m_globalAutomationTrack( dynamic_cast( - Track::create( Track::HiddenAutomationTrack, + Track::create( Track::Type::HiddenAutomation, this ) ) ), m_tempoModel( DefaultTempo, MinTempo, MaxTempo, this, tr( "Tempo" ) ), m_timeSigModel( this ), @@ -89,7 +89,7 @@ Song::Song() : m_savingProject( false ), m_loadingProject( false ), m_isCancelled( false ), - m_playMode( Mode_None ), + m_playMode( PlayMode::None ), m_length( 0 ), m_midiClipToPlay( nullptr ), m_loopMidiClip( false ), @@ -117,7 +117,7 @@ Song::Song() : this, SLOT(masterPitchChanged()));*/ qRegisterMetaType( "lmms::Note" ); - setType( SongContainer ); + setType( Type::Song ); for (auto& scale : m_scales) {scale = std::make_shared();} for (auto& keymap : m_keymaps) {keymap = std::make_shared();} @@ -186,11 +186,11 @@ void Song::setTimeSignature() void Song::savePos() { - gui::TimeLineWidget* tl = m_playPos[m_playMode].m_timeLine; + gui::TimeLineWidget* tl = getPlayPos().m_timeLine; if( tl != nullptr ) { - tl->savePos( m_playPos[m_playMode] ); + tl->savePos( getPlayPos() ); } } @@ -205,7 +205,7 @@ void Song::processNextBuffer() if (!m_playing) { return; } // At the beginning of the song, we have to reset the LFOs - if (m_playMode == Mode_PlaySong && getPlayPos() == 0) + if (m_playMode == PlayMode::Song && getPlayPos() == 0) { EnvelopeAndLfoParameters::instances()->reset(); } @@ -216,11 +216,11 @@ void Song::processNextBuffer() // Determine the list of tracks to play and the clip number switch (m_playMode) { - case Mode_PlaySong: + case PlayMode::Song: trackList = tracks(); break; - case Mode_PlayPattern: + case PlayMode::Pattern: if (Engine::patternStore()->numOfPatterns() > 0) { clipNum = Engine::patternStore()->currentPattern(); @@ -228,7 +228,7 @@ void Song::processNextBuffer() } break; - case Mode_PlayMidiClip: + case PlayMode::MidiClip: if (m_midiClipToPlay) { clipNum = m_midiClipToPlay->getTrack()->getClipNum(m_midiClipToPlay); @@ -291,11 +291,11 @@ void Song::processNextBuffer() // If we are playing a pattern track, or a MIDI clip with no loop enabled, // loop back to the beginning when we reach the end - if (m_playMode == Mode_PlayPattern) + if (m_playMode == PlayMode::Pattern) { enforceLoop(TimePos{0}, TimePos{Engine::patternStore()->lengthOfCurrentPattern(), 0}); } - else if (m_playMode == Mode_PlayMidiClip && m_loopMidiClip && !loopEnabled) + else if (m_playMode == PlayMode::MidiClip && m_loopMidiClip && !loopEnabled) { enforceLoop(TimePos{0}, m_midiClipToPlay->length()); } @@ -349,9 +349,9 @@ void Song::processNextBuffer() frameOffsetInPeriod += framesToPlay; frameOffsetInTick += framesToPlay; getPlayPos().setCurrentFrame(frameOffsetInTick); - m_elapsedMilliSeconds[m_playMode] += TimePos::ticksToMilliseconds(framesToPlay / framesPerTick, getTempo()); - m_elapsedBars = m_playPos[Mode_PlaySong].getBar(); - m_elapsedTicks = (m_playPos[Mode_PlaySong].getTicks() % ticksPerBar()) / 48; + m_elapsedMilliSeconds[static_cast(m_playMode)] += TimePos::ticksToMilliseconds(framesToPlay / framesPerTick, getTempo()); + m_elapsedBars = getPlayPos(PlayMode::Song).getBar(); + m_elapsedTicks = (getPlayPos(PlayMode::Song).getTicks() % ticksPerBar()) / 48; } } @@ -367,12 +367,12 @@ void Song::processAutomations(const TrackList &tracklist, TimePos timeStart, fpp switch (m_playMode) { - case Mode_PlaySong: + case PlayMode::Song: break; - case Mode_PlayPattern: + case PlayMode::Pattern: { Q_ASSERT(tracklist.size() == 1); - Q_ASSERT(tracklist.at(0)->type() == Track::PatternTrack); + Q_ASSERT(tracklist.at(0)->type() == Track::Type::Pattern); auto patternTrack = dynamic_cast(tracklist.at(0)); container = Engine::patternStore(); clipNum = patternTrack->patternIndex(); @@ -388,7 +388,7 @@ void Song::processAutomations(const TrackList &tracklist, TimePos timeStart, fpp Track::clipVector clips; for (Track* track : tracks) { - if (track->type() == Track::AutomationTrack) { + if (track->type() == Track::Type::Automation) { track->getClipsInRange(clips, 0, timeStart); } } @@ -444,12 +444,12 @@ void Song::setModified(bool value) bool Song::isExportDone() const { - return !isExporting() || m_playPos[m_playMode] >= m_exportSongEnd; + return !isExporting() || getPlayPos() >= m_exportSongEnd; } int Song::getExportProgress() const { - TimePos pos = m_playPos[m_playMode]; + TimePos pos = getPlayPos(); if (pos >= m_exportSongEnd) { @@ -486,7 +486,7 @@ void Song::playSong() stop(); } - m_playMode = Mode_PlaySong; + m_playMode = PlayMode::Song; m_playing = true; m_paused = false; @@ -525,7 +525,7 @@ void Song::playPattern() stop(); } - m_playMode = Mode_PlayPattern; + m_playMode = PlayMode::Pattern; m_playing = true; m_paused = false; @@ -551,7 +551,7 @@ void Song::playMidiClip( const MidiClip* midiClipToPlay, bool loop ) if( m_midiClipToPlay != nullptr ) { - m_playMode = Mode_PlayMidiClip; + m_playMode = PlayMode::MidiClip; m_playing = true; m_paused = false; } @@ -589,14 +589,14 @@ void Song::updateLength() -void Song::setPlayPos( tick_t ticks, PlayModes playMode ) +void Song::setPlayPos( tick_t ticks, PlayMode playMode ) { - tick_t ticksFromPlayMode = m_playPos[playMode].getTicks(); + tick_t ticksFromPlayMode = getPlayPos(playMode).getTicks(); m_elapsedTicks += ticksFromPlayMode - ticks; - m_elapsedMilliSeconds[playMode] += TimePos::ticksToMilliseconds( ticks - ticksFromPlayMode, getTempo() ); - m_playPos[playMode].setTicks( ticks ); - m_playPos[playMode].setCurrentFrame( 0.0f ); - m_playPos[playMode].setJumped( true ); + m_elapsedMilliSeconds[static_cast(playMode)] += TimePos::ticksToMilliseconds( ticks - ticksFromPlayMode, getTempo() ); + getPlayPos(playMode).setTicks( ticks ); + getPlayPos(playMode).setCurrentFrame( 0.0f ); + getPlayPos(playMode).setJumped( true ); // send a signal if playposition changes during playback if( isPlaying() ) @@ -634,7 +634,7 @@ void Song::togglePause() void Song::stop() { // do not stop/reset things again if we're stopped already - if( m_playMode == Mode_None ) + if( m_playMode == PlayMode::None ) { return; } @@ -644,7 +644,7 @@ void Song::stop() // To avoid race conditions with the processing threads Engine::audioEngine()->requestChangeInModel(); - TimeLineWidget * tl = m_playPos[m_playMode].m_timeLine; + TimeLineWidget * tl = getPlayPos().m_timeLine; m_paused = false; m_recording = true; @@ -652,41 +652,41 @@ void Song::stop() { switch( tl->behaviourAtStop() ) { - case TimeLineWidget::BackToZero: - m_playPos[m_playMode].setTicks(0); - m_elapsedMilliSeconds[m_playMode] = 0; + case TimeLineWidget::BehaviourAtStopState::BackToZero: + getPlayPos().setTicks(0); + m_elapsedMilliSeconds[static_cast(m_playMode)] = 0; break; - case TimeLineWidget::BackToStart: + case TimeLineWidget::BehaviourAtStopState::BackToStart: if( tl->savedPos() >= 0 ) { - m_playPos[m_playMode].setTicks(tl->savedPos().getTicks()); + getPlayPos().setTicks(tl->savedPos().getTicks()); setToTime(tl->savedPos()); tl->savePos( -1 ); } break; - case TimeLineWidget::KeepStopPosition: + case TimeLineWidget::BehaviourAtStopState::KeepStopPosition: break; } } else { - m_playPos[m_playMode].setTicks( 0 ); - m_elapsedMilliSeconds[m_playMode] = 0; + getPlayPos().setTicks( 0 ); + m_elapsedMilliSeconds[static_cast(m_playMode)] = 0; } m_playing = false; - m_elapsedMilliSeconds[Mode_None] = m_elapsedMilliSeconds[m_playMode]; - m_playPos[Mode_None].setTicks(m_playPos[m_playMode].getTicks()); + m_elapsedMilliSeconds[static_cast(PlayMode::None)] = m_elapsedMilliSeconds[static_cast(m_playMode)]; + getPlayPos(PlayMode::None).setTicks(getPlayPos().getTicks()); - m_playPos[m_playMode].setCurrentFrame( 0 ); + getPlayPos().setCurrentFrame( 0 ); m_vstSyncController.setPlaybackState( m_exporting ); m_vstSyncController.setAbsolutePosition( - m_playPos[m_playMode].getTicks() - + m_playPos[m_playMode].currentFrame() + getPlayPos().getTicks() + + getPlayPos().currentFrame() / (double) Engine::framesPerTick() ); // remove all note-play-handles that are active @@ -701,7 +701,7 @@ void Song::stop() } m_oldAutomatedValues.clear(); - m_playMode = Mode_None; + m_playMode = PlayMode::None; Engine::audioEngine()->doneChangeInModel(); @@ -721,19 +721,19 @@ void Song::startExport() if (m_renderBetweenMarkers) { - m_exportSongBegin = m_exportLoopBegin = m_playPos[Mode_PlaySong].m_timeLine->loopBegin(); - m_exportSongEnd = m_exportLoopEnd = m_playPos[Mode_PlaySong].m_timeLine->loopEnd(); + m_exportSongBegin = m_exportLoopBegin = getPlayPos(PlayMode::Song).m_timeLine->loopBegin(); + m_exportSongEnd = m_exportLoopEnd = getPlayPos(PlayMode::Song).m_timeLine->loopEnd(); - m_playPos[Mode_PlaySong].setTicks( m_playPos[Mode_PlaySong].m_timeLine->loopBegin().getTicks() ); + getPlayPos(PlayMode::Song).setTicks( getPlayPos(PlayMode::Song).m_timeLine->loopBegin().getTicks() ); } else { m_exportSongEnd = TimePos(m_length, 0); // Handle potentially ridiculous loop points gracefully. - if (m_loopRenderCount > 1 && m_playPos[Mode_PlaySong].m_timeLine->loopEnd() > m_exportSongEnd) + if (m_loopRenderCount > 1 && getPlayPos(PlayMode::Song).m_timeLine->loopEnd() > m_exportSongEnd) { - m_exportSongEnd = m_playPos[Mode_PlaySong].m_timeLine->loopEnd(); + m_exportSongEnd = getPlayPos(PlayMode::Song).m_timeLine->loopEnd(); } if (!m_exportLoop) @@ -741,17 +741,17 @@ void Song::startExport() m_exportSongBegin = TimePos(0,0); // FIXME: remove this check once we load timeline in headless mode - if (m_playPos[Mode_PlaySong].m_timeLine) + if (getPlayPos(PlayMode::Song).m_timeLine) { - m_exportLoopBegin = m_playPos[Mode_PlaySong].m_timeLine->loopBegin() < m_exportSongEnd && - m_playPos[Mode_PlaySong].m_timeLine->loopEnd() <= m_exportSongEnd ? - m_playPos[Mode_PlaySong].m_timeLine->loopBegin() : TimePos(0,0); - m_exportLoopEnd = m_playPos[Mode_PlaySong].m_timeLine->loopBegin() < m_exportSongEnd && - m_playPos[Mode_PlaySong].m_timeLine->loopEnd() <= m_exportSongEnd ? - m_playPos[Mode_PlaySong].m_timeLine->loopEnd() : TimePos(0,0); + m_exportLoopBegin = getPlayPos(PlayMode::Song).m_timeLine->loopBegin() < m_exportSongEnd && + getPlayPos(PlayMode::Song).m_timeLine->loopEnd() <= m_exportSongEnd ? + getPlayPos(PlayMode::Song).m_timeLine->loopBegin() : TimePos(0,0); + m_exportLoopEnd = getPlayPos(PlayMode::Song).m_timeLine->loopBegin() < m_exportSongEnd && + getPlayPos(PlayMode::Song).m_timeLine->loopEnd() <= m_exportSongEnd ? + getPlayPos(PlayMode::Song).m_timeLine->loopEnd() : TimePos(0,0); } - m_playPos[Mode_PlaySong].setTicks( 0 ); + getPlayPos(PlayMode::Song).setTicks( 0 ); } m_exportEffectiveLength = (m_exportLoopBegin - m_exportSongBegin) + (m_exportLoopEnd - m_exportLoopBegin) @@ -784,7 +784,7 @@ void Song::insertBar() { // FIXME journal batch of tracks instead of each track individually if (track->numOfClips() > 0) { track->addJournalCheckPoint(); } - track->insertBar(m_playPos[Mode_PlaySong]); + track->insertBar(getPlayPos(PlayMode::Song)); } m_tracksMutex.unlock(); } @@ -799,7 +799,7 @@ void Song::removeBar() { // FIXME journal batch of tracks instead of each track individually if (track->numOfClips() > 0) { track->addJournalCheckPoint(); } - track->removeBar(m_playPos[Mode_PlaySong]); + track->removeBar(getPlayPos(PlayMode::Song)); } m_tracksMutex.unlock(); } @@ -809,7 +809,7 @@ void Song::removeBar() void Song::addPatternTrack() { - Track * t = Track::create(Track::PatternTrack, this); + Track * t = Track::create(Track::Type::Pattern, this); Engine::patternStore()->setCurrentPattern(dynamic_cast(t)->patternIndex()); } @@ -818,7 +818,7 @@ void Song::addPatternTrack() void Song::addSampleTrack() { - ( void )Track::create( Track::SampleTrack, this ); + ( void )Track::create( Track::Type::Sample, this ); } @@ -826,7 +826,7 @@ void Song::addSampleTrack() void Song::addAutomationTrack() { - ( void )Track::create( Track::AutomationTrack, this ); + ( void )Track::create( Track::Type::Automation, this ); } @@ -859,9 +859,9 @@ void Song::clearProject() stop(); } - for( int i = 0; i < Mode_Count; i++ ) + for( int i = 0; i < PlayModeCount; i++ ) { - setPlayPos( 0, ( PlayModes )i ); + setPlayPos( 0, ( PlayMode )i ); } @@ -960,15 +960,15 @@ void Song::createNewProject() setProjectFileName(""); Track * t; - t = Track::create( Track::InstrumentTrack, this ); + t = Track::create( Track::Type::Instrument, this ); dynamic_cast( t )->loadInstrument( "tripleoscillator" ); - t = Track::create(Track::InstrumentTrack, Engine::patternStore()); + t = Track::create(Track::Type::Instrument, Engine::patternStore()); dynamic_cast( t )->loadInstrument( "kicker" ); - Track::create( Track::SampleTrack, this ); - Track::create( Track::PatternTrack, this ); - Track::create( Track::AutomationTrack, this ); + Track::create( Track::Type::Sample, this ); + Track::create( Track::Type::Pattern, this ); + Track::create( Track::Type::Automation, this ); m_tempoModel.setInitValue( DefaultTempo ); m_timeSigModel.reset(); @@ -1080,10 +1080,10 @@ void Song::loadProject( const QString & fileName ) m_masterVolumeModel.loadSettings( dataFile.head(), "mastervol" ); m_masterPitchModel.loadSettings( dataFile.head(), "masterpitch" ); - if( m_playPos[Mode_PlaySong].m_timeLine ) + if( getPlayPos(PlayMode::Song).m_timeLine ) { // reset loop-point-state - m_playPos[Mode_PlaySong].m_timeLine->toggleLoopPoints( 0 ); + getPlayPos(PlayMode::Song).m_timeLine->toggleLoopPoints( 0 ); } if( !dataFile.content().firstChildElement( "track" ).isNull() ) @@ -1119,7 +1119,7 @@ void Song::loadProject( const QString & fileName ) if( nd.isElement() && nd.nodeName() == "track" ) { ++m_nLoadingTrack; - if (nd.toElement().attribute("type").toInt() == Track::PatternTrack) + if (static_cast(nd.toElement().attribute("type").toInt()) == Track::Type::Pattern) { n += nd.toElement().elementsByTagName("patterntrack").at(0) .toElement().firstChildElement().childNodes().count(); @@ -1167,9 +1167,9 @@ void Song::loadProject( const QString & fileName ) { getGUI()->getProjectNotes()->SerializingObject::restoreState( node.toElement() ); } - else if( node.nodeName() == m_playPos[Mode_PlaySong].m_timeLine->nodeName() ) + else if( node.nodeName() == getPlayPos(PlayMode::Song).m_timeLine->nodeName() ) { - m_playPos[Mode_PlaySong].m_timeLine->restoreState( node.toElement() ); + getPlayPos(PlayMode::Song).m_timeLine->restoreState( node.toElement() ); } } } @@ -1185,7 +1185,7 @@ void Song::loadProject( const QString & fileName ) // Remove dummy controllers that was added for correct connections m_controllers.erase(std::remove_if(m_controllers.begin(), m_controllers.end(), - [](Controller* c){return c->type() == Controller::DummyController;}), + [](Controller* c){return c->type() == Controller::ControllerType::Dummy;}), m_controllers.end()); // resolve all IDs so that autoModels are automated @@ -1235,7 +1235,7 @@ bool Song::saveProjectFile(const QString & filename, bool withResources) { using gui::getGUI; - DataFile dataFile( DataFile::SongProject ); + DataFile dataFile( DataFile::Type::SongProject ); m_savingProject = true; m_tempoModel.saveSettings( dataFile, dataFile.head(), "bpm" ); @@ -1253,7 +1253,7 @@ bool Song::saveProjectFile(const QString & filename, bool withResources) getGUI()->pianoRoll()->saveState( dataFile, dataFile.content() ); getGUI()->automationEditor()->m_editor->saveState( dataFile, dataFile.content() ); getGUI()->getProjectNotes()->SerializingObject::saveState( dataFile, dataFile.content() ); - m_playPos[Mode_PlaySong].m_timeLine->saveState( dataFile, dataFile.content() ); + getPlayPos(PlayMode::Song).m_timeLine->saveState( dataFile, dataFile.content() ); } saveControllerStates( dataFile, dataFile.content() ); @@ -1280,7 +1280,7 @@ bool Song::guiSaveProject() // Save the current song with the given filename bool Song::guiSaveProjectAs(const QString & filename) { - DataFile dataFile(DataFile::SongProject); + DataFile dataFile(DataFile::Type::SongProject); QString fileNameWithExtension = dataFile.nameWithExtension(filename); bool withResources = m_saveOptions.saveAsProjectBundle.value(); @@ -1328,7 +1328,7 @@ void Song::restoreControllerStates( const QDomElement & element ) else { // Fix indices to ensure correct connections - m_controllers.push_back(Controller::create(Controller::DummyController, this)); + m_controllers.push_back(Controller::create(Controller::ControllerType::Dummy, this)); } node = node.nextSibling(); diff --git a/src/core/TempoSyncKnobModel.cpp b/src/core/TempoSyncKnobModel.cpp index 6fb457f2c55..e89716ab2c7 100644 --- a/src/core/TempoSyncKnobModel.cpp +++ b/src/core/TempoSyncKnobModel.cpp @@ -40,8 +40,8 @@ TempoSyncKnobModel::TempoSyncKnobModel( const float _val, const float _min, const float _scale, Model * _parent, const QString & _display_name ) : FloatModel( _val, _min, _max, _step, _parent, _display_name ), - m_tempoSyncMode( SyncNone ), - m_tempoLastSyncMode( SyncNone ), + m_tempoSyncMode( SyncMode::None ), + m_tempoLastSyncMode( SyncMode::None ), m_scale( _scale ), m_custom( _parent ) { @@ -55,15 +55,15 @@ TempoSyncKnobModel::TempoSyncKnobModel( const float _val, const float _min, void TempoSyncKnobModel::setTempoSync( QAction * _item ) { - setTempoSync( _item->data().toInt() ); + setTempoSync( static_cast(_item->data().toInt()) ); } -void TempoSyncKnobModel::setTempoSync( int _note_type ) +void TempoSyncKnobModel::setTempoSync( SyncMode _note_type ) { - setSyncMode( ( TempoSyncMode ) _note_type ); + setSyncMode( _note_type ); Engine::getSong()->setModified(); } @@ -74,34 +74,34 @@ void TempoSyncKnobModel::calculateTempoSyncTime( bpm_t _bpm ) { float conversionFactor = 1.0; - if( m_tempoSyncMode ) + if( m_tempoSyncMode != SyncMode::None ) { switch( m_tempoSyncMode ) { - case SyncCustom: + case SyncMode::Custom: conversionFactor = static_cast( m_custom.getDenominator() ) / static_cast( m_custom.getNumerator() ); break; - case SyncDoubleWholeNote: + case SyncMode::DoubleWholeNote: conversionFactor = 0.125; break; - case SyncWholeNote: + case SyncMode::WholeNote: conversionFactor = 0.25; break; - case SyncHalfNote: + case SyncMode::HalfNote: conversionFactor = 0.5; break; - case SyncQuarterNote: + case SyncMode::QuarterNote: conversionFactor = 1.0; break; - case SyncEighthNote: + case SyncMode::EighthNote: conversionFactor = 2.0; break; - case SyncSixteenthNote: + case SyncMode::SixteenthNote: conversionFactor = 4.0; break; - case SyncThirtysecondNote: + case SyncMode::ThirtysecondNote: conversionFactor = 8.0; break; default: ; @@ -138,18 +138,18 @@ void TempoSyncKnobModel::loadSettings( const QDomElement & _this, { FloatModel::loadSettings( _this, _name ); m_custom.loadSettings( _this, _name ); - setSyncMode( ( TempoSyncMode ) _this.attribute( _name + "_syncmode" ).toInt() ); + setSyncMode( ( SyncMode ) _this.attribute( _name + "_syncmode" ).toInt() ); } -void TempoSyncKnobModel::setSyncMode( TempoSyncMode _new_mode ) +void TempoSyncKnobModel::setSyncMode( SyncMode _new_mode ) { if( m_tempoSyncMode != _new_mode ) { m_tempoSyncMode = _new_mode; - if( _new_mode == SyncCustom ) + if( _new_mode == SyncMode::Custom ) { connect( &m_custom, SIGNAL(dataChanged()), this, SLOT(updateCustom()), @@ -174,7 +174,7 @@ void TempoSyncKnobModel::setScale( float _new_scale ) void TempoSyncKnobModel::updateCustom() { - setSyncMode( SyncCustom ); + setSyncMode( SyncMode::Custom ); } diff --git a/src/core/ToolPlugin.cpp b/src/core/ToolPlugin.cpp index 13702913771..dfcacc1bca4 100644 --- a/src/core/ToolPlugin.cpp +++ b/src/core/ToolPlugin.cpp @@ -42,7 +42,7 @@ ToolPlugin * ToolPlugin::instantiate( const QString & _plugin_name, Model * _par { Plugin * p = Plugin::instantiate( _plugin_name, _parent, nullptr ); // check whether instantiated plugin is a tool - if( p->type() == Plugin::Tool ) + if( p->type() == Plugin::Type::Tool ) { // everything ok, so return pointer return dynamic_cast( p ); diff --git a/src/core/Track.cpp b/src/core/Track.cpp index 33b9c8ef399..b034b95fb14 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -56,7 +56,7 @@ namespace lmms * * \todo check the definitions of all the properties - are they OK? */ -Track::Track( TrackTypes type, TrackContainer * tc ) : +Track::Track( Type type, TrackContainer * tc ) : Model( tc ), /*!< The track Model */ m_trackContainer( tc ), /*!< The track container object */ m_type( type ), /*!< The track type */ @@ -101,7 +101,7 @@ Track::~Track() * \param tt The type of track to create * \param tc The track container to attach to */ -Track * Track::create( TrackTypes tt, TrackContainer * tc ) +Track * Track::create( Type tt, TrackContainer * tc ) { Engine::audioEngine()->requestChangeInModel(); @@ -109,13 +109,13 @@ Track * Track::create( TrackTypes tt, TrackContainer * tc ) switch( tt ) { - case InstrumentTrack: t = new class InstrumentTrack( tc ); break; - case PatternTrack: t = new class PatternTrack( tc ); break; - case SampleTrack: t = new class SampleTrack( tc ); break; -// case EVENT_TRACK: -// case VIDEO_TRACK: - case AutomationTrack: t = new class AutomationTrack( tc ); break; - case HiddenAutomationTrack: + case Type::Instrument: t = new class InstrumentTrack( tc ); break; + case Type::Pattern: t = new class PatternTrack( tc ); break; + case Type::Sample: t = new class SampleTrack( tc ); break; +// case Type::Event: +// case Type::Video: + case Type::Automation: t = new class AutomationTrack( tc ); break; + case Type::HiddenAutomation: t = new class AutomationTrack( tc, true ); break; default: break; } @@ -145,7 +145,7 @@ Track * Track::create( const QDomElement & element, TrackContainer * tc ) Engine::audioEngine()->requestChangeInModel(); Track * t = create( - static_cast( element.attribute( "type" ).toInt() ), + static_cast( element.attribute( "type" ).toInt() ), tc ); if( t != nullptr ) { @@ -197,7 +197,7 @@ void Track::saveSettings( QDomDocument & doc, QDomElement & element ) { element.setTagName( "track" ); } - element.setAttribute( "type", type() ); + element.setAttribute( "type", static_cast(type()) ); element.setAttribute( "name", name() ); m_mutedModel.saveSettings( doc, element, "muted" ); m_soloModel.saveSettings( doc, element, "solo" ); @@ -249,7 +249,7 @@ void Track::saveSettings( QDomDocument & doc, QDomElement & element ) */ void Track::loadSettings( const QDomElement & element ) { - if( element.attribute( "type" ).toInt() != type() ) + if( static_cast(element.attribute( "type" ).toInt()) != type() ) { qWarning( "Current track-type does not match track-type of " "settings-node!\n" ); @@ -613,7 +613,7 @@ void Track::toggleSolo() { track->setMuted(false); } - else if (soloLegacyBehavior || track->type() != AutomationTrack) + else if (soloLegacyBehavior || track->type() != Type::Automation) { track->setMuted(true); } @@ -626,7 +626,7 @@ void Track::toggleSolo() { // Unless we are on the sololegacybehavior mode, only restores the // mute state if the track isn't an Automation Track - if (soloLegacyBehavior || track->type() != AutomationTrack) + if (soloLegacyBehavior || track->type() != Type::Automation) { track->setMuted(track->m_mutedBeforeSolo); } diff --git a/src/core/TrackContainer.cpp b/src/core/TrackContainer.cpp index af96ff1c43a..d4120e76174 100644 --- a/src/core/TrackContainer.cpp +++ b/src/core/TrackContainer.cpp @@ -156,13 +156,13 @@ void TrackContainer::loadSettings( const QDomElement & _this ) -int TrackContainer::countTracks( Track::TrackTypes _tt ) const +int TrackContainer::countTracks( Track::Type _tt ) const { int cnt = 0; m_tracksMutex.lockForRead(); for (const auto& track : m_tracks) { - if (track->type() == _tt || _tt == Track::NumTrackTypes) + if (track->type() == _tt || _tt == Track::Type::Count) { ++cnt; } @@ -176,7 +176,7 @@ int TrackContainer::countTracks( Track::TrackTypes _tt ) const void TrackContainer::addTrack( Track * _track ) { - if( _track->type() != Track::HiddenAutomationTrack ) + if( _track->type() != Track::Type::HiddenAutomation ) { _track->lock(); m_tracksMutex.lockForWrite(); @@ -268,9 +268,9 @@ AutomatedValueMap TrackContainer::automatedValuesFromTracks(const TrackList &tra switch(track->type()) { - case Track::AutomationTrack: - case Track::HiddenAutomationTrack: - case Track::PatternTrack: + case Track::Type::Automation: + case Track::Type::HiddenAutomation: + case Track::Type::Pattern: if (clipNum < 0) { track->getClipsInRange(clips, 0, time); } else { diff --git a/src/core/UpgradeExtendedNoteRange.cpp b/src/core/UpgradeExtendedNoteRange.cpp index 41cbc5c2629..e61da3723c4 100644 --- a/src/core/UpgradeExtendedNoteRange.cpp +++ b/src/core/UpgradeExtendedNoteRange.cpp @@ -183,10 +183,10 @@ static void fixTrack(QDomElement & track, std::set & automatedBase return; } - Track::TrackTypes const trackType = static_cast(track.attribute("type").toInt()); + Track::Type const trackType = static_cast(track.attribute("type").toInt()); // BB tracks need special handling because they contain a track container of their own - if (trackType == Track::PatternTrack) + if (trackType == Track::Type::Pattern) { // Assuming that a BB track cannot contain another BB track here... QDomNodeList subTracks = track.elementsByTagName("track"); @@ -233,7 +233,7 @@ static void fixAutomationTracks(QDomElement & song, std::set const for (int i = 0; i < tracks.size(); ++i) { QDomElement currentTrack = tracks.item(i).toElement(); - if (currentTrack.attribute("type").toInt() != Track::AutomationTrack) + if (static_cast(currentTrack.attribute("type").toInt()) != Track::Type::Automation) { continue; } diff --git a/src/core/audio/AudioFileFlac.cpp b/src/core/audio/AudioFileFlac.cpp index 9b49017c842..af71003d18c 100644 --- a/src/core/audio/AudioFileFlac.cpp +++ b/src/core/audio/AudioFileFlac.cpp @@ -58,8 +58,8 @@ bool AudioFileFlac::startEncoding() switch (getOutputSettings().getBitDepth()) { - case OutputSettings::Depth_24Bit: - case OutputSettings::Depth_32Bit: + case OutputSettings::BitDepth::Depth24Bit: + case OutputSettings::BitDepth::Depth32Bit: // FLAC does not support 32bit sampling, so take it as 24. m_sfinfo.format |= SF_FORMAT_PCM_24; break; @@ -94,7 +94,7 @@ void AudioFileFlac::writeBuffer(surroundSampleFrame const* _ab, fpp_t const fram OutputSettings::BitDepth depth = getOutputSettings().getBitDepth(); float clipvalue = std::nextafterf( -1.0f, 0.0f ); - if (depth == OutputSettings::Depth_24Bit || depth == OutputSettings::Depth_32Bit) // Float encoding + if (depth == OutputSettings::BitDepth::Depth24Bit || depth == OutputSettings::BitDepth::Depth32Bit) // Float encoding { auto buf = std::vector(frames * channels()); for(fpp_t frame = 0; frame < frames; ++frame) diff --git a/src/core/audio/AudioFileMP3.cpp b/src/core/audio/AudioFileMP3.cpp index 4930e9ad6a1..ef067715229 100644 --- a/src/core/audio/AudioFileMP3.cpp +++ b/src/core/audio/AudioFileMP3.cpp @@ -94,11 +94,11 @@ MPEG_mode mapToMPEG_mode(OutputSettings::StereoMode stereoMode) { switch (stereoMode) { - case OutputSettings::StereoMode_Stereo: + case OutputSettings::StereoMode::Stereo: return STEREO; - case OutputSettings::StereoMode_JointStereo: + case OutputSettings::StereoMode::JointStereo: return JOINT_STEREO; - case OutputSettings::StereoMode_Mono: + case OutputSettings::StereoMode::Mono: return MONO; default: return NOT_SET; diff --git a/src/core/audio/AudioFileWave.cpp b/src/core/audio/AudioFileWave.cpp index b78b04403b0..9c51437ffe1 100644 --- a/src/core/audio/AudioFileWave.cpp +++ b/src/core/audio/AudioFileWave.cpp @@ -64,13 +64,13 @@ bool AudioFileWave::startEncoding() switch( getOutputSettings().getBitDepth() ) { - case OutputSettings::Depth_32Bit: + case OutputSettings::BitDepth::Depth32Bit: m_si.format |= SF_FORMAT_FLOAT; break; - case OutputSettings::Depth_24Bit: + case OutputSettings::BitDepth::Depth24Bit: m_si.format |= SF_FORMAT_PCM_24; break; - case OutputSettings::Depth_16Bit: + case OutputSettings::BitDepth::Depth16Bit: default: m_si.format |= SF_FORMAT_PCM_16; break; @@ -102,7 +102,7 @@ void AudioFileWave::writeBuffer( const surroundSampleFrame * _ab, { OutputSettings::BitDepth bitDepth = getOutputSettings().getBitDepth(); - if( bitDepth == OutputSettings::Depth_32Bit || bitDepth == OutputSettings::Depth_24Bit ) + if( bitDepth == OutputSettings::BitDepth::Depth32Bit || bitDepth == OutputSettings::BitDepth::Depth24Bit ) { auto buf = new float[_frames * channels()]; for( fpp_t frame = 0; frame < _frames; ++frame ) diff --git a/src/core/audio/AudioPort.cpp b/src/core/audio/AudioPort.cpp index 4bbf509d8c3..7bae3db1cf5 100644 --- a/src/core/audio/AudioPort.cpp +++ b/src/core/audio/AudioPort.cpp @@ -121,7 +121,7 @@ void AudioPort::doProcessing() if( ph->buffer() ) { if( ph->usesBuffer() - && ( ph->type() == PlayHandle::TypeNotePlayHandle + && ( ph->type() == PlayHandle::Type::NotePlayHandle || !MixHelpers::isSilent( ph->buffer(), fpp ) ) ) { m_bufferUsage = true; diff --git a/src/core/fft_helpers.cpp b/src/core/fft_helpers.cpp index 63088f655b9..35906e8d3d1 100644 --- a/src/core/fft_helpers.cpp +++ b/src/core/fft_helpers.cpp @@ -102,7 +102,7 @@ int notEmpty(const std::vector &spectrum) * * return -1 on error */ -int precomputeWindow(float *window, unsigned int length, FFT_WINDOWS type, bool normalized) +int precomputeWindow(float *window, unsigned int length, FFTWindow type, bool normalized) { if (window == nullptr) {return -1;} @@ -117,23 +117,23 @@ int precomputeWindow(float *window, unsigned int length, FFT_WINDOWS type, bool switch (type) { default: - case RECTANGULAR: + case FFTWindow::Rectangular: for (unsigned int i = 0; i < length; i++) {window[i] = 1.0;} gain = 1; return 0; - case BLACKMAN_HARRIS: + case FFTWindow::BlackmanHarris: a0 = 0.35875; a1 = 0.48829; a2 = 0.14128; a3 = 0.01168; break; - case HAMMING: + case FFTWindow::Hamming: a0 = 0.54; a1 = 1.0 - a0; a2 = 0; a3 = 0; break; - case HANNING: + case FFTWindow::Hanning: a0 = 0.5; a1 = 1.0 - a0; a2 = 0; diff --git a/src/core/lv2/Lv2ControlBase.cpp b/src/core/lv2/Lv2ControlBase.cpp index 3d21474b029..64cdc51fddc 100644 --- a/src/core/lv2/Lv2ControlBase.cpp +++ b/src/core/lv2/Lv2ControlBase.cpp @@ -39,7 +39,7 @@ namespace lmms { -Plugin::PluginTypes Lv2ControlBase::check(const LilvPlugin *plugin, +Plugin::Type Lv2ControlBase::check(const LilvPlugin *plugin, std::vector &issues) { // for some reason, all checks can be done by one processor... diff --git a/src/core/lv2/Lv2Manager.cpp b/src/core/lv2/Lv2Manager.cpp index cc90f5e059c..9c62703e0a4 100644 --- a/src/core/lv2/Lv2Manager.cpp +++ b/src/core/lv2/Lv2Manager.cpp @@ -217,7 +217,7 @@ void Lv2Manager::initPlugins() const LilvPlugin* curPlug = lilv_plugins_get(plugins, itr); std::vector issues; - Plugin::PluginTypes type = Lv2ControlBase::check(curPlug, issues); + Plugin::Type type = Lv2ControlBase::check(curPlug, issues); std::sort(issues.begin(), issues.end()); auto last = std::unique(issues.begin(), issues.end()); issues.erase(last, issues.end()); @@ -240,7 +240,7 @@ void Lv2Manager::initPlugins() { if(std::any_of(issues.begin(), issues.end(), [](const PluginIssue& iss) { - return iss.type() == PluginIssueType::blacklisted; })) + return iss.type() == PluginIssueType::Blacklisted; })) { ++blacklisted; } diff --git a/src/core/lv2/Lv2Ports.cpp b/src/core/lv2/Lv2Ports.cpp index 2faee067d5c..a4625936e62 100644 --- a/src/core/lv2/Lv2Ports.cpp +++ b/src/core/lv2/Lv2Ports.cpp @@ -126,7 +126,7 @@ std::vector Meta::get(const LilvPlugin *plugin, else if (isA(LV2_CORE__OutputPort)) { m_flow = Flow::Output; } else { m_flow = Flow::Unknown; - issue(unknownPortFlow, portName); + issue(PluginIssueType::UnknownPortFlow, portName); } m_def = .0f; @@ -145,7 +145,7 @@ std::vector Meta::get(const LilvPlugin *plugin, if (isA(LV2_CORE__CVPort)) { // currently not supported, but we can still check the metadata - issue(badPortType, "cvPort"); + issue(PluginIssueType::BadPortType, "cvPort"); } m_type = isA(LV2_CORE__CVPort) ? Type::Cv : Type::Control; @@ -172,21 +172,21 @@ std::vector Meta::get(const LilvPlugin *plugin, } }; - takeRangeValue(def.get(), m_def, portHasNoDef); + takeRangeValue(def.get(), m_def, PluginIssueType::PortHasNoDef); if (isToggle) { m_min = .0f; m_max = 1.f; if(def.get() && m_def != m_min && m_def != m_max) { - issue(defaultValueNotInRange, portName); + issue(PluginIssueType::DefaultValueNotInRange, portName); } } else { // take min/max - takeRangeValue(min.get(), m_min, portHasNoMin); - takeRangeValue(max.get(), m_max, portHasNoMax); + takeRangeValue(min.get(), m_min, PluginIssueType::PortHasNoMin); + takeRangeValue(max.get(), m_max, PluginIssueType::PortHasNoMax); if(m_type == Type::Cv) { // no range is allowed and bashed to [-1,+1], @@ -196,10 +196,10 @@ std::vector Meta::get(const LilvPlugin *plugin, m_min = -1.f; m_max = +1.f; } - else if(!m_min_set()) { issue(portHasNoMin, portName); } - else if(!m_max_set()) { issue(portHasNoMax, portName); } + else if(!m_min_set()) { issue(PluginIssueType::PortHasNoMin, portName); } + else if(!m_max_set()) { issue(PluginIssueType::PortHasNoMax, portName); } } - if(m_min > m_max) { issue(minGreaterMax, portName); } + if(m_min > m_max) { issue(PluginIssueType::MinGreaterMax, portName); } // sampleRate if (hasProperty(LV2_CORE__sampleRate)) { m_sampleRate = true; } @@ -207,7 +207,7 @@ std::vector Meta::get(const LilvPlugin *plugin, // default value if (def.get()) { - if (m_def < m_min) { issue(defaultValueNotInRange, portName); } + if (m_def < m_min) { issue(PluginIssueType::DefaultValueNotInRange, portName); } else if (m_def > m_max) { if(m_sampleRate) @@ -215,7 +215,7 @@ std::vector Meta::get(const LilvPlugin *plugin, // multiplying with sample rate will hopefully lead us // to a good default value } - else { issue(defaultValueNotInRange, portName); } + else { issue(PluginIssueType::DefaultValueNotInRange, portName); } } } @@ -254,7 +254,7 @@ std::vector Meta::get(const LilvPlugin *plugin, { if (m_optional) { m_used = false; } else { - issue(PluginIssueType::unknownPortType, portName); + issue(PluginIssueType::UnknownPortType, portName); } } @@ -265,16 +265,16 @@ std::vector Meta::get(const LilvPlugin *plugin, // be non-Lv2-conforming if(m_min == std::numeric_limits::lowest()) { - issue(PluginIssueType::logScaleMinMissing, portName); + issue(PluginIssueType::LogScaleMinMissing, portName); } if(m_max == std::numeric_limits::max()) { - issue(PluginIssueType::logScaleMaxMissing, portName); + issue(PluginIssueType::LogScaleMaxMissing, portName); } // forbid min < 0 < max if(m_min < 0.f && m_max > 0.f) { - issue(PluginIssueType::logScaleMinMaxDifferentSigns, portName); + issue(PluginIssueType::LogScaleMinMaxDifferentSigns, portName); } m_logarithmic = true; } diff --git a/src/core/lv2/Lv2Proc.cpp b/src/core/lv2/Lv2Proc.cpp index 31af47a6383..e0541b948c9 100644 --- a/src/core/lv2/Lv2Proc.cpp +++ b/src/core/lv2/Lv2Proc.cpp @@ -61,7 +61,7 @@ struct MidiInputEvent -Plugin::PluginTypes Lv2Proc::check(const LilvPlugin *plugin, +Plugin::Type Lv2Proc::check(const LilvPlugin *plugin, std::vector& issues) { unsigned maxPorts = lilv_plugin_get_num_ports(plugin); @@ -79,7 +79,7 @@ Plugin::PluginTypes Lv2Proc::check(const LilvPlugin *plugin, if (!Engine::ignorePluginBlacklist() && pluginBlacklist.find(pluginUri) != pluginBlacklist.end()) { - issues.emplace_back(blacklisted); + issues.emplace_back(PluginIssueType::Blacklisted); } for (unsigned portNum = 0; portNum < maxPorts; ++portNum) @@ -106,19 +106,19 @@ Plugin::PluginTypes Lv2Proc::check(const LilvPlugin *plugin, } if (audioChannels[inCount] > 2) - issues.emplace_back(tooManyInputChannels, + issues.emplace_back(PluginIssueType::TooManyInputChannels, std::to_string(audioChannels[inCount])); if (audioChannels[outCount] == 0) - issues.emplace_back(noOutputChannel); + issues.emplace_back(PluginIssueType::NoOutputChannel); else if (audioChannels[outCount] > 2) - issues.emplace_back(tooManyOutputChannels, + issues.emplace_back(PluginIssueType::TooManyOutputChannels, std::to_string(audioChannels[outCount])); if (midiChannels[inCount] > 1) - issues.emplace_back(tooManyMidiInputChannels, + issues.emplace_back(PluginIssueType::TooManyMidiInputChannels, std::to_string(midiChannels[inCount])); if (midiChannels[outCount] > 1) - issues.emplace_back(tooManyMidiOutputChannels, + issues.emplace_back(PluginIssueType::TooManyMidiOutputChannels, std::to_string(midiChannels[outCount])); AutoLilvNodes reqFeats(lilv_plugin_get_required_features(plugin)); @@ -128,7 +128,7 @@ Plugin::PluginTypes Lv2Proc::check(const LilvPlugin *plugin, lilv_nodes_get(reqFeats.get(), itr)); if(!Lv2Features::isFeatureSupported(reqFeatName)) { - issues.emplace_back(featureNotSupported, reqFeatName); + issues.emplace_back(PluginIssueType::FeatureNotSupported, reqFeatName); } } @@ -144,16 +144,16 @@ Plugin::PluginTypes Lv2Proc::check(const LilvPlugin *plugin, { // yes, this is not a Lv2 feature, // but it's a feature in abstract sense - issues.emplace_back(featureNotSupported, ro); + issues.emplace_back(PluginIssueType::FeatureNotSupported, ro); } } } return (audioChannels[inCount] > 2 || audioChannels[outCount] > 2) - ? Plugin::Undefined + ? Plugin::Type::Undefined : (audioChannels[inCount] > 0) - ? Plugin::Effect - : Plugin::Instrument; + ? Plugin::Type::Effect + : Plugin::Type::Instrument; } diff --git a/src/core/lv2/Lv2SubPluginFeatures.cpp b/src/core/lv2/Lv2SubPluginFeatures.cpp index 4e02bc698db..135da3e2a10 100644 --- a/src/core/lv2/Lv2SubPluginFeatures.cpp +++ b/src/core/lv2/Lv2SubPluginFeatures.cpp @@ -59,7 +59,7 @@ QString Lv2SubPluginFeatures::pluginName(const LilvPlugin *plug) -Lv2SubPluginFeatures::Lv2SubPluginFeatures(Plugin::PluginTypes type) : +Lv2SubPluginFeatures::Lv2SubPluginFeatures(Plugin::Type type) : SubPluginFeatures(type) { } diff --git a/src/core/main.cpp b/src/core/main.cpp index da13181fe35..25a6ab9c53e 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -363,9 +363,9 @@ int main( int argc, char * * argv ) new QCoreApplication( argc, argv ) : new gui::MainApplication(argc, argv); - AudioEngine::qualitySettings qs( AudioEngine::qualitySettings::Mode_HighQuality ); - OutputSettings os( 44100, OutputSettings::BitRateSettings(160, false), OutputSettings::Depth_16Bit, OutputSettings::StereoMode_JointStereo ); - ProjectRenderer::ExportFileFormats eff = ProjectRenderer::WaveFile; + AudioEngine::qualitySettings qs( AudioEngine::qualitySettings::Mode::HighQuality ); + OutputSettings os( 44100, OutputSettings::BitRateSettings(160, false), OutputSettings::BitDepth::Depth16Bit, OutputSettings::StereoMode::JointStereo ); + ProjectRenderer::ExportFileFormat eff = ProjectRenderer::ExportFileFormat::Wave; // second of two command-line parsing stages for( int i = 1; i < argc; ++i ) @@ -517,23 +517,23 @@ int main( int argc, char * * argv ) if( ext == "wav" ) { - eff = ProjectRenderer::WaveFile; + eff = ProjectRenderer::ExportFileFormat::Wave; } #ifdef LMMS_HAVE_OGGVORBIS else if( ext == "ogg" ) { - eff = ProjectRenderer::OggFile; + eff = ProjectRenderer::ExportFileFormat::Ogg; } #endif #ifdef LMMS_HAVE_MP3LAME else if( ext == "mp3" ) { - eff = ProjectRenderer::MP3File; + eff = ProjectRenderer::ExportFileFormat::MP3; } #endif else if (ext == "flac") { - eff = ProjectRenderer::FlacFile; + eff = ProjectRenderer::ExportFileFormat::Flac; } else { @@ -596,15 +596,15 @@ int main( int argc, char * * argv ) if( mode == "s" ) { - os.setStereoMode(OutputSettings::StereoMode_Stereo); + os.setStereoMode(OutputSettings::StereoMode::Stereo); } else if( mode == "j" ) { - os.setStereoMode(OutputSettings::StereoMode_JointStereo); + os.setStereoMode(OutputSettings::StereoMode::JointStereo); } else if( mode == "m" ) { - os.setStereoMode(OutputSettings::StereoMode_Mono); + os.setStereoMode(OutputSettings::StereoMode::Mono); } else { @@ -613,7 +613,7 @@ int main( int argc, char * * argv ) } else if( arg =="--float" || arg == "-a" ) { - os.setBitDepth(OutputSettings::Depth_32Bit); + os.setBitDepth(OutputSettings::BitDepth::Depth32Bit); } else if( arg == "--interpolation" || arg == "-i" ) { @@ -629,19 +629,19 @@ int main( int argc, char * * argv ) if( ip == "linear" ) { - qs.interpolation = AudioEngine::qualitySettings::Interpolation_Linear; + qs.interpolation = AudioEngine::qualitySettings::Interpolation::Linear; } else if( ip == "sincfastest" ) { - qs.interpolation = AudioEngine::qualitySettings::Interpolation_SincFastest; + qs.interpolation = AudioEngine::qualitySettings::Interpolation::SincFastest; } else if( ip == "sincmedium" ) { - qs.interpolation = AudioEngine::qualitySettings::Interpolation_SincMedium; + qs.interpolation = AudioEngine::qualitySettings::Interpolation::SincMedium; } else if( ip == "sincbest" ) { - qs.interpolation = AudioEngine::qualitySettings::Interpolation_SincBest; + qs.interpolation = AudioEngine::qualitySettings::Interpolation::SincBest; } else { @@ -663,16 +663,16 @@ int main( int argc, char * * argv ) switch( o ) { case 1: - qs.oversampling = AudioEngine::qualitySettings::Oversampling_None; + qs.oversampling = AudioEngine::qualitySettings::Oversampling::None; break; case 2: - qs.oversampling = AudioEngine::qualitySettings::Oversampling_2x; + qs.oversampling = AudioEngine::qualitySettings::Oversampling::X2; break; case 4: - qs.oversampling = AudioEngine::qualitySettings::Oversampling_4x; + qs.oversampling = AudioEngine::qualitySettings::Oversampling::X4; break; case 8: - qs.oversampling = AudioEngine::qualitySettings::Oversampling_8x; + qs.oversampling = AudioEngine::qualitySettings::Oversampling::X8; break; default: return usageError( QString( "Invalid oversampling %1" ).arg( argv[i] ) ); diff --git a/src/core/midi/MidiAlsaSeq.cpp b/src/core/midi/MidiAlsaSeq.cpp index 760840c77c9..0b3bab8195a 100644 --- a/src/core/midi/MidiAlsaSeq.cpp +++ b/src/core/midi/MidiAlsaSeq.cpp @@ -245,16 +245,16 @@ void MidiAlsaSeq::applyPortMode( MidiPort * _port ) switch( _port->mode() ) { - case MidiPort::Duplex: + case MidiPort::Mode::Duplex: caps[1] |= SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ; - case MidiPort::Input: + case MidiPort::Mode::Input: caps[0] |= SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE; break; - case MidiPort::Output: + case MidiPort::Mode::Output: caps[1] |= SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ; break; diff --git a/src/core/midi/MidiController.cpp b/src/core/midi/MidiController.cpp index fbd48e94543..d7c89e940c2 100644 --- a/src/core/midi/MidiController.cpp +++ b/src/core/midi/MidiController.cpp @@ -33,9 +33,9 @@ namespace lmms MidiController::MidiController( Model * _parent ) : - Controller( Controller::MidiController, _parent, tr( "MIDI Controller" ) ), + Controller( ControllerType::Midi, _parent, tr( "MIDI Controller" ) ), MidiEventProcessor(), - m_midiPort( tr( "unnamed_midi_controller" ), Engine::audioEngine()->midiClient(), this, this, MidiPort::Input ), + m_midiPort( tr( "unnamed_midi_controller" ), Engine::audioEngine()->midiClient(), this, this, MidiPort::Mode::Input ), m_lastValue( 0.0f ), m_previousValue( 0.0f ) { diff --git a/src/core/midi/MidiPort.cpp b/src/core/midi/MidiPort.cpp index b656d9541f4..c7c947e8e4f 100644 --- a/src/core/midi/MidiPort.cpp +++ b/src/core/midi/MidiPort.cpp @@ -66,8 +66,8 @@ MidiPort::MidiPort( const QString& name, { m_midiClient->addPort( this ); - m_readableModel.setValue( m_mode == Input || m_mode == Duplex ); - m_writableModel.setValue( m_mode == Output || m_mode == Duplex ); + m_readableModel.setValue( m_mode == Mode::Input || m_mode == Mode::Duplex ); + m_writableModel.setValue( m_mode == Mode::Output || m_mode == Mode::Duplex ); connect( &m_readableModel, SIGNAL(dataChanged()), this, SLOT(updateMidiPortMode()), Qt::DirectConnection ); @@ -325,10 +325,10 @@ void MidiPort::subscribeWritablePort( const QString& port, bool subscribe ) void MidiPort::updateMidiPortMode() { // this small lookup-table makes everything easier - static const Modes modeTable[2][2] = + static const Mode modeTable[2][2] = { - { Disabled, Output }, - { Input, Duplex } + { Mode::Disabled, Mode::Output }, + { Mode::Input, Mode::Duplex } } ; setMode( modeTable[m_readableModel.value()][m_writableModel.value()] ); diff --git a/src/gui/ControllerView.cpp b/src/gui/ControllerView.cpp index 3e3f4b9d1d9..d32e8d49c09 100644 --- a/src/gui/ControllerView.cpp +++ b/src/gui/ControllerView.cpp @@ -149,7 +149,7 @@ void ControllerView::renameController() if( ok && !new_name.isEmpty() ) { c->setName( new_name ); - if( getController()->type() == Controller::LfoController ) + if( getController()->type() == Controller::ControllerType::Lfo ) { m_controllerDlg->setWindowTitle( tr( "LFO" ) + " (" + new_name + ")" ); } diff --git a/src/gui/Controls.cpp b/src/gui/Controls.cpp index 8c007ee9929..209b0fce1f9 100644 --- a/src/gui/Controls.cpp +++ b/src/gui/Controls.cpp @@ -95,7 +95,7 @@ AutomatableModelView* CheckControl::modelView() { return m_checkBox; } CheckControl::CheckControl(QWidget *parent) : m_widget(new QWidget(parent)), - m_checkBox(new LedCheckBox(nullptr, QString(), LedCheckBox::Green)), + m_checkBox(new LedCheckBox(nullptr, QString(), LedCheckBox::LedColor::Green)), m_label(new QLabel(m_widget)) { auto vbox = new QVBoxLayout(m_widget); diff --git a/src/gui/EffectView.cpp b/src/gui/EffectView.cpp index f2caaadd530..7f7f9ee9df5 100644 --- a/src/gui/EffectView.cpp +++ b/src/gui/EffectView.cpp @@ -56,28 +56,28 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) : // Disable effects that are of type "DummyEffect" bool isEnabled = !dynamic_cast( effect() ); - m_bypass = new LedCheckBox( this, "", isEnabled ? LedCheckBox::Green : LedCheckBox::Red ); + m_bypass = new LedCheckBox( this, "", isEnabled ? LedCheckBox::LedColor::Green : LedCheckBox::LedColor::Red ); m_bypass->move( 3, 3 ); m_bypass->setEnabled( isEnabled ); m_bypass->setToolTip(tr("On/Off")); - m_wetDry = new Knob( knobBright_26, this ); + m_wetDry = new Knob( KnobType::Bright26, this ); m_wetDry->setLabel( tr( "W/D" ) ); m_wetDry->move( 40 - m_wetDry->width() / 2, 5 ); m_wetDry->setEnabled( isEnabled ); m_wetDry->setHintText( tr( "Wet Level:" ), "" ); - m_autoQuit = new TempoSyncKnob( knobBright_26, this ); + m_autoQuit = new TempoSyncKnob( KnobType::Bright26, this ); m_autoQuit->setLabel( tr( "DECAY" ) ); m_autoQuit->move( 78 - m_autoQuit->width() / 2, 5 ); m_autoQuit->setEnabled( isEnabled && !effect()->m_autoQuitDisabled ); m_autoQuit->setHintText( tr( "Time:" ), "ms" ); - m_gate = new Knob( knobBright_26, this ); + m_gate = new Knob( KnobType::Bright26, this ); m_gate->setLabel( tr( "GATE" ) ); m_gate->move( 116 - m_gate->width() / 2, 5 ); m_gate->setEnabled( isEnabled && !effect()->m_autoQuitDisabled ); diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index 0672cd347a0..c0763d542ae 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -440,7 +440,7 @@ void FileBrowserTreeWidget::keyPressEvent(QKeyEvent * ke ) if (file == nullptr) { return; } // When moving to a new sound, preview it. Skip presets, they can play forever - if (vertical && file->type() == FileItem::SampleFile) + if (vertical && file->type() == FileItem::FileType::Sample) { previewFileItem(file); } @@ -535,7 +535,7 @@ void FileBrowserTreeWidget::contextMenuEvent(QContextMenuEvent * e ) QList FileBrowserTreeWidget::getContextActions(FileItem* file, bool songEditor) { QList result = QList(); - const bool fileIsSample = file->type() == FileItem::SampleFile; + const bool fileIsSample = file->type() == FileItem::FileType::Sample; QString instrumentAction = fileIsSample ? tr("Send to new AudioFileProcessor instance") : @@ -603,7 +603,7 @@ void FileBrowserTreeWidget::previewFileItem(FileItem* file) // In special case of sample-files we do not care about // handling() rather than directly creating a SamplePlayHandle - if (file->type() == FileItem::SampleFile) + if (file->type() == FileItem::FileType::Sample) { TextFloat * tf = TextFloat::displayMessage( tr("Loading sample"), @@ -621,15 +621,15 @@ void FileBrowserTreeWidget::previewFileItem(FileItem* file) ext == "gig" || ext == "pat") && !getPluginFactory()->pluginSupportingExtension(ext).isNull()) { - const bool isPlugin = file->handling() == FileItem::LoadByPlugin; + const bool isPlugin = file->handling() == FileItem::FileHandling::LoadByPlugin; newPPH = new PresetPreviewPlayHandle(fileName, isPlugin); } - else if (file->type() != FileItem::VstPluginFile && file->isTrack()) + else if (file->type() != FileItem::FileType::VstPlugin && file->isTrack()) { DataFile dataFile(fileName); if (dataFile.validate(ext)) { - const bool isPlugin = file->handling() == FileItem::LoadByPlugin; + const bool isPlugin = file->handling() == FileItem::FileHandling::LoadByPlugin; newPPH = new PresetPreviewPlayHandle(fileName, isPlugin, &dataFile); } else @@ -681,34 +681,34 @@ void FileBrowserTreeWidget::mouseMoveEvent( QMouseEvent * me ) { switch( f->type() ) { - case FileItem::PresetFile: - new StringPairDrag( f->handling() == FileItem::LoadAsPreset ? + case FileItem::FileType::Preset: + new StringPairDrag( f->handling() == FileItem::FileHandling::LoadAsPreset ? "presetfile" : "pluginpresetfile", f->fullName(), embed::getIconPixmap( "preset_file" ), this ); break; - case FileItem::SampleFile: + case FileItem::FileType::Sample: new StringPairDrag( "samplefile", f->fullName(), embed::getIconPixmap( "sample_file" ), this ); break; - case FileItem::SoundFontFile: + case FileItem::FileType::SoundFont: new StringPairDrag( "soundfontfile", f->fullName(), embed::getIconPixmap( "soundfont_file" ), this ); break; - case FileItem::PatchFile: + case FileItem::FileType::Patch: new StringPairDrag( "patchfile", f->fullName(), embed::getIconPixmap( "sample_file" ), this ); break; - case FileItem::VstPluginFile: + case FileItem::FileType::VstPlugin: new StringPairDrag( "vstpluginfile", f->fullName(), embed::getIconPixmap( "vst_plugin_file" ), this ); break; - case FileItem::MidiFile: + case FileItem::FileType::Midi: new StringPairDrag( "importedproject", f->fullName(), embed::getIconPixmap( "midi_file" ), this ); break; - case FileItem::ProjectFile: + case FileItem::FileType::Project: new StringPairDrag( "projectfile", f->fullName(), embed::getIconPixmap( "project_file" ), this ); break; @@ -732,7 +732,7 @@ void FileBrowserTreeWidget::mouseReleaseEvent(QMouseEvent * me ) if (m_previewPlayHandle == nullptr) { return; } // Only sample previews may continue after mouse up. Is this a sample preview? - bool isSample = m_previewPlayHandle->type() == PlayHandle::TypeSamplePlayHandle; + bool isSample = m_previewPlayHandle->type() == PlayHandle::Type::SamplePlayHandle; // Even sample previews should only continue if the user wants them to. Do they? bool shouldContinue = ConfigManager::inst()->value("ui", "letpreviewsfinish").toInt(); // If both are true the preview may continue, otherwise we stop it @@ -747,14 +747,14 @@ void FileBrowserTreeWidget::handleFile(FileItem * f, InstrumentTrack * it) Engine::audioEngine()->requestChangeInModel(); switch( f->handling() ) { - case FileItem::LoadAsProject: + case FileItem::FileHandling::LoadAsProject: if( getGUI()->mainWindow()->mayChangeProject(true) ) { Engine::getSong()->loadProject( f->fullName() ); } break; - case FileItem::LoadByPlugin: + case FileItem::FileHandling::LoadByPlugin: { const QString e = f->extension(); Instrument * i = it->instrument(); @@ -769,17 +769,17 @@ void FileBrowserTreeWidget::handleFile(FileItem * f, InstrumentTrack * it) break; } - case FileItem::LoadAsPreset: { + case FileItem::FileHandling::LoadAsPreset: { DataFile dataFile(f->fullName()); it->replaceInstrument(dataFile); break; } - case FileItem::ImportAsProject: + case FileItem::FileHandling::ImportAsProject: ImportFilter::import( f->fullName(), Engine::getSong() ); break; - case FileItem::NotSupported: + case FileItem::FileHandling::NotSupported: default: break; @@ -799,14 +799,14 @@ void FileBrowserTreeWidget::activateListItem(QTreeWidgetItem * item, return; } - if( f->handling() == FileItem::LoadAsProject || - f->handling() == FileItem::ImportAsProject ) + if( f->handling() == FileItem::FileHandling::LoadAsProject || + f->handling() == FileItem::FileHandling::ImportAsProject ) { handleFile( f, nullptr ); } - else if( f->handling() != FileItem::NotSupported ) + else if( f->handling() != FileItem::FileHandling::NotSupported ) { - auto it = dynamic_cast(Track::create(Track::InstrumentTrack, Engine::patternStore())); + auto it = dynamic_cast(Track::create(Track::Type::Instrument, Engine::patternStore())); handleFile( f, it ); } } @@ -818,7 +818,7 @@ void FileBrowserTreeWidget::openInNewInstrumentTrack(TrackContainer* tc, FileIte { if(item->isTrack()) { - auto it = dynamic_cast(Track::create(Track::InstrumentTrack, tc)); + auto it = dynamic_cast(Track::create(Track::Type::Instrument, tc)); handleFile(item, it); } } @@ -840,10 +840,10 @@ void FileBrowserTreeWidget::openInNewInstrumentTrack(FileItem* item, bool songEd bool FileBrowserTreeWidget::openInNewSampleTrack(FileItem* item) { // Can't add non-samples to a sample track - if (item->type() != FileItem::SampleFile) { return false; } + if (item->type() != FileItem::FileType::Sample) { return false; } // Create a new sample track for this sample - auto sampleTrack = static_cast(Track::create(Track::SampleTrack, Engine::getSong())); + auto sampleTrack = static_cast(Track::create(Track::Type::Sample, Engine::getSong())); // Add the sample clip to the track Engine::audioEngine()->requestChangeInModel(); @@ -1113,26 +1113,26 @@ void FileItem::initPixmaps() switch( m_type ) { - case ProjectFile: + case FileType::Project: setIcon( 0, *s_projectFilePixmap ); break; - case PresetFile: + case FileType::Preset: setIcon( 0, *s_presetFilePixmap ); break; - case SoundFontFile: + case FileType::SoundFont: setIcon( 0, *s_soundfontFilePixmap ); break; - case VstPluginFile: + case FileType::VstPlugin: setIcon( 0, *s_vstPluginFilePixmap ); break; - case SampleFile: - case PatchFile: // TODO + case FileType::Sample: + case FileType::Patch: // TODO setIcon( 0, *s_sampleFilePixmap ); break; - case MidiFile: + case FileType::Midi: setIcon( 0, *s_midiFilePixmap ); break; - case UnknownFile: + case FileType::Unknown: default: setIcon( 0, *s_unknownFilePixmap ); break; @@ -1144,36 +1144,36 @@ void FileItem::initPixmaps() void FileItem::determineFileType() { - m_handling = NotSupported; + m_handling = FileHandling::NotSupported; const QString ext = extension(); if( ext == "mmp" || ext == "mpt" || ext == "mmpz" ) { - m_type = ProjectFile; - m_handling = LoadAsProject; + m_type = FileType::Project; + m_handling = FileHandling::LoadAsProject; } else if( ext == "xpf" || ext == "xml" ) { - m_type = PresetFile; - m_handling = LoadAsPreset; + m_type = FileType::Preset; + m_handling = FileHandling::LoadAsPreset; } else if( ext == "xiz" && ! getPluginFactory()->pluginSupportingExtension(ext).isNull() ) { - m_type = PresetFile; - m_handling = LoadByPlugin; + m_type = FileType::Preset; + m_handling = FileHandling::LoadByPlugin; } else if( ext == "sf2" || ext == "sf3" ) { - m_type = SoundFontFile; + m_type = FileType::SoundFont; } else if( ext == "pat" ) { - m_type = PatchFile; + m_type = FileType::Patch; } else if( ext == "mid" || ext == "midi" || ext == "rmi" ) { - m_type = MidiFile; - m_handling = ImportAsProject; + m_type = FileType::Midi; + m_handling = FileHandling::ImportAsProject; } else if( ext == "dll" #ifdef LMMS_BUILD_LINUX @@ -1181,28 +1181,28 @@ void FileItem::determineFileType() #endif ) { - m_type = VstPluginFile; - m_handling = LoadByPlugin; + m_type = FileType::VstPlugin; + m_handling = FileHandling::LoadByPlugin; } else if ( ext == "lv2" ) { - m_type = PresetFile; - m_handling = LoadByPlugin; + m_type = FileType::Preset; + m_handling = FileHandling::LoadByPlugin; } else { - m_type = UnknownFile; + m_type = FileType::Unknown; } - if( m_handling == NotSupported && + if( m_handling == FileHandling::NotSupported && !ext.isEmpty() && ! getPluginFactory()->pluginSupportingExtension(ext).isNull() ) { - m_handling = LoadByPlugin; + m_handling = FileHandling::LoadByPlugin; // classify as sample if not classified by anything yet but can // be handled by a certain plugin - if( m_type == UnknownFile ) + if( m_type == FileType::Unknown ) { - m_type = SampleFile; + m_type = FileType::Sample; } } } diff --git a/src/gui/LadspaControlView.cpp b/src/gui/LadspaControlView.cpp index 46e208d2e0b..dbc3b8059bc 100644 --- a/src/gui/LadspaControlView.cpp +++ b/src/gui/LadspaControlView.cpp @@ -60,9 +60,9 @@ LadspaControlView::LadspaControlView( QWidget * _parent, switch( m_ctl->port()->data_type ) { - case TOGGLED: + case BufferDataType::Toggled: { - auto toggle = new LedCheckBox(m_ctl->port()->name, this, QString(), LedCheckBox::Green); + auto toggle = new LedCheckBox(m_ctl->port()->name, this, QString(), LedCheckBox::LedColor::Green); toggle->setModel( m_ctl->toggledModel() ); layout->addWidget( toggle ); if( link != nullptr ) @@ -78,14 +78,14 @@ LadspaControlView::LadspaControlView( QWidget * _parent, break; } - case INTEGER: - case ENUM: - case FLOATING: - knb = new Knob( knobBright_26, this, m_ctl->port()->name ); + case BufferDataType::Integer: + case BufferDataType::Enum: + case BufferDataType::Floating: + knb = new Knob( KnobType::Bright26, this, m_ctl->port()->name ); break; - case TIME: - knb = new TempoSyncKnob( knobBright_26, this, m_ctl->port()->name ); + case BufferDataType::Time: + knb = new TempoSyncKnob( KnobType::Bright26, this, m_ctl->port()->name ); break; default: @@ -94,7 +94,7 @@ LadspaControlView::LadspaControlView( QWidget * _parent, if( knb != nullptr ) { - if( m_ctl->port()->data_type != TIME ) + if( m_ctl->port()->data_type != BufferDataType::Time ) { knb->setModel( m_ctl->knobModel() ); } diff --git a/src/gui/LfoControllerDialog.cpp b/src/gui/LfoControllerDialog.cpp index 64602cd745a..77362b169aa 100644 --- a/src/gui/LfoControllerDialog.cpp +++ b/src/gui/LfoControllerDialog.cpp @@ -61,22 +61,22 @@ LfoControllerDialog::LfoControllerDialog( Controller * _model, QWidget * _parent setWindowIcon( embed::getIconPixmap( "controller" ) ); setFixedSize( 240, 58 ); - m_baseKnob = new Knob( knobBright_26, this ); + m_baseKnob = new Knob( KnobType::Bright26, this ); m_baseKnob->setLabel( tr( "BASE" ) ); m_baseKnob->move( CD_LFO_BASE_CD_KNOB_X, CD_LFO_CD_KNOB_Y ); m_baseKnob->setHintText( tr( "Base:" ), "" ); - m_speedKnob = new TempoSyncKnob( knobBright_26, this ); + m_speedKnob = new TempoSyncKnob( KnobType::Bright26, this ); m_speedKnob->setLabel( tr( "FREQ" ) ); m_speedKnob->move( CD_LFO_SPEED_CD_KNOB_X, CD_LFO_CD_KNOB_Y ); m_speedKnob->setHintText( tr( "LFO frequency:" ), "" ); - m_amountKnob = new Knob( knobBright_26, this ); + m_amountKnob = new Knob( KnobType::Bright26, this ); m_amountKnob->setLabel( tr( "AMNT" ) ); m_amountKnob->move( CD_LFO_AMOUNT_CD_KNOB_X, CD_LFO_CD_KNOB_Y ); m_amountKnob->setHintText( tr( "Modulation amount:" ), "" ); - m_phaseKnob = new Knob( knobBright_26, this ); + m_phaseKnob = new Knob( KnobType::Bright26, this ); m_phaseKnob->setLabel( tr( "PHS" ) ); m_phaseKnob->move( CD_LFO_PHASE_CD_KNOB_X, CD_LFO_CD_KNOB_Y ); m_phaseKnob->setHintText( tr( "Phase offset:" ) , "" + tr( " degrees" ) ); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 40c8334bab1..559756169c6 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -84,7 +84,7 @@ MainWindow::MainWindow() : m_autoSaveTimer( this ), m_viewMenu( nullptr ), m_metronomeToggle( 0 ), - m_session( Normal ) + m_session( SessionState::Normal ) { setAttribute( Qt::WA_DeleteOnClose ); @@ -377,7 +377,7 @@ void MainWindow::finalize() m_toolsMenu = new QMenu( this ); - for( const Plugin::Descriptor* desc : getPluginFactory()->descriptors(Plugin::Tool) ) + for( const Plugin::Descriptor* desc : getPluginFactory()->descriptors(Plugin::Type::Tool) ) { m_toolsMenu->addAction( desc->logo->pixmap(), desc->displayName ); m_tools.push_back( ToolPlugin::instantiate( desc->name, /*this*/nullptr ) @@ -514,7 +514,7 @@ void MainWindow::finalize() ConfigManager::inst()->value( "audioengine", "audiodev" ) ) ) { // if so, offer the audio settings section of the setup dialog - SetupDialog sd( SetupDialog::AudioSettings ); + SetupDialog sd( SetupDialog::ConfigTab::AudioSettings ); sd.exec(); } @@ -600,7 +600,7 @@ void MainWindow::resetWindowTitle() title += '*'; } - if( getSession() == Recover ) + if( getSession() == SessionState::Recover ) { title += " - " + tr( "Recover session. Please save your work!" ); } @@ -618,7 +618,7 @@ bool MainWindow::mayChangeProject(bool stopPlayback) Engine::getSong()->stop(); } - if( !Engine::getSong()->isModified() && getSession() != Recover ) + if( !Engine::getSong()->isModified() && getSession() != SessionState::Recover ) { return( true ); } @@ -635,9 +635,9 @@ bool MainWindow::mayChangeProject(bool stopPlayback) "last saving. Do you want to save it " "now?" ); - QMessageBox mb( ( getSession() == Recover ? + QMessageBox mb( ( getSession() == SessionState::Recover ? messageTitleRecovered : messageTitleUnsaved ), - ( getSession() == Recover ? + ( getSession() == SessionState::Recover ? messageRecovered : messageUnsaved ), QMessageBox::Question, QMessageBox::Save, @@ -652,7 +652,7 @@ bool MainWindow::mayChangeProject(bool stopPlayback) } else if( answer == QMessageBox::Discard ) { - if( getSession() == Recover ) + if( getSession() == SessionState::Recover ) { sessionCleanup(); } @@ -795,7 +795,7 @@ bool MainWindow::saveProject() } else if( this->guiSaveProject() ) { - if( getSession() == Recover ) + if( getSession() == SessionState::Recover ) { sessionCleanup(); } @@ -850,7 +850,7 @@ bool MainWindow::saveProjectAs() } if( this->guiSaveProjectAs( fname ) ) { - if( getSession() == Recover ) + if( getSession() == SessionState::Recover ) { sessionCleanup(); } @@ -1214,19 +1214,19 @@ void MainWindow::updatePlayPauseIcons() { switch( Engine::getSong()->playMode() ) { - case Song::Mode_PlaySong: + case Song::PlayMode::Song: getGUI()->songEditor()->setPauseIcon( true ); break; - case Song::Mode_PlayAutomationClip: + case Song::PlayMode::AutomationClip: getGUI()->automationEditor()->setPauseIcon( true ); break; - case Song::Mode_PlayPattern: + case Song::PlayMode::Pattern: getGUI()->patternEditor()->setPauseIcon( true ); break; - case Song::Mode_PlayMidiClip: + case Song::PlayMode::MidiClip: getGUI()->pianoRoll()->setPauseIcon( true ); break; @@ -1288,7 +1288,7 @@ void MainWindow::sessionCleanup() { // delete recover session files QFile::remove( ConfigManager::inst()->recoveryFile() ); - setSession( Normal ); + setSession( SessionState::Normal ); } @@ -1480,7 +1480,7 @@ void MainWindow::exportProject(bool multiExport) efd.setFileMode( FileDialog::AnyFile ); int idx = 0; QStringList types; - while( ProjectRenderer::fileEncodeDevices[idx].m_fileFormat != ProjectRenderer::NumFileFormats) + while( ProjectRenderer::fileEncodeDevices[idx].m_fileFormat != ProjectRenderer::ExportFileFormat::Count) { if(ProjectRenderer::fileEncodeDevices[idx].isAvailable()) { types << tr(ProjectRenderer::fileEncodeDevices[idx].m_description); @@ -1625,17 +1625,17 @@ void MainWindow::onSongStopped() SongEditorWindow* songEditor = getGUI()->songEditor(); switch( tl->behaviourAtStop() ) { - case TimeLineWidget::BackToZero: - if( songEditor && ( tl->autoScroll() == TimeLineWidget::AutoScrollEnabled ) ) + case TimeLineWidget::BehaviourAtStopState::BackToZero: + if( songEditor && ( tl->autoScroll() == TimeLineWidget::AutoScrollState::Enabled ) ) { songEditor->m_editor->updatePosition(0); } break; - case TimeLineWidget::BackToStart: + case TimeLineWidget::BehaviourAtStopState::BackToStart: if( tl->savedPos() >= 0 ) { - if(songEditor && ( tl->autoScroll() == TimeLineWidget::AutoScrollEnabled ) ) + if(songEditor && ( tl->autoScroll() == TimeLineWidget::AutoScrollState::Enabled ) ) { songEditor->m_editor->updatePosition( TimePos(tl->savedPos().getTicks() ) ); } @@ -1643,7 +1643,7 @@ void MainWindow::onSongStopped() } break; - case TimeLineWidget::KeepStopPosition: + case TimeLineWidget::BehaviourAtStopState::KeepStopPosition: break; } } diff --git a/src/gui/MicrotunerConfig.cpp b/src/gui/MicrotunerConfig.cpp index 316bf54d6b1..7ab4cc0b1ac 100644 --- a/src/gui/MicrotunerConfig.cpp +++ b/src/gui/MicrotunerConfig.cpp @@ -64,6 +64,16 @@ MicrotunerConfig::MicrotunerConfig() : m_baseKeyModel(DefaultBaseKey, 0, NumKeys - 1, nullptr, tr("Base key")), m_baseFreqModel(DefaultBaseFreq, 0.1f, 9999.999f, 0.001f, nullptr, tr("Base note frequency")) { +#if QT_VERSION < 0x50C00 + // Workaround for a bug in Qt versions below 5.12, + // where argument-dependent-lookup fails for QFlags operators + // declared inside a namepsace. + // This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h + // See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348 + + using ::operator|; +#endif + setWindowIcon(embed::getIconPixmap("microtuner")); setWindowTitle(tr("Microtuner")); diff --git a/src/gui/MidiCCRackView.cpp b/src/gui/MidiCCRackView.cpp index 7e0d71f7884..a0b1496fb54 100644 --- a/src/gui/MidiCCRackView.cpp +++ b/src/gui/MidiCCRackView.cpp @@ -89,7 +89,7 @@ MidiCCRackView::MidiCCRackView(InstrumentTrack * track) : // Adds the controller knobs for (int i = 0; i < MidiControllerCount; ++i) { - m_controllerKnob[i] = new Knob(knobBright_26); + m_controllerKnob[i] = new Knob(KnobType::Bright26); m_controllerKnob[i]->setLabel(tr("CC %1").arg(i)); knobsAreaLayout->addWidget(m_controllerKnob[i], i/4, i%4); } diff --git a/src/gui/MixerLine.cpp b/src/gui/MixerLine.cpp index 030ea892ec3..a90f13f833e 100644 --- a/src/gui/MixerLine.cpp +++ b/src/gui/MixerLine.cpp @@ -96,7 +96,7 @@ MixerLine::MixerLine( QWidget * _parent, MixerView * _mv, int _channelIndex ) : setCursor( QCursor( embed::getIconPixmap( "hand" ), 3, 3 ) ); // mixer sends knob - m_sendKnob = new Knob( knobBright_26, this, tr( "Channel send amount" ) ); + m_sendKnob = new Knob( KnobType::Bright26, this, tr( "Channel send amount" ) ); m_sendKnob->move( 3, 22 ); m_sendKnob->setVisible( false ); diff --git a/src/gui/MixerView.cpp b/src/gui/MixerView.cpp index a9582b4e24b..0edebcb8a94 100644 --- a/src/gui/MixerView.cpp +++ b/src/gui/MixerView.cpp @@ -57,6 +57,16 @@ MixerView::MixerView() : ModelView( nullptr, this ), SerializingObjectHook() { +#if QT_VERSION < 0x50C00 + // Workaround for a bug in Qt versions below 5.12, + // where argument-dependent-lookup fails for QFlags operators + // declared inside a namepsace. + // This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h + // See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348 + + using ::operator|; +#endif + Mixer * m = Engine::mixer(); m->setHook( this ); @@ -245,13 +255,13 @@ void MixerView::updateMaxChannelSelector() { for (const auto& track : trackList) { - if (track->type() == Track::InstrumentTrack) + if (track->type() == Track::Type::Instrument) { auto inst = (InstrumentTrack*)track; inst->mixerChannelModel()->setRange(0, m_mixerChannelViews.size()-1,1); } - else if (track->type() == Track::SampleTrack) + else if (track->type() == Track::Type::Sample) { auto strk = (SampleTrack*)track; strk->mixerChannelModel()->setRange(0, diff --git a/src/gui/PluginBrowser.cpp b/src/gui/PluginBrowser.cpp index b59064f05a6..7ba8bcc5362 100644 --- a/src/gui/PluginBrowser.cpp +++ b/src/gui/PluginBrowser.cpp @@ -161,7 +161,7 @@ void PluginBrowser::addPlugins() m_descTree->clear(); // Fetch and sort all instrument plugin descriptors - auto descs = getPluginFactory()->descriptors(Plugin::Instrument); + auto descs = getPluginFactory()->descriptors(Plugin::Type::Instrument); std::sort(descs.begin(), descs.end(), [](auto d1, auto d2) { @@ -305,7 +305,7 @@ void PluginDescWidget::contextMenuEvent(QContextMenuEvent* e) void PluginDescWidget::openInNewInstrumentTrack(QString value) { TrackContainer* tc = Engine::getSong(); - auto it = dynamic_cast(Track::create(Track::InstrumentTrack, tc)); + auto it = dynamic_cast(Track::create(Track::Type::Instrument, tc)); auto ilt = new InstrumentLoaderThread(this, it, value); ilt->start(); } diff --git a/src/gui/SampleTrackWindow.cpp b/src/gui/SampleTrackWindow.cpp index 6fe70bf4128..68b5eb8a223 100644 --- a/src/gui/SampleTrackWindow.cpp +++ b/src/gui/SampleTrackWindow.cpp @@ -54,6 +54,16 @@ SampleTrackWindow::SampleTrackWindow(SampleTrackView * tv) : m_track(tv->model()), m_stv(tv) { +#if QT_VERSION < 0x50C00 + // Workaround for a bug in Qt versions below 5.12, + // where argument-dependent-lookup fails for QFlags operators + // declared inside a namepsace. + // This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h + // See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348 + + using ::operator|; +#endif + // init own layout + widgets setFocusPolicy(Qt::StrongFocus); auto vlayout = new QVBoxLayout(this); @@ -94,7 +104,7 @@ SampleTrackWindow::SampleTrackWindow(SampleTrackView * tv) : Qt::Alignment widgetAlignment = Qt::AlignHCenter | Qt::AlignCenter; // set up volume knob - m_volumeKnob = new Knob(knobBright_26, nullptr, tr("Sample volume")); + m_volumeKnob = new Knob(KnobType::Bright26, nullptr, tr("Sample volume")); m_volumeKnob->setVolumeKnob(true); m_volumeKnob->setHintText(tr("Volume:"), "%"); @@ -108,7 +118,7 @@ SampleTrackWindow::SampleTrackWindow(SampleTrackView * tv) : // set up panning knob - m_panningKnob = new Knob(knobBright_26, nullptr, tr("Panning")); + m_panningKnob = new Knob(KnobType::Bright26, nullptr, tr("Panning")); m_panningKnob->setHintText(tr("Panning:"), ""); basicControlsLayout->addWidget(m_panningKnob, 0, 1); diff --git a/src/gui/clips/AutomationClipView.cpp b/src/gui/clips/AutomationClipView.cpp index a5d415a2ea2..3e0e12b75d0 100644 --- a/src/gui/clips/AutomationClipView.cpp +++ b/src/gui/clips/AutomationClipView.cpp @@ -321,7 +321,7 @@ void AutomationClipView::paintEvent( QPaintEvent * ) // the value of the end of the shape between the two nodes will be the inValue of // the next node. float nextValue; - if( m_clip->progressionType() == AutomationClip::DiscreteProgression ) + if( m_clip->progressionType() == AutomationClip::ProgressionType::Discrete ) { nextValue = OUTVAL(it); } diff --git a/src/gui/clips/ClipView.cpp b/src/gui/clips/ClipView.cpp index b78605906ca..7a7a19c1119 100644 --- a/src/gui/clips/ClipView.cpp +++ b/src/gui/clips/ClipView.cpp @@ -87,7 +87,7 @@ ClipView::ClipView( Clip * clip, m_initialClipPos( TimePos(0) ), m_initialClipEnd( TimePos(0) ), m_clip( clip ), - m_action( NoAction ), + m_action( Action::None ), m_initialMousePos( QPoint( 0, 0 ) ), m_initialMouseGlobalPos( QPoint( 0, 0 ) ), m_initialOffsets( QVector() ), @@ -435,7 +435,7 @@ void ClipView::dragEnterEvent( QDragEnterEvent * dee ) else { StringPairDrag::processDragEnterEvent( dee, "clip_" + - QString::number( m_clip->getTrack()->type() ) ); + QString::number( static_cast(m_clip->getTrack()->type()) ) ); } } @@ -457,7 +457,7 @@ void ClipView::dropEvent( QDropEvent * de ) QString value = StringPairDrag::decodeValue( de ); // Track must be the same type to paste into - if( type != ( "clip_" + QString::number( m_clip->getTrack()->type() ) ) ) + if( type != ( "clip_" + QString::number( static_cast(m_clip->getTrack()->type()) ) ) ) { return; } @@ -537,7 +537,7 @@ DataFile ClipView::createClipDataFiles( { Track * t = m_trackView->getTrack(); TrackContainer * tc = t->trackContainer(); - DataFile dataFile( DataFile::DragNDropData ); + DataFile dataFile( DataFile::Type::DragNDropData ); QDomElement clipParent = dataFile.createElement("clips"); for (const auto& clipView : clipViews) @@ -547,7 +547,7 @@ DataFile ClipView::createClipDataFiles( int trackIndex = std::distance(tc->tracks().begin(), std::find(tc->tracks().begin(), tc->tracks().end(), clipTrack)); QDomElement clipElement = dataFile.createElement("clip"); clipElement.setAttribute( "trackIndex", trackIndex ); - clipElement.setAttribute( "trackType", clipTrack->type() ); + clipElement.setAttribute( "trackType", static_cast(clipTrack->type()) ); clipElement.setAttribute( "trackName", clipTrack->name() ); clipView->m_clip->saveState(dataFile, clipElement); clipParent.appendChild( clipElement ); @@ -645,27 +645,27 @@ void ClipView::mousePressEvent( QMouseEvent * me ) { if( isSelected() ) { - m_action = CopySelection; + m_action = Action::CopySelection; } else { - m_action = ToggleSelected; + m_action = Action::ToggleSelected; } } else { if( isSelected() ) { - m_action = MoveSelection; + m_action = Action::MoveSelection; } else { getGUI()->songEditor()->m_editor->selectAllClips( false ); m_clip->addJournalCheckPoint(); - // Move, Resize and ResizeLeft - // Split action doesn't disable Clip journalling - if (m_action == Move || m_action == Resize || m_action == ResizeLeft) + // Action::Move, Action::Resize and Action::ResizeLeft + // Action::Split action doesn't disable Clip journalling + if (m_action == Action::Move || m_action == Action::Resize || m_action == Action::ResizeLeft) { m_clip->setJournalling(false); } @@ -675,22 +675,22 @@ void ClipView::mousePressEvent( QMouseEvent * me ) if( m_clip->getAutoResize() ) { // Always move clips that can't be manually resized - m_action = Move; + m_action = Action::Move; setCursor( Qt::SizeAllCursor ); } else if( me->x() >= width() - RESIZE_GRIP_WIDTH ) { - m_action = Resize; + m_action = Action::Resize; setCursor( Qt::SizeHorCursor ); } else if( me->x() < RESIZE_GRIP_WIDTH && (sClip || pClip) ) { - m_action = ResizeLeft; + m_action = Action::ResizeLeft; setCursor( Qt::SizeHorCursor ); } else if( sClip && knifeMode ) { - m_action = Split; + m_action = Action::Split; setCursor( m_cursorKnife ); setMarkerPos( knifeMarkerPos( me ) ); setMarkerEnabled( true ); @@ -698,11 +698,11 @@ void ClipView::mousePressEvent( QMouseEvent * me ) } else { - m_action = Move; + m_action = Action::Move; setCursor( Qt::SizeAllCursor ); } - if( m_action == Move ) + if( m_action == Action::Move ) { s_textFloat->setTitle( tr( "Current position" ) ); s_textFloat->setText( QString( "%1:%2" ). @@ -710,7 +710,7 @@ void ClipView::mousePressEvent( QMouseEvent * me ) arg( m_clip->startPosition().getTicks() % TimePos::ticksPerBar() ) ); } - else if( m_action == Resize || m_action == ResizeLeft ) + else if( m_action == Action::Resize || m_action == Action::ResizeLeft ) { s_textFloat->setTitle( tr( "Current length" ) ); s_textFloat->setText( tr( "%1:%2 (%3:%4 to %5:%6)" ). @@ -727,11 +727,11 @@ void ClipView::mousePressEvent( QMouseEvent * me ) // s_textFloat->reparent( this ); // setup text-float as if Clip was already moved/resized s_textFloat->moveGlobal( this, QPoint( width() + 2, height() + 2) ); - if ( m_action != Split) { s_textFloat->show(); } + if ( m_action != Action::Split) { s_textFloat->show(); } } delete m_hint; - QString hint = m_action == Move || m_action == MoveSelection + QString hint = m_action == Action::Move || m_action == Action::MoveSelection ? tr( "Press <%1> and drag to make a copy." ) : tr( "Press <%1> for free resizing." ); m_hint = TextFloat::displayMessage( tr( "Hint" ), hint.arg(UI_CTRL_KEY), @@ -748,9 +748,9 @@ void ClipView::mousePressEvent( QMouseEvent * me ) { remove( active ); } - if (m_action == Split) + if (m_action == Action::Split) { - m_action = NoAction; + m_action = Action::None; auto sClip = dynamic_cast(m_clip); if (sClip) { @@ -790,12 +790,12 @@ void ClipView::mousePressEvent( QMouseEvent * me ) */ void ClipView::mouseMoveEvent( QMouseEvent * me ) { - if( m_action == CopySelection || m_action == ToggleSelected ) + if( m_action == Action::CopySelection || m_action == Action::ToggleSelected ) { if( mouseMovedDistance( me, 2 ) == true ) { QVector clipViews; - if( m_action == CopySelection ) + if( m_action == Action::CopySelection ) { // Collect all selected Clips QVector so = @@ -816,7 +816,7 @@ void ClipView::mouseMoveEvent( QMouseEvent * me ) } // Clear the action here because mouseReleaseEvent will not get // triggered once we go into drag. - m_action = NoAction; + m_action = Action::None; // Write the Clips to the DataFile for copying DataFile dataFile = createClipDataFiles( clipViews ); @@ -827,7 +827,7 @@ void ClipView::mouseMoveEvent( QMouseEvent * me ) Qt::KeepAspectRatio, Qt::SmoothTransformation ); new StringPairDrag( QString( "clip_%1" ).arg( - m_clip->getTrack()->type() ), + static_cast(m_clip->getTrack()->type()) ), dataFile.toString(), thumbnail, this ); } } @@ -839,7 +839,7 @@ void ClipView::mouseMoveEvent( QMouseEvent * me ) } const float ppb = m_trackView->trackContainerView()->pixelsPerBar(); - if( m_action == Move ) + if( m_action == Action::Move ) { TimePos newPos = draggedClipPos( me ); m_clip->movePosition(newPos); @@ -851,7 +851,7 @@ void ClipView::mouseMoveEvent( QMouseEvent * me ) TimePos::ticksPerBar() ) ); s_textFloat->moveGlobal( this, QPoint( width() + 2, height() + 2 ) ); } - else if( m_action == MoveSelection ) + else if( m_action == Action::MoveSelection ) { // 1: Find the position we want to move the grabbed Clip to TimePos newPos = draggedClipPos( me ); @@ -881,13 +881,13 @@ void ClipView::mouseMoveEvent( QMouseEvent * me ) ( *it )->movePosition( newPos + m_initialOffsets[index] ); } } - else if( m_action == Resize || m_action == ResizeLeft ) + else if( m_action == Action::Resize || m_action == Action::ResizeLeft ) { const float snapSize = getGUI()->songEditor()->m_editor->getSnapSize(); // Length in ticks of one snap increment const TimePos snapLength = TimePos( (int)(snapSize * TimePos::ticksPerBar()) ); - if( m_action == Resize ) + if( m_action == Action::Resize ) { // The clip's new length TimePos l = static_cast( me->x() * TimePos::ticksPerBar() / ppb ); @@ -990,7 +990,7 @@ void ClipView::mouseMoveEvent( QMouseEvent * me ) TimePos::ticksPerBar() ) ); s_textFloat->moveGlobal( this, QPoint( width() + 2, height() + 2) ); } - else if( m_action == Split ) + else if( m_action == Action::Split ) { auto sClip = dynamic_cast(m_clip); if (sClip) { @@ -1015,21 +1015,21 @@ void ClipView::mouseMoveEvent( QMouseEvent * me ) */ void ClipView::mouseReleaseEvent( QMouseEvent * me ) { - // If the CopySelection was chosen as the action due to mouse movement, + // If the Action::CopySelection was chosen as the action due to mouse movement, // it will have been cleared. At this point Toggle is the desired action. // An active StringPairDrag will prevent this method from being called, - // so a real CopySelection would not have occurred. - if( m_action == CopySelection || - ( m_action == ToggleSelected && mouseMovedDistance( me, 2 ) == false ) ) + // so a real Action::CopySelection would not have occurred. + if( m_action == Action::CopySelection || + ( m_action == Action::ToggleSelected && mouseMovedDistance( me, 2 ) == false ) ) { setSelected( !isSelected() ); } - else if( m_action == Move || m_action == Resize || m_action == ResizeLeft ) + else if( m_action == Action::Move || m_action == Action::Resize || m_action == Action::ResizeLeft ) { // TODO: Fix m_clip->setJournalling() consistency m_clip->setJournalling( true ); } - else if( m_action == Split ) + else if( m_action == Action::Split ) { const float ppb = m_trackView->trackContainerView()->pixelsPerBar(); const TimePos relPos = me->pos().x() * TimePos::ticksPerBar() / ppb; @@ -1039,7 +1039,7 @@ void ClipView::mouseReleaseEvent( QMouseEvent * me ) ); } - m_action = NoAction; + m_action = Action::None; delete m_hint; m_hint = nullptr; s_textFloat->hide(); @@ -1079,7 +1079,7 @@ void ClipView::contextMenuEvent( QContextMenuEvent * cme ) individualClip ? tr("Delete (middle mousebutton)") : tr("Delete selection (middle mousebutton)"), - [this](){ contextMenuAction( Remove ); } ); + [this](){ contextMenuAction( ContextMenuAction::Remove ); } ); contextMenu.addSeparator(); @@ -1088,14 +1088,14 @@ void ClipView::contextMenuEvent( QContextMenuEvent * cme ) individualClip ? tr("Cut") : tr("Cut selection"), - [this](){ contextMenuAction( Cut ); } ); + [this](){ contextMenuAction( ContextMenuAction::Cut ); } ); if (canMergeSelection(selectedClips)) { contextMenu.addAction( embed::getIconPixmap("edit_merge"), tr("Merge Selection"), - [this]() { contextMenuAction(Merge); } + [this]() { contextMenuAction(ContextMenuAction::Merge); } ); } } @@ -1105,12 +1105,12 @@ void ClipView::contextMenuEvent( QContextMenuEvent * cme ) individualClip ? tr("Copy") : tr("Copy selection"), - [this](){ contextMenuAction( Copy ); } ); + [this](){ contextMenuAction( ContextMenuAction::Copy ); } ); contextMenu.addAction( embed::getIconPixmap( "edit_paste" ), tr( "Paste" ), - [this](){ contextMenuAction( Paste ); } ); + [this](){ contextMenuAction( ContextMenuAction::Paste ); } ); contextMenu.addSeparator(); @@ -1119,7 +1119,7 @@ void ClipView::contextMenuEvent( QContextMenuEvent * cme ) (individualClip ? tr("Mute/unmute (<%1> + middle click)") : tr("Mute/unmute selection (<%1> + middle click)")).arg(UI_CTRL_KEY), - [this](){ contextMenuAction( Mute ); } ); + [this](){ contextMenuAction( ContextMenuAction::Mute ); } ); contextMenu.addSeparator(); @@ -1143,22 +1143,22 @@ void ClipView::contextMenuAction( ContextMenuAction action ) switch( action ) { - case Remove: + case ContextMenuAction::Remove: remove( active ); break; - case Cut: + case ContextMenuAction::Cut: cut( active ); break; - case Copy: + case ContextMenuAction::Copy: copy( active ); break; - case Paste: + case ContextMenuAction::Paste: paste(); break; - case Mute: + case ContextMenuAction::Mute: toggleMute( active ); break; - case Merge: + case ContextMenuAction::Merge: mergeClips(active); break; } @@ -1205,7 +1205,7 @@ void ClipView::copy( QVector clipvs ) DataFile dataFile = createClipDataFiles( clipvs ); // Copy the Clip type as a key and the Clip data file to the clipboard - copyStringPair( QString( "clip_%1" ).arg( m_clip->getTrack()->type() ), + copyStringPair( QString( "clip_%1" ).arg( static_cast(m_clip->getTrack()->type()) ), dataFile.toString() ); } diff --git a/src/gui/clips/MidiClipView.cpp b/src/gui/clips/MidiClipView.cpp index e3ef9fd20b9..79c4cd73d68 100644 --- a/src/gui/clips/MidiClipView.cpp +++ b/src/gui/clips/MidiClipView.cpp @@ -204,7 +204,7 @@ void MidiClipView::transposeSelection() void MidiClipView::constructContextMenu( QMenu * _cm ) { - bool isBeat = m_clip->type() == MidiClip::BeatClip; + bool isBeat = m_clip->type() == MidiClip::Type::BeatClip; auto a = new QAction(embed::getIconPixmap("piano"), tr("Open in piano-roll"), _cm); _cm->insertAction( _cm->actions()[0], a ); @@ -253,7 +253,7 @@ void MidiClipView::mousePressEvent( QMouseEvent * _me ) { bool displayPattern = fixedClips() || (pixelsPerBar() >= 96 && m_legacySEPattern); if( _me->button() == Qt::LeftButton && - m_clip->m_clipType == MidiClip::BeatClip && + m_clip->m_clipType == MidiClip::Type::BeatClip && displayPattern && _me->y() > height() - s_stepBtnOff->height() ) // when mouse button is pressed in pattern mode @@ -311,7 +311,7 @@ void MidiClipView::mouseDoubleClickEvent(QMouseEvent *_me) _me->ignore(); return; } - if( m_clip->m_clipType == MidiClip::MelodyClip || !fixedClips() ) + if( m_clip->m_clipType == MidiClip::Type::MelodyClip || !fixedClips() ) { openInPianoRoll(); } @@ -322,7 +322,7 @@ void MidiClipView::mouseDoubleClickEvent(QMouseEvent *_me) void MidiClipView::wheelEvent(QWheelEvent * we) { - if(m_clip->m_clipType == MidiClip::BeatClip && + if(m_clip->m_clipType == MidiClip::Type::BeatClip && (fixedClips() || pixelsPerBar() >= 96) && position(we).y() > height() - s_stepBtnOff->height()) { @@ -400,7 +400,7 @@ void MidiClipView::paintEvent( QPaintEvent * ) QColor c; bool const muted = m_clip->getTrack()->isMuted() || m_clip->isMuted(); bool current = getGUI()->pianoRoll()->currentMidiClip() == m_clip; - bool beatClip = m_clip->m_clipType == MidiClip::BeatClip; + bool beatClip = m_clip->m_clipType == MidiClip::Type::BeatClip; if( beatClip ) { @@ -460,7 +460,7 @@ void MidiClipView::paintEvent( QPaintEvent * ) bool displayPattern = fixedClips() || (pixelsPerBar >= 96 && m_legacySEPattern); // melody clip paint event NoteVector const & noteCollection = m_clip->m_notes; - if( m_clip->m_clipType == MidiClip::MelodyClip && !noteCollection.empty() ) + if( m_clip->m_clipType == MidiClip::Type::MelodyClip && !noteCollection.empty() ) { // Compute the minimum and maximum key in the clip // so that we know how much there is to draw. diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 1289c5626c2..a24165332d0 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -90,13 +90,13 @@ AutomationEditor::AutomationEditor() : m_bottomLevel( 0 ), m_topLevel( 0 ), m_currentPosition(), - m_action( NONE ), + m_action( Action::None ), m_drawLastLevel( 0.0f ), m_drawLastTick( 0 ), m_ppb( DEFAULT_PPB ), m_y_delta( DEFAULT_Y_DELTA ), m_y_auto( true ), - m_editMode( DRAW ), + m_editMode( EditMode::Draw ), m_mouseDownLeft(false), m_mouseDownRight( false ), m_scrollBack( false ), @@ -147,9 +147,9 @@ AutomationEditor::AutomationEditor() : // add time-line m_timeLine = new TimeLineWidget( VALUES_WIDTH, 0, m_ppb, Engine::getSong()->getPlayPos( - Song::Mode_PlayAutomationClip ), + Song::PlayMode::AutomationClip ), m_currentPosition, - Song::Mode_PlayAutomationClip, this ); + Song::PlayMode::AutomationClip, this ); connect( this, SIGNAL( positionChanged( const lmms::TimePos& ) ), m_timeLine, SLOT( updatePosition( const lmms::TimePos& ) ) ); connect( m_timeLine, SIGNAL( positionChanged( const lmms::TimePos& ) ), @@ -492,15 +492,15 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) // a node, while others require that we know if we clicked the outValue // of a node. bool editingOutValue = ( - m_editMode == DRAW_OUTVALUES - || (m_editMode == ERASE && m_mouseDownRight) + m_editMode == EditMode::DrawOutValues + || (m_editMode == EditMode::Erase && m_mouseDownRight) ); timeMap::iterator clickedNode = getNodeAt(mouseEvent->x(), mouseEvent->y(), editingOutValue); switch (m_editMode) { - case DRAW: + case EditMode::Draw: { m_clip->addJournalCheckPoint(); @@ -518,7 +518,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) m_drawLastLevel = level; // Changes the action to drawing a line of nodes - m_action = DRAW_LINE; + m_action = Action::DrawLine; } else // No shift, we are just creating/moving nodes { @@ -540,8 +540,8 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) // is being dragged, so if we don't update it we have a bogus iterator clickedNode = tm.find(newTime); - // Set the action to MOVE_VALUE so moveMouseEvent() knows we are moving a node - m_action = MOVE_VALUE; + // Set the action to Action::MoveValue so moveMouseEvent() knows we are moving a node + m_action = Action::MoveValue; // Calculate the offset from the place the mouse click happened in comparison // to the center of the node @@ -559,7 +559,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) Engine::getSong()->setModified(); } - else if (m_mouseDownRight) // Right click on DRAW mode erases values + else if (m_mouseDownRight) // Right click on EditMode::Draw mode erases values { // Update the last clicked position so we remove all nodes from // that point up to the point we release the mouse button @@ -568,11 +568,11 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) // If we right-clicked a node, remove it eraseNode(clickedNode); - m_action = ERASE_VALUES; + m_action = Action::EraseValues; } break; } - case ERASE: + case EditMode::Erase: { m_clip->addJournalCheckPoint(); @@ -586,7 +586,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) // If we right-clicked a node, remove it eraseNode(clickedNode); - m_action = ERASE_VALUES; + m_action = Action::EraseValues; } else if (m_mouseDownRight) // And right click resets outValues { @@ -597,11 +597,11 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) // that point up to the point we release the mouse button m_drawLastTick = posTicks; - m_action = RESET_OUTVALUES; + m_action = Action::ResetOutValues; } break; } - case DRAW_OUTVALUES: + case EditMode::DrawOutValues: { m_clip->addJournalCheckPoint(); @@ -615,7 +615,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) clickedNode.value().setOutValue(level); - m_action = MOVE_OUTVALUE; + m_action = Action::MoveOutValue; Engine::getSong()->setModified(); } @@ -635,7 +635,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) m_draggedOutValueKey = POS(clickedNode); clickedNode.value().setOutValue(level); - m_action = MOVE_OUTVALUE; + m_action = Action::MoveOutValue; Engine::getSong()->setModified(); } @@ -650,7 +650,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) // that point up to the point we release the mouse button m_drawLastTick = posTicks; - m_action = RESET_OUTVALUES; + m_action = Action::ResetOutValues; } break; } @@ -671,13 +671,13 @@ void AutomationEditor::mouseDoubleClickEvent(QMouseEvent * mouseEvent) if (mouseEvent->y() <= TOP_MARGIN || mouseEvent->x() < VALUES_WIDTH) { return; } // Are we fine tuning the inValue or outValue? - const bool isOutVal = (m_editMode == DRAW_OUTVALUES); + const bool isOutVal = (m_editMode == EditMode::DrawOutValues); timeMap::iterator clickedNode = getNodeAt(mouseEvent->x(), mouseEvent->y(), isOutVal); switch (m_editMode) { - case DRAW: - case DRAW_OUTVALUES: + case EditMode::Draw: + case EditMode::DrawOutValues: if (fineTuneValue(clickedNode, isOutVal)) { update(); } break; default: @@ -703,9 +703,9 @@ void AutomationEditor::mouseReleaseEvent(QMouseEvent * mouseEvent ) mustRepaint = true; } - if (m_editMode == DRAW) + if (m_editMode == EditMode::Draw) { - if (m_action == MOVE_VALUE) + if (m_action == Action::MoveValue) { // Actually apply the value of the node being dragged m_clip->applyDragValue(); @@ -714,7 +714,7 @@ void AutomationEditor::mouseReleaseEvent(QMouseEvent * mouseEvent ) QApplication::restoreOverrideCursor(); } - m_action = NONE; + m_action = Action::None; if (mustRepaint) { repaint(); } } @@ -742,12 +742,12 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) switch (m_editMode) { - case DRAW: + case EditMode::Draw: { // We are dragging a node if (m_mouseDownLeft) { - if (m_action == MOVE_VALUE) + if (m_action == Action::MoveValue) { // When we clicked the node, we might have clicked slightly off // so we account for that offset for a smooth drag @@ -770,7 +770,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) Engine::getSong()->setModified(); } - /* else if (m_action == DRAW_LINE) + /* else if (m_action == Action::DrawLine) { // We are drawing a line. For now do nothing (as before), but later logic // could be added here so the line is updated according to the new mouse position @@ -779,7 +779,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) } else if (m_mouseDownRight) // We are removing nodes { - if (m_action == ERASE_VALUES) + if (m_action == Action::EraseValues) { // If we moved the mouse past the beginning correct the position in ticks posTicks = qMax(posTicks, 0); @@ -794,7 +794,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) } break; } - case ERASE: + case EditMode::Erase: { // If we moved the mouse past the beginning correct the position in ticks posTicks = qMax(posTicks, 0); @@ -802,7 +802,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) // Left button removes nodes if (m_mouseDownLeft) { - if (m_action == ERASE_VALUES) + if (m_action == Action::EraseValues) { // Removing automation nodes @@ -814,7 +814,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) } else if (m_mouseDownRight) // Right button resets outValues { - if (m_action == RESET_OUTVALUES) + if (m_action == Action::ResetOutValues) { // Reseting outValues @@ -826,7 +826,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) } break; } - case DRAW_OUTVALUES: + case EditMode::DrawOutValues: { // If we moved the mouse past the beginning correct the position in ticks posTicks = qMax(posTicks, 0); @@ -834,7 +834,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) // Left button moves outValues if (m_mouseDownLeft) { - if (m_action == MOVE_OUTVALUE) + if (m_action == Action::MoveOutValue) { // We are moving the outValue of the node timeMap & tm = m_clip->getTimeMap(); @@ -850,7 +850,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) } else if (m_mouseDownRight) // Right button resets them { - if (m_action == RESET_OUTVALUES) + if (m_action == Action::ResetOutValues) { // Reseting outValues @@ -1172,7 +1172,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) // the value of the end of the shape between the two nodes will be the inValue of // the next node. float nextValue; - if( m_clip->progressionType() == AutomationClip::DiscreteProgression ) + if( m_clip->progressionType() == AutomationClip::ProgressionType::Discrete ) { nextValue = OUTVAL(it); } @@ -1248,22 +1248,22 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) // draw current edit-mode-icon below the cursor switch( m_editMode ) { - case DRAW: + case EditMode::Draw: { - if (m_action == ERASE_VALUES) { cursor = s_toolErase; } - else if (m_action == MOVE_VALUE) { cursor = s_toolMove; } + if (m_action == Action::EraseValues) { cursor = s_toolErase; } + else if (m_action == Action::MoveValue) { cursor = s_toolMove; } else { cursor = s_toolDraw; } break; } - case ERASE: + case EditMode::Erase: { cursor = s_toolErase; break; } - case DRAW_OUTVALUES: + case EditMode::DrawOutValues: { - if (m_action == RESET_OUTVALUES) { cursor = s_toolErase; } - else if (m_action == MOVE_OUTVALUE) { cursor = s_toolMove; } + if (m_action == Action::ResetOutValues) { cursor = s_toolErase; } + else if (m_action == Action::MoveOutValue) { cursor = s_toolMove; } else { cursor = s_toolDrawOut; } break; } @@ -1400,7 +1400,7 @@ void AutomationEditor::resizeEvent(QResizeEvent * re) if( Engine::getSong() ) { - Engine::getSong()->getPlayPos( Song::Mode_PlayAutomationClip + Engine::getSong()->getPlayPos( Song::PlayMode::AutomationClip ).m_timeLine->setFixedWidth( width() ); } @@ -1525,7 +1525,7 @@ void AutomationEditor::play() if( !m_clip->getTrack() ) { - if( Engine::getSong()->playMode() != Song::Mode_PlayMidiClip ) + if( Engine::getSong()->playMode() != Song::PlayMode::MidiClip ) { Engine::getSong()->stop(); Engine::getSong()->playMidiClip( getGUI()->pianoRoll()->currentMidiClip() ); @@ -1599,7 +1599,7 @@ void AutomationEditor::verScrolled(int new_pos ) -void AutomationEditor::setEditMode(AutomationEditor::EditModes mode) +void AutomationEditor::setEditMode(AutomationEditor::EditMode mode) { if (m_editMode == mode) return; @@ -1614,13 +1614,13 @@ void AutomationEditor::setEditMode(AutomationEditor::EditModes mode) void AutomationEditor::setEditMode(int mode) { - setEditMode((AutomationEditor::EditModes) mode); + setEditMode((AutomationEditor::EditMode) mode); } -void AutomationEditor::setProgressionType(AutomationClip::ProgressionTypes type) +void AutomationEditor::setProgressionType(AutomationClip::ProgressionType type) { if (validClip()) { @@ -1633,7 +1633,7 @@ void AutomationEditor::setProgressionType(AutomationClip::ProgressionTypes type) void AutomationEditor::setProgressionType(int type) { - setProgressionType((AutomationClip::ProgressionTypes) type); + setProgressionType((AutomationClip::ProgressionType) type); } @@ -1655,7 +1655,7 @@ void AutomationEditor::updatePosition(const TimePos & t ) { if( ( Engine::getSong()->isPlaying() && Engine::getSong()->playMode() == - Song::Mode_PlayAutomationClip ) || + Song::PlayMode::AutomationClip ) || m_scrollBack == true ) { const int w = width() - VALUES_WIDTH; @@ -1877,7 +1877,7 @@ AutomationEditorWindow::AutomationEditorWindow() : connect(progression_type_group, SIGNAL(triggered(int)), m_editor, SLOT(setProgressionType(int))); // setup tension-stuff - m_tensionKnob = new Knob( knobSmall_17, this, "Tension" ); + m_tensionKnob = new Knob( KnobType::Small17, this, "Tension" ); m_tensionKnob->setModel(m_editor->m_tensionModel); m_tensionKnob->setToolTip(tr("Tension value for spline")); @@ -1989,15 +1989,15 @@ void AutomationEditorWindow::setCurrentClip(AutomationClip* clip) switch(m_editor->m_clip->progressionType()) { - case AutomationClip::DiscreteProgression: + case AutomationClip::ProgressionType::Discrete: m_discreteAction->setChecked(true); m_tensionKnob->setEnabled(false); break; - case AutomationClip::LinearProgression: + case AutomationClip::ProgressionType::Linear: m_linearAction->setChecked(true); m_tensionKnob->setEnabled(false); break; - case AutomationClip::CubicHermiteProgression: + case AutomationClip::ProgressionType::CubicHermite: m_cubicHermiteAction->setChecked(true); m_tensionKnob->setEnabled(true); break; diff --git a/src/gui/editors/PatternEditor.cpp b/src/gui/editors/PatternEditor.cpp index b2d2f5c3f62..229c90bc234 100644 --- a/src/gui/editors/PatternEditor.cpp +++ b/src/gui/editors/PatternEditor.cpp @@ -73,7 +73,7 @@ void PatternEditor::removeSteps() for (const auto& track : tl) { - if (track->type() == Track::InstrumentTrack) + if (track->type() == Track::Type::Instrument) { auto p = static_cast(track->getClip(m_ps->currentPattern())); p->removeSteps(); @@ -86,7 +86,7 @@ void PatternEditor::removeSteps() void PatternEditor::addSampleTrack() { - (void) Track::create( Track::SampleTrack, model() ); + (void) Track::create( Track::Type::Sample, model() ); } @@ -94,7 +94,7 @@ void PatternEditor::addSampleTrack() void PatternEditor::addAutomationTrack() { - (void) Track::create( Track::AutomationTrack, model() ); + (void) Track::create( Track::Type::Automation, model() ); } @@ -180,7 +180,7 @@ void PatternEditor::makeSteps( bool clone ) for (const auto& track : tl) { - if (track->type() == Track::InstrumentTrack) + if (track->type() == Track::Type::Instrument) { auto p = static_cast(track->getClip(m_ps->currentPattern())); if( clone ) @@ -306,7 +306,7 @@ QSize PatternEditorWindow::sizeHint() const void PatternEditorWindow::play() { - if (Engine::getSong()->playMode() != Song::Mode_PlayPattern) + if (Engine::getSong()->playMode() != Song::PlayMode::Pattern) { Engine::getSong()->playPattern(); } diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 753dfe77f67..0cc8257255f 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -113,7 +113,7 @@ const int RESIZE_AREA_WIDTH = 9; const int NOTE_EDIT_LINE_WIDTH = 3; // key where to start -const int INITIAL_START_KEY = Key_C + Octave_4 * KeysPerOctave; +const int INITIAL_START_KEY = Octave::Octave_4 + Key::C; // number of each note to provide in quantization and note lengths const int NUM_EVEN_LENGTHS = 6; @@ -138,11 +138,11 @@ static QString getNoteString(int key) } // used for drawing of piano -std::array PianoRoll::prKeyOrder +std::array PianoRoll::prKeyOrder { - PR_WHITE_KEY_SMALL, PR_BLACK_KEY, PR_WHITE_KEY_BIG, PR_BLACK_KEY, - PR_WHITE_KEY_SMALL, PR_WHITE_KEY_SMALL, PR_BLACK_KEY, PR_WHITE_KEY_BIG, - PR_BLACK_KEY, PR_WHITE_KEY_BIG, PR_BLACK_KEY, PR_WHITE_KEY_SMALL + KeyType::WhiteSmall, KeyType::Black, KeyType::WhiteBig, KeyType::Black, + KeyType::WhiteSmall, KeyType::WhiteSmall, KeyType::Black, KeyType::WhiteBig, + KeyType::Black, KeyType::WhiteBig, KeyType::Black, KeyType::WhiteSmall } ; @@ -168,8 +168,8 @@ PianoRoll::PianoRoll() : m_currentPosition(), m_recording( false ), m_currentNote( nullptr ), - m_action( ActionNone ), - m_noteEditMode( NoteEditVolume ), + m_action( Action::None ), + m_noteEditMode( NoteEditMode::Volume ), m_moveBoundaryLeft( 0 ), m_moveBoundaryTop( 0 ), m_moveBoundaryRight( 0 ), @@ -191,8 +191,8 @@ PianoRoll::PianoRoll() : m_minResizeLen( 0 ), m_startKey( INITIAL_START_KEY ), m_lastKey( 0 ), - m_editMode( ModeDraw ), - m_ctrlMode( ModeDraw ), + m_editMode( EditMode::Draw ), + m_ctrlMode( EditMode::Draw ), m_mouseDownRight( false ), m_scrollBack( false ), m_stepRecorderWidget(this, DEFAULT_PR_PPB, PR_TOP_MARGIN, PR_BOTTOM_MARGIN + m_notesEditHeight, WHITE_KEY_WIDTH, 0), @@ -241,12 +241,12 @@ PianoRoll::PianoRoll() : auto unmarkAllAction = new QAction(tr("Unmark all"), this); auto copyAllNotesAction = new QAction(tr("Select all notes on this key"), this); - connect( markSemitoneAction, &QAction::triggered, [this](){ markSemiTone(stmaMarkCurrentSemiTone); }); - connect( markAllOctaveSemitonesAction, &QAction::triggered, [this](){ markSemiTone(stmaMarkAllOctaveSemiTones); }); - connect( markScaleAction, &QAction::triggered, [this](){ markSemiTone(stmaMarkCurrentScale); }); - connect( markChordAction, &QAction::triggered, [this](){ markSemiTone(stmaMarkCurrentChord); }); - connect( unmarkAllAction, &QAction::triggered, [this](){ markSemiTone(stmaUnmarkAll); }); - connect( copyAllNotesAction, &QAction::triggered, [this](){ markSemiTone(stmaCopyAllNotesOnKey); }); + connect( markSemitoneAction, &QAction::triggered, [this](){ markSemiTone(SemiToneMarkerAction::MarkCurrentSemiTone); }); + connect( markAllOctaveSemitonesAction, &QAction::triggered, [this](){ markSemiTone(SemiToneMarkerAction::MarkAllOctaveSemiTones); }); + connect( markScaleAction, &QAction::triggered, [this](){ markSemiTone(SemiToneMarkerAction::MarkCurrentScale); }); + connect( markChordAction, &QAction::triggered, [this](){ markSemiTone(SemiToneMarkerAction::MarkCurrentChord); }); + connect( unmarkAllAction, &QAction::triggered, [this](){ markSemiTone(SemiToneMarkerAction::UnmarkAll); }); + connect( copyAllNotesAction, &QAction::triggered, [this](){ markSemiTone(SemiToneMarkerAction::CopyAllNotesOnKey); }); markScaleAction->setEnabled( false ); markChordAction->setEnabled( false ); @@ -298,9 +298,9 @@ PianoRoll::PianoRoll() : // add time-line m_timeLine = new TimeLineWidget(m_whiteKeyWidth, 0, m_ppb, Engine::getSong()->getPlayPos( - Song::Mode_PlayMidiClip ), + Song::PlayMode::MidiClip ), m_currentPosition, - Song::Mode_PlayMidiClip, this ); + Song::PlayMode::MidiClip, this ); connect( this, SIGNAL( positionChanged( const lmms::TimePos& ) ), m_timeLine, SLOT( updatePosition( const lmms::TimePos& ) ) ); connect( m_timeLine, SIGNAL( positionChanged( const lmms::TimePos& ) ), @@ -314,12 +314,12 @@ PianoRoll::PianoRoll() : this, SLOT( updatePositionStepRecording( const lmms::TimePos& ) ) ); // update timeline when in record-accompany mode - connect( Engine::getSong()->getPlayPos( Song::Mode_PlaySong ).m_timeLine, + connect( Engine::getSong()->getPlayPos( Song::PlayMode::Song ).m_timeLine, SIGNAL( positionChanged( const lmms::TimePos& ) ), this, SLOT( updatePositionAccompany( const lmms::TimePos& ) ) ); // TODO -/* connect( engine::getSong()->getPlayPos( Song::Mode_PlayPattern ).m_timeLine, +/* connect( engine::getSong()->getPlayPos( Song::PlayMode::Pattern ).m_timeLine, SIGNAL( positionChanged( const lmms::TimePos& ) ), this, SLOT( updatePositionAccompany( const lmms::TimePos& ) ) );*/ @@ -524,7 +524,7 @@ void PianoRoll::changeNoteEditMode( int i ) } -void PianoRoll::markSemiTone(int i, bool fromMenu) +void PianoRoll::markSemiTone(SemiToneMarkerAction i, bool fromMenu) { const int key = fromMenu ? getKey(mapFromGlobal(m_semiToneMarkerMenu->pos()).y()) @@ -533,14 +533,14 @@ void PianoRoll::markSemiTone(int i, bool fromMenu) // if "No key" is selected, key is -1, unmark all semitones // or if scale changed from toolbar to "No scale", unmark all semitones - if (!fromMenu && (key < 0 || m_scaleModel.value() == 0)) { i = stmaUnmarkAll; } + if (!fromMenu && (key < 0 || m_scaleModel.value() == 0)) { i = SemiToneMarkerAction::UnmarkAll; } - switch( static_cast( i ) ) + switch(i) { - case stmaUnmarkAll: + case SemiToneMarkerAction::UnmarkAll: m_markedSemiTones.clear(); break; - case stmaMarkCurrentSemiTone: + case SemiToneMarkerAction::MarkCurrentSemiTone: { QList::iterator it = std::find( m_markedSemiTones.begin(), m_markedSemiTones.end(), key ); if( it != m_markedSemiTones.end() ) @@ -553,7 +553,7 @@ void PianoRoll::markSemiTone(int i, bool fromMenu) } break; } - case stmaMarkAllOctaveSemiTones: + case SemiToneMarkerAction::MarkAllOctaveSemiTones: { QList aok = getAllOctavesForKey(key); @@ -578,10 +578,10 @@ void PianoRoll::markSemiTone(int i, bool fromMenu) break; } - case stmaMarkCurrentScale: + case SemiToneMarkerAction::MarkCurrentScale: chord = & InstrumentFunctionNoteStacking::ChordTable::getInstance() .getScaleByName( m_scaleModel.currentText() ); - case stmaMarkCurrentChord: + case SemiToneMarkerAction::MarkCurrentChord: { if( ! chord ) { @@ -611,7 +611,7 @@ void PianoRoll::markSemiTone(int i, bool fromMenu) } break; } - case stmaCopyAllNotesOnKey: + case SemiToneMarkerAction::CopyAllNotesOnKey: { selectNotesOnKey(); break; @@ -858,7 +858,7 @@ void PianoRoll::setCurrentMidiClip( MidiClip* newMidiClip ) } // force the song-editor to stop playing if it played a MIDI clip before - if (Engine::getSong()->playMode() == Song::Mode_PlayMidiClip) + if (Engine::getSong()->playMode() == Song::PlayMode::MidiClip) { Engine::getSong()->playMidiClip( nullptr ); } @@ -1146,12 +1146,12 @@ void PianoRoll::drawDetuningInfo( QPainter & _p, const Note * _n, int _x, // node to the other switch (_n->detuning()->automationClip()->progressionType()) { - case AutomationClip::DiscreteProgression: + case AutomationClip::ProgressionType::Discrete: _p.drawLine(old_x, pre_y, cur_x, pre_y); _p.drawLine(cur_x, pre_y, cur_x, cur_y); break; - case AutomationClip::CubicHermiteProgression: /* TODO */ - case AutomationClip::LinearProgression: + case AutomationClip::ProgressionType::CubicHermite: /* TODO */ + case AutomationClip::ProgressionType::Linear: _p.drawLine(old_x, pre_y, cur_x, cur_y); break; } @@ -1299,7 +1299,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) if( hasValidMidiClip() && ke->modifiers() == Qt::NoModifier ) { - const int key_num = PianoView::getKeyFromKeyEvent( ke ) + ( DefaultOctave - 1 ) * KeysPerOctave; + const int key_num = PianoView::getKeyFromKeyEvent( ke ); if (!ke->isAutoRepeat() && key_num > -1) { @@ -1316,7 +1316,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) case Qt::Key_Down: { int direction = (ke->key() == Qt::Key_Up ? +1 : -1); - if( ( ke->modifiers() & Qt::ControlModifier ) && m_action == ActionNone ) + if( ( ke->modifiers() & Qt::ControlModifier ) && m_action == Action::None ) { // shift selection by one octave // if nothing selected, shift _everything_ @@ -1334,7 +1334,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) } } } - else if((ke->modifiers() & Qt::ShiftModifier) && m_action == ActionNone) + else if((ke->modifiers() & Qt::ShiftModifier) && m_action == Action::None) { // Move selected notes by one semitone if (hasValidMidiClip()) @@ -1350,8 +1350,8 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) // if they are moving notes around or resizing, // recalculate the note/resize position - if( m_action == ActionMoveNote || - m_action == ActionResizeNote ) + if( m_action == Action::MoveNote || + m_action == Action::ResizeNote ) { dragNotes( m_lastMouseX, @@ -1370,7 +1370,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) case Qt::Key_Left: { int direction = (ke->key() == Qt::Key_Right ? +1 : -1); - if( ke->modifiers() & Qt::ControlModifier && m_action == ActionNone ) + if( ke->modifiers() & Qt::ControlModifier && m_action == Action::None ) { // Move selected notes by one bar to the left if (hasValidMidiClip()) @@ -1378,7 +1378,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) shiftPos( direction * TimePos::ticksPerBar() ); } } - else if( ke->modifiers() & Qt::ShiftModifier && m_action == ActionNone) + else if( ke->modifiers() & Qt::ShiftModifier && m_action == Action::None) { // move notes if (hasValidMidiClip()) @@ -1409,8 +1409,8 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) // if they are moving notes around or resizing, // recalculate the note/resize position - if( m_action == ActionMoveNote || - m_action == ActionResizeNote ) + if( m_action == Action::MoveNote || + m_action == Action::ResizeNote ) { dragNotes( m_lastMouseX, @@ -1446,7 +1446,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) case Qt::Key_Escape: // On the Knife mode, ESC cancels it - if (m_editMode == ModeEditKnife) + if (m_editMode == EditMode::Knife) { cancelKnifeAction(); } @@ -1501,7 +1501,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) case Qt::Key_Control: // Ctrl will not enter selection mode if we are // in Knife mode, but unquantize it - if (m_editMode == ModeEditKnife) + if (m_editMode == EditMode::Knife) { break; } @@ -1512,7 +1512,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) if ( !( ke->modifiers() & Qt::ShiftModifier ) && isActiveWindow() ) { m_ctrlMode = m_editMode; - m_editMode = ModeSelect; + m_editMode = EditMode::Select; setCursor( Qt::ArrowCursor ); ke->accept(); } @@ -1531,7 +1531,7 @@ void PianoRoll::keyReleaseEvent(QKeyEvent* ke ) { if( hasValidMidiClip() && ke->modifiers() == Qt::NoModifier ) { - const int key_num = PianoView::getKeyFromKeyEvent( ke ) + ( DefaultOctave - 1 ) * KeysPerOctave; + const int key_num = PianoView::getKeyFromKeyEvent( ke ); if (!ke->isAutoRepeat() && key_num > -1) { m_midiClip->instrumentTrack()->pianoModel()->handleKeyRelease(key_num); @@ -1544,7 +1544,7 @@ void PianoRoll::keyReleaseEvent(QKeyEvent* ke ) switch( ke->key() ) { case Qt::Key_Control: - if (m_editMode == ModeEditKnife) + if (m_editMode == EditMode::Knife) { break; } @@ -1637,7 +1637,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) } // -- Knife - if (m_editMode == ModeEditKnife && me->button() == Qt::LeftButton) + if (m_editMode == EditMode::Knife && me->button() == Qt::LeftButton) { NoteVector n; Note* note = noteUnderMouse(); @@ -1656,7 +1656,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) return; } - if( m_editMode == ModeEditDetuning && noteUnderMouse() ) + if( m_editMode == EditMode::Detuning && noteUnderMouse() ) { static QPointer detuningClip = nullptr; if (detuningClip.data() != nullptr) @@ -1675,10 +1675,10 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) } // if holding control, go to selection mode unless shift is also pressed - if( me->modifiers() & Qt::ControlModifier && m_editMode != ModeSelect ) + if( me->modifiers() & Qt::ControlModifier && m_editMode != EditMode::Select ) { m_ctrlMode = m_editMode; - m_editMode = ModeSelect; + m_editMode = EditMode::Select; setCursor( Qt::ArrowCursor ); update(); } @@ -1694,7 +1694,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) me->y() > keyAreaBottom() && me->y() < noteEditTop()) { // resizing the note edit area - m_action = ActionResizeNoteEditArea; + m_action = Action::ResizeNoteEditArea; return; } @@ -1764,7 +1764,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) } // left button?? else if( me->button() == Qt::LeftButton && - m_editMode == ModeDraw ) + m_editMode == EditMode::Draw ) { // whether this action creates new note(s) or not bool is_new_note = false; @@ -1871,7 +1871,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) { m_midiClip->addJournalCheckPoint(); // then resize the note - m_action = ActionResizeNote; + m_action = Action::ResizeNote; //Calculate the minimum length we should allow when resizing //each note, and let all notes use the smallest one found @@ -1901,7 +1901,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) } // otherwise move it - m_action = ActionMoveNote; + m_action = Action::MoveNote; // set move-cursor setCursor( Qt::SizeAllCursor ); @@ -1931,8 +1931,8 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) Engine::getSong()->setModified(); } else if( ( me->buttons() == Qt::RightButton && - m_editMode == ModeDraw ) || - m_editMode == ModeErase ) + m_editMode == EditMode::Draw ) || + m_editMode == EditMode::Erase ) { // erase single note m_mouseDownRight = true; @@ -1944,7 +1944,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) } } else if( me->button() == Qt::LeftButton && - m_editMode == ModeSelect ) + m_editMode == EditMode::Select ) { // select an area of notes @@ -1952,7 +1952,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) m_selectedTick = 0; m_selectStartKey = key_num; m_selectedKeys = 1; - m_action = ActionSelectNotes; + m_action = Action::SelectNotes; // call mousemove to fix glitch where selection // appears in wrong spot on mousedown @@ -1990,7 +1990,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) { // clicked in the box below the keys to the left of note edit area m_noteEditMode = (NoteEditMode)(((int)m_noteEditMode)+1); - if( m_noteEditMode == NoteEditCount ) + if( m_noteEditMode == NoteEditMode::Count ) { m_noteEditMode = (NoteEditMode) 0; } @@ -2163,11 +2163,11 @@ void PianoRoll::pauseChordNotes(int key) void PianoRoll::setKnifeAction() { - if (m_editMode != ModeEditKnife) + if (m_editMode != EditMode::Knife) { m_knifeMode = m_editMode; - m_editMode = ModeEditKnife; - m_action = ActionKnife; + m_editMode = EditMode::Knife; + m_action = Action::Knife; setCursor(Qt::ArrowCursor); update(); } @@ -2176,7 +2176,7 @@ void PianoRoll::setKnifeAction() void PianoRoll::cancelKnifeAction() { m_editMode = m_knifeMode; - m_action = ActionNone; + m_action = Action::None; update(); } @@ -2281,7 +2281,7 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * me ) s_textFloat->hide(); // Quit knife mode if we pressed and released the right mouse button - if (m_editMode == ModeEditKnife && me->button() == Qt::RightButton) + if (m_editMode == EditMode::Knife && me->button() == Qt::RightButton) { cancelKnifeAction(); } @@ -2290,14 +2290,14 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * me ) { mustRepaint = true; - if( m_action == ActionSelectNotes && m_editMode == ModeSelect ) + if( m_action == Action::SelectNotes && m_editMode == EditMode::Select ) { // select the notes within the selection rectangle and // then destroy the selection rectangle computeSelectedNotes( me->modifiers() & Qt::ShiftModifier ); } - else if( m_action == ActionMoveNote ) + else if( m_action == Action::MoveNote ) { // we moved one or more notes so they have to be // moved properly according to new starting- @@ -2306,7 +2306,7 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * me ) } - if( m_action == ActionMoveNote || m_action == ActionResizeNote ) + if( m_action == Action::MoveNote || m_action == Action::ResizeNote ) { // if we only moved one note, deselect it so we can // edit the notes in the note edit area @@ -2345,12 +2345,12 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * me ) m_currentNote = nullptr; - if (m_action != ActionKnife) + if (m_action != Action::Knife) { - m_action = ActionNone; + m_action = Action::None; } - if( m_editMode == ModeDraw ) + if( m_editMode == EditMode::Draw ) { setCursor( Qt::ArrowCursor ); } @@ -2372,7 +2372,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) return; } - if( m_action == ActionNone && me->buttons() == 0 ) + if( m_action == Action::None && me->buttons() == 0 ) { // When cursor is between note editing area and volume/panning // area show vertical size cursor. @@ -2382,7 +2382,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) return; } } - else if( m_action == ActionResizeNoteEditArea ) + else if( m_action == Action::ResizeNoteEditArea ) { // Don't try to show more keys than the full keyboard, bail if trying to if (m_pianoKeysVisible == NumKeys && me->y() > m_moveStartY) @@ -2406,22 +2406,22 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) } // Update Knife position if we are on knife mode - if (m_editMode == ModeEditKnife) + if (m_editMode == EditMode::Knife) { updateKnifePos(me); } - if( me->y() > PR_TOP_MARGIN || m_action != ActionNone ) + if( me->y() > PR_TOP_MARGIN || m_action != Action::None ) { bool edit_note = ( me->y() > noteEditTop() ) - && m_action != ActionSelectNotes; + && m_action != Action::SelectNotes; int key_num = getKey( me->y() ); int x = me->x(); // see if they clicked on the keyboard on the left - if (x < m_whiteKeyWidth && m_action == ActionNone + if (x < m_whiteKeyWidth && m_action == Action::None && ! edit_note && key_num != m_lastKey && me->buttons() & Qt::LeftButton ) { @@ -2434,14 +2434,14 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) x -= m_whiteKeyWidth; if( me->buttons() & Qt::LeftButton - && m_editMode == ModeDraw - && (m_action == ActionMoveNote || m_action == ActionResizeNote ) ) + && m_editMode == EditMode::Draw + && (m_action == Action::MoveNote || m_action == Action::ResizeNote ) ) { // handle moving notes and resizing them bool replay_note = key_num != m_lastKey - && m_action == ActionMoveNote; + && m_action == Action::MoveNote; - if( replay_note || ( m_action == ActionMoveNote && ( me->modifiers() & Qt::ShiftModifier ) && ! m_startedWithShift ) ) + if( replay_note || ( m_action == Action::MoveNote && ( me->modifiers() & Qt::ShiftModifier ) && ! m_startedWithShift ) ) { pauseTestNotes(); } @@ -2454,13 +2454,13 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) me->modifiers() & Qt::ControlModifier ); - if( replay_note && m_action == ActionMoveNote && ! ( ( me->modifiers() & Qt::ShiftModifier ) && ! m_startedWithShift ) ) + if( replay_note && m_action == Action::MoveNote && ! ( ( me->modifiers() & Qt::ShiftModifier ) && ! m_startedWithShift ) ) { pauseTestNotes( false ); } } - else if( m_editMode != ModeErase && - ( edit_note || m_action == ActionChangeNoteProperty ) && + else if( m_editMode != EditMode::Erase && + ( edit_note || m_action == Action::ChangeNoteProperty ) && ( me->buttons() & Qt::LeftButton || me->buttons() & Qt::MiddleButton || ( me->buttons() & Qt::RightButton && me->modifiers() & Qt::ShiftModifier ) ) ) { @@ -2501,12 +2501,12 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) PanningRight); } - if( m_noteEditMode == NoteEditVolume ) + if( m_noteEditMode == NoteEditMode::Volume ) { m_lastNoteVolume = vol; showVolTextFloat( vol, me->pos() ); } - else if( m_noteEditMode == NoteEditPanning ) + else if( m_noteEditMode == NoteEditMode::Panning ) { m_lastNotePanning = pan; showPanTextFloat( pan, me->pos() ); @@ -2533,7 +2533,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) ( isUnderPosition && n->selected() && altPressed ) ) { - if( m_noteEditMode == NoteEditVolume ) + if( m_noteEditMode == NoteEditMode::Volume ) { n->setVolume( vol ); @@ -2541,7 +2541,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) m_midiClip->instrumentTrack()->processInEvent( MidiEvent( MidiKeyPressure, -1, n->key(), n->midiVelocity( baseVelocity ) ) ); } - else if( m_noteEditMode == NoteEditPanning ) + else if( m_noteEditMode == NoteEditMode::Panning ) { n->setPanning( pan ); MidiEvent evt( MidiMetaEvent, -1, n->key(), panningToMidi( pan ) ); @@ -2566,7 +2566,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) m_midiClip->dataChanged(); } - else if( me->buttons() == Qt::NoButton && m_editMode == ModeDraw ) + else if( me->buttons() == Qt::NoButton && m_editMode == EditMode::Draw ) { // set move- or resize-cursor @@ -2619,8 +2619,8 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) } } else if( me->buttons() & Qt::LeftButton && - m_editMode == ModeSelect && - m_action == ActionSelectNotes ) + m_editMode == EditMode::Select && + m_action == Action::SelectNotes ) { // change size of selection @@ -2640,8 +2640,8 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) --m_selectedKeys; } } - else if( ( m_editMode == ModeDraw && me->buttons() & Qt::RightButton ) - || ( m_editMode == ModeErase && me->buttons() ) ) + else if( ( m_editMode == EditMode::Draw && me->buttons() & Qt::RightButton ) + || ( m_editMode == EditMode::Erase && me->buttons() ) ) { // holding down right-click to delete notes or holding down // any key if in erase mode @@ -2693,7 +2693,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) } } } - else if (me->buttons() == Qt::NoButton && m_editMode != ModeDraw && m_editMode != ModeEditKnife) + else if (me->buttons() == Qt::NoButton && m_editMode != EditMode::Draw && m_editMode != EditMode::Knife) { // Is needed to restore cursor when it previously was set to // Qt::SizeVerCursor (between keyAreaBottom and noteEditTop) @@ -2703,8 +2703,8 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me ) else { if( me->buttons() & Qt::LeftButton && - m_editMode == ModeSelect && - m_action == ActionSelectNotes ) + m_editMode == EditMode::Select && + m_action == Action::SelectNotes ) { int x = me->x() - m_whiteKeyWidth; @@ -2823,11 +2823,11 @@ void PianoRoll::dragNotes(int x, int y, bool alt, bool shift, bool ctrl) // get note-vector of current MIDI clip const NoteVector & notes = m_midiClip->notes(); - if (m_action == ActionMoveNote) + if (m_action == Action::MoveNote) { // Calculate the offset for either Nudge or Snap modes int noteOffset = off_ticks; - if (m_gridMode == gridSnap && quantization () > 1) + if (m_gridMode == GridMode::Snap && quantization () > 1) { // Get the mouse timeline absolute position TimePos mousePos(m_currentNote->oldPos().getTicks() + off_ticks); @@ -2849,7 +2849,7 @@ void PianoRoll::dragNotes(int x, int y, bool alt, bool shift, bool ctrl) ? mousePosEndQ.getTicks() - m_currentNote->oldPos().getTicks() - m_currentNote->oldLength().getTicks() : mousePosQ.getTicks() - m_currentNote->oldPos().getTicks(); } - else if (m_gridMode == gridNudge) + else if (m_gridMode == GridMode::Nudge) { // if they're not holding alt, quantize the offset if (!alt) @@ -2877,7 +2877,7 @@ void PianoRoll::dragNotes(int x, int y, bool alt, bool shift, bool ctrl) { // Quick resize is only enabled on Nudge mode, since resizing the note // while in Snap mode breaks the calculation of the note offset - if (shift && ! m_startedWithShift && m_gridMode == gridNudge) + if (shift && ! m_startedWithShift && m_gridMode == GridMode::Nudge) { // quick resize, toggled by holding shift after starting a note move, but not before int ticks_new = note->oldLength().getTicks() + noteOffset; @@ -2901,7 +2901,7 @@ void PianoRoll::dragNotes(int x, int y, bool alt, bool shift, bool ctrl) } } } - else if (m_action == ActionResizeNote) + else if (m_action == Action::ResizeNote) { // When resizing notes: // If shift is not pressed, resize the selected notes but do not rearrange them @@ -3002,7 +3002,7 @@ void PianoRoll::dragNotes(int x, int y, bool alt, bool shift, bool ctrl) // shift is not pressed; stretch length of selected notes but not their position int minLength = alt ? 1 : m_minResizeLen.getTicks(); - if (m_gridMode == gridSnap) + if (m_gridMode == GridMode::Snap) { // Calculate the end point of the note being dragged TimePos oldEndPoint = m_currentNote->oldPos() + m_currentNote->oldLength(); @@ -3099,7 +3099,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) topKey = qBound(0, m_startKey + m_pianoKeysVisible - 1, NumKeys - 1); topNote = topKey % KeysPerOctave; // if not resizing the note edit area, we can change m_notesEditHeight - if (m_action != ActionResizeNoteEditArea && partialKeyVisible != 0) + if (m_action != Action::ResizeNoteEditArea && partialKeyVisible != 0) { // calculate the height change adding and subtracting the partial key int noteAreaPlus = (m_notesEditHeight + partialKeyVisible) - m_userSetNotesEditHeight; @@ -3153,11 +3153,11 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) { switch (prKeyOrder[key % KeysPerOctave]) { - case PR_WHITE_KEY_BIG: + case KeyType::WhiteBig: return m_whiteKeyBigHeight; - case PR_WHITE_KEY_SMALL: + case KeyType::WhiteSmall: return m_whiteKeySmallHeight; - case PR_BLACK_KEY: + case KeyType::Black: return m_blackKeyHeight; } return 0; // should never happen @@ -3170,15 +3170,15 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) const int keyCode = key % KeysPerOctave; switch (prKeyOrder[keyCode]) { - case PR_WHITE_KEY_BIG: + case KeyType::WhiteBig: return m_whiteKeySmallHeight; - case PR_WHITE_KEY_SMALL: + case KeyType::WhiteSmall: // These two keys need to adjust up small height instead of only key line height - if (keyCode == Key_C || keyCode == Key_F) + if (static_cast(keyCode) == Key::C || static_cast(keyCode) == Key::F) { return m_whiteKeySmallHeight; } - case PR_BLACK_KEY: + case KeyType::Black: return m_blackKeyHeight; } return 0; // should never happen @@ -3189,10 +3189,10 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) { switch (prKeyOrder[key % KeysPerOctave]) { - case PR_WHITE_KEY_SMALL: - case PR_WHITE_KEY_BIG: + case KeyType::WhiteSmall: + case KeyType::WhiteBig: return m_whiteKeyWidth; - case PR_BLACK_KEY: + case KeyType::Black: return m_blackKeyWidth; } return 0; // should never happen @@ -3212,8 +3212,8 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) p.setPen(QColor(0, 0, 0)); switch (prKeyOrder[keyCode]) { - case PR_WHITE_KEY_SMALL: - case PR_WHITE_KEY_BIG: + case KeyType::WhiteSmall: + case KeyType::WhiteBig: if (mapped) { if (pressed) { p.setBrush(m_whiteKeyActiveBackground); } @@ -3224,7 +3224,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) p.setBrush(m_whiteKeyDisabledBackground); } break; - case PR_BLACK_KEY: + case KeyType::Black: if (mapped) { if (pressed) { p.setBrush(m_blackKeyActiveBackground); } @@ -3238,7 +3238,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) // draw key p.drawRect(PIANO_X, yt, kw, kh); // draw note name - if (keyCode == Key_C || (drawNoteNames && Piano::isWhiteKey(key))) + if (static_cast(keyCode) == Key::C || (drawNoteNames && Piano::isWhiteKey(key))) { // small font sizes have 1 pixel offset instead of 2 auto zoomOffset = m_zoomYLevels[m_zoomingYModel.value()] > 1.0f ? 2 : 1; @@ -3252,7 +3252,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) p.setPen(pressed ? m_whiteKeyActiveTextShadow : m_whiteKeyInactiveTextShadow); p.drawText(textRect.adjusted(0, 1, 1, 0), Qt::AlignRight | Qt::AlignHCenter, noteString); p.setPen(pressed ? m_whiteKeyActiveTextColor : m_whiteKeyInactiveTextColor); - // if (keyCode == Key_C) { p.setPen(textColor()); } + // if (static_cast(keyCode) == Key::C) { p.setPen(textColor()); } // else { p.setPen(textColorLight()); } p.drawText(textRect, Qt::AlignRight | Qt::AlignHCenter, noteString); } @@ -3263,17 +3263,17 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) const int y ) { - if (key % KeysPerOctave == Key_C) { p.setPen(m_beatLineColor); } + if (static_cast(key % KeysPerOctave) == Key::C) { p.setPen(m_beatLineColor); } else { p.setPen(m_lineColor); } p.drawLine(m_whiteKeyWidth, y, width(), y); }; // correct y offset of the top key switch (prKeyOrder[topNote]) { - case PR_WHITE_KEY_SMALL: - case PR_WHITE_KEY_BIG: + case KeyType::WhiteSmall: + case KeyType::WhiteBig: break; - case PR_BLACK_KEY: + case KeyType::Black: // draw extra white key drawKey(topKey + 1, grid_line_y - m_keyLineHeight); } @@ -3381,7 +3381,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) p.drawText( QRect( 0, keyAreaBottom(), m_whiteKeyWidth, noteEditBottom() - keyAreaBottom()), Qt::AlignCenter | Qt::TextWordWrap, - m_nemStr.at( m_noteEditMode ) + ":" ); + m_nemStr.at(static_cast(m_noteEditMode)) + ":" ); // set clipping area, because we are not allowed to paint over // keyboard... @@ -3507,7 +3507,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) // draw note editing stuff int editHandleTop = 0; - if( m_noteEditMode == NoteEditVolume ) + if( m_noteEditMode == NoteEditMode::Volume ) { QColor color = m_barColor.lighter(30 + (note->getVolume() * 90 / MaxVolume)); if( note->selected() ) @@ -3525,7 +3525,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) noteEditLeft() + x + 0.5, noteEditBottom() + 0.5 ) ); } - else if( m_noteEditMode == NoteEditPanning ) + else if( m_noteEditMode == NoteEditMode::Panning ) { QColor color = m_noteColor; if( note->selected() ) @@ -3559,7 +3559,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) } // -- Knife tool (draw cut line) - if (m_action == ActionKnife) + if (m_action == Action::Knife) { auto xCoordOfTick = [this](int tick) { return m_whiteKeyWidth + ( @@ -3696,12 +3696,12 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) // draw current edit-mode-icon below the cursor switch( m_editMode ) { - case ModeDraw: + case EditMode::Draw: if( m_mouseDownRight ) { cursor = s_toolErase; } - else if( m_action == ActionMoveNote ) + else if( m_action == Action::MoveNote ) { cursor = s_toolMove; } @@ -3710,10 +3710,10 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) cursor = s_toolDraw; } break; - case ModeErase: cursor = s_toolErase; break; - case ModeSelect: cursor = s_toolSelect; break; - case ModeEditDetuning: cursor = s_toolOpen; break; - case ModeEditKnife: cursor = s_toolKnife; break; + case EditMode::Erase: cursor = s_toolErase; break; + case EditMode::Select: cursor = s_toolSelect; break; + case EditMode::Detuning: cursor = s_toolOpen; break; + case EditMode::Knife: cursor = s_toolKnife; break; } QPoint mousePosition = mapFromGlobal( QCursor::pos() ); if( cursor != nullptr && mousePosition.y() > keyAreaTop() && mousePosition.x() > noteEditLeft()) @@ -3756,7 +3756,7 @@ void PianoRoll::resizeEvent(QResizeEvent* re) { updatePositionLineHeight(); updateScrollbars(); - Engine::getSong()->getPlayPos(Song::Mode_PlayMidiClip) + Engine::getSong()->getPlayPos(Song::PlayMode::MidiClip) .m_timeLine->setFixedWidth(width()); update(); } @@ -3794,7 +3794,7 @@ void PianoRoll::wheelEvent(QWheelEvent * we ) if( nv.size() > 0 ) { const int step = we->angleDelta().y() > 0 ? 1 : -1; - if( m_noteEditMode == NoteEditVolume ) + if( m_noteEditMode == NoteEditMode::Volume ) { for ( Note * n : nv ) { @@ -3813,7 +3813,7 @@ void PianoRoll::wheelEvent(QWheelEvent * we ) showVolTextFloat(nv[0]->getVolume(), position(we), 1000); } } - else if( m_noteEditMode == NoteEditPanning ) + else if( m_noteEditMode == NoteEditMode::Panning ) { for ( Note * n : nv ) { @@ -3921,9 +3921,9 @@ void PianoRoll::focusOutEvent( QFocusEvent * ) m_midiClip->instrumentTrack()->pianoModel()->setKeyState( i, false ); } } - if (m_editMode == ModeEditKnife) { + if (m_editMode == EditMode::Knife) { m_editMode = m_knifeMode; - m_action = ActionNone; + m_action = Action::None; } else { m_editMode = m_ctrlMode; } @@ -3968,13 +3968,13 @@ QList PianoRoll::getAllOctavesForKey( int keyToMirror ) const return keys; } -Song::PlayModes PianoRoll::desiredPlayModeForAccompany() const +Song::PlayMode PianoRoll::desiredPlayModeForAccompany() const { if (m_midiClip->getTrack()->trackContainer() == Engine::patternStore()) { - return Song::Mode_PlayPattern; + return Song::PlayMode::Pattern; } - return Song::Mode_PlaySong; + return Song::PlayMode::Song; } @@ -3987,7 +3987,7 @@ void PianoRoll::play() return; } - if( Engine::getSong()->playMode() != Song::Mode_PlayMidiClip ) + if( Engine::getSong()->playMode() != Song::PlayMode::MidiClip ) { Engine::getSong()->playMidiClip( m_midiClip ); } @@ -4065,7 +4065,7 @@ bool PianoRoll::toggleStepRecording() { m_stepRecorder.start( Engine::getSong()->getPlayPos( - Song::Mode_PlayMidiClip), newNoteLen()); + Song::PlayMode::MidiClip), newNoteLen()); } } } @@ -4080,7 +4080,7 @@ void PianoRoll::stop() { Engine::getSong()->stop(); m_recording = false; - m_scrollBack = ( m_timeLine->autoScroll() == TimeLineWidget::AutoScrollEnabled ); + m_scrollBack = ( m_timeLine->autoScroll() == TimeLineWidget::AutoScrollState::Enabled ); } @@ -4093,10 +4093,10 @@ void PianoRoll::startRecordNote(const Note & n ) if( m_recording && Engine::getSong()->isPlaying() && (Engine::getSong()->playMode() == desiredPlayModeForAccompany() || - Engine::getSong()->playMode() == Song::Mode_PlayMidiClip )) + Engine::getSong()->playMode() == Song::PlayMode::MidiClip )) { TimePos sub; - if( Engine::getSong()->playMode() == Song::Mode_PlaySong ) + if( Engine::getSong()->playMode() == Song::PlayMode::Song ) { sub = m_midiClip->startPosition(); } @@ -4127,7 +4127,7 @@ void PianoRoll::finishRecordNote(const Note & n ) ( Engine::getSong()->playMode() == desiredPlayModeForAccompany() || Engine::getSong()->playMode() == - Song::Mode_PlayMidiClip ) ) + Song::PlayMode::MidiClip ) ) { for( QList::Iterator it = m_recordingNotes.begin(); it != m_recordingNotes.end(); ++it ) @@ -4179,7 +4179,7 @@ void PianoRoll::verScrolled( int new_pos ) void PianoRoll::setEditMode(int mode) { - m_ctrlMode = m_editMode = (EditModes) mode; + m_ctrlMode = m_editMode = (EditMode) mode; } @@ -4271,7 +4271,7 @@ void PianoRoll::selectNotesOnKey() void PianoRoll::enterValue( NoteVector* nv ) { - if( m_noteEditMode == NoteEditVolume ) + if( m_noteEditMode == NoteEditMode::Volume ) { bool ok; int new_val; @@ -4290,7 +4290,7 @@ void PianoRoll::enterValue( NoteVector* nv ) m_lastNoteVolume = new_val; } } - else if( m_noteEditMode == NoteEditPanning ) + else if( m_noteEditMode == NoteEditMode::Panning ) { bool ok; int new_val; @@ -4338,7 +4338,7 @@ void PianoRoll::copyToClipboard( const NoteVector & notes ) const // For copyString() and MimeType enum class using namespace Clipboard; - DataFile dataFile( DataFile::ClipboardData ); + DataFile dataFile( DataFile::Type::ClipboardData ); QDomElement note_list = dataFile.createElement( "note-list" ); dataFile.content().appendChild( note_list ); @@ -4495,8 +4495,8 @@ void PianoRoll::autoScroll( const TimePos & t ) void PianoRoll::updatePosition( const TimePos & t ) { if( ( Engine::getSong()->isPlaying() - && Engine::getSong()->playMode() == Song::Mode_PlayMidiClip - && m_timeLine->autoScroll() == TimeLineWidget::AutoScrollEnabled + && Engine::getSong()->playMode() == Song::PlayMode::MidiClip + && m_timeLine->autoScroll() == TimeLineWidget::AutoScrollState::Enabled ) || m_scrollBack ) { autoScroll( t ); @@ -4532,16 +4532,16 @@ void PianoRoll::updatePositionAccompany( const TimePos & t ) Song * s = Engine::getSong(); if( m_recording && hasValidMidiClip() && - s->playMode() != Song::Mode_PlayMidiClip ) + s->playMode() != Song::PlayMode::MidiClip ) { TimePos pos = t; - if (s->playMode() != Song::Mode_PlayPattern) + if (s->playMode() != Song::PlayMode::Pattern) { pos -= m_midiClip->startPosition(); } if( (int) pos > 0 ) { - s->getPlayPos( Song::Mode_PlayMidiClip ).setTicks( pos ); + s->getPlayPos( Song::PlayMode::MidiClip ).setTicks( pos ); autoScroll( pos ); } } @@ -4596,7 +4596,7 @@ void PianoRoll::noteLengthChanged() void PianoRoll::keyChanged() { - markSemiTone(stmaMarkCurrentScale, false); + markSemiTone(SemiToneMarkerAction::MarkCurrentScale, false); } int PianoRoll::quantization() const @@ -4617,7 +4617,7 @@ int PianoRoll::quantization() const } -void PianoRoll::quantizeNotes(QuantizeActions mode) +void PianoRoll::quantizeNotes(QuantizeAction mode) { if( ! hasValidMidiClip() ) { @@ -4645,11 +4645,11 @@ void PianoRoll::quantizeNotes(QuantizeActions mode) Note copy(*n); m_midiClip->removeNote( n ); - if (mode == QuantizeBoth || mode == QuantizePos) + if (mode == QuantizeAction::Both || mode == QuantizeAction::Pos) { copy.quantizePos(quantization()); } - if (mode == QuantizeBoth || mode == QuantizeLength) + if (mode == QuantizeAction::Both || mode == QuantizeAction::Length) { copy.quantizeLength(quantization()); } @@ -4737,9 +4737,9 @@ Note * PianoRoll::noteUnderMouse() void PianoRoll::changeSnapMode() { - // gridNudge, - // gridSnap, - // gridFree - to be implemented + // GridMode::Nudge, + // GridMode::Snap, + // GridMode::Free - to be implemented m_gridMode = static_cast(m_snapModel.value()); } @@ -4783,8 +4783,8 @@ PianoRollWindow::PianoRollWindow() : auto quantizeLengthAction = new QAction(tr("Quantize lengths"), this); connect(quantizeAction, &QAction::triggered, [this](){ m_editor->quantizeNotes(); }); - connect(quantizePosAction, &QAction::triggered, [this](){ m_editor->quantizeNotes(PianoRoll::QuantizePos); }); - connect(quantizeLengthAction, &QAction::triggered, [this](){ m_editor->quantizeNotes(PianoRoll::QuantizeLength); }); + connect(quantizePosAction, &QAction::triggered, [this](){ m_editor->quantizeNotes(PianoRoll::QuantizeAction::Pos); }); + connect(quantizeLengthAction, &QAction::triggered, [this](){ m_editor->quantizeNotes(PianoRoll::QuantizeAction::Length); }); quantizeButton->setPopupMode(QToolButton::MenuButtonPopup); quantizeButton->setDefaultAction(quantizeAction); @@ -5189,7 +5189,7 @@ void PianoRollWindow::saveSettings( QDomDocument & doc, QDomElement & de ) de.appendChild(markedSemiTonesRoot); } - de.setAttribute("stopbehaviour", m_editor->m_timeLine->behaviourAtStop()); + de.setAttribute("stopbehaviour", static_cast(m_editor->m_timeLine->behaviourAtStop())); MainWindow::saveWidgetState( this, de ); } @@ -5281,7 +5281,7 @@ void PianoRollWindow::exportMidiClip() exportDialog.setDefaultSuffix(suffix); const QString fullPath = exportDialog.selectedFiles()[0]; - DataFile dataFile(DataFile::MidiClip); + DataFile dataFile(DataFile::Type::MidiClip); m_editor->m_midiClip->saveSettings(dataFile, dataFile.content()); if (dataFile.writeFile(fullPath)) diff --git a/src/gui/editors/PositionLine.cpp b/src/gui/editors/PositionLine.cpp index 7dd8b3b13a7..8b938443d41 100644 --- a/src/gui/editors/PositionLine.cpp +++ b/src/gui/editors/PositionLine.cpp @@ -64,8 +64,8 @@ void PositionLine::paintEvent(QPaintEvent* pe) // If gradient is enabled, we're in focus and we're playing, enable gradient if (m_hasTailGradient && Engine::getSong()->isPlaying() && - (Engine::getSong()->playMode() == Song::Mode_PlaySong || - Engine::getSong()->playMode() == Song::Mode_PlayMidiClip)) + (Engine::getSong()->playMode() == Song::PlayMode::Song || + Engine::getSong()->playMode() == Song::PlayMode::MidiClip)) { c.setAlpha(60); gradient.setColorAt(w, c); diff --git a/src/gui/editors/SongEditor.cpp b/src/gui/editors/SongEditor.cpp index 939c1fdf4a2..5180687596e 100644 --- a/src/gui/editors/SongEditor.cpp +++ b/src/gui/editors/SongEditor.cpp @@ -82,7 +82,7 @@ SongEditor::SongEditor( Song * song ) : m_proportionalSnap( false ), m_scrollBack( false ), m_smoothScroll( ConfigManager::inst()->value( "ui", "smoothscroll" ).toInt() ), - m_mode(DrawMode), + m_mode(EditMode::Draw), m_origin(), m_scrollPos(), m_mousePos(), @@ -99,11 +99,11 @@ SongEditor::SongEditor( Song * song ) : m_timeLine = new TimeLineWidget( m_trackHeadWidth, 32, pixelsPerBar(), - m_song->m_playPos[Song::Mode_PlaySong], + m_song->getPlayPos(Song::PlayMode::Song), m_currentPosition, - Song::Mode_PlaySong, this ); + Song::PlayMode::Song, this ); connect( this, SIGNAL( positionChanged( const lmms::TimePos& ) ), - m_song->m_playPos[Song::Mode_PlaySong].m_timeLine, + m_song->getPlayPos(Song::PlayMode::Song).m_timeLine, SLOT( updatePosition( const lmms::TimePos& ) ) ); connect( m_timeLine, SIGNAL( positionChanged( const lmms::TimePos& ) ), this, SLOT( updatePosition( const lmms::TimePos& ) ) ); @@ -341,8 +341,8 @@ QString SongEditor::getSnapSizeString() const void SongEditor::setHighQuality( bool hq ) { Engine::audioEngine()->changeQuality( AudioEngine::qualitySettings( - hq ? AudioEngine::qualitySettings::Mode_HighQuality : - AudioEngine::qualitySettings::Mode_Draft ) ); + hq ? AudioEngine::qualitySettings::Mode::HighQuality : + AudioEngine::qualitySettings::Mode::Draft ) ); } @@ -456,17 +456,17 @@ void SongEditor::setEditMode( EditMode mode ) void SongEditor::setEditModeDraw() { - setEditMode(DrawMode); + setEditMode(EditMode::Draw); } void SongEditor::setEditModeKnife() { - setEditMode(KnifeMode); + setEditMode(EditMode::Knife); } void SongEditor::setEditModeSelect() { - setEditMode(SelectMode); + setEditMode(EditMode::Select); } void SongEditor::toggleProportionalSnap() @@ -496,7 +496,7 @@ void SongEditor::keyPressEvent( QKeyEvent * ke ) tick_t t = m_song->currentTick() - TimePos::ticksPerBar(); if( t >= 0 ) { - m_song->setPlayPos( t, Song::Mode_PlaySong ); + m_song->setPlayPos( t, Song::PlayMode::Song ); } } else if( ke->key() == Qt::Key_Right ) @@ -504,12 +504,12 @@ void SongEditor::keyPressEvent( QKeyEvent * ke ) tick_t t = m_song->currentTick() + TimePos::ticksPerBar(); if( t < MaxSongLength ) { - m_song->setPlayPos( t, Song::Mode_PlaySong ); + m_song->setPlayPos( t, Song::PlayMode::Song ); } } else if( ke->key() == Qt::Key_Home ) { - m_song->setPlayPos( 0, Song::Mode_PlaySong ); + m_song->setPlayPos( 0, Song::PlayMode::Song ); } else if( ke->key() == Qt::Key_Delete || ke->key() == Qt::Key_Backspace ) { @@ -560,7 +560,7 @@ void SongEditor::wheelEvent( QWheelEvent * we ) m_leftRightScroll->setValue(m_leftRightScroll->value() + bar - newBar); // update timeline - m_song->m_playPos[Song::Mode_PlaySong].m_timeLine->setPixelsPerBar(pixelsPerBar()); + m_song->getPlayPos(Song::PlayMode::Song).m_timeLine->setPixelsPerBar(pixelsPerBar()); // and make sure, all Clip's are resized and relocated realignTracks(); } @@ -788,8 +788,8 @@ void SongEditor::updatePosition( const TimePos & t ) trackOpWidth = TRACK_OP_WIDTH; } - if( ( m_song->isPlaying() && m_song->m_playMode == Song::Mode_PlaySong - && m_timeLine->autoScroll() == TimeLineWidget::AutoScrollEnabled) || + if( ( m_song->isPlaying() && m_song->m_playMode == Song::PlayMode::Song + && m_timeLine->autoScroll() == TimeLineWidget::AutoScrollState::Enabled) || m_scrollBack == true ) { m_smoothScroll = ConfigManager::inst()->value( "ui", "smoothscroll" ).toInt(); @@ -808,7 +808,7 @@ void SongEditor::updatePosition( const TimePos & t ) m_scrollBack = false; } - const int x = m_song->m_playPos[Song::Mode_PlaySong].m_timeLine-> + const int x = m_song->getPlayPos(Song::PlayMode::Song).m_timeLine-> markerX( t ) + 8; if( x >= trackOpWidth + widgetWidth -1 ) { @@ -872,7 +872,7 @@ void SongEditor::zoomingChanged() int ppb = calculatePixelsPerBar(); setPixelsPerBar(ppb); - m_song->m_playPos[Song::Mode_PlaySong].m_timeLine->setPixelsPerBar(ppb); + m_song->getPlayPos(Song::PlayMode::Song).m_timeLine->setPixelsPerBar(ppb); realignTracks(); updateRubberband(); m_timeLine->setSnapSize(getSnapSize()); @@ -895,7 +895,7 @@ void SongEditor::selectAllClips( bool select ) bool SongEditor::allowRubberband() const { - return m_mode == SelectMode; + return m_mode == EditMode::Select; } @@ -903,7 +903,7 @@ bool SongEditor::allowRubberband() const bool SongEditor::knifeMode() const { - return m_mode == KnifeMode; + return m_mode == EditMode::Knife; } @@ -1104,7 +1104,7 @@ void SongEditorWindow::changeEvent(QEvent *event) void SongEditorWindow::play() { emit playTriggered(); - if( Engine::getSong()->playMode() != Song::Mode_PlaySong ) + if( Engine::getSong()->playMode() != Song::PlayMode::Song ) { Engine::getSong()->playSong(); } diff --git a/src/gui/editors/TimeLineWidget.cpp b/src/gui/editors/TimeLineWidget.cpp index b051fa79b69..423485a2589 100644 --- a/src/gui/editors/TimeLineWidget.cpp +++ b/src/gui/editors/TimeLineWidget.cpp @@ -49,7 +49,7 @@ namespace QPixmap * TimeLineWidget::s_posMarkerPixmap = nullptr; TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppb, - Song::PlayPos & pos, const TimePos & begin, Song::PlayModes mode, + Song::PlayPos & pos, const TimePos & begin, Song::PlayMode mode, QWidget * parent ) : QWidget( parent ), m_inactiveLoopColor( 52, 63, 53, 64 ), @@ -61,9 +61,9 @@ TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppb, m_loopRectangleVerticalPadding( 1 ), m_barLineColor( 192, 192, 192 ), m_barNumberColor( m_barLineColor.darker( 120 ) ), - m_autoScroll( AutoScrollEnabled ), - m_loopPoints( LoopPointsDisabled ), - m_behaviourAtStop( BackToZero ), + m_autoScroll( AutoScrollState::Enabled ), + m_loopPoints( LoopPointState::Disabled ), + m_behaviourAtStop( BehaviourAtStopState::BackToZero ), m_changedPosition( true ), m_xOffset( xoff ), m_posMarkerX( 0 ), @@ -74,7 +74,7 @@ TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppb, m_mode( mode ), m_savedPos( -1 ), m_hint( nullptr ), - m_action( NoAction ), + m_action( Action::NoAction ), m_moveXOff( 0 ) { m_loopPos[0] = 0; @@ -157,7 +157,7 @@ void TimeLineWidget::addToolButtons( QToolBar * _tool_bar ) SLOT(toggleBehaviourAtStop(int))); connect( this, SIGNAL(loadBehaviourAtStop(int)), behaviourAtStop, SLOT(changeState(int))); - behaviourAtStop->changeState( BackToStart ); + behaviourAtStop->changeState( static_cast(BehaviourAtStopState::BackToStart) ); _tool_bar->addWidget( autoScroll ); _tool_bar->addWidget( loopPoints ); @@ -171,8 +171,8 @@ void TimeLineWidget::saveSettings( QDomDocument & _doc, QDomElement & _this ) { _this.setAttribute( "lp0pos", (int) loopBegin() ); _this.setAttribute( "lp1pos", (int) loopEnd() ); - _this.setAttribute( "lpstate", m_loopPoints ); - _this.setAttribute( "stopbehaviour", m_behaviourAtStop ); + _this.setAttribute( "lpstate", static_cast(m_loopPoints) ); + _this.setAttribute( "stopbehaviour", static_cast(m_behaviourAtStop) ); } @@ -182,10 +182,10 @@ void TimeLineWidget::loadSettings( const QDomElement & _this ) { m_loopPos[0] = _this.attribute( "lp0pos" ).toInt(); m_loopPos[1] = _this.attribute( "lp1pos" ).toInt(); - m_loopPoints = static_cast( + m_loopPoints = static_cast( _this.attribute( "lpstate" ).toInt() ); update(); - emit loopPointStateLoaded( m_loopPoints ); + emit loopPointStateLoaded( static_cast(m_loopPoints) ); if( _this.hasAttribute( "stopbehaviour" ) ) { @@ -214,7 +214,7 @@ void TimeLineWidget::updatePosition( const TimePos & ) void TimeLineWidget::toggleAutoScroll( int _n ) { - m_autoScroll = static_cast( _n ); + m_autoScroll = static_cast( _n ); } @@ -222,7 +222,7 @@ void TimeLineWidget::toggleAutoScroll( int _n ) void TimeLineWidget::toggleLoopPoints( int _n ) { - m_loopPoints = static_cast( _n ); + m_loopPoints = static_cast( _n ); update(); } @@ -231,7 +231,7 @@ void TimeLineWidget::toggleLoopPoints( int _n ) void TimeLineWidget::toggleBehaviourAtStop( int _n ) { - m_behaviourAtStop = static_cast( _n ); + m_behaviourAtStop = static_cast( _n ); } @@ -327,7 +327,7 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event ) } if( event->button() == Qt::LeftButton && !(event->modifiers() & Qt::ShiftModifier) ) { - m_action = MovePositionMarker; + m_action = Action::MovePositionMarker; if( event->x() - m_xOffset < s_posMarkerPixmap->width() ) { m_moveXOff = event->x() - m_xOffset; @@ -339,7 +339,7 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event ) } else if( event->button() == Qt::LeftButton && (event->modifiers() & Qt::ShiftModifier) ) { - m_action = SelectSongClip; + m_action = Action::SelectSongClip; m_initalXSelect = event->x(); } else if( event->button() == Qt::RightButton ) @@ -348,12 +348,12 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event ) const TimePos t = m_begin + static_cast( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * TimePos::ticksPerBar() / m_ppb ); const TimePos loopMid = ( m_loopPos[0] + m_loopPos[1] ) / 2; - m_action = t < loopMid ? MoveLoopBegin : MoveLoopEnd; + m_action = t < loopMid ? Action::MoveLoopBegin : Action::MoveLoopEnd; std::sort(std::begin(m_loopPos), std::end(m_loopPos)); - m_loopPos[( m_action == MoveLoopBegin ) ? 0 : 1] = t; + m_loopPos[( m_action == Action::MoveLoopBegin ) ? 0 : 1] = t; } - if( m_action == MoveLoopBegin || m_action == MoveLoopEnd ) + if( m_action == Action::MoveLoopBegin || m_action == Action::MoveLoopEnd ) { delete m_hint; m_hint = TextFloat::displayMessage( tr( "Hint" ), @@ -373,13 +373,13 @@ void TimeLineWidget::mouseMoveEvent( QMouseEvent* event ) switch( m_action ) { - case MovePositionMarker: + case Action::MovePositionMarker: m_pos.setTicks(t.getTicks()); Engine::getSong()->setToTime(t, m_mode); if (!( Engine::getSong()->isPlaying())) { - //Song::Mode_None is used when nothing is being played. - Engine::getSong()->setToTime(t, Song::Mode_None); + //Song::PlayMode::None is used when nothing is being played. + Engine::getSong()->setToTime(t, Song::PlayMode::None); } m_pos.setCurrentFrame( 0 ); m_pos.setJumped( true ); @@ -387,10 +387,10 @@ void TimeLineWidget::mouseMoveEvent( QMouseEvent* event ) positionMarkerMoved(); break; - case MoveLoopBegin: - case MoveLoopEnd: + case Action::MoveLoopBegin: + case Action::MoveLoopEnd: { - const int i = m_action - MoveLoopBegin; // i == 0 || i == 1 + const int i = m_action == Action::MoveLoopBegin ? 0 : 1; const bool control = event->modifiers() & Qt::ControlModifier; if (control) { @@ -409,13 +409,13 @@ void TimeLineWidget::mouseMoveEvent( QMouseEvent* event ) const int offset = control ? 1 : m_snapSize * TimePos::ticksPerBar(); // Note, swap 1 and 0 below and the behavior "skips" the other // marking instead of pushing it. - if (m_action == MoveLoopBegin) { m_loopPos[0] -= offset; } + if (m_action == Action::MoveLoopBegin) { m_loopPos[0] -= offset; } else { m_loopPos[1] += offset; } } update(); break; } - case SelectSongClip: + case Action::SelectSongClip: emit regionSelectedFromPixels( m_initalXSelect , event->x() ); break; @@ -431,8 +431,8 @@ void TimeLineWidget::mouseReleaseEvent( QMouseEvent* event ) { delete m_hint; m_hint = nullptr; - if ( m_action == SelectSongClip ) { emit selectionFinished(); } - m_action = NoAction; + if ( m_action == Action::SelectSongClip ) { emit selectionFinished(); } + m_action = Action::NoAction; } diff --git a/src/gui/editors/TrackContainerView.cpp b/src/gui/editors/TrackContainerView.cpp index 83017fb1ae7..60a46838041 100644 --- a/src/gui/editors/TrackContainerView.cpp +++ b/src/gui/editors/TrackContainerView.cpp @@ -372,8 +372,8 @@ void TrackContainerView::dragEnterEvent( QDragEnterEvent * _dee ) QString( "presetfile,pluginpresetfile,samplefile,instrument," "importedproject,soundfontfile,patchfile,vstpluginfile,projectfile," "track_%1,track_%2" ). - arg( Track::InstrumentTrack ). - arg( Track::SampleTrack ) ); + arg( static_cast(Track::Type::Instrument) ). + arg( static_cast(Track::Type::Sample) ) ); } @@ -394,7 +394,7 @@ void TrackContainerView::dropEvent( QDropEvent * _de ) QString value = StringPairDrag::decodeValue( _de ); if( type == "instrument" ) { - auto it = dynamic_cast(Track::create(Track::InstrumentTrack, m_tc)); + auto it = dynamic_cast(Track::create(Track::Type::Instrument, m_tc)); auto ilt = new InstrumentLoaderThread(this, it, value); ilt->start(); //it->toggledInstrumentTrackButton( true ); @@ -404,7 +404,7 @@ void TrackContainerView::dropEvent( QDropEvent * _de ) || type == "soundfontfile" || type == "vstpluginfile" || type == "patchfile" ) { - auto it = dynamic_cast(Track::create(Track::InstrumentTrack, m_tc)); + auto it = dynamic_cast(Track::create(Track::Type::Instrument, m_tc)); PluginFactory::PluginInfoAndKey piakn = getPluginFactory()->pluginSupportingExtension(FileItem::extension(value)); Instrument * i = it->loadInstrument(piakn.info.name(), &piakn.key); @@ -415,7 +415,7 @@ void TrackContainerView::dropEvent( QDropEvent * _de ) else if( type == "presetfile" ) { DataFile dataFile( value ); - auto it = dynamic_cast(Track::create(Track::InstrumentTrack, m_tc)); + auto it = dynamic_cast(Track::create(Track::Type::Instrument, m_tc)); it->setSimpleSerializing(); it->loadSettings( dataFile.content().toElement() ); //it->toggledInstrumentTrackButton( true ); diff --git a/src/gui/instrument/EnvelopeAndLfoView.cpp b/src/gui/instrument/EnvelopeAndLfoView.cpp index df0e1120df6..edb6c99c797 100644 --- a/src/gui/instrument/EnvelopeAndLfoView.cpp +++ b/src/gui/instrument/EnvelopeAndLfoView.cpp @@ -99,43 +99,43 @@ EnvelopeAndLfoView::EnvelopeAndLfoView( QWidget * _parent ) : s_lfoGraph = new QPixmap( embed::getIconPixmap( "lfo_graph" ) ); } - m_predelayKnob = new Knob( knobBright_26, this ); + m_predelayKnob = new Knob( KnobType::Bright26, this ); m_predelayKnob->setLabel( tr( "DEL" ) ); m_predelayKnob->move( PREDELAY_KNOB_X, ENV_KNOBS_Y ); m_predelayKnob->setHintText( tr( "Pre-delay:" ), "" ); - m_attackKnob = new Knob( knobBright_26, this ); + m_attackKnob = new Knob( KnobType::Bright26, this ); m_attackKnob->setLabel( tr( "ATT" ) ); m_attackKnob->move( ATTACK_KNOB_X, ENV_KNOBS_Y ); m_attackKnob->setHintText( tr( "Attack:" ), "" ); - m_holdKnob = new Knob( knobBright_26, this ); + m_holdKnob = new Knob( KnobType::Bright26, this ); m_holdKnob->setLabel( tr( "HOLD" ) ); m_holdKnob->move( HOLD_KNOB_X, ENV_KNOBS_Y ); m_holdKnob->setHintText( tr( "Hold:" ), "" ); - m_decayKnob = new Knob( knobBright_26, this ); + m_decayKnob = new Knob( KnobType::Bright26, this ); m_decayKnob->setLabel( tr( "DEC" ) ); m_decayKnob->move( DECAY_KNOB_X, ENV_KNOBS_Y ); m_decayKnob->setHintText( tr( "Decay:" ), "" ); - m_sustainKnob = new Knob( knobBright_26, this ); + m_sustainKnob = new Knob( KnobType::Bright26, this ); m_sustainKnob->setLabel( tr( "SUST" ) ); m_sustainKnob->move( SUSTAIN_KNOB_X, ENV_KNOBS_Y ); m_sustainKnob->setHintText( tr( "Sustain:" ), "" ); - m_releaseKnob = new Knob( knobBright_26, this ); + m_releaseKnob = new Knob( KnobType::Bright26, this ); m_releaseKnob->setLabel( tr( "REL" ) ); m_releaseKnob->move( RELEASE_KNOB_X, ENV_KNOBS_Y ); m_releaseKnob->setHintText( tr( "Release:" ), "" ); - m_amountKnob = new Knob( knobBright_26, this ); + m_amountKnob = new Knob( KnobType::Bright26, this ); m_amountKnob->setLabel( tr( "AMT" ) ); m_amountKnob->move( AMOUNT_KNOB_X, ENV_GRAPH_Y ); m_amountKnob->setHintText( tr( "Modulation amount:" ), "" ); @@ -143,25 +143,25 @@ EnvelopeAndLfoView::EnvelopeAndLfoView( QWidget * _parent ) : - m_lfoPredelayKnob = new Knob( knobBright_26, this ); + m_lfoPredelayKnob = new Knob( KnobType::Bright26, this ); m_lfoPredelayKnob->setLabel( tr( "DEL" ) ); m_lfoPredelayKnob->move( LFO_PREDELAY_KNOB_X, LFO_KNOB_Y ); m_lfoPredelayKnob->setHintText( tr( "Pre-delay:" ), "" ); - m_lfoAttackKnob = new Knob( knobBright_26, this ); + m_lfoAttackKnob = new Knob( KnobType::Bright26, this ); m_lfoAttackKnob->setLabel( tr( "ATT" ) ); m_lfoAttackKnob->move( LFO_ATTACK_KNOB_X, LFO_KNOB_Y ); m_lfoAttackKnob->setHintText( tr( "Attack:" ), "" ); - m_lfoSpeedKnob = new TempoSyncKnob( knobBright_26, this ); + m_lfoSpeedKnob = new TempoSyncKnob( KnobType::Bright26, this ); m_lfoSpeedKnob->setLabel( tr( "SPD" ) ); m_lfoSpeedKnob->move( LFO_SPEED_KNOB_X, LFO_KNOB_Y ); m_lfoSpeedKnob->setHintText( tr( "Frequency:" ), "" ); - m_lfoAmountKnob = new Knob( knobBright_26, this ); + m_lfoAmountKnob = new Knob( KnobType::Bright26, this ); m_lfoAmountKnob->setLabel( tr( "AMT" ) ); m_lfoAmountKnob->move( LFO_AMOUNT_KNOB_X, LFO_KNOB_Y ); m_lfoAmountKnob->setHintText( tr( "Modulation amount:" ), "" ); @@ -310,7 +310,7 @@ void EnvelopeAndLfoView::dragEnterEvent( QDragEnterEvent * _dee ) { StringPairDrag::processDragEnterEvent( _dee, QString( "samplefile,clip_%1" ).arg( - Track::SampleTrack ) ); + static_cast(Track::Type::Sample) ) ); } @@ -325,18 +325,18 @@ void EnvelopeAndLfoView::dropEvent( QDropEvent * _de ) m_params->m_userWave.setAudioFile( StringPairDrag::decodeValue( _de ) ); m_userLfoBtn->model()->setValue( true ); - m_params->m_lfoWaveModel.setValue(EnvelopeAndLfoParameters::UserDefinedWave); + m_params->m_lfoWaveModel.setValue(static_cast(EnvelopeAndLfoParameters::LfoShape::UserDefinedWave)); _de->accept(); update(); } - else if( type == QString( "clip_%1" ).arg( Track::SampleTrack ) ) + else if( type == QString( "clip_%1" ).arg( static_cast(Track::Type::Sample) ) ) { DataFile dataFile( value.toUtf8() ); m_params->m_userWave.setAudioFile( dataFile.content(). firstChildElement().firstChildElement(). firstChildElement().attribute( "src" ) ); m_userLfoBtn->model()->setValue( true ); - m_params->m_lfoWaveModel.setValue(EnvelopeAndLfoParameters::UserDefinedWave); + m_params->m_lfoWaveModel.setValue(static_cast(EnvelopeAndLfoParameters::LfoShape::UserDefinedWave)); _de->accept(); update(); } @@ -459,29 +459,30 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) float phase = ( cur_sample -= m_params->m_lfoPredelayFrames ) / osc_frames; - switch( m_params->m_lfoWaveModel.value() ) + switch( static_cast(m_params->m_lfoWaveModel.value()) ) { - case EnvelopeAndLfoParameters::SineWave: + case EnvelopeAndLfoParameters::LfoShape::SineWave: + default: val = Oscillator::sinSample( phase ); break; - case EnvelopeAndLfoParameters::TriangleWave: + case EnvelopeAndLfoParameters::LfoShape::TriangleWave: val = Oscillator::triangleSample( phase ); break; - case EnvelopeAndLfoParameters::SawWave: + case EnvelopeAndLfoParameters::LfoShape::SawWave: val = Oscillator::sawSample( phase ); break; - case EnvelopeAndLfoParameters::SquareWave: + case EnvelopeAndLfoParameters::LfoShape::SquareWave: val = Oscillator::squareSample( phase ); break; - case EnvelopeAndLfoParameters::RandomWave: + case EnvelopeAndLfoParameters::LfoShape::RandomWave: if( x % (int)( 900 * m_lfoSpeedKnob->value() + 1 ) == 0 ) { m_randomGraph = Oscillator::noiseSample( 0.0f ); } val = m_randomGraph; break; - case EnvelopeAndLfoParameters::UserDefinedWave: + case EnvelopeAndLfoParameters::LfoShape::UserDefinedWave: val = m_params->m_userWave. userWaveSample( phase ); break; @@ -516,8 +517,8 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) void EnvelopeAndLfoView::lfoUserWaveChanged() { - if( m_params->m_lfoWaveModel.value() == - EnvelopeAndLfoParameters::UserDefinedWave ) + if( static_cast(m_params->m_lfoWaveModel.value()) == + EnvelopeAndLfoParameters::LfoShape::UserDefinedWave ) { if( m_params->m_userWave.frames() <= 1 ) { diff --git a/src/gui/instrument/InstrumentFunctionViews.cpp b/src/gui/instrument/InstrumentFunctionViews.cpp index a4f0e670ab1..c9aa04272da 100644 --- a/src/gui/instrument/InstrumentFunctionViews.cpp +++ b/src/gui/instrument/InstrumentFunctionViews.cpp @@ -44,7 +44,7 @@ InstrumentFunctionNoteStackingView::InstrumentFunctionNoteStackingView( Instrume m_cc( cc ), m_chordsGroupBox( new GroupBox( tr( "STACKING" ) ) ), m_chordsComboBox( new ComboBox() ), - m_chordRangeKnob( new Knob( knobBright_26 ) ) + m_chordRangeKnob( new Knob( KnobType::Bright26 ) ) { auto topLayout = new QHBoxLayout(this); topLayout->setContentsMargins(0, 0, 0, 0); @@ -98,13 +98,13 @@ InstrumentFunctionArpeggioView::InstrumentFunctionArpeggioView( InstrumentFuncti m_a( arp ), m_arpGroupBox( new GroupBox( tr( "ARPEGGIO" ) ) ), m_arpComboBox( new ComboBox() ), - m_arpRangeKnob( new Knob( knobBright_26 ) ), - m_arpRepeatsKnob( new Knob( knobBright_26 ) ), - m_arpCycleKnob( new Knob( knobBright_26 ) ), - m_arpSkipKnob( new Knob( knobBright_26 ) ), - m_arpMissKnob( new Knob( knobBright_26 ) ), - m_arpTimeKnob( new TempoSyncKnob( knobBright_26 ) ), - m_arpGateKnob( new Knob( knobBright_26 ) ), + m_arpRangeKnob( new Knob( KnobType::Bright26 ) ), + m_arpRepeatsKnob( new Knob( KnobType::Bright26 ) ), + m_arpCycleKnob( new Knob( KnobType::Bright26 ) ), + m_arpSkipKnob( new Knob( KnobType::Bright26 ) ), + m_arpMissKnob( new Knob( KnobType::Bright26 ) ), + m_arpTimeKnob( new TempoSyncKnob( KnobType::Bright26 ) ), + m_arpGateKnob( new Knob( KnobType::Bright26 ) ), m_arpDirectionComboBox( new ComboBox() ), m_arpModeComboBox( new ComboBox() ) { diff --git a/src/gui/instrument/InstrumentSoundShapingView.cpp b/src/gui/instrument/InstrumentSoundShapingView.cpp index dd5c14a093d..1bfc166b342 100644 --- a/src/gui/instrument/InstrumentSoundShapingView.cpp +++ b/src/gui/instrument/InstrumentSoundShapingView.cpp @@ -80,13 +80,13 @@ InstrumentSoundShapingView::InstrumentSoundShapingView( QWidget * _parent ) : m_filterComboBox->setFont( pointSize<8>( m_filterComboBox->font() ) ); - m_filterCutKnob = new Knob( knobBright_26, m_filterGroupBox ); + m_filterCutKnob = new Knob( KnobType::Bright26, m_filterGroupBox ); m_filterCutKnob->setLabel( tr( "FREQ" ) ); m_filterCutKnob->move( 140, 18 ); m_filterCutKnob->setHintText( tr( "Cutoff frequency:" ), " " + tr( "Hz" ) ); - m_filterResKnob = new Knob( knobBright_26, m_filterGroupBox ); + m_filterResKnob = new Knob( KnobType::Bright26, m_filterGroupBox ); m_filterResKnob->setLabel( tr( "Q/RESO" ) ); m_filterResKnob->move( 196, 18 ); m_filterResKnob->setHintText( tr( "Q/Resonance:" ), "" ); diff --git a/src/gui/instrument/InstrumentTrackWindow.cpp b/src/gui/instrument/InstrumentTrackWindow.cpp index 1d26dd9dc8e..43cca0dac1f 100644 --- a/src/gui/instrument/InstrumentTrackWindow.cpp +++ b/src/gui/instrument/InstrumentTrackWindow.cpp @@ -148,7 +148,7 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : Qt::Alignment widgetAlignment = Qt::AlignHCenter | Qt::AlignCenter; // set up volume knob - m_volumeKnob = new Knob( knobBright_26, nullptr, tr( "Volume" ) ); + m_volumeKnob = new Knob( KnobType::Bright26, nullptr, tr( "Volume" ) ); m_volumeKnob->setVolumeKnob( true ); m_volumeKnob->setHintText( tr( "Volume:" ), "%" ); @@ -162,7 +162,7 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : // set up panning knob - m_panningKnob = new Knob( knobBright_26, nullptr, tr( "Panning" ) ); + m_panningKnob = new Knob( KnobType::Bright26, nullptr, tr( "Panning" ) ); m_panningKnob->setHintText( tr( "Panning:" ), "" ); basicControlsLayout->addWidget( m_panningKnob, 0, 1 ); @@ -178,7 +178,7 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : // set up pitch knob - m_pitchKnob = new Knob( knobBright_26, nullptr, tr( "Pitch" ) ); + m_pitchKnob = new Knob( KnobType::Bright26, nullptr, tr( "Pitch" ) ); m_pitchKnob->setHintText( tr( "Pitch:" ), " " + tr( "cents" ) ); basicControlsLayout->addWidget( m_pitchKnob, 0, 3 ); @@ -356,7 +356,7 @@ void InstrumentTrackWindow::modelChanged() m_mixerChannelNumber->setModel( &m_track->m_mixerChannelModel ); m_pianoView->setModel( &m_track->m_piano ); - if( m_track->instrument() && m_track->instrument()->flags().testFlag( Instrument::IsNotBendable ) == false ) + if( m_track->instrument() && m_track->instrument()->flags().testFlag( Instrument::Flag::IsNotBendable ) == false ) { m_pitchKnob->setModel( &m_track->m_pitchModel ); m_pitchRangeSpinBox->setModel( &m_track->m_pitchRangeModel ); @@ -374,7 +374,7 @@ void InstrumentTrackWindow::modelChanged() m_pitchRangeLabel->hide(); } - if (m_track->instrument() && m_track->instrument()->flags().testFlag(Instrument::IsMidiBased)) + if (m_track->instrument() && m_track->instrument()->flags().testFlag(Instrument::Flag::IsMidiBased)) { m_miscView->microtunerGroupBox()->hide(); m_track->m_microtuner.enabledModel()->setValue(false); @@ -425,7 +425,7 @@ void InstrumentTrackWindow::saveSettingsBtnClicked() !sfd.selectedFiles().isEmpty() && !sfd.selectedFiles().first().isEmpty() ) { - DataFile dataFile(DataFile::InstrumentTrackSettings); + DataFile dataFile(DataFile::Type::InstrumentTrackSettings); QDomElement& content(dataFile.content()); m_track->setSimpleSerializing(); @@ -466,7 +466,7 @@ void InstrumentTrackWindow::updateInstrumentView() m_tabWidget->addTab( m_instrumentView, tr( "Plugin" ), "plugin_tab", 0 ); m_tabWidget->setActiveTab( 0 ); - m_ssView->setFunctionsHidden( m_track->m_instrument->flags().testFlag( Instrument::IsSingleStreamed ) ); + m_ssView->setFunctionsHidden( m_track->m_instrument->flags().testFlag( Instrument::Flag::IsSingleStreamed ) ); modelChanged(); // Get the instrument window to refresh m_track->dataChanged(); // Get the text on the trackButton to change diff --git a/src/gui/instrument/PianoView.cpp b/src/gui/instrument/PianoView.cpp index a2df50e4702..20db2e8e83f 100644 --- a/src/gui/instrument/PianoView.cpp +++ b/src/gui/instrument/PianoView.cpp @@ -64,7 +64,7 @@ namespace lmms::gui */ auto WhiteKeys = std::array { - Key_C, Key_D, Key_E, Key_F, Key_G, Key_A, Key_H + Key::C, Key::D, Key::E, Key::F, Key::G, Key::A, Key::H } ; @@ -95,7 +95,7 @@ PianoView::PianoView(QWidget *parent) : QWidget(parent), /*!< Our parent */ ModelView(nullptr, this), /*!< Our view Model */ m_piano(nullptr), /*!< Our piano Model */ - m_startKey(Key_C + Octave_3*KeysPerOctave), /*!< The first key displayed? */ + m_startKey(Octave::Octave_3 + Key::C), /*!< The first key displayed? */ m_lastKey(-1), /*!< The last key displayed? */ m_movedNoteModel(nullptr) /*!< Key marker which is being moved */ { @@ -138,7 +138,7 @@ PianoView::PianoView(QWidget *parent) : m_pianoScroll = new QScrollBar( Qt::Horizontal, this ); m_pianoScroll->setSingleStep( 1 ); m_pianoScroll->setPageStep( 20 ); - m_pianoScroll->setValue(Octave_3 * Piano::WhiteKeysPerOctave); + m_pianoScroll->setValue(static_cast(Octave::Octave_3) * Piano::WhiteKeysPerOctave); // and connect it to this widget connect( m_pianoScroll, SIGNAL(valueChanged(int)), @@ -155,14 +155,10 @@ PianoView::PianoView(QWidget *parent) : connect(Engine::getSong(), SIGNAL(keymapListChanged(int)), this, SLOT(update())); } -/*! \brief Map a keyboard key being pressed to a note in our keyboard view - * - * \param _k The keyboard scan code of the key being pressed. - * \todo check the scan codes for ',' = c, 'L' = c#, '.' = d, ':' = d#, - * '/' = d, '[' = f', '=' = f'#, ']' = g' - Paul's additions - */ -int PianoView::getKeyFromKeyEvent( QKeyEvent * _ke ) +static int getKeyOffsetFromKeyEvent( QKeyEvent * _ke ) { + // TODO: check the scan codes for ',' = c, 'L' = c#, '.' = d, ':' = d#, + // '/' = d, '[' = f', '=' = f'#, ']' = g' - Paul's additions #ifdef LMMS_BUILD_APPLE const int k = _ke->nativeVirtualKey(); #else @@ -297,8 +293,14 @@ int PianoView::getKeyFromKeyEvent( QKeyEvent * _ke ) return -100; } - - +/*! \brief Map a keyboard key being pressed to a note in our keyboard view + * + */ +int PianoView::getKeyFromKeyEvent( QKeyEvent * ke ) +{ + const auto key = static_cast(getKeyOffsetFromKeyEvent(ke)); + return DefaultOctave + key - KeysPerOctave; +} /*! \brief Register a change to this piano display view * @@ -398,8 +400,8 @@ int PianoView::getKeyFromMouse( const QPoint & _p ) const */ void PianoView::pianoScrolled(int new_pos) { - m_startKey = WhiteKeys[new_pos % Piano::WhiteKeysPerOctave] + - (new_pos / Piano::WhiteKeysPerOctave) * KeysPerOctave; + m_startKey = static_cast(new_pos / Piano::WhiteKeysPerOctave) + + WhiteKeys[new_pos % Piano::WhiteKeysPerOctave]; update(); } @@ -625,8 +627,7 @@ void PianoView::mouseMoveEvent( QMouseEvent * _me ) */ void PianoView::keyPressEvent( QKeyEvent * _ke ) { - const int key_num = getKeyFromKeyEvent( _ke ) + - ( DefaultOctave - 1 ) * KeysPerOctave; + const int key_num = getKeyFromKeyEvent( _ke ); if( _ke->isAutoRepeat() == false && key_num > -1 ) { @@ -654,8 +655,7 @@ void PianoView::keyPressEvent( QKeyEvent * _ke ) */ void PianoView::keyReleaseEvent( QKeyEvent * _ke ) { - const int key_num = getKeyFromKeyEvent( _ke ) + - ( DefaultOctave - 1 ) * KeysPerOctave; + const int key_num = getKeyFromKeyEvent( _ke ); if( _ke->isAutoRepeat() == false && key_num > -1 ) { if( m_piano != nullptr ) @@ -913,7 +913,7 @@ void PianoView::paintEvent( QPaintEvent * ) x += PW_WHITE_KEY_WIDTH; - if ((Keys)(cur_key % KeysPerOctave) == Key_C) + if ((Key)(cur_key % KeysPerOctave) == Key::C) { // label key of note C with "C" and number of current octave p.drawText(x - PW_WHITE_KEY_WIDTH, LABEL_TEXT_SIZE + 2, @@ -927,7 +927,7 @@ void PianoView::paintEvent( QPaintEvent * ) int white_cnt = 0; int startKey = m_startKey; - if (startKey > 0 && Piano::isBlackKey(static_cast(--startKey))) + if (startKey > 0 && Piano::isBlackKey(--startKey)) { if (m_piano && m_piano->instrumentTrack()->isKeyMapped(startKey)) { diff --git a/src/gui/menus/MidiPortMenu.cpp b/src/gui/menus/MidiPortMenu.cpp index b1ddf71c9ad..296be3506f1 100644 --- a/src/gui/menus/MidiPortMenu.cpp +++ b/src/gui/menus/MidiPortMenu.cpp @@ -30,7 +30,7 @@ namespace lmms::gui { -MidiPortMenu::MidiPortMenu( MidiPort::Modes _mode ) : +MidiPortMenu::MidiPortMenu( MidiPort::Mode _mode ) : ModelView( nullptr, this ), m_mode( _mode ) { @@ -46,12 +46,12 @@ MidiPortMenu::MidiPortMenu( MidiPort::Modes _mode ) : void MidiPortMenu::modelChanged() { auto mp = castModel(); - if( m_mode == MidiPort::Input ) + if( m_mode == MidiPort::Mode::Input ) { connect( mp, SIGNAL(readablePortsChanged()), this, SLOT(updateMenu())); } - else if( m_mode == MidiPort::Output ) + else if( m_mode == MidiPort::Mode::Output ) { connect( mp, SIGNAL(writablePortsChanged()), this, SLOT(updateMenu())); @@ -64,12 +64,12 @@ void MidiPortMenu::modelChanged() void MidiPortMenu::activatedPort( QAction * _item ) { - if( m_mode == MidiPort::Input ) + if( m_mode == MidiPort::Mode::Input ) { castModel()->subscribeReadablePort( _item->text(), _item->isChecked() ); } - else if( m_mode == MidiPort::Output ) + else if( m_mode == MidiPort::Mode::Output ) { castModel()->subscribeWritablePort( _item->text(), _item->isChecked() ); @@ -82,7 +82,7 @@ void MidiPortMenu::activatedPort( QAction * _item ) void MidiPortMenu::updateMenu() { auto mp = castModel(); - const MidiPort::Map & map = ( m_mode == MidiPort::Input ) ? + const MidiPort::Map & map = ( m_mode == MidiPort::Mode::Input ) ? mp->readablePorts() : mp->writablePorts(); clear(); for( MidiPort::Map::ConstIterator it = map.begin(); diff --git a/src/gui/modals/ControllerConnectionDialog.cpp b/src/gui/modals/ControllerConnectionDialog.cpp index 040ed9e0f39..79daa25b565 100644 --- a/src/gui/modals/ControllerConnectionDialog.cpp +++ b/src/gui/modals/ControllerConnectionDialog.cpp @@ -169,7 +169,7 @@ ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent, // our port-menus when being clicked if( !Engine::audioEngine()->midiClient()->isRaw() ) { - m_readablePorts = new MidiPortMenu( MidiPort::Input ); + m_readablePorts = new MidiPortMenu( MidiPort::Mode::Input ); connect( m_readablePorts, SIGNAL(triggered(QAction*)), this, SLOT(enableAutoDetect(QAction*))); auto rp_btn = new ToolButton(m_midiGroupBox); @@ -242,9 +242,9 @@ ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent, { cc = m_targetModel->controllerConnection(); - if( cc && cc->getController()->type() != Controller::DummyController && Engine::getSong() ) + if( cc && cc->getController()->type() != Controller::ControllerType::Dummy && Engine::getSong() ) { - if ( cc->getController()->type() == Controller::MidiController ) + if ( cc->getController()->type() == Controller::ControllerType::Midi ) { m_midiGroupBox->model()->setValue( true ); // ensure controller is created diff --git a/src/gui/modals/EffectSelectDialog.cpp b/src/gui/modals/EffectSelectDialog.cpp index eac5a3783fd..31ffd772856 100644 --- a/src/gui/modals/EffectSelectDialog.cpp +++ b/src/gui/modals/EffectSelectDialog.cpp @@ -53,7 +53,7 @@ EffectSelectDialog::EffectSelectDialog( QWidget * _parent ) : EffectKeyList subPluginEffectKeys; - for (const Plugin::Descriptor* desc: getPluginFactory()->descriptors(Plugin::Effect)) + for (const Plugin::Descriptor* desc: getPluginFactory()->descriptors(Plugin::Type::Effect)) { if( desc->subPluginFeatures ) { diff --git a/src/gui/modals/ExportProjectDialog.cpp b/src/gui/modals/ExportProjectDialog.cpp index 1f937c37496..fe39082e450 100644 --- a/src/gui/modals/ExportProjectDialog.cpp +++ b/src/gui/modals/ExportProjectDialog.cpp @@ -66,7 +66,7 @@ ExportProjectDialog::ExportProjectDialog( const QString & _file_name, // Add to combo box. fileFormatCB->addItem( ProjectRenderer::tr( ProjectRenderer::fileEncodeDevices[i].m_description ), - QVariant( ProjectRenderer::fileEncodeDevices[i].m_fileFormat ) // Format tag; later used for identification. + QVariant( static_cast(ProjectRenderer::fileEncodeDevices[i].m_fileFormat) ) // Format tag; later used for identification. ); // If this is our extension, select it. @@ -142,13 +142,13 @@ OutputSettings::StereoMode mapToStereoMode(int index) switch (index) { case 0: - return OutputSettings::StereoMode_Mono; + return OutputSettings::StereoMode::Mono; case 1: - return OutputSettings::StereoMode_Stereo; + return OutputSettings::StereoMode::Stereo; case 2: - return OutputSettings::StereoMode_JointStereo; + return OutputSettings::StereoMode::JointStereo; default: - return OutputSettings::StereoMode_Stereo; + return OutputSettings::StereoMode::Stereo; } } @@ -216,27 +216,27 @@ void ExportProjectDialog::onFileFormatChanged(int index) // and adjust the UI properly. QVariant format_tag = fileFormatCB->itemData(index); bool successful_conversion = false; - auto exportFormat = static_cast( + auto exportFormat = static_cast( format_tag.toInt(&successful_conversion) ); Q_ASSERT(successful_conversion); - bool stereoModeVisible = (exportFormat == ProjectRenderer::MP3File); + bool stereoModeVisible = (exportFormat == ProjectRenderer::ExportFileFormat::MP3); - bool sampleRateControlsVisible = (exportFormat != ProjectRenderer::MP3File); + bool sampleRateControlsVisible = (exportFormat != ProjectRenderer::ExportFileFormat::MP3); bool bitRateControlsEnabled = - (exportFormat == ProjectRenderer::OggFile || - exportFormat == ProjectRenderer::MP3File); + (exportFormat == ProjectRenderer::ExportFileFormat::Ogg || + exportFormat == ProjectRenderer::ExportFileFormat::MP3); bool bitDepthControlEnabled = - (exportFormat == ProjectRenderer::WaveFile || - exportFormat == ProjectRenderer::FlacFile); + (exportFormat == ProjectRenderer::ExportFileFormat::Wave || + exportFormat == ProjectRenderer::ExportFileFormat::Flac); - bool variableBitrateVisible = !(exportFormat == ProjectRenderer::MP3File || exportFormat == ProjectRenderer::FlacFile); + bool variableBitrateVisible = !(exportFormat == ProjectRenderer::ExportFileFormat::MP3 || exportFormat == ProjectRenderer::ExportFileFormat::Flac); #ifdef LMMS_HAVE_SF_COMPLEVEL - bool compressionLevelVisible = (exportFormat == ProjectRenderer::FlacFile); + bool compressionLevelVisible = (exportFormat == ProjectRenderer::ExportFileFormat::Flac); compressionWidget->setVisible(compressionLevelVisible); #endif @@ -251,12 +251,12 @@ void ExportProjectDialog::onFileFormatChanged(int index) void ExportProjectDialog::startBtnClicked() { - m_ft = ProjectRenderer::NumFileFormats; + m_ft = ProjectRenderer::ExportFileFormat::Count; // Get file format from current menu selection. bool successful_conversion = false; QVariant tag = fileFormatCB->itemData(fileFormatCB->currentIndex()); - m_ft = static_cast( + m_ft = static_cast( tag.toInt(&successful_conversion) ); diff --git a/src/gui/modals/SetupDialog.cpp b/src/gui/modals/SetupDialog.cpp index 33505c3997d..63b84506e46 100644 --- a/src/gui/modals/SetupDialog.cpp +++ b/src/gui/modals/SetupDialog.cpp @@ -91,7 +91,7 @@ inline void labelWidget(QWidget * w, const QString & txt) -SetupDialog::SetupDialog(ConfigTabs tab_to_open) : +SetupDialog::SetupDialog(ConfigTab tab_to_open) : m_displaydBFS(ConfigManager::inst()->value( "app", "displaydbfs").toInt()), m_tooltips(!ConfigManager::inst()->value( @@ -837,7 +837,7 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : tr("Paths"), 4, true, true)->setIcon( embed::getIconPixmap("setup_directories")); - m_tabBar->setActiveTab(tab_to_open); + m_tabBar->setActiveTab(static_cast(tab_to_open)); // Horizontal layout ordering. hlayout->addSpacing(2); diff --git a/src/gui/tracks/InstrumentTrackView.cpp b/src/gui/tracks/InstrumentTrackView.cpp index 17adc99a6de..669fdaccb8f 100644 --- a/src/gui/tracks/InstrumentTrackView.cpp +++ b/src/gui/tracks/InstrumentTrackView.cpp @@ -87,7 +87,7 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerV widgetWidth = DEFAULT_SETTINGS_WIDGET_WIDTH; } - m_volumeKnob = new Knob( knobSmall_17, getTrackSettingsWidget(), + m_volumeKnob = new Knob( KnobType::Small17, getTrackSettingsWidget(), tr( "Volume" ) ); m_volumeKnob->setVolumeKnob( true ); m_volumeKnob->setModel( &_it->m_volumeModel ); @@ -96,7 +96,7 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerV m_volumeKnob->setLabel( tr( "VOL" ) ); m_volumeKnob->show(); - m_panningKnob = new Knob( knobSmall_17, getTrackSettingsWidget(), + m_panningKnob = new Knob( KnobType::Small17, getTrackSettingsWidget(), tr( "Panning" ) ); m_panningKnob->setModel( &_it->m_panningModel ); m_panningKnob->setHintText(tr("Panning:"), "%"); @@ -110,9 +110,9 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerV if( !Engine::audioEngine()->midiClient()->isRaw() ) { _it->m_midiPort.m_readablePortsMenu = new MidiPortMenu( - MidiPort::Input ); + MidiPort::Mode::Input ); _it->m_midiPort.m_writablePortsMenu = new MidiPortMenu( - MidiPort::Output ); + MidiPort::Mode::Output ); _it->m_midiPort.m_readablePortsMenu->setModel( &_it->m_midiPort ); _it->m_midiPort.m_writablePortsMenu->setModel( diff --git a/src/gui/tracks/SampleTrackView.cpp b/src/gui/tracks/SampleTrackView.cpp index fbdd41ded06..6a6a2c5fd2e 100644 --- a/src/gui/tracks/SampleTrackView.cpp +++ b/src/gui/tracks/SampleTrackView.cpp @@ -59,7 +59,7 @@ SampleTrackView::SampleTrackView( SampleTrack * _t, TrackContainerView* tcv ) : m_tlb->move(3, 1); m_tlb->show(); - m_volumeKnob = new Knob( knobSmall_17, getTrackSettingsWidget(), + m_volumeKnob = new Knob( KnobType::Small17, getTrackSettingsWidget(), tr( "Track volume" ) ); m_volumeKnob->setVolumeKnob( true ); m_volumeKnob->setModel( &_t->m_volumeModel ); @@ -73,7 +73,7 @@ SampleTrackView::SampleTrackView( SampleTrack * _t, TrackContainerView* tcv ) : m_volumeKnob->setLabel( tr( "VOL" ) ); m_volumeKnob->show(); - m_panningKnob = new Knob( knobSmall_17, getTrackSettingsWidget(), + m_panningKnob = new Knob( KnobType::Small17, getTrackSettingsWidget(), tr( "Panning" ) ); m_panningKnob->setModel( &_t->m_panningModel ); m_panningKnob->setHintText( tr( "Panning:" ), "%" ); diff --git a/src/gui/tracks/TrackContentWidget.cpp b/src/gui/tracks/TrackContentWidget.cpp index ca7123bdaea..442d717bfd1 100644 --- a/src/gui/tracks/TrackContentWidget.cpp +++ b/src/gui/tracks/TrackContentWidget.cpp @@ -291,7 +291,7 @@ void TrackContentWidget::dragEnterEvent( QDragEnterEvent * dee ) else { StringPairDrag::processDragEnterEvent( dee, "clip_" + - QString::number( getTrack()->type() ) ); + QString::number( static_cast(getTrack()->type()) ) ); } } @@ -325,7 +325,7 @@ bool TrackContentWidget::canPasteSelection( TimePos clipPos, const QMimeData* md QString value = decodeValue( md ); // We can only paste into tracks of the same type - if (type != ("clip_" + QString::number(t->type()))) + if (type != ("clip_" + QString::number(static_cast(t->type())))) { return false; } @@ -382,7 +382,7 @@ bool TrackContentWidget::canPasteSelection( TimePos clipPos, const QMimeData* md } // Track must be of the same type - auto startTrackType = clipElement.attributeNode("trackType").value().toInt(); + auto startTrackType = static_cast(clipElement.attributeNode("trackType").value().toInt()); Track * endTrack = tracks.at( finalTrackIndex ); if( startTrackType != endTrack->type() ) { @@ -538,7 +538,7 @@ void TrackContentWidget::mousePressEvent( QMouseEvent * me ) // Enable box select if control is held when clicking an empty space // (If we had clicked a Clip it would have intercepted the mouse event) if( me->modifiers() & Qt::ControlModifier ){ - getGUI()->songEditor()->m_editor->setEditMode(SongEditor::EditMode::SelectMode); + getGUI()->songEditor()->m_editor->setEditMode(SongEditor::EditMode::Select); } // Forward event to allow box select if the editor supports it and is in that mode if( m_trackView->trackContainerView()->allowRubberband() == true ) @@ -655,7 +655,7 @@ void TrackContentWidget::contextMenuEvent( QContextMenuEvent * cme ) QMenu contextMenu( this ); QAction *pasteA = contextMenu.addAction( embed::getIconPixmap( "edit_paste" ), - tr( "Paste" ), [this, cme](){ contextMenuAction( cme, Paste ); } ); + tr( "Paste" ), [this, cme](){ contextMenuAction( cme, ContextMenuAction::Paste ); } ); // If we can't paste in the current TCW for some reason, disable the action so the user knows pasteA->setEnabled( canPasteSelection( getPosition( cme->x() ), getMimeData() ) ? true : false ); @@ -669,7 +669,7 @@ void TrackContentWidget::contextMenuAction( QContextMenuEvent * cme, ContextMenu switch( action ) { - case Paste: + case ContextMenuAction::Paste: // Paste the selection on the TimePos of the context menu event TimePos clipPos = getPosition( cme->x() ); diff --git a/src/gui/tracks/TrackLabelButton.cpp b/src/gui/tracks/TrackLabelButton.cpp index 3f1b4587158..2a50a4aa254 100644 --- a/src/gui/tracks/TrackLabelButton.cpp +++ b/src/gui/tracks/TrackLabelButton.cpp @@ -187,7 +187,7 @@ void TrackLabelButton::mouseReleaseEvent( QMouseEvent *_me ) void TrackLabelButton::paintEvent( QPaintEvent * _pe ) { - if( m_trackView->getTrack()->type() == Track::InstrumentTrack ) + if( m_trackView->getTrack()->type() == Track::Type::Instrument ) { auto it = dynamic_cast(m_trackView->getTrack()); const PixmapLoader * pl; diff --git a/src/gui/tracks/TrackOperationsWidget.cpp b/src/gui/tracks/TrackOperationsWidget.cpp index ddbd2eacdb1..ce6177d76da 100644 --- a/src/gui/tracks/TrackOperationsWidget.cpp +++ b/src/gui/tracks/TrackOperationsWidget.cpp @@ -137,12 +137,12 @@ void TrackOperationsWidget::mousePressEvent( QMouseEvent * me ) { if( me->button() == Qt::LeftButton && me->modifiers() & Qt::ControlModifier && - m_trackView->getTrack()->type() != Track::PatternTrack) + m_trackView->getTrack()->type() != Track::Type::Pattern) { - DataFile dataFile( DataFile::DragNDropData ); + DataFile dataFile( DataFile::Type::DragNDropData ); m_trackView->getTrack()->saveState( dataFile, dataFile.content() ); new StringPairDrag( QString( "track_%1" ).arg( - m_trackView->getTrack()->type() ), + static_cast(m_trackView->getTrack()->type()) ), dataFile.toString(), m_trackView->getTrackSettingsWidget()->grab(), this ); } diff --git a/src/gui/tracks/TrackView.cpp b/src/gui/tracks/TrackView.cpp index 3e9257a0d81..426be7e3626 100644 --- a/src/gui/tracks/TrackView.cpp +++ b/src/gui/tracks/TrackView.cpp @@ -65,7 +65,7 @@ TrackView::TrackView( Track * track, TrackContainerView * tcv ) : m_trackOperationsWidget( this ), /*!< Our trackOperationsWidget */ m_trackSettingsWidget( this ), /*!< Our trackSettingsWidget */ m_trackContentWidget( this ), /*!< Our trackContentWidget */ - m_action( NoAction ) /*!< The action we're currently performing */ + m_action( Action::None ) /*!< The action we're currently performing */ { setAutoFillBackground( true ); QPalette pal; @@ -207,7 +207,7 @@ void TrackView::modelChanged() void TrackView::dragEnterEvent( QDragEnterEvent * dee ) { StringPairDrag::processDragEnterEvent( dee, "track_" + - QString::number( m_track->type() ) ); + QString::number( static_cast(m_track->type()) ) ); } @@ -225,7 +225,7 @@ void TrackView::dropEvent( QDropEvent * de ) { QString type = StringPairDrag::decodeKey( de ); QString value = StringPairDrag::decodeValue( de ); - if( type == ( "track_" + QString::number( m_track->type() ) ) ) + if( type == ( "track_" + QString::number( static_cast(m_track->type()) ) ) ) { // value contains our XML-data so simply create a // DataFile which does the rest for us... @@ -278,7 +278,7 @@ void TrackView::mousePressEvent( QMouseEvent * me ) { if( me->modifiers() & Qt::ShiftModifier ) { - m_action = ResizeTrack; + m_action = Action::Resize; QCursor::setPos( mapToGlobal( QPoint( me->x(), height() ) ) ); QCursor c( Qt::SizeVerCursor); @@ -292,7 +292,7 @@ void TrackView::mousePressEvent( QMouseEvent * me ) return; } - m_action = MoveTrack; + m_action = Action::Move; QCursor c( Qt::SizeVerCursor ); QApplication::setOverrideCursor( c ); @@ -338,7 +338,7 @@ void TrackView::mouseMoveEvent( QMouseEvent * me ) { QWidget::mouseMoveEvent( me ); } - else if( m_action == MoveTrack ) + else if( m_action == Action::Move ) { // look which track-widget the mouse-cursor is over const int yPos = @@ -362,7 +362,7 @@ void TrackView::mouseMoveEvent( QMouseEvent * me ) } } } - else if( m_action == ResizeTrack ) + else if( m_action == Action::Resize ) { setFixedHeight( qMax( me->y(), MINIMAL_TRACK_HEIGHT ) ); m_trackContainerView->realignTracks(); @@ -383,7 +383,7 @@ void TrackView::mouseMoveEvent( QMouseEvent * me ) */ void TrackView::mouseReleaseEvent( QMouseEvent * me ) { - m_action = NoAction; + m_action = Action::None; while( QApplication::overrideCursor() != nullptr ) { QApplication::restoreOverrideCursor(); diff --git a/src/gui/widgets/CustomTextKnob.cpp b/src/gui/widgets/CustomTextKnob.cpp index ce880608ccc..a4edde47ccb 100644 --- a/src/gui/widgets/CustomTextKnob.cpp +++ b/src/gui/widgets/CustomTextKnob.cpp @@ -28,7 +28,7 @@ namespace lmms::gui { -CustomTextKnob::CustomTextKnob( knobTypes _knob_num, QWidget * _parent, const QString & _name, const QString & _value_text ) : +CustomTextKnob::CustomTextKnob( KnobType _knob_num, QWidget * _parent, const QString & _name, const QString & _value_text ) : Knob( _knob_num, _parent, _name ), m_value_text( _value_text ) {} diff --git a/src/gui/widgets/Graph.cpp b/src/gui/widgets/Graph.cpp index 53a0a130dab..9972209a842 100644 --- a/src/gui/widgets/Graph.cpp +++ b/src/gui/widgets/Graph.cpp @@ -36,7 +36,7 @@ namespace lmms namespace gui { -Graph::Graph( QWidget * _parent, graphStyle _style, int _width, +Graph::Graph( QWidget * _parent, Style _style, int _width, int _height ) : QWidget( _parent ), /* TODO: size, background? */ @@ -305,7 +305,7 @@ void Graph::paintEvent( QPaintEvent * ) switch( m_graphStyle ) { - case Graph::LinearStyle: + case Style::Linear: p.setRenderHints( QPainter::Antialiasing, true ); for( int i=0; i < length; i++ ) @@ -329,7 +329,7 @@ void Graph::paintEvent( QPaintEvent * ) break; - case Graph::NearestStyle: + case Style::Nearest: for( int i=0; i < length; i++ ) { p.drawLine(2+static_cast(i*xscale), @@ -350,7 +350,7 @@ void Graph::paintEvent( QPaintEvent * ) 2+static_cast( ( (*samps)[length] - maxVal ) * yscale ) ); break; - case Graph::LinearNonCyclicStyle: + case Style::LinearNonCyclic: p.setRenderHints( QPainter::Antialiasing, true ); for( int i=0; i < length; i++ ) @@ -369,7 +369,7 @@ void Graph::paintEvent( QPaintEvent * ) p.setRenderHints( QPainter::Antialiasing, false ); break; - case Graph::BarStyle: + case Style::Bar: for( int i=0; i <= length; i++ ) { p.fillRect( 2+static_cast( i*xscale ), diff --git a/src/gui/widgets/Knob.cpp b/src/gui/widgets/Knob.cpp index 8640bb81dce..d67c6dbddca 100644 --- a/src/gui/widgets/Knob.cpp +++ b/src/gui/widgets/Knob.cpp @@ -57,7 +57,7 @@ SimpleTextFloat * Knob::s_textFloat = nullptr; -Knob::Knob( knobTypes _knob_num, QWidget * _parent, const QString & _name ) : +Knob::Knob( KnobType _knob_num, QWidget * _parent, const QString & _name ) : QWidget( _parent ), FloatModelView( new FloatModel( 0, 0, 0, 1, nullptr, _name, true ), this ), m_label( "" ), @@ -75,7 +75,7 @@ Knob::Knob( knobTypes _knob_num, QWidget * _parent, const QString & _name ) : } Knob::Knob( QWidget * _parent, const QString & _name ) : - Knob( knobBright_26, _parent, _name ) + Knob( KnobType::Bright26, _parent, _name ) { } @@ -106,15 +106,15 @@ void Knob::initUi( const QString & _name ) // overrides that color. switch (knobNum()) { - case knobSmall_17: - case knobBright_26: - case knobDark_28: + case KnobType::Small17: + case KnobType::Bright26: + case KnobType::Dark28: m_lineActiveColor = QApplication::palette().color(QPalette::Active, QPalette::WindowText); m_arcActiveColor = QColor(QApplication::palette().color( QPalette::Active, QPalette::WindowText)); m_arcActiveColor.setAlpha(70); break; - case knobVintage_32: + case KnobType::Vintage32: m_lineActiveColor = QApplication::palette().color(QPalette::Active, QPalette::Shadow); m_arcActiveColor = QColor(QApplication::palette().color( QPalette::Active, QPalette::Shadow)); @@ -132,24 +132,24 @@ void Knob::initUi( const QString & _name ) void Knob::onKnobNumUpdated() { - if( m_knobNum != knobStyled ) + if( m_knobNum != KnobType::Styled ) { QString knobFilename; switch (m_knobNum) { - case knobDark_28: + case KnobType::Dark28: knobFilename = "knob01"; break; - case knobBright_26: + case KnobType::Bright26: knobFilename = "knob02"; break; - case knobSmall_17: + case KnobType::Small17: knobFilename = "knob03"; break; - case knobVintage_32: + case KnobType::Vintage32: knobFilename = "knob05"; break; - case knobStyled: // only here to stop the compiler from complaining + case KnobType::Styled: // only here to stop the compiler from complaining break; } @@ -251,7 +251,7 @@ void Knob::setOuterRadius( float r ) -knobTypes Knob::knobNum() const +KnobType Knob::knobNum() const { return m_knobNum; } @@ -259,7 +259,7 @@ knobTypes Knob::knobNum() const -void Knob::setknobNum( knobTypes k ) +void Knob::setknobNum( KnobType k ) { if( m_knobNum != k ) { @@ -397,7 +397,7 @@ void Knob::drawKnob( QPainter * _p ) QPoint mid; - if( m_knobNum == knobStyled ) + if( m_knobNum == KnobType::Styled ) { p.setRenderHint( QPainter::Antialiasing ); @@ -448,17 +448,17 @@ void Knob::drawKnob( QPainter * _p ) p.setPen(QPen(currentLineColor, 2)); switch( m_knobNum ) { - case knobSmall_17: + case KnobType::Small17: { p.drawLine( calculateLine( mid, radius-2 ) ); break; } - case knobBright_26: + case KnobType::Bright26: { p.drawLine( calculateLine( mid, radius-5 ) ); break; } - case knobDark_28: + case KnobType::Dark28: { const float rb = qMax( ( radius - 10 ) / 3.0, 0.0 ); @@ -468,12 +468,12 @@ void Knob::drawKnob( QPainter * _p ) p.drawLine( ln ); break; } - case knobVintage_32: + case KnobType::Vintage32: { p.drawLine( calculateLine( mid, radius-2, 2 ) ); break; } - case knobStyled: + case KnobType::Styled: break; } diff --git a/src/gui/widgets/LedCheckBox.cpp b/src/gui/widgets/LedCheckBox.cpp index 1be07281577..0c16bf391ae 100644 --- a/src/gui/widgets/LedCheckBox.cpp +++ b/src/gui/widgets/LedCheckBox.cpp @@ -44,7 +44,7 @@ static const auto names = std::array LedCheckBox::LedCheckBox( const QString & _text, QWidget * _parent, - const QString & _name, LedColors _color ) : + const QString & _name, LedColor _color ) : AutomatableButton( _parent, _name ), m_text( _text ) { @@ -55,7 +55,7 @@ LedCheckBox::LedCheckBox( const QString & _text, QWidget * _parent, LedCheckBox::LedCheckBox( QWidget * _parent, - const QString & _name, LedColors _color ) : + const QString & _name, LedColor _color ) : LedCheckBox( QString(), _parent, _name, _color ) { } @@ -103,16 +103,12 @@ void LedCheckBox::paintEvent( QPaintEvent * ) -void LedCheckBox::initUi( LedColors _color ) +void LedCheckBox::initUi( LedColor _color ) { setCheckable( true ); - if( _color >= NumColors || _color < Yellow ) - { - _color = Yellow; - } m_ledOnPixmap = new QPixmap( embed::getIconPixmap( - names[_color].toUtf8().constData() ) ); + names[static_cast(_color)].toUtf8().constData() ) ); m_ledOffPixmap = new QPixmap( embed::getIconPixmap( "led_off" ) ); setFont( pointSize<7>( font() ) ); diff --git a/src/gui/widgets/TempoSyncKnob.cpp b/src/gui/widgets/TempoSyncKnob.cpp index 86ee6df3cfc..b58e61cf4a8 100644 --- a/src/gui/widgets/TempoSyncKnob.cpp +++ b/src/gui/widgets/TempoSyncKnob.cpp @@ -42,7 +42,7 @@ namespace lmms::gui -TempoSyncKnob::TempoSyncKnob( knobTypes _knob_num, QWidget * _parent, +TempoSyncKnob::TempoSyncKnob( KnobType _knob_num, QWidget * _parent, const QString & _name ) : Knob( _knob_num, _parent, _name ), m_tempoSyncIcon( embed::getIconPixmap( "tempo_sync" ) ), @@ -104,51 +104,51 @@ void TempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) connect( syncMenu, SIGNAL(triggered(QAction*)), model(), SLOT(setTempoSync(QAction*))); syncMenu->addAction( embed::getIconPixmap( "note_none" ), - tr( "No Sync" ) )->setData( (int) TempoSyncKnobModel::SyncNone ); + tr( "No Sync" ) )->setData( (int) TempoSyncKnobModel::SyncMode::None ); if( limit / 0.125f <= model()->maxValue() ) { syncMenu->addAction( embed::getIconPixmap( "note_double_whole" ), tr( "Eight beats" ) )->setData( - (int) TempoSyncKnobModel::SyncDoubleWholeNote ); + (int) TempoSyncKnobModel::SyncMode::DoubleWholeNote ); } if( limit / 0.25f <= model()->maxValue() ) { syncMenu->addAction( embed::getIconPixmap( "note_whole" ), tr( "Whole note" ) )->setData( - (int) TempoSyncKnobModel::SyncWholeNote ); + (int) TempoSyncKnobModel::SyncMode::WholeNote ); } if( limit / 0.5f <= model()->maxValue() ) { syncMenu->addAction( embed::getIconPixmap( "note_half" ), tr( "Half note" ) )->setData( - (int) TempoSyncKnobModel::SyncHalfNote ); + (int) TempoSyncKnobModel::SyncMode::HalfNote ); } if( limit <= model()->maxValue() ) { syncMenu->addAction( embed::getIconPixmap( "note_quarter" ), tr( "Quarter note" ) )->setData( - (int) TempoSyncKnobModel::SyncQuarterNote ); + (int) TempoSyncKnobModel::SyncMode::QuarterNote ); } if( limit / 2.0f <= model()->maxValue() ) { syncMenu->addAction( embed::getIconPixmap( "note_eighth" ), tr( "8th note" ) )->setData( - (int) TempoSyncKnobModel::SyncEighthNote ); + (int) TempoSyncKnobModel::SyncMode::EighthNote ); } if( limit / 4.0f <= model()->maxValue() ) { syncMenu->addAction( embed::getIconPixmap( "note_sixteenth" ), tr( "16th note" ) )->setData( - (int) TempoSyncKnobModel::SyncSixteenthNote ); + (int) TempoSyncKnobModel::SyncMode::SixteenthNote ); } syncMenu->addAction( embed::getIconPixmap( "note_thirtysecond" ), tr( "32nd note" ) )->setData( - (int) TempoSyncKnobModel::SyncThirtysecondNote ); + (int) TempoSyncKnobModel::SyncMode::ThirtysecondNote ); syncMenu->addAction( embed::getIconPixmap( "dont_know" ), tr( "Custom..." ), this, SLOT(showCustom()) )->setData( - (int) TempoSyncKnobModel::SyncCustom ); + (int) TempoSyncKnobModel::SyncMode::Custom ); contextMenu.addSeparator(); } @@ -162,11 +162,11 @@ void TempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) void TempoSyncKnob::updateDescAndIcon() { - if( model()->m_tempoSyncMode ) + if( model()->m_tempoSyncMode != TempoSyncKnobModel::SyncMode::None ) { switch( model()->m_tempoSyncMode ) { - case TempoSyncKnobModel::SyncCustom: + case TempoSyncKnobModel::SyncMode::Custom: m_tempoSyncDescription = tr( "Custom " ) + "(" + QString::number( model()->m_custom.numeratorModel().value() ) + @@ -174,31 +174,31 @@ void TempoSyncKnob::updateDescAndIcon() QString::number( model()->m_custom.denominatorModel().value() ) + ")"; break; - case TempoSyncKnobModel::SyncDoubleWholeNote: + case TempoSyncKnobModel::SyncMode::DoubleWholeNote: m_tempoSyncDescription = tr( "Synced to Eight Beats" ); break; - case TempoSyncKnobModel::SyncWholeNote: + case TempoSyncKnobModel::SyncMode::WholeNote: m_tempoSyncDescription = tr( "Synced to Whole Note" ); break; - case TempoSyncKnobModel::SyncHalfNote: + case TempoSyncKnobModel::SyncMode::HalfNote: m_tempoSyncDescription = tr( "Synced to Half Note" ); break; - case TempoSyncKnobModel::SyncQuarterNote: + case TempoSyncKnobModel::SyncMode::QuarterNote: m_tempoSyncDescription = tr( "Synced to Quarter Note" ); break; - case TempoSyncKnobModel::SyncEighthNote: + case TempoSyncKnobModel::SyncMode::EighthNote: m_tempoSyncDescription = tr( "Synced to 8th Note" ); break; - case TempoSyncKnobModel::SyncSixteenthNote: + case TempoSyncKnobModel::SyncMode::SixteenthNote: m_tempoSyncDescription = tr( "Synced to 16th Note" ); break; - case TempoSyncKnobModel::SyncThirtysecondNote: + case TempoSyncKnobModel::SyncMode::ThirtysecondNote: m_tempoSyncDescription = tr( "Synced to 32nd Note" ); break; @@ -210,38 +210,38 @@ void TempoSyncKnob::updateDescAndIcon() m_tempoSyncDescription = tr( "Tempo Sync" ); } if( m_custom != nullptr && - model()->m_tempoSyncMode != TempoSyncKnobModel::SyncCustom ) + model()->m_tempoSyncMode != TempoSyncKnobModel::SyncMode::Custom ) { m_custom->parentWidget()->hide(); } switch( model()->m_tempoSyncMode ) { - case TempoSyncKnobModel::SyncNone: + case TempoSyncKnobModel::SyncMode::None: m_tempoSyncIcon = embed::getIconPixmap( "tempo_sync" ); break; - case TempoSyncKnobModel::SyncCustom: + case TempoSyncKnobModel::SyncMode::Custom: m_tempoSyncIcon = embed::getIconPixmap( "dont_know" ); break; - case TempoSyncKnobModel::SyncDoubleWholeNote: + case TempoSyncKnobModel::SyncMode::DoubleWholeNote: m_tempoSyncIcon = embed::getIconPixmap( "note_double_whole" ); break; - case TempoSyncKnobModel::SyncWholeNote: + case TempoSyncKnobModel::SyncMode::WholeNote: m_tempoSyncIcon = embed::getIconPixmap( "note_whole" ); break; - case TempoSyncKnobModel::SyncHalfNote: + case TempoSyncKnobModel::SyncMode::HalfNote: m_tempoSyncIcon = embed::getIconPixmap( "note_half" ); break; - case TempoSyncKnobModel::SyncQuarterNote: + case TempoSyncKnobModel::SyncMode::QuarterNote: m_tempoSyncIcon = embed::getIconPixmap( "note_quarter" ); break; - case TempoSyncKnobModel::SyncEighthNote: + case TempoSyncKnobModel::SyncMode::EighthNote: m_tempoSyncIcon = embed::getIconPixmap( "note_eighth" ); break; - case TempoSyncKnobModel::SyncSixteenthNote: + case TempoSyncKnobModel::SyncMode::SixteenthNote: m_tempoSyncIcon = embed::getIconPixmap( "note_sixteenth" ); break; - case TempoSyncKnobModel::SyncThirtysecondNote: + case TempoSyncKnobModel::SyncMode::ThirtysecondNote: m_tempoSyncIcon = embed::getIconPixmap( "note_thirtysecond" ); break; default: @@ -305,7 +305,7 @@ void TempoSyncKnob::showCustom() m_custom->setModel( &model()->m_custom ); } m_custom->parentWidget()->show(); - model()->setTempoSync( TempoSyncKnobModel::SyncCustom ); + model()->setTempoSync( TempoSyncKnobModel::SyncMode::Custom ); } diff --git a/src/gui/widgets/TimeDisplayWidget.cpp b/src/gui/widgets/TimeDisplayWidget.cpp index cf139d4a8b1..3dad6b1b022 100644 --- a/src/gui/widgets/TimeDisplayWidget.cpp +++ b/src/gui/widgets/TimeDisplayWidget.cpp @@ -36,7 +36,7 @@ namespace lmms::gui TimeDisplayWidget::TimeDisplayWidget() : QWidget(), - m_displayMode( MinutesSeconds ), + m_displayMode( DisplayMode::MinutesSeconds ), m_spinBoxesLayout( this ), m_majorLCD( 4, this ), m_minorLCD( 2, this ), @@ -65,13 +65,13 @@ void TimeDisplayWidget::setDisplayMode( DisplayMode displayMode ) switch( m_displayMode ) { - case MinutesSeconds: + case DisplayMode::MinutesSeconds: m_majorLCD.setLabel( tr( "MIN" ) ); m_minorLCD.setLabel( tr( "SEC" ) ); m_milliSecondsLCD.setLabel( tr( "MSEC" ) ); break; - case BarsTicks: + case DisplayMode::BarsTicks: m_majorLCD.setLabel( tr( "BAR" ) ); m_minorLCD.setLabel( tr( "BEAT" ) ); m_milliSecondsLCD.setLabel( tr( "TICK" ) ); @@ -90,7 +90,7 @@ void TimeDisplayWidget::updateTime() switch( m_displayMode ) { - case MinutesSeconds: + case DisplayMode::MinutesSeconds: int msec; msec = s->getMilliseconds(); m_majorLCD.setValue(msec / 60000); @@ -98,7 +98,7 @@ void TimeDisplayWidget::updateTime() m_milliSecondsLCD.setValue(msec % 1000); break; - case BarsTicks: + case DisplayMode::BarsTicks: int tick; tick = s->getPlayPos().getTicks(); m_majorLCD.setValue((int)(tick / s->ticksPerBar()) + 1); @@ -119,13 +119,13 @@ void TimeDisplayWidget::mousePressEvent( QMouseEvent* mouseEvent ) { if( mouseEvent->button() == Qt::LeftButton ) { - if( m_displayMode == MinutesSeconds ) + if( m_displayMode == DisplayMode::MinutesSeconds ) { - setDisplayMode( BarsTicks ); + setDisplayMode( DisplayMode::BarsTicks ); } else { - setDisplayMode( MinutesSeconds ); + setDisplayMode( DisplayMode::MinutesSeconds ); } } } diff --git a/src/tracks/AutomationTrack.cpp b/src/tracks/AutomationTrack.cpp index deb6f763cff..e353197f877 100644 --- a/src/tracks/AutomationTrack.cpp +++ b/src/tracks/AutomationTrack.cpp @@ -34,7 +34,7 @@ namespace lmms AutomationTrack::AutomationTrack( TrackContainer* tc, bool _hidden ) : - Track( _hidden ? HiddenAutomationTrack : Track::AutomationTrack, tc ) + Track( _hidden ? Type::HiddenAutomation : Type::Automation, tc ) { setName( tr( "Automation track" ) ); } @@ -77,7 +77,7 @@ void AutomationTrack::saveTrackSpecificSettings( QDomDocument & _doc, void AutomationTrack::loadTrackSpecificSettings( const QDomElement & _this ) { // just in case something somehow wrent wrong... - if( type() == HiddenAutomationTrack ) + if( type() == Type::HiddenAutomation ) { setMuted( false ); } diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index a688aed9ab6..84b73614b86 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -45,7 +45,7 @@ namespace lmms InstrumentTrack::InstrumentTrack( TrackContainer* tc ) : - Track( Track::InstrumentTrack, tc ), + Track( Track::Type::Instrument, tc ), MidiEventProcessor(), m_midiPort( tr( "unnamed_track" ), Engine::audioEngine()->midiClient(), this, this ), @@ -220,7 +220,7 @@ InstrumentTrack::~InstrumentTrack() void InstrumentTrack::processAudioBuffer( sampleFrame* buf, const fpp_t frames, NotePlayHandle* n ) { // we must not play the sound if this InstrumentTrack is muted... - if( isMuted() || ( Engine::getSong()->playMode() != Song::Mode_PlayMidiClip && + if( isMuted() || ( Engine::getSong()->playMode() != Song::PlayMode::MidiClip && n && n->isPatternTrackMuted() ) || ! m_instrument ) { return; @@ -230,7 +230,7 @@ void InstrumentTrack::processAudioBuffer( sampleFrame* buf, const fpp_t frames, // We could do that in all other cases as well but the overhead for silence test is bigger than // what we potentially save. While playing a note, a NotePlayHandle-driven instrument will produce sound in // 99 of 100 cases so that test would be a waste of time. - if( m_instrument->flags().testFlag( Instrument::IsSingleStreamed ) && + if( m_instrument->flags().testFlag( Instrument::Flag::IsSingleStreamed ) && MixHelpers::isSilent( buf, frames ) ) { // at least pass one silent buffer to allow @@ -260,7 +260,7 @@ void InstrumentTrack::processAudioBuffer( sampleFrame* buf, const fpp_t frames, // instruments using instrument-play-handles will call this method // without any knowledge about notes, so they pass NULL for n, which // is no problem for us since we just bypass the envelopes+LFOs - if( m_instrument->flags().testFlag( Instrument::IsSingleStreamed ) == false && n != nullptr ) + if( m_instrument->flags().testFlag( Instrument::Flag::IsSingleStreamed ) == false && n != nullptr ) { const f_cnt_t offset = n->noteOffset(); m_soundShaping.processAudioBuffer( buf + offset, frames - offset, n ); @@ -343,7 +343,7 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const TimePos& tim typeInfo::max() / 2, Note( TimePos(), TimePos(), event.key(), event.volume( midiPort()->baseVelocity() ) ), nullptr, event.channel(), - NotePlayHandle::OriginMidiInput ); + NotePlayHandle::Origin::MidiInput ); m_notes[event.key()] = nph; if( ! Engine::audioEngine()->addPlayHandle( nph ) ) { @@ -363,7 +363,7 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const TimePos& tim m_notes[event.key()]->noteOff( offset ); if (isSustainPedalPressed() && m_notes[event.key()]->origin() == - m_notes[event.key()]->OriginMidiInput) + NotePlayHandle::Origin::MidiInput) { m_sustainedNotes << m_notes[event.key()]; } @@ -403,7 +403,7 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const TimePos& tim if (nph && nph->isReleased()) { if( nph->origin() == - nph->OriginMidiInput) + NotePlayHandle::Origin::MidiInput) { nph->setLength( TimePos( static_cast( @@ -536,10 +536,10 @@ void InstrumentTrack::silenceAllNotes( bool removeIPH ) // invalidate all NotePlayHandles and PresetPreviewHandles linked to this track m_processHandles.clear(); - quint8 flags = PlayHandle::TypeNotePlayHandle | PlayHandle::TypePresetPreviewHandle; + auto flags = PlayHandle::Type::NotePlayHandle | PlayHandle::Type::PresetPreviewHandle; if( removeIPH ) { - flags |= PlayHandle::TypeInstrumentPlayHandle; + flags |= PlayHandle::Type::InstrumentPlayHandle; } Engine::audioEngine()->removePlayHandlesOfTypes( this, flags ); Engine::audioEngine()->doneChangeInModel(); @@ -726,7 +726,7 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, auto c = dynamic_cast(clip); // everything which is not a MIDI clip won't be played // A MIDI clip playing in the Piano Roll window will always play - if (c == nullptr || (Engine::getSong()->playMode() != Song::Mode_PlayMidiClip && clip->isMuted())) + if (c == nullptr || (Engine::getSong()->playMode() != Song::PlayMode::MidiClip && clip->isMuted())) { continue; } diff --git a/src/tracks/MidiClip.cpp b/src/tracks/MidiClip.cpp index 4fa2af5d8a8..b35979f61f8 100644 --- a/src/tracks/MidiClip.cpp +++ b/src/tracks/MidiClip.cpp @@ -48,7 +48,7 @@ QPixmap * gui::MidiClipView::s_stepBtnOffLight = nullptr; MidiClip::MidiClip( InstrumentTrack * _instrument_track ) : Clip( _instrument_track ), m_instrumentTrack( _instrument_track ), - m_clipType( BeatClip ), + m_clipType( Type::BeatClip ), m_steps( TimePos::stepsPerBar() ) { if (_instrument_track->trackContainer() == Engine::patternStore()) @@ -76,11 +76,11 @@ MidiClip::MidiClip( const MidiClip& other ) : init(); switch( getTrack()->trackContainer()->type() ) { - case TrackContainer::PatternContainer: + case TrackContainer::Type::Pattern: setAutoResize( true ); break; - case TrackContainer::SongContainer: + case TrackContainer::Type::Song: // move down default: setAutoResize( false ); @@ -111,7 +111,7 @@ void MidiClip::resizeToFirstTrack() m_instrumentTrack->trackContainer()->tracks(); for (const auto& track : tracks) { - if (track->type() == Track::InstrumentTrack) + if (track->type() == Track::Type::Instrument) { if (track != m_instrumentTrack) { @@ -144,7 +144,7 @@ void MidiClip::init() void MidiClip::updateLength() { - if( m_clipType == BeatClip ) + if( m_clipType == Type::BeatClip ) { changeLength( beatClipLength() ); updatePatternTrack(); @@ -337,10 +337,10 @@ void MidiClip::splitNotes(NoteVector notes, TimePos pos) -void MidiClip::setType( MidiClipTypes _new_clip_type ) +void MidiClip::setType( Type _new_clip_type ) { - if( _new_clip_type == BeatClip || - _new_clip_type == MelodyClip ) + if( _new_clip_type == Type::BeatClip || + _new_clip_type == Type::MelodyClip ) { m_clipType = _new_clip_type; } @@ -355,11 +355,11 @@ void MidiClip::checkType() { if (note->length() > 0) { - setType(MelodyClip); + setType(Type::MelodyClip); return; } } - setType( BeatClip ); + setType( Type::BeatClip ); } @@ -367,7 +367,7 @@ void MidiClip::checkType() void MidiClip::saveSettings( QDomDocument & _doc, QDomElement & _this ) { - _this.setAttribute( "type", m_clipType ); + _this.setAttribute( "type", static_cast(m_clipType) ); _this.setAttribute( "name", name() ); if( usesCustomClipColor() ) @@ -401,7 +401,7 @@ void MidiClip::saveSettings( QDomDocument & _doc, QDomElement & _this ) void MidiClip::loadSettings( const QDomElement & _this ) { - m_clipType = static_cast( _this.attribute( "type" + m_clipType = static_cast( _this.attribute( "type" ).toInt() ); setName( _this.attribute( "name" ) ); diff --git a/src/tracks/PatternTrack.cpp b/src/tracks/PatternTrack.cpp index cdcd108ff0c..bdde4780c50 100644 --- a/src/tracks/PatternTrack.cpp +++ b/src/tracks/PatternTrack.cpp @@ -41,7 +41,7 @@ PatternTrack::infoMap PatternTrack::s_infoMap; PatternTrack::PatternTrack(TrackContainer* tc) : - Track(Track::PatternTrack, tc) + Track(Track::Type::Pattern, tc) { int patternNum = s_infoMap.size(); s_infoMap[this] = patternNum; @@ -61,9 +61,9 @@ PatternTrack::PatternTrack(TrackContainer* tc) : PatternTrack::~PatternTrack() { Engine::audioEngine()->removePlayHandlesOfTypes( this, - PlayHandle::TypeNotePlayHandle - | PlayHandle::TypeInstrumentPlayHandle - | PlayHandle::TypeSamplePlayHandle ); + PlayHandle::Type::NotePlayHandle + | PlayHandle::Type::InstrumentPlayHandle + | PlayHandle::Type::SamplePlayHandle ); const int pattern = s_infoMap[this]; Engine::patternStore()->removePattern(pattern); diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index af5cbef6d15..876cb307fdd 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -45,7 +45,7 @@ namespace lmms SampleTrack::SampleTrack(TrackContainer* tc) : - Track(Track::SampleTrack, tc), + Track(Track::Type::Sample, tc), m_volumeModel(DefaultVolume, MinVolume, MaxVolume, 0.1f, this, tr("Volume")), m_panningModel(DefaultPanning, PanningLeft, PanningRight, 0.1f, this, tr("Panning")), m_mixerChannelModel(0, 0, 0, this, tr("Mixer channel")), @@ -64,7 +64,7 @@ SampleTrack::SampleTrack(TrackContainer* tc) : SampleTrack::~SampleTrack() { - Engine::audioEngine()->removePlayHandlesOfTypes( this, PlayHandle::TypeSamplePlayHandle ); + Engine::audioEngine()->removePlayHandlesOfTypes( this, PlayHandle::Type::SamplePlayHandle ); } @@ -229,7 +229,7 @@ void SampleTrack::loadTrackSpecificSettings( const QDomElement & _this ) void SampleTrack::updateClips() { - Engine::audioEngine()->removePlayHandlesOfTypes( this, PlayHandle::TypeSamplePlayHandle ); + Engine::audioEngine()->removePlayHandlesOfTypes( this, PlayHandle::Type::SamplePlayHandle ); setPlayingClips( false ); } diff --git a/tests/src/core/ProjectVersionTest.cpp b/tests/src/core/ProjectVersionTest.cpp index 2d066dca543..387d9005660 100644 --- a/tests/src/core/ProjectVersionTest.cpp +++ b/tests/src/core/ProjectVersionTest.cpp @@ -34,13 +34,13 @@ private slots: { using namespace lmms; - QVERIFY(ProjectVersion("1.1.0", ProjectVersion::Minor) > "1.0.3"); - QVERIFY(ProjectVersion("1.1.0", ProjectVersion::Major) < "2.1.0"); - QVERIFY(ProjectVersion("1.1.0", ProjectVersion::Release) > "0.2.1"); - QVERIFY(ProjectVersion("1.1.4", ProjectVersion::Release) < "1.1.10"); - QVERIFY(ProjectVersion("1.1.0", ProjectVersion::Minor) == "1.1.5"); - QVERIFY( ! ( ProjectVersion("3.1.0", ProjectVersion::Minor) < "2.2.5" ) ); - QVERIFY( ! ( ProjectVersion("2.5.0", ProjectVersion::Release) < "2.2.5" ) ); + QVERIFY(ProjectVersion("1.1.0", ProjectVersion::CompareType::Minor) > "1.0.3"); + QVERIFY(ProjectVersion("1.1.0", ProjectVersion::CompareType::Major) < "2.1.0"); + QVERIFY(ProjectVersion("1.1.0", ProjectVersion::CompareType::Release) > "0.2.1"); + QVERIFY(ProjectVersion("1.1.4", ProjectVersion::CompareType::Release) < "1.1.10"); + QVERIFY(ProjectVersion("1.1.0", ProjectVersion::CompareType::Minor) == "1.1.5"); + QVERIFY( ! ( ProjectVersion("3.1.0", ProjectVersion::CompareType::Minor) < "2.2.5" ) ); + QVERIFY( ! ( ProjectVersion("2.5.0", ProjectVersion::CompareType::Release) < "2.2.5" ) ); //A pre-release version has lower precedence than a normal version QVERIFY(ProjectVersion("1.1.0") > "1.1.0-alpha"); //But higher precedence than the previous version @@ -62,7 +62,7 @@ private slots: QVERIFY(ProjectVersion("1.2.3.42") == "1.2.3"); //CompareVersion "All" should compare every identifier QVERIFY( - ProjectVersion("1.0.0-a.b.c.d.e.f.g.h.i.j.k.l", ProjectVersion::All) + ProjectVersion("1.0.0-a.b.c.d.e.f.g.h.i.j.k.l", ProjectVersion::CompareType::All) < "1.0.0-a.b.c.d.e.f.g.h.i.j.k.m" ); //Prerelease identifiers may contain hyphens diff --git a/tests/src/tracks/AutomationTrackTest.cpp b/tests/src/tracks/AutomationTrackTest.cpp index 2bf8759920b..05f345f8b8f 100644 --- a/tests/src/tracks/AutomationTrackTest.cpp +++ b/tests/src/tracks/AutomationTrackTest.cpp @@ -52,7 +52,7 @@ private slots: using namespace lmms; AutomationClip c(nullptr); - c.setProgressionType(AutomationClip::LinearProgression); + c.setProgressionType(AutomationClip::ProgressionType::Linear); c.putValue(0, 0.0, false); c.putValue(100, 1.0, false); @@ -69,7 +69,7 @@ private slots: using namespace lmms; AutomationClip c(nullptr); - c.setProgressionType(AutomationClip::DiscreteProgression); + c.setProgressionType(AutomationClip::ProgressionType::Discrete); c.putValue(0, 0.0, false); c.putValue(100, 1.0, false); @@ -89,14 +89,14 @@ private slots: AutomationTrack track(song); AutomationClip c1(&track); - c1.setProgressionType(AutomationClip::LinearProgression); + c1.setProgressionType(AutomationClip::ProgressionType::Linear); c1.putValue(0, 0.0, false); c1.putValue(10, 1.0, false); c1.movePosition(0); c1.addObject(&model); AutomationClip c2(&track); - c2.setProgressionType(AutomationClip::LinearProgression); + c2.setProgressionType(AutomationClip::ProgressionType::Linear); c2.putValue(0, 0.0, false); c2.putValue(100, 1.0, false); c2.movePosition(100); @@ -125,7 +125,7 @@ private slots: AutomationTrack track(song); AutomationClip c(&track); - c.setProgressionType(AutomationClip::LinearProgression); + c.setProgressionType(AutomationClip::ProgressionType::Linear); c.addObject(&model); c.putValue(0, 0.0, false); @@ -149,7 +149,7 @@ private slots: auto song = Engine::getSong(); InstrumentTrack* instrumentTrack = - dynamic_cast(Track::create(Track::InstrumentTrack, song)); + dynamic_cast(Track::create(Track::Type::Instrument, song)); MidiClip* midiClip = dynamic_cast(instrumentTrack->createClip(0)); midiClip->changeLength(TimePos(4, 0)); @@ -158,7 +158,7 @@ private slots: DetuningHelper* dh = note->detuning(); auto clip = dh->automationClip(); - clip->setProgressionType( AutomationClip::LinearProgression ); + clip->setProgressionType( AutomationClip::ProgressionType::Linear ); clip->putValue(TimePos(0, 0), 0.0); clip->putValue(TimePos(4, 0), 1.0); @@ -175,7 +175,7 @@ private slots: auto song = Engine::getSong(); auto patternStore = Engine::patternStore(); PatternTrack patternTrack(song); - Track* automationTrack = Track::create(Track::AutomationTrack, patternStore); + Track* automationTrack = Track::create(Track::Type::Automation, patternStore); QVERIFY(automationTrack->numOfClips()); AutomationClip* c1 = dynamic_cast(automationTrack->getClip(0)); @@ -183,7 +183,7 @@ private slots: FloatModel model; - c1->setProgressionType(AutomationClip::LinearProgression); + c1->setProgressionType(AutomationClip::ProgressionType::Linear); c1->putValue(0, 0.0, false); c1->putValue(10, 1.0, false); c1->addObject(&model); @@ -222,8 +222,8 @@ private slots: AutomationClip localClip(&localTrack); FloatModel model; - globalClip.setProgressionType(AutomationClip::DiscreteProgression); - localClip.setProgressionType(AutomationClip::DiscreteProgression); + globalClip.setProgressionType(AutomationClip::ProgressionType::Discrete); + localClip.setProgressionType(AutomationClip::ProgressionType::Discrete); globalClip.addObject(&model); localClip.addObject(&model); globalClip.putValue(0, 100.0f, false);