Macro cleanup (#6095)

Summary:

* `NULL` -> `nullptr`
* `gui` -> Function `getGUI()`
* `pluginFactory` -> Function `getPluginFactory()`
* `assert` (redefinition) -> using `NDEBUG` instead, which standard `assert` respects.
* `powf` (C stdlib symbol clash) -> removed and all expansions replaced with calls to `std::pow`.
* `exp10` (nonstandard function symbol clash) -> removed and all expansions replaced with calls to `std::pow`.
* `PATH_DEV_DSP` -> File-scope QString of identical name and value.
* `VST_SNC_SHM_KEY_FILE` -> constexpr char* with identical name and value.
* `MM_ALLOC` and `MM_FREE` -> Functions with identical name and implementation.
* `INVAL`, `OUTVAL`, etc. for automation nodes -> Functions with identical names and implementations.
* BandLimitedWave.h: All integer constant macros replaced with constexpr ints of same name and value.
* `FAST_RAND_MAX` -> constexpr int of same name and value.
* `QSTR_TO_STDSTR` -> Function with identical name and equivalent implementation.
* `CCONST` -> constexpr function template with identical name and implementation.
* `F_OPEN_UTF8` -> Function with identical name and equivalent implementation.
* `LADSPA_PATH_SEPARATOR` -> constexpr char with identical name and value.
* `UI_CTRL_KEY` -> constexpr char* with identical name and value.
* `ALIGN_SIZE` -> Renamed to `LMMS_ALIGN_SIZE` and converted from a macro to a constexpr size_t.
* `JACK_MIDI_BUFFER_MAX` -> constexpr size_t with identical name and value.
* versioninfo.h: `PLATFORM`, `MACHINE` and `COMPILER_VERSION` -> prefixed with `LMMS_BUILDCONF_` and converted from macros to constexpr char* literals.
* Header guard _OSCILLOSCOPE -> renamed to OSCILLOSCOPE_H
* Header guard _TIME_DISPLAY_WIDGET -> renamed to TIME_DISPLAY_WIDGET_H
* C-style typecasts in DrumSynth.cpp have been replaced with `static_cast`.
* constexpr numerical constants are initialized with assignment notation instead of curly brace intializers.
* In portsmf, `Alg_seq::operator[]` will throw an exception instead of returning null if the operator index is out of range.

Additionally, in many places, global constants that were declared as `const T foo = bar;` were changed from const to constexpr, leaving them const and making them potentially evaluable at compile time.

Some macros that only appeared in single source files and were unused in those files have been removed entirely.
This commit is contained in:
Levin Oehlmann
2021-09-30 18:01:27 +02:00
committed by GitHub
parent 32b454fbec
commit f742710758
291 changed files with 1807 additions and 1762 deletions

View File

@@ -37,6 +37,7 @@
#include "Note.h"
#include "FifoBuffer.h"
#include "AudioEngineProfiler.h"
#include "PlayHandle.h"
class AudioDevice;
@@ -283,7 +284,7 @@ public:
inline bool hasFifoWriter() const
{
return m_fifoWriter != NULL;
return m_fifoWriter != nullptr;
}
void pushInputFrames( sampleFrame * _ab, const f_cnt_t _frames );

View File

@@ -47,7 +47,8 @@ public:
Dynamic // jobs can be added while processing queue
} ;
#define JOB_QUEUE_SIZE 8192
static constexpr size_t JOB_QUEUE_SIZE = 8192;
JobQueue() :
m_items(),
m_writeIndex( 0 ),

View File

@@ -42,8 +42,8 @@ class AudioPort : public ThreadableJob
MM_OPERATORS
public:
AudioPort( const QString & _name, bool _has_effect_chain = true,
FloatModel * volumeModel = NULL, FloatModel * panningModel = NULL,
BoolModel * mutedModel = NULL );
FloatModel * volumeModel = nullptr, FloatModel * panningModel = nullptr,
BoolModel * mutedModel = nullptr );
virtual ~AudioPort();
inline sampleFrame * buffer()

View File

@@ -120,7 +120,7 @@ public:
bool isAutomated() const;
bool isAutomatedOrControlled() const
{
return isAutomated() || m_controllerConnection != NULL;
return isAutomated() || m_controllerConnection != nullptr;
}
ControllerConnection* controllerConnection() const
@@ -326,7 +326,7 @@ protected:
const float min = 0,
const float max = 0,
const float step = 0,
Model* parent = NULL,
Model* parent = nullptr,
const QString& displayName = QString(),
bool defaultConstructed = false );
//! returns a value which is in range between min() and
@@ -457,7 +457,7 @@ class LMMS_EXPORT FloatModel : public TypedAutomatableModel<float>
MODEL_IS_VISITABLE
public:
FloatModel( float val = 0, float min = 0, float max = 0, float step = 0,
Model * parent = NULL,
Model * parent = nullptr,
const QString& displayName = QString(),
bool defaultConstructed = false ) :
TypedAutomatableModel( val, min, max, step, parent, displayName, defaultConstructed )
@@ -475,7 +475,7 @@ class LMMS_EXPORT IntModel : public TypedAutomatableModel<int>
MODEL_IS_VISITABLE
public:
IntModel( int val = 0, int min = 0, int max = 0,
Model* parent = NULL,
Model* parent = nullptr,
const QString& displayName = QString(),
bool defaultConstructed = false ) :
TypedAutomatableModel( val, min, max, 1, parent, displayName, defaultConstructed )
@@ -491,7 +491,7 @@ class LMMS_EXPORT BoolModel : public TypedAutomatableModel<bool>
MODEL_IS_VISITABLE
public:
BoolModel( const bool val = false,
Model* parent = NULL,
Model* parent = nullptr,
const QString& displayName = QString(),
bool defaultConstructed = false ) :
TypedAutomatableModel( val, false, true, 1, parent, displayName, defaultConstructed )

View File

@@ -26,14 +26,6 @@
#ifndef AUTOMATION_NODE_H
#define AUTOMATION_NODE_H
// MACROs to help handling automation nodes
#define INVAL(x) ((x).value().getInValue())
#define OUTVAL(x) ((x).value().getOutValue())
#define OFFSET(x) ((x).value().getValueOffset())
#define INTAN(x) ((x).value().getInTangent())
#define OUTTAN(x) ((x).value().getOutTangent())
#define POS(x) ((x).key())
class AutomationPattern;

View File

@@ -53,6 +53,8 @@ public:
typedef QMap<int, AutomationNode> timeMap;
typedef QVector<QPointer<AutomatableModel>> objectVector;
using TimemapIterator = timeMap::const_iterator;
AutomationPattern( AutomationTrack * _auto_track );
AutomationPattern( const AutomationPattern & _pat_to_copy );
virtual ~AutomationPattern() = default;
@@ -207,5 +209,37 @@ private:
} ;
//Short-hand functions to access node values in an automation pattern;
// replacement for CPP macros with the same purpose; could be refactored
// further in the future.
inline float INVAL(AutomationPattern::TimemapIterator it)
{
return it->getInValue();
}
inline float OUTVAL(AutomationPattern::TimemapIterator it)
{
return it->getOutValue();
}
inline float OFFSET(AutomationPattern::TimemapIterator it)
{
return it->getValueOffset();
}
inline float INTAN(AutomationPattern::TimemapIterator it)
{
return it->getInTangent();
}
inline float OUTTAN(AutomationPattern::TimemapIterator it)
{
return it->getOutTangent();
}
inline int POS(AutomationPattern::TimemapIterator it)
{
return it.key();
}
#endif

View File

@@ -36,12 +36,12 @@ class QString;
#include "Engine.h"
#include "AudioEngine.h"
#define MAXLEN 11
#define MIPMAPSIZE 2 << ( MAXLEN + 1 )
#define MIPMAPSIZE3 3 << ( MAXLEN + 1 )
#define MAXTBL 23
#define MINTLEN 2 << 0
#define MAXTLEN 3 << MAXLEN
constexpr int MAXLEN = 11;
constexpr int MIPMAPSIZE = 2 << ( MAXLEN + 1 );
constexpr int MIPMAPSIZE3 = 3 << ( MAXLEN + 1 );
constexpr int MAXTBL = 23;
constexpr int MINTLEN = 2 << 0;
constexpr int MAXTLEN = 3 << MAXLEN;
// table for table sizes
const int TLENS[MAXTBL+1] = { 2 << 0, 3 << 0, 2 << 1, 3 << 1,

View File

@@ -273,7 +273,7 @@ public:
m_type = _idx == DoubleLowPass
? LowPass
: Moog;
if( m_subFilter == NULL )
if( m_subFilter == nullptr )
{
m_subFilter = new BasicFilters<CHANNELS>(
static_cast<sample_rate_t>(
@@ -286,7 +286,7 @@ public:
m_doubleFilter( false ),
m_sampleRate( (float) _sample_rate ),
m_sampleRatio( 1.0f / m_sampleRate ),
m_subFilter( NULL )
m_subFilter( nullptr )
{
clearHistory();
}

View File

@@ -36,7 +36,7 @@ class LMMS_EXPORT ComboBox : public QWidget, public IntModelView
{
Q_OBJECT
public:
ComboBox( QWidget* parent = NULL, const QString& name = QString() );
ComboBox( QWidget* parent = nullptr, const QString& name = QString() );
virtual ~ComboBox();
ComboBoxModel* model()

View File

@@ -39,7 +39,7 @@ class LMMS_EXPORT ComboBoxModel : public IntModel
Q_OBJECT
MODEL_IS_VISITABLE
public:
ComboBoxModel( Model* parent = NULL,
ComboBoxModel( Model* parent = nullptr,
const QString& displayName = QString(),
bool isDefaultConstructed = false ) :
IntModel( 0, 0, 0, parent, displayName, isDefaultConstructed )

View File

@@ -60,7 +60,7 @@ class LMMS_EXPORT ConfigManager : public QObject
public:
static inline ConfigManager * inst()
{
if(s_instanceOfMe == NULL )
if(s_instanceOfMe == nullptr )
{
s_instanceOfMe = new ConfigManager();
}

View File

@@ -9,9 +9,9 @@ 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 = NULL, const QString & _name = QString(), const QString & _value_text = QString() );
CustomTextKnob( knobTypes _knob_num, QWidget * _parent = nullptr, const QString & _name = QString(), const QString & _value_text = QString() );
CustomTextKnob( QWidget * _parent = NULL, const QString & _name = QString(), const QString & _value_text = QString() ); //!< default ctor
CustomTextKnob( QWidget * _parent = nullptr, const QString & _name = QString(), const QString & _value_text = QString() ); //!< default ctor
CustomTextKnob( const Knob& other ) = delete;

View File

@@ -72,7 +72,7 @@ public:
m_delay( 0 ),
m_fraction( 0.0 )
{
m_buffer = MM_ALLOC( frame, maxDelay );
m_buffer = MM_ALLOC<frame>(maxDelay );
memset( m_buffer, 0, sizeof( frame ) * maxDelay );
}
virtual ~CombFeedback()
@@ -85,7 +85,7 @@ public:
if( maxDelay > m_size )
{
MM_FREE( m_buffer );
m_buffer = MM_ALLOC( frame, maxDelay );
m_buffer = MM_ALLOC<frame>( maxDelay );
memset( m_buffer, 0, sizeof( frame ) * maxDelay );
}
m_size = maxDelay;
@@ -143,7 +143,7 @@ class CombFeedfwd
m_delay( 0 ),
m_fraction( 0.0 )
{
m_buffer = MM_ALLOC( frame, maxDelay );
m_buffer = MM_ALLOC<frame>( maxDelay );
memset( m_buffer, 0, sizeof( frame ) * maxDelay );
}
virtual ~CombFeedfwd()
@@ -156,7 +156,7 @@ class CombFeedfwd
if( maxDelay > m_size )
{
MM_FREE( m_buffer );
m_buffer = MM_ALLOC( frame, maxDelay );
m_buffer = MM_ALLOC<frame>( maxDelay );
memset( m_buffer, 0, sizeof( frame ) * maxDelay );
}
m_size = maxDelay;
@@ -214,7 +214,7 @@ class CombFeedbackDualtap
m_delay( 0 ),
m_fraction( 0.0 )
{
m_buffer = MM_ALLOC( frame, maxDelay );
m_buffer = MM_ALLOC<frame>( maxDelay );
memset( m_buffer, 0, sizeof( frame ) * maxDelay );
}
virtual ~CombFeedbackDualtap()
@@ -227,7 +227,7 @@ class CombFeedbackDualtap
if( maxDelay > m_size )
{
MM_FREE( m_buffer );
m_buffer = MM_ALLOC( frame, maxDelay );
m_buffer = MM_ALLOC<frame>( maxDelay );
memset( m_buffer, 0, sizeof( frame ) * maxDelay );
}
m_size = maxDelay;
@@ -295,7 +295,7 @@ public:
m_delay( 0 ),
m_fraction( 0.0 )
{
m_buffer = MM_ALLOC( frame, maxDelay );
m_buffer = MM_ALLOC<frame>( maxDelay );
memset( m_buffer, 0, sizeof( frame ) * maxDelay );
}
virtual ~AllpassDelay()
@@ -308,7 +308,7 @@ public:
if( maxDelay > m_size )
{
MM_FREE( m_buffer );
m_buffer = MM_ALLOC( frame, maxDelay );
m_buffer = MM_ALLOC<frame>( maxDelay );
memset( m_buffer, 0, sizeof( frame ) * maxDelay );
}
m_size = maxDelay;

View File

@@ -84,7 +84,7 @@ class DummyEffect : public Effect
Q_OBJECT
public:
DummyEffect( Model * _parent, const QDomElement& originalPluginData ) :
Effect( NULL, _parent, NULL ),
Effect( nullptr, _parent, nullptr ),
m_controls( this ),
m_originalPluginData( originalPluginData )
{

View File

@@ -39,7 +39,7 @@ class DummyInstrument : public Instrument
{
public:
DummyInstrument( InstrumentTrack * _instrument_track ) :
Instrument( _instrument_track, NULL )
Instrument( _instrument_track, nullptr )
{
}

View File

@@ -34,7 +34,7 @@ class DummyPlugin : public Plugin
{
public:
DummyPlugin() :
Plugin( NULL, NULL )
Plugin( nullptr, nullptr )
{
}

View File

@@ -43,7 +43,7 @@ class EffectRackView : public QWidget, public ModelView
{
Q_OBJECT
public:
EffectRackView( EffectChain* model, QWidget* parent = NULL );
EffectRackView( EffectChain* model, QWidget* parent = nullptr );
virtual ~EffectRackView();
static constexpr int DEFAULT_WIDTH = 245;

View File

@@ -112,7 +112,7 @@ public:
static inline LmmsCore * inst()
{
if( s_instanceOfMe == NULL )
if( s_instanceOfMe == nullptr )
{
s_instanceOfMe = new LmmsCore();
}
@@ -133,7 +133,7 @@ private:
static inline void deleteHelper( T * * ptr )
{
T * tmp = *ptr;
*ptr = NULL;
*ptr = nullptr;
delete tmp;
}

View File

@@ -35,7 +35,7 @@
class LMMS_EXPORT ExportFilter : public Plugin
{
public:
ExportFilter( const Descriptor * _descriptor ) : Plugin( _descriptor, NULL ) {}
ExportFilter( const Descriptor * _descriptor ) : Plugin( _descriptor, nullptr ) {}
virtual ~ExportFilter() {}

View File

@@ -34,7 +34,7 @@ class FxLineLcdSpinBox : public LcdSpinBox
{
Q_OBJECT
public:
FxLineLcdSpinBox(int numDigits, QWidget * parent, const QString& name, TrackView * tv = NULL) :
FxLineLcdSpinBox(int numDigits, QWidget * parent, const QString& name, TrackView * tv = nullptr) :
LcdSpinBox(numDigits, parent, name), m_tv(tv)
{}
virtual ~FxLineLcdSpinBox() {}

View File

@@ -39,7 +39,7 @@ class GroupBox : public QWidget, public BoolModelView
{
Q_OBJECT
public:
GroupBox( const QString & _caption, QWidget * _parent = NULL );
GroupBox( const QString & _caption, QWidget * _parent = nullptr );
virtual ~GroupBox();
void modelChanged() override;

View File

@@ -85,6 +85,7 @@ private:
QLabel* m_loadingProgressLabel;
};
#define gui GuiApplication::instance()
// Short-hand function
LMMS_EXPORT GuiApplication* getGUI();
#endif // GUIAPPLICATION_H

View File

@@ -36,7 +36,7 @@ public:
InlineAutomation() :
FloatModel(),
sharedObject(),
m_autoPattern( NULL )
m_autoPattern( nullptr )
{
}
@@ -52,7 +52,7 @@ public:
bool hasAutomation() const
{
if( m_autoPattern != NULL && m_autoPattern->getTimeMap().isEmpty() == false )
if( m_autoPattern != nullptr && m_autoPattern->getTimeMap().isEmpty() == false )
{
// Prevent saving inline automation if there's just one node at the beginning of
// the pattern, which has a InValue equal to the value of model (which is going
@@ -77,9 +77,9 @@ public:
AutomationPattern * automationPattern()
{
if( m_autoPattern == NULL )
if( m_autoPattern == nullptr )
{
m_autoPattern = new AutomationPattern( NULL );
m_autoPattern = new AutomationPattern( nullptr );
m_autoPattern->addObject( this );
}
return m_autoPattern;

View File

@@ -44,7 +44,7 @@ class InstrumentFunctionNoteStackingView : public QWidget, public ModelView
{
Q_OBJECT
public:
InstrumentFunctionNoteStackingView( InstrumentFunctionNoteStacking* cc, QWidget* parent = NULL );
InstrumentFunctionNoteStackingView( InstrumentFunctionNoteStacking* cc, QWidget* parent = nullptr );
virtual ~InstrumentFunctionNoteStackingView();
@@ -67,7 +67,7 @@ class InstrumentFunctionArpeggioView : public QWidget, public ModelView
{
Q_OBJECT
public:
InstrumentFunctionArpeggioView( InstrumentFunctionArpeggio* arp, QWidget* parent = NULL );
InstrumentFunctionArpeggioView( InstrumentFunctionArpeggio* arp, QWidget* parent = nullptr );
virtual ~InstrumentFunctionArpeggioView();

View File

@@ -48,18 +48,24 @@ std::wstring toWString(const std::string& s)
#ifdef LMMS_BUILD_WIN32
#include <io.h>
#define F_OPEN_UTF8(a, b) _wfopen(toWString(a).data(), L##b)
#else
#ifdef LMMS_HAVE_UNISTD_H
#include <unistd.h>
#endif
#define F_OPEN_UTF8(a, b) fopen((a).data(), b)
#endif
FILE* F_OPEN_UTF8(std::string const& fname, const char* mode){
#ifdef LMMS_BUILD_WIN32
return _wfopen(toWString(fname).data(), toWString(mode).data());
#else
return fopen(fname.data(), mode);
#endif
}
int fileToDescriptor(FILE* f, bool closeFile = true)
{
int fh;
if (f == NULL) {return -1;}
if (f == nullptr) {return -1;}
#ifdef LMMS_BUILD_WIN32
fh = _dup(_fileno(f));

View File

@@ -79,8 +79,8 @@ 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 = NULL, const QString & _name = QString() );
Knob( QWidget * _parent = NULL, const QString & _name = QString() ); //!< default ctor
Knob( knobTypes _knob_num, QWidget * _parent = nullptr, const QString & _name = QString() );
Knob( QWidget * _parent = nullptr, const QString & _name = QString() ); //!< default ctor
Knob( const Knob& other ) = delete;
// TODO: remove

View File

@@ -33,7 +33,7 @@ class LeftRightNav : public QWidget
{
Q_OBJECT
public:
LeftRightNav(QWidget *parent=NULL);
LeftRightNav(QWidget *parent=nullptr);
PixmapButton* getLeftBtn();
PixmapButton* getRightBtn();
void setShortcuts(const QKeySequence &leftShortcut=Qt::Key_Minus, const QKeySequence &rightShortcut=Qt::Key_Plus);

View File

@@ -85,8 +85,18 @@ static void operator delete[] ( void * ptr ) \
}
// for use in cases where overriding new/delete isn't a possibility
#define MM_ALLOC( type, count ) reinterpret_cast<type*>( MemoryManager::alloc( sizeof( type ) * count ) )
template<typename T>
T* MM_ALLOC(size_t count)
{
return reinterpret_cast<T*>(
MemoryManager::alloc(sizeof(T) * count));
}
// and just for symmetry...
#define MM_FREE( ptr ) MemoryManager::free( ptr )
template<typename T>
void MM_FREE(T* ptr)
{
MemoryManager::free(ptr);
}
#endif

View File

@@ -44,7 +44,7 @@ public:
m_type( type ),
m_metaEvent( MidiMetaInvalid ),
m_channel( channel ),
m_sysExData( NULL ),
m_sysExData( nullptr ),
m_sourcePort(sourcePort),
m_source(source)
{

View File

@@ -42,7 +42,7 @@
#include "MidiClient.h"
#include "AudioJack.h"
#define JACK_MIDI_BUFFER_MAX 64 /* events */
constexpr size_t JACK_MIDI_BUFFER_MAX = 64; /* events */
class QLineEdit;

View File

@@ -71,7 +71,7 @@ public:
MidiPort( const QString& name,
MidiClient* client,
MidiEventProcessor* eventProcessor,
Model* parent = NULL,
Model* parent = nullptr,
Mode mode = Disabled );
virtual ~MidiPort();

View File

@@ -91,7 +91,7 @@ public:
int key = DefaultKey,
volume_t volume = DefaultVolume,
panning_t panning = DefaultPanning,
DetuningHelper * detuning = NULL );
DetuningHelper * detuning = nullptr );
Note( const Note & note );
virtual ~Note();

View File

@@ -67,7 +67,7 @@ public:
const f_cnt_t offset,
const f_cnt_t frames,
const Note& noteToPlay,
NotePlayHandle* parent = NULL,
NotePlayHandle* parent = nullptr,
int midiEventChannel = -1,
Origin origin = OriginPattern );
virtual ~NotePlayHandle();
@@ -344,7 +344,7 @@ public:
const f_cnt_t offset,
const f_cnt_t frames,
const Note& noteToPlay,
NotePlayHandle* parent = NULL,
NotePlayHandle* parent = nullptr,
int midiEventChannel = -1,
NotePlayHandle::Origin origin = NotePlayHandle::OriginPattern );
static void release( NotePlayHandle * nph );

View File

@@ -23,8 +23,8 @@
*/
#ifndef _OSCILLOSCOPE
#define _OSCILLOSCOPE
#ifndef OSCILLOSCOPE_H
#define OSCILLOSCOPE_H
#include <QWidget>
#include <QPixmap>
@@ -73,4 +73,4 @@ private:
QColor m_clippingColor;
} ;
#endif
#endif // OSCILLOSCOPE_H

View File

@@ -41,7 +41,7 @@ class LMMS_EXPORT PeakController : public Controller
Q_OBJECT
public:
PeakController( Model * _parent,
PeakControllerEffect *_peak_effect = NULL );
PeakControllerEffect *_peak_effect = nullptr );
virtual ~PeakController();

View File

@@ -137,7 +137,7 @@ public:
bool hasValidPattern() const
{
return m_pattern != NULL;
return m_pattern != nullptr;
}
Song::PlayModes desiredPlayModeForAccompany() const;

View File

@@ -29,9 +29,9 @@
typedef int16_t pitch_t;
const pitch_t CentsPerSemitone = 100;
const pitch_t MinPitchDefault = -CentsPerSemitone;
const pitch_t MaxPitchDefault = CentsPerSemitone;
const pitch_t DefaultPitch = 0;
constexpr pitch_t CentsPerSemitone = 100;
constexpr pitch_t MinPitchDefault = -CentsPerSemitone;
constexpr pitch_t MaxPitchDefault = CentsPerSemitone;
constexpr pitch_t DefaultPitch = 0;
#endif

View File

@@ -130,7 +130,7 @@ public:
{
typedef QMap<QString, QString> AttributeMap;
inline Key( const Plugin::Descriptor * desc = NULL,
inline Key( const Plugin::Descriptor * desc = nullptr,
const QString & name = QString(),
const AttributeMap & am = AttributeMap()
)

View File

@@ -103,6 +103,7 @@ private:
static std::unique_ptr<PluginFactory> s_instance;
};
#define pluginFactory PluginFactory::instance()
//Short-hand function
LMMS_EXPORT PluginFactory* getPluginFactory();
#endif // PLUGINFACTORY_H

View File

@@ -74,7 +74,7 @@ public:
// restoring a journalling object later
void freeID( const jo_id_t _id )
{
reallocID( _id, NULL );
reallocID( _id, nullptr );
}
//! hack, not used when saving a file
@@ -90,7 +90,7 @@ public:
{
return m_joIDs[_id];
}
return NULL;
return nullptr;
}

View File

@@ -64,7 +64,7 @@ public:
bool isReady() const
{
return m_fileDev != NULL;
return m_fileDev != nullptr;
}
static ExportFileFormats getFileFormatFromExtension(

View File

@@ -92,6 +92,7 @@ typedef int32_t key_t;
#include <QtCore/QMutex>
#include <QtCore/QProcess>
#include <QtCore/QThread>
#include <QtCore/QString>
#ifndef SYNC_WITH_SHM_FIFO
#include <poll.h>
@@ -137,7 +138,7 @@ public:
#else
m_shmID( -1 ),
#endif
m_data( NULL ),
m_data( nullptr ),
m_dataSem( QString() ),
m_messageSem( QString() ),
m_lockDepth( 0 )
@@ -157,7 +158,7 @@ public:
}
m_data = (shmData *) shmat( m_shmID, 0, 0 );
#endif
assert( m_data != NULL );
assert( m_data != nullptr );
m_data->startPtr = m_data->endPtr = 0;
static int k = 0;
m_data->dataSem.semKey = ( getpid()<<10 ) + ++k;
@@ -180,7 +181,7 @@ public:
#else
m_shmID( shmget( _shm_key, 0, 0 ) ),
#endif
m_data( NULL ),
m_data( nullptr ),
m_dataSem( QString() ),
m_messageSem( QString() ),
m_lockDepth( 0 )
@@ -196,7 +197,7 @@ public:
m_data = (shmData *) shmat( m_shmID, 0, 0 );
}
#endif
assert( m_data != NULL );
assert( m_data != nullptr );
m_dataSem.setKey( QString::number( m_data->dataSem.semKey ) );
m_messageSem.setKey( QString::number(
m_data->messageSem.semKey ) );
@@ -208,7 +209,7 @@ public:
if( m_master )
{
#ifndef USE_QT_SHMEM
shmctl( m_shmID, IPC_RMID, NULL );
shmctl( m_shmID, IPC_RMID, nullptr );
#endif
}
#ifndef USE_QT_SHMEM
@@ -1031,8 +1032,8 @@ RemotePluginBase::RemotePluginBase() :
setlocale( LC_NUMERIC, "C" );
#endif
#ifndef SYNC_WITH_SHM_FIFO
pthread_mutex_init( &m_receiveMutex, NULL );
pthread_mutex_init( &m_sendMutex, NULL );
pthread_mutex_init( &m_receiveMutex, nullptr );
pthread_mutex_init( &m_sendMutex, nullptr );
#endif
}
@@ -1194,8 +1195,8 @@ RemotePluginClient::RemotePluginClient( const char * socketPath ) :
m_shmObj(),
m_shmQtID( "/usr/bin/lmms" ),
#endif
m_vstSyncData( NULL ),
m_shm( NULL ),
m_vstSyncData( nullptr ),
m_shm( nullptr ),
m_inputCount( 0 ),
m_outputCount( 0 ),
m_sampleRate( 44100 ),
@@ -1400,10 +1401,10 @@ void RemotePluginClient::setShmKey( key_t _key, int _size )
debugMessage( buf );
}
#else
if( m_shm != NULL )
if( m_shm != nullptr )
{
shmdt( m_shm );
m_shm = NULL;
m_shm = nullptr;
}
// only called for detaching SHM?
@@ -1429,9 +1430,9 @@ void RemotePluginClient::setShmKey( key_t _key, int _size )
void RemotePluginClient::doProcessing()
{
if( m_shm != NULL )
if( m_shm != nullptr )
{
process( (sampleFrame *)( m_inputCount > 0 ? m_shm : NULL ),
process( (sampleFrame *)( m_inputCount > 0 ? m_shm : nullptr ),
(sampleFrame *)( m_shm +
( m_inputCount*m_bufferSize ) ) );
}
@@ -1443,8 +1444,14 @@ void RemotePluginClient::doProcessing()
#endif
#else
#define QSTR_TO_STDSTR(s) std::string( s.toUtf8().constData() )
LMMS_EXPORT inline std::string QSTR_TO_STDSTR(QString const& qstr)
{
return qstr.toStdString();
}
#endif
#endif

View File

@@ -32,7 +32,7 @@ class RmsHelper
{
public:
RmsHelper( int size ) :
m_buffer( NULL )
m_buffer( nullptr )
{
setSize( size );
}

View File

@@ -74,14 +74,14 @@ class SerializingObjectHook
{
public:
SerializingObjectHook() :
m_hookedIn( NULL )
m_hookedIn( nullptr )
{
}
virtual ~SerializingObjectHook()
{
if( m_hookedIn != NULL )
if( m_hookedIn != nullptr )
{
m_hookedIn->setHook( NULL );
m_hookedIn->setHook( nullptr );
}
}

View File

@@ -97,7 +97,7 @@ public:
public:
PlayPos( const int abs = 0 ) :
TimePos( abs ),
m_timeLine( NULL ),
m_timeLine( nullptr ),
m_currentFrame( 0.0f )
{
}

View File

@@ -55,7 +55,7 @@ class LMMS_EXPORT SubWindow : public QMdiSubWindow
Q_PROPERTY( QColor borderColor READ borderColor WRITE setBorderColor )
public:
SubWindow( QWidget *parent = NULL, Qt::WindowFlags windowFlags = QFlag(0) );
SubWindow( QWidget *parent = nullptr, Qt::WindowFlags windowFlags = QFlag(0) );
// same as QWidet::normalGeometry, but works properly under X11 (see https://bugreports.qt.io/browse/QTBUG-256)
QRect getTrueNormalGeometry() const;
QBrush activeColor() const;

View File

@@ -42,7 +42,7 @@ public:
bool usePixmap = false, bool resizable = false );
virtual ~TabWidget() = default;
void addTab( QWidget * w, const QString & name, const char *pixmap = NULL, int idx = -1 );
void addTab( QWidget * w, const QString & name, const char *pixmap = nullptr, int idx = -1 );
void setActiveTab( int idx );

View File

@@ -38,7 +38,7 @@ class LMMS_EXPORT TempoSyncKnob : public Knob
{
Q_OBJECT
public:
TempoSyncKnob( knobTypes knobNum, QWidget* parent = NULL, const QString& name = QString() );
TempoSyncKnob( knobTypes knobNum, QWidget* parent = nullptr, const QString& name = QString() );
virtual ~TempoSyncKnob();
const QString & syncDescription();

View File

@@ -50,14 +50,14 @@ public:
static TextFloat * displayMessage( const QString & _msg,
int _timeout = 2000,
QWidget * _parent = NULL,
QWidget * _parent = nullptr,
int _add_y_margin = 0 );
static TextFloat * displayMessage( const QString & _title,
const QString & _msg,
const QPixmap & _pixmap =
QPixmap(),
int _timeout = 2000,
QWidget * _parent = NULL );
QWidget * _parent = nullptr );
void moveGlobal( QWidget * _w, const QPoint & _offset )
{

View File

@@ -23,8 +23,8 @@
*
*/
#ifndef _TIME_DISPLAY_WIDGET
#define _TIME_DISPLAY_WIDGET
#ifndef TIME_DISPLAY_WIDGET_H
#define TIME_DISPLAY_WIDGET_H
#include <QWidget>
#include <QHBoxLayout>
@@ -67,4 +67,4 @@ private:
} ;
#endif
#endif // TIME_DISPLAY_WIDGET_H

View File

@@ -58,7 +58,7 @@ public:
virtual AutomationPattern * tempoAutomationPattern()
{
return NULL;
return nullptr;
}
int countTracks( Track::TrackTypes _tt = Track::NumTrackTypes ) const;

View File

@@ -34,8 +34,8 @@
//#define VST_SNC_LATENCY
// define file for ftok as shared memory shmget key
#define VST_SNC_SHM_KEY_FILE "/dev/null"
//#define VST_SNC_SHM_RND_KEY 3561653564469
constexpr const char* VST_SNC_SHM_KEY_FILE = "/dev/null";
//constexpr int64_t VST_SNC_SHM_RND_KEY = 3561653564469;

View File

@@ -27,125 +27,132 @@
#define AEFFECTX_H
#include <stdint.h>
#include <type_traits>
// Calling convention
#define VST_CALL_CONV __cdecl
#define CCONST(a, b, c, d)( ( ( (int32_t) a ) << 24 ) | \
( ( (int32_t) b ) << 16 ) | \
( ( (int32_t) c ) << 8 ) | \
( ( (int32_t) d ) << 0 ) )
template<typename T>
constexpr int32_t CCONST(T a, T b, T c, T d)
{
static_assert(std::is_convertible<T,int32_t>::value, "int32 compatibility required.");
return (
static_cast<int32_t>(a) << 24 |
static_cast<int32_t>(b) << 16 |
static_cast<int32_t>(c) << 8 |
static_cast<int32_t>(d) << 0);
}
const int audioMasterAutomate = 0;
const int audioMasterVersion = 1;
const int audioMasterCurrentId = 2;
const int audioMasterIdle = 3;
const int audioMasterPinConnected = 4;
constexpr int audioMasterAutomate = 0;
constexpr int audioMasterVersion = 1;
constexpr int audioMasterCurrentId = 2;
constexpr int audioMasterIdle = 3;
constexpr int audioMasterPinConnected = 4;
// unsupported? 5
const int audioMasterWantMidi = 6;
const int audioMasterGetTime = 7;
const int audioMasterProcessEvents = 8;
const int audioMasterSetTime = 9;
const int audioMasterTempoAt = 10;
const int audioMasterGetNumAutomatableParameters = 11;
const int audioMasterGetParameterQuantization = 12;
const int audioMasterIOChanged = 13;
const int audioMasterNeedIdle = 14;
const int audioMasterSizeWindow = 15;
const int audioMasterGetSampleRate = 16;
const int audioMasterGetBlockSize = 17;
const int audioMasterGetInputLatency = 18;
const int audioMasterGetOutputLatency = 19;
const int audioMasterGetPreviousPlug = 20;
const int audioMasterGetNextPlug = 21;
const int audioMasterWillReplaceOrAccumulate = 22;
const int audioMasterGetCurrentProcessLevel = 23;
const int audioMasterGetAutomationState = 24;
const int audioMasterOfflineStart = 25;
const int audioMasterOfflineRead = 26;
const int audioMasterOfflineWrite = 27;
const int audioMasterOfflineGetCurrentPass = 28;
const int audioMasterOfflineGetCurrentMetaPass = 29;
const int audioMasterSetOutputSampleRate = 30;
constexpr int audioMasterWantMidi = 6;
constexpr int audioMasterGetTime = 7;
constexpr int audioMasterProcessEvents = 8;
constexpr int audioMasterSetTime = 9;
constexpr int audioMasterTempoAt = 10;
constexpr int audioMasterGetNumAutomatableParameters = 11;
constexpr int audioMasterGetParameterQuantization = 12;
constexpr int audioMasterIOChanged = 13;
constexpr int audioMasterNeedIdle = 14;
constexpr int audioMasterSizeWindow = 15;
constexpr int audioMasterGetSampleRate = 16;
constexpr int audioMasterGetBlockSize = 17;
constexpr int audioMasterGetInputLatency = 18;
constexpr int audioMasterGetOutputLatency = 19;
constexpr int audioMasterGetPreviousPlug = 20;
constexpr int audioMasterGetNextPlug = 21;
constexpr int audioMasterWillReplaceOrAccumulate = 22;
constexpr int audioMasterGetCurrentProcessLevel = 23;
constexpr int audioMasterGetAutomationState = 24;
constexpr int audioMasterOfflineStart = 25;
constexpr int audioMasterOfflineRead = 26;
constexpr int audioMasterOfflineWrite = 27;
constexpr int audioMasterOfflineGetCurrentPass = 28;
constexpr int audioMasterOfflineGetCurrentMetaPass = 29;
constexpr int audioMasterSetOutputSampleRate = 30;
// unsupported? 31
const int audioMasterGetSpeakerArrangement = 31; // deprecated in 2.4?
const int audioMasterGetVendorString = 32;
const int audioMasterGetProductString = 33;
const int audioMasterGetVendorVersion = 34;
const int audioMasterVendorSpecific = 35;
const int audioMasterSetIcon = 36;
const int audioMasterCanDo = 37;
const int audioMasterGetLanguage = 38;
const int audioMasterOpenWindow = 39;
const int audioMasterCloseWindow = 40;
const int audioMasterGetDirectory = 41;
const int audioMasterUpdateDisplay = 42;
const int audioMasterBeginEdit = 43;
const int audioMasterEndEdit = 44;
const int audioMasterOpenFileSelector = 45;
const int audioMasterCloseFileSelector = 46; // currently unused
const int audioMasterEditFile = 47; // currently unused
const int audioMasterGetChunkFile = 48; // currently unused
const int audioMasterGetInputSpeakerArrangement = 49; // currently unused
constexpr int audioMasterGetSpeakerArrangement = 31; // deprecated in 2.4?
constexpr int audioMasterGetVendorString = 32;
constexpr int audioMasterGetProductString = 33;
constexpr int audioMasterGetVendorVersion = 34;
constexpr int audioMasterVendorSpecific = 35;
constexpr int audioMasterSetIcon = 36;
constexpr int audioMasterCanDo = 37;
constexpr int audioMasterGetLanguage = 38;
constexpr int audioMasterOpenWindow = 39;
constexpr int audioMasterCloseWindow = 40;
constexpr int audioMasterGetDirectory = 41;
constexpr int audioMasterUpdateDisplay = 42;
constexpr int audioMasterBeginEdit = 43;
constexpr int audioMasterEndEdit = 44;
constexpr int audioMasterOpenFileSelector = 45;
constexpr int audioMasterCloseFileSelector = 46; // currently unused
constexpr int audioMasterEditFile = 47; // currently unused
constexpr int audioMasterGetChunkFile = 48; // currently unused
constexpr int audioMasterGetInputSpeakerArrangement = 49; // currently unused
const int effFlagsHasEditor = 1;
const int effFlagsCanReplacing = 1 << 4; // very likely
const int effFlagsIsSynth = 1 << 8; // currently unused
constexpr int effFlagsHasEditor = 1;
constexpr int effFlagsCanReplacing = 1 << 4; // very likely
constexpr int effFlagsIsSynth = 1 << 8; // currently unused
const int effOpen = 0;
const int effClose = 1; // currently unused
const int effSetProgram = 2; // currently unused
const int effGetProgram = 3; // currently unused
const int effGetProgramName = 5; // currently unused
const int effGetParamLabel = 6;
const int effGetParamDisplay = 7;
const int effGetParamName = 8; // currently unused
const int effSetSampleRate = 10;
const int effSetBlockSize = 11;
const int effMainsChanged = 12;
const int effEditGetRect = 13;
const int effEditOpen = 14;
const int effEditClose = 15;
const int effEditIdle = 19;
const int effEditTop = 20;
const int effSetChunk = 24;
const int effProcessEvents = 25;
const int effGetEffectName = 45;
const int effGetVendorString = 47;
const int effGetProductString = 48;
const int effGetVendorVersion = 49;
const int effCanDo = 51; // currently unused
const int effGetVstVersion = 58; // currently unused
constexpr int effOpen = 0;
constexpr int effClose = 1; // currently unused
constexpr int effSetProgram = 2; // currently unused
constexpr int effGetProgram = 3; // currently unused
constexpr int effGetProgramName = 5; // currently unused
constexpr int effGetParamLabel = 6;
constexpr int effGetParamDisplay = 7;
constexpr int effGetParamName = 8; // currently unused
constexpr int effSetSampleRate = 10;
constexpr int effSetBlockSize = 11;
constexpr int effMainsChanged = 12;
constexpr int effEditGetRect = 13;
constexpr int effEditOpen = 14;
constexpr int effEditClose = 15;
constexpr int effEditIdle = 19;
constexpr int effEditTop = 20;
constexpr int effSetChunk = 24;
constexpr int effProcessEvents = 25;
constexpr int effGetEffectName = 45;
constexpr int effGetVendorString = 47;
constexpr int effGetProductString = 48;
constexpr int effGetVendorVersion = 49;
constexpr int effCanDo = 51; // currently unused
constexpr int effGetVstVersion = 58; // currently unused
const int kEffectMagic = CCONST( 'V', 's', 't', 'P' );
const int kVstLangEnglish = 1;
const int kVstMidiType = 1;
constexpr int kEffectMagic = CCONST( 'V', 's', 't', 'P' );
constexpr int kVstLangEnglish = 1;
constexpr int kVstMidiType = 1;
const int kVstTransportChanged = 1;
const int kVstTransportPlaying = 1 << 1;
const int kVstTransportCycleActive = 1 << 2;
const int kVstTransportRecording = 1 << 3; // currently unused
const int kVstPpqPosValid = 1 << 9;
const int kVstTempoValid = 1 << 10;
const int kVstBarsValid = 1 << 11;
const int kVstCyclePosValid = 1 << 12;
const int kVstTimeSigValid = 1 << 13;
const int kVstSmpteValid = 1 << 14; // currently unused
const int kVstClockValid = 1 << 15; // currently unused
constexpr int kVstTransportChanged = 1;
constexpr int kVstTransportPlaying = 1 << 1;
constexpr int kVstTransportCycleActive = 1 << 2;
constexpr int kVstTransportRecording = 1 << 3; // currently unused
constexpr int kVstPpqPosValid = 1 << 9;
constexpr int kVstTempoValid = 1 << 10;
constexpr int kVstBarsValid = 1 << 11;
constexpr int kVstCyclePosValid = 1 << 12;
constexpr int kVstTimeSigValid = 1 << 13;
constexpr int kVstSmpteValid = 1 << 14; // currently unused
constexpr int kVstClockValid = 1 << 15; // currently unused
// currently unused
const int kVstSmpte24fps = 0;
const int kVstSmpte25fps = 1;
const int kVstSmpte2997fps = 2;
const int kVstSmpte30fps = 3;
const int kVstSmpte2997dfps = 4;
const int kVstSmpte30dfps = 5;
const int kVstSmpteFilm16mm = 6; // very likely
const int kVstSmpteFilm35mm = 7; // very likely
const int kVstSmpte239fps = 10;
const int kVstSmpte249fps = 11;
const int kVstSmpte599fps = 12;
const int kVstSmpte60fps = 13;
constexpr int kVstSmpte24fps = 0;
constexpr int kVstSmpte25fps = 1;
constexpr int kVstSmpte2997fps = 2;
constexpr int kVstSmpte30fps = 3;
constexpr int kVstSmpte2997dfps = 4;
constexpr int kVstSmpte30dfps = 5;
constexpr int kVstSmpteFilm16mm = 6; // very likely
constexpr int kVstSmpteFilm35mm = 7; // very likely
constexpr int kVstSmpte239fps = 10;
constexpr int kVstSmpte249fps = 11;
constexpr int kVstSmpte599fps = 12;
constexpr int kVstSmpte60fps = 13;

View File

@@ -28,16 +28,14 @@
#include "lmmsconfig.h"
// set whether debug-stuff (like messages on the console, asserts and other
// additional range-checkings) should be compiled
#ifdef LMMS_DEBUG
#include <assert.h>
#else
#ifndef assert
#define assert(x) ((void)(x))
#endif
// Define standard macro NDEBUG when building without debug flag to make sure asserts become no-ops.
#ifndef LMMS_DEBUG
#ifndef NDEBUG
#define NDEBUG
#endif
#endif
#include <cassert>
#include <cstdio>

View File

@@ -71,7 +71,7 @@ class PixmapLoader
{
public:
PixmapLoader( const PixmapLoader * _ref ) :
m_name( _ref != NULL ? _ref->m_name : QString() ),
m_name( _ref != nullptr ? _ref->m_name : QString() ),
m_xpm( _ref->m_xpm )
{
}

View File

@@ -109,9 +109,9 @@ inline bool typeInfo<float>::isEqual( float x, float y )
const ch_cnt_t DEFAULT_CHANNELS = 2;
constexpr ch_cnt_t DEFAULT_CHANNELS = 2;
const ch_cnt_t SURROUND_CHANNELS =
constexpr ch_cnt_t SURROUND_CHANNELS =
#define LMMS_DISABLE_SURROUND
#ifndef LMMS_DISABLE_SURROUND
4;
@@ -119,28 +119,29 @@ const ch_cnt_t SURROUND_CHANNELS =
2;
#endif
constexpr char LADSPA_PATH_SEPERATOR =
#ifdef LMMS_BUILD_WIN32
#define LADSPA_PATH_SEPERATOR ';'
';';
#else
#define LADSPA_PATH_SEPERATOR ':'
':';
#endif
using sampleFrame = std::array<sample_t, DEFAULT_CHANNELS>;
using surroundSampleFrame = std::array<sample_t, SURROUND_CHANNELS>;
#define ALIGN_SIZE 16
constexpr size_t LMMS_ALIGN_SIZE = 16;
#define STRINGIFY(s) STR(s)
#define STR(PN) #PN
// Abstract away GUI CTRL key (linux/windows) vs ⌘ (apple)
constexpr const char* UI_CTRL_KEY =
#ifdef LMMS_BUILD_APPLE
# define UI_CTRL_KEY "⌘"
"";
#else
# define UI_CTRL_KEY "Ctrl"
"Ctrl";
#endif
#endif

View File

@@ -25,37 +25,37 @@
#ifndef LMMS_CONSTANTS_H
#define LMMS_CONSTANTS_H
const long double LD_PI = 3.14159265358979323846264338327950288419716939937510;
const long double LD_2PI = LD_PI * 2.0;
const long double LD_PI_2 = LD_PI * 0.5;
const long double LD_PI_R = 1.0 / LD_PI;
const long double LD_PI_SQR = LD_PI * LD_PI;
const long double LD_E = 2.71828182845904523536028747135266249775724709369995;
const long double LD_E_R = 1.0 / LD_E;
constexpr long double LD_PI = 3.14159265358979323846264338327950288419716939937510;
constexpr long double LD_2PI = LD_PI * 2.0;
constexpr long double LD_PI_2 = LD_PI * 0.5;
constexpr long double LD_PI_R = 1.0 / LD_PI;
constexpr long double LD_PI_SQR = LD_PI * LD_PI;
constexpr long double LD_E = 2.71828182845904523536028747135266249775724709369995;
constexpr long double LD_E_R = 1.0 / LD_E;
const double D_PI = (double) LD_PI;
const double D_2PI = (double) LD_2PI;
const double D_PI_2 = (double) LD_PI_2;
const double D_PI_R = (double) LD_PI_R;
const double D_PI_SQR = (double) LD_PI_SQR;
const double D_E = (double) LD_E;
const double D_E_R = (double) LD_E_R;
constexpr double D_PI = (double) LD_PI;
constexpr double D_2PI = (double) LD_2PI;
constexpr double D_PI_2 = (double) LD_PI_2;
constexpr double D_PI_R = (double) LD_PI_R;
constexpr double D_PI_SQR = (double) LD_PI_SQR;
constexpr double D_E = (double) LD_E;
constexpr double D_E_R = (double) LD_E_R;
const float F_PI = (float) LD_PI;
const float F_2PI = (float) LD_2PI;
const float F_PI_2 = (float) LD_PI_2;
const float F_PI_R = (float) LD_PI_R;
const float F_PI_SQR = (float) LD_PI_SQR;
const float F_E = (float) LD_E;
const float F_E_R = (float) LD_E_R;
constexpr float F_PI = (float) LD_PI;
constexpr float F_2PI = (float) LD_2PI;
constexpr float F_PI_2 = (float) LD_PI_2;
constexpr float F_PI_R = (float) LD_PI_R;
constexpr float F_PI_SQR = (float) LD_PI_SQR;
constexpr float F_E = (float) LD_E;
constexpr float F_E_R = (float) LD_E_R;
// Microtuner
const unsigned int MaxScaleCount = 10; //!< number of scales per project
const unsigned int MaxKeymapCount = 10; //!< number of keyboard mappings per project
constexpr unsigned int MaxScaleCount = 10; //!< number of scales per project
constexpr unsigned int MaxKeymapCount = 10; //!< number of keyboard mappings per project
// Frequency ranges (in Hz).
// Arbitrary low limit for logarithmic frequency scale; >1 Hz.
const int LOWEST_LOG_FREQ = 5;
constexpr int LOWEST_LOG_FREQ = 5;
// Full range is defined by LOWEST_LOG_FREQ and current sample rate.
enum FREQUENCY_RANGES
@@ -67,14 +67,14 @@ enum FREQUENCY_RANGES
FRANGE_HIGH
};
const int FRANGE_AUDIBLE_START = 20;
const int FRANGE_AUDIBLE_END = 20000;
const int FRANGE_BASS_START = 20;
const int FRANGE_BASS_END = 300;
const int FRANGE_MIDS_START = 200;
const int FRANGE_MIDS_END = 5000;
const int FRANGE_HIGH_START = 4000;
const int FRANGE_HIGH_END = 20000;
constexpr int FRANGE_AUDIBLE_START = 20;
constexpr int FRANGE_AUDIBLE_END = 20000;
constexpr int FRANGE_BASS_START = 20;
constexpr int FRANGE_BASS_END = 300;
constexpr int FRANGE_MIDS_START = 200;
constexpr int FRANGE_MIDS_END = 5000;
constexpr int FRANGE_HIGH_START = 4000;
constexpr int FRANGE_HIGH_END = 20000;
// Amplitude ranges (in dBFS).
// Reference: full scale sine wave (-1.0 to 1.0) is 0 dB.
@@ -87,13 +87,13 @@ enum AMPLITUDE_RANGES
ARANGE_SILENT
};
const int ARANGE_EXTENDED_START = -80;
const int ARANGE_EXTENDED_END = 20;
const int ARANGE_AUDIBLE_START = -50;
const int ARANGE_AUDIBLE_END = 0;
const int ARANGE_LOUD_START = -30;
const int ARANGE_LOUD_END = 0;
const int ARANGE_SILENT_START = -60;
const int ARANGE_SILENT_END = -10;
constexpr int ARANGE_EXTENDED_START = -80;
constexpr int ARANGE_EXTENDED_END = 20;
constexpr int ARANGE_AUDIBLE_START = -50;
constexpr int ARANGE_AUDIBLE_END = 0;
constexpr int ARANGE_LOUD_START = -30;
constexpr int ARANGE_LOUD_END = 0;
constexpr int ARANGE_SILENT_START = -60;
constexpr int ARANGE_SILENT_END = -10;
#endif

View File

@@ -33,10 +33,6 @@
#include <cmath>
#ifndef exp10
#define exp10(x) std::pow( 10.0, x )
#endif
#ifdef __INTEL_COMPILER
static inline float absFraction( const float _x )
@@ -123,7 +119,7 @@ static inline float absFraction( float _x )
#define FAST_RAND_MAX 32767
constexpr int FAST_RAND_MAX = 32767;
static inline int fast_rand()
{
static unsigned long next = 1;
@@ -263,7 +259,7 @@ static inline float safeDbfsToAmp( float dbfs )
{
return std::isinf( dbfs )
? 0.0f
: exp10( dbfs * 0.05f );
: std::pow(10.f, dbfs * 0.05f );
}
@@ -281,7 +277,7 @@ static inline float ampToDbfs( float amp )
//! @return Linear amplitude
static inline float dbfsToAmp( float dbfs )
{
return exp10( dbfs * 0.05f );
return std::pow(10.f, dbfs * 0.05f );
}

View File

@@ -26,9 +26,9 @@
#ifndef PANNING_CONSTANTS_H
#define PANNING_CONSTANTS_H
const panning_t PanningRight = ( 0 + 100 );
const panning_t PanningLeft = - PanningRight;
const panning_t PanningCenter = 0;
const panning_t DefaultPanning = PanningCenter;
constexpr panning_t PanningRight = ( 0 + 100 );
constexpr panning_t PanningLeft = - PanningRight;
constexpr panning_t PanningCenter = 0;
constexpr panning_t DefaultPanning = PanningCenter;
#endif

View File

@@ -1,61 +1,49 @@
#include "lmms_basics.h"
#ifdef __GNUC__
#define COMPILER_VERSION "GCC " __VERSION__
constexpr const char* LMMS_BUILDCONF_COMPILER_VERSION = "GCC " __VERSION__;
#elif defined(_MSC_VER)
#define COMPILER_VERSION "MSVC " STRINGIFY(_MSC_FULL_VER)
constexpr const char* LMMS_BUILDCONF_COMPILER_VERSION = "MSVC " STRINGIFY(_MSC_FULL_VER);
#else
#define COMPILER_VERSION "unknown compiler"
constexpr const char* LMMS_BUILDCONF_COMPILER_VERSION = "unknown compiler";
#endif
#ifdef LMMS_HOST_X86
#define MACHINE "i386"
#endif
#ifdef LMMS_HOST_X86_64
#define MACHINE "x86_64"
#endif
#ifdef LMMS_HOST_ARM32
#define MACHINE "arm32"
#endif
#ifdef LMMS_HOST_ARM64
#define MACHINE "arm64"
#endif
#ifdef LMMS_HOST_RISCV32
#define MACHINE "riscv32"
#endif
#ifdef LMMS_HOST_RISCV64
#define MACHINE "riscv64"
#endif
#ifndef MACHINE
#define MACHINE "unknown processor"
constexpr const char* LMMS_BUILDCONF_MACHINE = "i386";
#elif defined(LMMS_HOST_X86_64)
constexpr const char* LMMS_BUILDCONF_MACHINE = "x86_64";
#elif defined(LMMS_HOST_ARM32)
constexpr const char* LMMS_BUILDCONF_MACHINE = "arm32";
#elif defined(LMMS_HOST_ARM64)
constexpr const char* LMMS_BUILDCONF_MACHINE = "arm64";
#elif defined(LMMS_HOST_RISCV32)
constexpr const char* LMMS_BUILDCONF_MACHINE = "riscv32";
#elif defined(LMMS_HOST_RISCV64)
constexpr const char* LMMS_BUILDCONF_MACHINE = "riscv64";
#else
constexpr const char* LMMS_BUILDCONF_MACHINE = "unknown processor";
#endif
#ifdef LMMS_BUILD_LINUX
#define PLATFORM "Linux"
constexpr const char* LMMS_BUILDCONF_PLATFORM = "Linux";
#endif
#ifdef LMMS_BUILD_APPLE
#define PLATFORM "OS X"
constexpr const char* LMMS_BUILDCONF_PLATFORM = "OS X";
#endif
#ifdef LMMS_BUILD_OPENBSD
#define PLATFORM "OpenBSD"
constexpr const char* LMMS_BUILDCONF_PLATFORM = "OpenBSD";
#endif
#ifdef LMMS_BUILD_FREEBSD
#define PLATFORM "FreeBSD"
constexpr const char* LMMS_BUILDCONF_PLATFORM = "FreeBSD";
#endif
#ifdef LMMS_BUILD_WIN32
#define PLATFORM "win32"
constexpr const char* LMMS_BUILDCONF_PLATFORM = "win32";
#endif
#ifdef LMMS_BUILD_HAIKU
#define PLATFORM "Haiku"
constexpr const char* LMMS_BUILDCONF_PLATFORM = "Haiku";
#endif

View File

@@ -28,9 +28,9 @@
#include "lmms_basics.h"
const volume_t MinVolume = 0;
const volume_t MaxVolume = 200;
const volume_t DefaultVolume = 100;
constexpr volume_t MinVolume = 0;
constexpr volume_t MaxVolume = 200;
constexpr volume_t DefaultVolume = 100;
typedef struct
{