[Code Cleanup] Cleaned up some header files and move a bit of debugging logic to cmake (#7677)

* Renamed lmms_basics.h to LmmsTypes.h and scoped it down for that purpose.

* Shifted the LMMS_STRINGIFY macro to it's own header.

* Removed the debug.h header file and use cmake to handle the macro logic.

* Remove some unused headers and include directives
This commit is contained in:
Rossmaxx
2025-03-24 19:07:46 +05:30
committed by GitHub
parent db9ccbeb56
commit 7367750823
95 changed files with 108 additions and 206 deletions

View File

@@ -28,7 +28,7 @@
#include <QMutex>
#include <samplerate.h>
#include "lmms_basics.h"
#include "LmmsTypes.h"
class QThread;

View File

@@ -34,7 +34,7 @@
#include <vector>
#include "AudioDevice.h"
#include "lmms_basics.h"
#include "LmmsTypes.h"
#include "SampleFrame.h"
#include "LocklessList.h"
#include "FifoBuffer.h"

View File

@@ -29,7 +29,7 @@
#include <atomic>
#include <QFile>
#include "lmms_basics.h"
#include "LmmsTypes.h"
#include "MicroTimer.h"
namespace lmms

View File

@@ -37,7 +37,7 @@
#include "MidiClip.h"
#include "SampleClip.h"
#include "TimePos.h"
#include "lmms_basics.h"
#include "LmmsTypes.h"
#include "SampleThumbnail.h"
class QPainter;

View File

@@ -31,7 +31,7 @@ class QString;
#include "lmms_export.h"
#include "interpolation.h"
#include "lmms_basics.h"
#include "LmmsTypes.h"
#include "lmms_math.h"
#include "Engine.h"
#include "AudioEngine.h"

View File

@@ -36,7 +36,9 @@
#include <cmath>
#include <numbers>
#include "lmms_basics.h"
#include "lmms_constants.h"
#include "LmmsTypes.h"
namespace lmms
{
@@ -207,7 +209,7 @@ public:
inline float update( float s, ch_cnt_t ch )
{
if (std::abs(s) < 1.0e-10f && std::abs(m_z1[ch]) < 1.0e-10f) { return 0.0f; }
if (std::abs(s) < F_EPSILON && std::abs(m_z1[ch]) < F_EPSILON) { return 0.0f; }
return m_z1[ch] = s * m_a0 + m_z1[ch] * m_b1;
}
@@ -593,7 +595,7 @@ public:
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
if (std::abs(_in0) < F_EPSILON && std::abs(m_vflast[0][_chnl]) < F_EPSILON) { return 0.0f; } // performance hack - skip processing when the numbers get too small
const int os = m_type == FilterType::FastFormant ? 1 : 4; // no oversampling for fast formant
for( int o = 0; o < os; ++o )

View File

@@ -27,7 +27,7 @@
#define LMMS_BUFFER_MANAGER_H
#include "lmms_export.h"
#include "lmms_basics.h"
#include "LmmsTypes.h"
namespace lmms
{

View File

@@ -31,7 +31,7 @@
#include <QPixmap>
#include <QWidget>
#include "lmms_basics.h"
#include "LmmsTypes.h"
namespace lmms::gui

View File

@@ -29,7 +29,6 @@
#include <QCloseEvent>
#include "SerializingObject.h"
#include "lmms_basics.h"
class QPushButton;

View File

@@ -28,7 +28,7 @@
#include <cmath>
#include "lmms_basics.h"
#include "LmmsTypes.h"
namespace lmms
{

View File

@@ -28,7 +28,7 @@
#include <stdint.h>
#include "lmms_basics.h"
#include "LmmsTypes.h"
class QString;

View File

@@ -28,7 +28,7 @@
#include <numbers>
#include "lmms_math.h"
#include "lmms_basics.h"
#include "LmmsTypes.h"
#include "SampleFrame.h"
namespace lmms::DspEffectLibrary

View File

@@ -30,7 +30,6 @@
#include "EffectChain.h"
#include "ModelView.h"
#include "lmms_basics.h"
class QScrollArea;
class QVBoxLayout;

View File

@@ -30,7 +30,7 @@
#include "lmmsconfig.h"
#include "lmms_export.h"
#include "lmms_basics.h"
#include "LmmsTypes.h"
namespace lmms
{

View File

@@ -32,7 +32,7 @@
#include "AutomatableModel.h"
#include "SampleBuffer.h"
#include "TempoSyncKnobModel.h"
#include "lmms_basics.h"
#include "LmmsTypes.h"
namespace lmms
{

View File

@@ -32,7 +32,7 @@
#include "Model.h"
#include "ModelView.h"
#include "lmms_basics.h"
#include "LmmsTypes.h"
namespace lmms
{

View File

@@ -30,7 +30,7 @@
#include "Flags.h"
#include "lmms_export.h"
#include "lmms_basics.h"
#include "LmmsTypes.h"
#include "Plugin.h"
#include "TimePos.h"

View File

@@ -27,7 +27,7 @@
#include <QStack>
#include "lmms_basics.h"
#include "LmmsTypes.h"
#include "SerializingObject.h"
namespace lmms

View File

@@ -36,7 +36,7 @@
#include "lmms_export.h"
#include "lmms_basics.h"
#include "LmmsTypes.h"
namespace lmms

View File

@@ -31,8 +31,8 @@
#include "AutomatableModel.h"
#include "Controller.h"
#include "ControllerDialog.h"
#include "SampleBuffer.h"
#include "TempoSyncKnobModel.h"
#include "Oscillator.h"
namespace lmms
{

View File

@@ -1,8 +1,8 @@
/*
* debug.h - header file to be included for debugging purposes
*
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* LmmsCommonMacros.h - defines some common macros used in the codebase
*
* Copyright (c) 2025 Roshan M R (Ross Maxx) <mrroshan127/at/gmail/dot/com>
*
* This file is part of LMMS - https://lmms.io
*
* This program is free software; you can redistribute it and/or
@@ -22,20 +22,15 @@
*
*/
#ifndef LMMS_DEBUG_H
#define LMMS_DEBUG_H
#ifndef LMMS_COMMON_MACROS_H
#define LMMS_COMMON_MACROS_H
#include "lmmsconfig.h"
namespace lmms
{
// 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 // LMMS_DEBUG
#define LMMS_STRINGIFY(s) LMMS_STR(s) // a macro used to stringify the plugin name
#define LMMS_STR(PN) #PN
#include <cassert>
#include <cstdio>
} // namespace lmms
#endif // LMMS_DEBUG_H
#endif // LMMS_COMMON_MACROS_H

View File

@@ -1,5 +1,5 @@
/*
* lmms_basics.h - typedefs for common types that are used in the whole app
* LmmsTypes.h - typedefs for common types that are used in the whole app
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
@@ -26,13 +26,9 @@
#define LMMS_TYPES_H
#include <cstddef>
#include "lmmsconfig.h"
#include <cstdint>
namespace lmms
{
@@ -55,20 +51,6 @@ using mix_ch_t = uint16_t; // Mixer-channel (0 to MAX_CHANNEL)
using jo_id_t = uint32_t; // (unique) ID of a journalling object
constexpr ch_cnt_t DEFAULT_CHANNELS = 2;
constexpr char LADSPA_PATH_SEPERATOR =
#ifdef LMMS_BUILD_WIN32
';';
#else
':';
#endif
#define LMMS_STRINGIFY(s) LMMS_STR(s)
#define LMMS_STR(PN) #PN
} // namespace lmms
#endif // LMMS_TYPES_H

View File

@@ -30,7 +30,7 @@
#include <ringbuffer/ringbuffer.h>
#include "lmms_basics.h"
#include "LmmsTypes.h"
namespace lmms
{

View File

@@ -34,7 +34,7 @@
#include <vector>
#include "Flags.h"
#include "lmms_basics.h"
#include "LmmsTypes.h"
#include "PluginIssue.h"

View File

@@ -25,8 +25,6 @@
#ifndef LMMS_MIDI_H
#define LMMS_MIDI_H
#include "lmms_basics.h"
namespace lmms
{

View File

@@ -25,7 +25,7 @@
#ifndef LMMS_MIX_HELPERS_H
#define LMMS_MIX_HELPERS_H
#include "lmms_basics.h"
#include "LmmsTypes.h"
namespace lmms
{

View File

@@ -34,7 +34,6 @@
#include "Engine.h"
#include "lmms_math.h"
#include "lmmsconfig.h"
#include "AudioEngine.h"
#include "OscillatorConstants.h"
#include "SampleBuffer.h"

View File

@@ -28,7 +28,7 @@
#include <array>
#include "lmms_basics.h"
#include "LmmsTypes.h"
namespace lmms::OscillatorConstants
{

View File

@@ -28,7 +28,7 @@
#include <QWidget>
#include <QPixmap>
#include "lmms_basics.h"
#include "LmmsTypes.h"
namespace lmms
{

View File

@@ -26,7 +26,7 @@
#ifndef LMMS_OUTPUT_SETTINGS_H
#define LMMS_OUTPUT_SETTINGS_H
#include "lmms_basics.h"
#include "LmmsTypes.h"
namespace lmms
{

View File

@@ -35,7 +35,7 @@
#include "ComboBoxModel.h"
#include "SerializingObject.h"
#include "Note.h"
#include "lmms_basics.h"
#include "LmmsTypes.h"
#include "Song.h"
#include "StepRecorder.h"
#include "StepRecorderWidget.h"

View File

@@ -32,7 +32,7 @@
#include "Flags.h"
#include "ThreadableJob.h"
#include "lmms_basics.h"
#include "LmmsTypes.h"
class QThread;

View File

@@ -28,7 +28,7 @@
#include <QHash>
#include <QStack>
#include "lmms_basics.h"
#include "LmmsTypes.h"
#include "DataFile.h"

View File

@@ -26,7 +26,6 @@
#define LMMS_PROJECT_RENDERER_H
#include "AudioFileDevice.h"
#include "lmmsconfig.h"
#include "AudioEngine.h"
#include "OutputSettings.h"

View File

@@ -27,6 +27,8 @@
#include "MidiEvent.h"
#include "lmmsconfig.h"
#include <atomic>
#include <vector>
#include <cstdio>

View File

@@ -28,7 +28,7 @@
#include <cmath>
#include <QObject>
#include "lmms_basics.h"
#include "LmmsTypes.h"
#include "lmms_export.h"

View File

@@ -34,7 +34,7 @@
#include "AudioEngine.h"
#include "Engine.h"
#include "lmms_basics.h"
#include "LmmsTypes.h"
#include "lmms_export.h"
namespace lmms {

View File

@@ -31,7 +31,6 @@
#include <string>
#include <vector>
#include "lmms_basics.h"
#include "SampleFrame.h"
namespace lmms {

View File

@@ -26,7 +26,8 @@
#ifndef LMMS_SAMPLEFRAME_H
#define LMMS_SAMPLEFRAME_H
#include "lmms_basics.h"
#include "LmmsTypes.h"
#include "lmms_constants.h"
#include <algorithm>
#include <array>

View File

@@ -30,7 +30,6 @@
#include "AudioDevice.h"
#include "AudioDeviceSetupWidget.h"
#include "lmmsconfig.h"
#include "MidiClient.h"
#include "MidiSetupWidget.h"

View File

@@ -1,72 +0,0 @@
/*
* SweepOscillator.h - sweeping oscillator
*
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - https://lmms.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef LMMS_SWEEP_OSCILLATOR_H
#define LMMS_SWEEP_OSCILLATOR_H
#include "Oscillator.h"
#include "DspEffectLibrary.h"
namespace lmms
{
template<class FX = DspEffectLibrary::StereoBypass>
class SweepOscillator
{
public:
SweepOscillator( const FX & _fx = FX() ) :
m_phase( 0.0f ),
m_FX( _fx )
{
}
virtual ~SweepOscillator() = default;
void update( SampleFrame* buf, const fpp_t frames, const float freq1, const float freq2, const float sampleRate )
{
const float df = freq2 - freq1;
for( fpp_t frame = 0; frame < frames; ++frame )
{
const sample_t s = Oscillator::sinSample( m_phase );
buf[frame][0] = s;
buf[frame][1] = s;
m_FX.nextSample( buf[frame][0], buf[frame][1] );
m_phase += ( freq1 + ( frame * df / frames ) ) / sampleRate;
}
}
private:
float m_phase;
FX m_FX;
// inline sample_t getSample( const float _sample );
// inline void recalcPhase();
} ;
} // namespace lmms
#endif // LMMS_SWEEP_OSCILLATOR_H

View File

@@ -25,7 +25,7 @@
#ifndef LMMS_THREADABLE_JOB_H
#define LMMS_THREADABLE_JOB_H
#include "lmms_basics.h"
#include "LmmsTypes.h"
#include <atomic>

View File

@@ -29,7 +29,7 @@
#include <algorithm>
#include <cassert>
#include "lmms_export.h"
#include "lmms_basics.h"
#include "LmmsTypes.h"
namespace lmms
{

View File

@@ -31,7 +31,7 @@
#include "AutomatableModel.h"
#include "JournallingObject.h"
#include "lmms_basics.h"
#include "LmmsTypes.h"
#include <optional>

View File

@@ -32,7 +32,8 @@
#include <QString>
#include "lmms_export.h"
#include "lmms_basics.h"
#include "LmmsCommonMacros.h"
namespace lmms {

View File

@@ -25,10 +25,9 @@
#ifndef LMMS_ENDIAN_HANDLING_H
#define LMMS_ENDIAN_HANDLING_H
#include <cstdint>
#include <QSysInfo>
#include "lmms_basics.h"
namespace lmms
{

View File

@@ -25,17 +25,23 @@
#ifndef LMMS_CONSTANTS_H
#define LMMS_CONSTANTS_H
#include "lmmsconfig.h"
#include "LmmsTypes.h"
namespace lmms
{
// Prefer using `approximatelyEqual()` from lmms_math.h rather than
// using this directly
inline constexpr float F_EPSILON = 1.0e-10f; // 10^-10
inline constexpr ch_cnt_t DEFAULT_CHANNELS = 2;
// Microtuner
inline constexpr unsigned MaxScaleCount = 10; //!< number of scales per project
inline constexpr unsigned MaxKeymapCount = 10; //!< number of keyboard mappings per project
// Note: All constants below are used only in spectrum analyser
// Frequency ranges (in Hz).
// Arbitrary low limit for logarithmic frequency scale; >1 Hz.
inline constexpr auto LOWEST_LOG_FREQ = 5;
@@ -79,6 +85,15 @@ inline constexpr auto ARANGE_LOUD_END = 0;
inline constexpr auto ARANGE_SILENT_START = -60;
inline constexpr auto ARANGE_SILENT_END = -10;
// This macro is used to handle path seperation properly in windows
constexpr char LADSPA_PATH_SEPERATOR =
#ifdef LMMS_BUILD_WIN32
';';
#else
':';
#endif
} // namespace lmms
#endif // LMMS_CONSTANTS_H

View File

@@ -34,7 +34,6 @@
#include <numbers>
#include <concepts>
#include "lmmsconfig.h"
#include "lmms_constants.h"
namespace lmms

View File

@@ -26,7 +26,7 @@
#ifndef LMMS_PANNING_H
#define LMMS_PANNING_H
#include "lmms_basics.h"
#include "LmmsTypes.h"
#include "Midi.h"
#include "volume.h"

View File

@@ -1,7 +1,7 @@
#ifndef LMMS_VERSION_INFO_H
#define LMMS_VERSION_INFO_H
#include "lmms_basics.h"
#include "LmmsCommonMacros.h"
#if defined(__GNUC__)
constexpr const char* LMMS_BUILDCONF_COMPILER_VERSION = "GCC " __VERSION__;

View File

@@ -26,7 +26,7 @@
#ifndef LMMS_VOLUME_H
#define LMMS_VOLUME_H
#include "lmms_basics.h"
#include "LmmsTypes.h"
namespace lmms
{