diff --git a/CHANGELOG b/CHANGELOG index 34a1989..ac62aea 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ ******************************************************************************* === 1.0.14 === +* Fixed several issues reported by PVS Studio static analyzer. * Fixed band characteristics report for FFTCrossover. === 1.0.13 === diff --git a/README.md b/README.md index a553b66..6d73a3b 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,7 @@ Set of modules provided: * Spectrum analyzer -Supported platforms -====== +## Supported platforms The build and correct unit test execution has been confirmed for following platforms: * FreeBSD @@ -57,16 +56,14 @@ The build and correct unit test execution has been confirmed for following platf * Windows 32-bit * Windows 64-bit -Requirements -====== +## Requirements The following packages need to be installed for building: * gcc >= 4.9 * GNU make >= 4.0 -Building -====== +## Building To build the library, perform the following commands: @@ -114,8 +111,7 @@ To build source code archive with all possible dependencies, run: make distsrc ``` -Usage -====== +## Usage Here's the code snippet of how the library can be initialized and used in C++: @@ -200,3 +196,7 @@ int main(int argc, const char **argv) return res; } ``` + +## SAST Tools + +* [PVS-Studio](https://pvs-studio.com/en/pvs-studio/?utm_source=website&utm_medium=github&utm_campaign=open_source) - static analyzer for C, C++, C#, and Java code. diff --git a/include/lsp-plug.in/dsp-units/3d/RayTrace3D.h b/include/lsp-plug.in/dsp-units/3d/RayTrace3D.h index 5736697..76baee5 100644 --- a/include/lsp-plug.in/dsp-units/3d/RayTrace3D.h +++ b/include/lsp-plug.in/dsp-units/3d/RayTrace3D.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2021 Linux Studio Plugins Project - * (C) 2021 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-dsp-units * Created on: 10 авг. 2021 г. @@ -90,10 +90,10 @@ namespace lsp private: RayTrace3D *trace; stats_t stats; + ssize_t heavy_state; lltl::parray tasks; lltl::parray bindings; // Bindings lltl::parray objects; - ssize_t heavy_state; protected: status_t main_loop(); @@ -173,16 +173,14 @@ namespace lsp status_t do_process(size_t threads, float initial); public: - /** Default constructor - * - */ explicit RayTrace3D(); - - /** Destructor - * - */ + RayTrace3D(const RayTrace3D &) = delete; + RayTrace3D(RayTrace3D &&) = delete; ~RayTrace3D(); + RayTrace3D & operator = (const RayTrace3D &) = delete; + RayTrace3D & operator = (RayTrace3D &&) = delete; + public: /** * Initialize raytrace object @@ -320,8 +318,8 @@ namespace lsp status_t process(size_t threads, float initial); }; - } // namespace dspu -} // namespace lsp + } /* namespace dspu */ +} /* namespace lsp */ diff --git a/include/lsp-plug.in/dsp-units/filters/SpectralTilt.h b/include/lsp-plug.in/dsp-units/filters/SpectralTilt.h index 0c4320a..88b4174 100644 --- a/include/lsp-plug.in/dsp-units/filters/SpectralTilt.h +++ b/include/lsp-plug.in/dsp-units/filters/SpectralTilt.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2021 Linux Studio Plugins Project - * (C) 2021 Stefano Tronci + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Stefano Tronci * * This file is part of lsp-dsp-units * Created on: 15 Sept 2021 @@ -66,10 +66,6 @@ namespace lsp class LSP_DSP_UNITS_PUBLIC SpectralTilt { - private: - SpectralTilt & operator = (const SpectralTilt &); - SpectralTilt(const SpectralTilt &); - protected: typedef struct bilinear_spec_t @@ -101,8 +97,13 @@ namespace lsp public: explicit SpectralTilt(); + SpectralTilt(const SpectralTilt &) = delete; + SpectralTilt(SpectralTilt &&) = delete; ~SpectralTilt(); + SpectralTilt & operator = (const SpectralTilt &) = delete; + SpectralTilt & operator = (SpectralTilt &&) = delete; + void construct(); void destroy(); @@ -209,7 +210,7 @@ namespace lsp void dump(IStateDumper *v) const; }; - } -} + } /* namespace dspu */ +} /* namespace lsp */ #endif /* LSP_PLUG_IN_DSP_UNITS_FILTERS_SPECTRALTILT_H_ */ diff --git a/include/lsp-plug.in/dsp-units/noise/Generator.h b/include/lsp-plug.in/dsp-units/noise/Generator.h index 1f81caf..37862e6 100644 --- a/include/lsp-plug.in/dsp-units/noise/Generator.h +++ b/include/lsp-plug.in/dsp-units/noise/Generator.h @@ -36,8 +36,7 @@ namespace lsp { NG_GEN_MLS, NG_GEN_LCG, - NG_GEN_VELVET, - NG_GEN_MAX + NG_GEN_VELVET }; enum ng_color_t @@ -48,7 +47,7 @@ namespace lsp NG_COLOR_BLUE, NG_COLOR_VIOLET, NG_COLOR_ARBITRARY, - NG_COLOR_MAX, + NG_COLOR_BROWN = NG_COLOR_RED, NG_COLOR_BROWNIAN = NG_COLOR_RED }; diff --git a/include/lsp-plug.in/dsp-units/noise/LCG.h b/include/lsp-plug.in/dsp-units/noise/LCG.h index 7e9f956..4b0c06b 100644 --- a/include/lsp-plug.in/dsp-units/noise/LCG.h +++ b/include/lsp-plug.in/dsp-units/noise/LCG.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2021 Linux Studio Plugins Project - * (C) 2021 Stefano Tronci + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Stefano Tronci * * This file is part of lsp-dsp-units * Created on: 13 Jun 2021 @@ -34,8 +34,7 @@ namespace lsp LCG_UNIFORM, // Uniform over [-1, 1), X fAmplitude + fOffset LCG_EXPONENTIAL, // Double sided exponential over [-1, 1], X fAmplitude + fOffset LCG_TRIANGULAR, // Triangular over [-1, 1], X fAmplitude + fOffset - LCG_GAUSSIAN, // Gaussian of mean 0 and standard deviation 1, X fAmplitude + fOffset - LCG_MAX + LCG_GAUSSIAN // Gaussian of mean 0 and standard deviation 1, X fAmplitude + fOffset }; /** LCG stands for Linear Congruential Generator. @@ -47,10 +46,6 @@ namespace lsp */ class LSP_DSP_UNITS_PUBLIC LCG { - private: - LCG & operator = (const LCG &); - LCG(const LCG &); - private: lcg_dist_t enDistribution; @@ -61,8 +56,13 @@ namespace lsp public: explicit LCG(); + LCG(const LCG &) = delete; + LCG(LCG &&) = delete; ~LCG(); + LCG & operator = (const LCG &) = delete; + LCG & operator = (LCG &) = delete; + void construct(); void destroy(); @@ -84,9 +84,6 @@ namespace lsp */ inline void set_distribution(lcg_dist_t dist) { - if ((dist < LCG_UNIFORM) || (dist >= LCG_MAX)) - return; - enDistribution = dist; } @@ -150,7 +147,7 @@ namespace lsp */ void dump(IStateDumper *v) const; }; - } -} + } /* namespace dspu */ +} /* namespace lsp */ #endif /* LSP_PLUG_IN_DSP_UNITS_NOISE_LCG_H_ */ diff --git a/include/lsp-plug.in/dsp-units/noise/Velvet.h b/include/lsp-plug.in/dsp-units/noise/Velvet.h index 3b5643d..2024149 100644 --- a/include/lsp-plug.in/dsp-units/noise/Velvet.h +++ b/include/lsp-plug.in/dsp-units/noise/Velvet.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2021 Linux Studio Plugins Project - * (C) 2021 Stefano Tronci + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Stefano Tronci * * This file is part of lsp-dsp-units * Created on: 27 Jun 2021 @@ -33,8 +33,7 @@ namespace lsp enum vn_core_t { VN_CORE_MLS, // Only compatible with OVN, OVNA and ARN (not crushed) - VN_CORE_LCG, - VN_CORE_MAX + VN_CORE_LCG }; enum vn_velvet_type_t @@ -42,8 +41,7 @@ namespace lsp VN_VELVET_OVN, VN_VELVET_OVNA, VN_VELVET_ARN, - VN_VELVET_TRN, - VN_VELVET_MAX + VN_VELVET_TRN }; /** As in GENERALIZATIONS OF VELVET NOISE AND THEIR USE IN 1-BIT MUSIC by Kurt James Werner @@ -199,7 +197,7 @@ namespace lsp */ void dump(IStateDumper *v) const; }; - } -} + } /* namespace dspu */ +} /* namespace lsp */ #endif /* LSP_PLUG_IN_DSP_UNITS_NOISE_VELVET_H_ */ diff --git a/include/lsp-plug.in/dsp-units/sampling/Playback.h b/include/lsp-plug.in/dsp-units/sampling/Playback.h index eff81fd..5ad4040 100644 --- a/include/lsp-plug.in/dsp-units/sampling/Playback.h +++ b/include/lsp-plug.in/dsp-units/sampling/Playback.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2022 Linux Studio Plugins Project - * (C) 2022 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-dsp-units * Created on: 18 нояб. 2022 г. @@ -52,12 +52,12 @@ namespace lsp Playback(Playback &&src); ~Playback(); + Playback & operator = (const Playback & src); + Playback & operator = (Playback && src); + void construct(); void destroy(); - public: - Playback & operator = (const Playback & src); - public: /** * Check that playback is still valid. Should be called before reading playback parameters diff --git a/include/lsp-plug.in/dsp-units/sampling/SamplePlayer.h b/include/lsp-plug.in/dsp-units/sampling/SamplePlayer.h index cab3296..cdcf830 100644 --- a/include/lsp-plug.in/dsp-units/sampling/SamplePlayer.h +++ b/include/lsp-plug.in/dsp-units/sampling/SamplePlayer.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2020 Linux Studio Plugins Project - * (C) 2020 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-dsp-units * Created on: 13 марта 2016 г. @@ -35,10 +35,6 @@ namespace lsp { class LSP_DSP_UNITS_PUBLIC SamplePlayer { - private: - SamplePlayer & operator = (const SamplePlayer &); - SamplePlayer(const SamplePlayer &); - protected: typedef struct play_item_t: public playback::playback_t { @@ -81,8 +77,13 @@ namespace lsp public: explicit SamplePlayer(); + SamplePlayer(const SamplePlayer &) = delete; + SamplePlayer(SamplePlayer &&) = delete; ~SamplePlayer(); + SamplePlayer & operator = (const SamplePlayer &) = delete; + SamplePlayer & operator = (SamplePlayer &&) = delete; + /** * Construct sample player */ diff --git a/include/lsp-plug.in/dsp-units/util/Convolver.h b/include/lsp-plug.in/dsp-units/util/Convolver.h index d851062..7397299 100644 --- a/include/lsp-plug.in/dsp-units/util/Convolver.h +++ b/include/lsp-plug.in/dsp-units/util/Convolver.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2020 Linux Studio Plugins Project - * (C) 2020 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-dsp-units * Created on: 29 янв. 2016 г. @@ -34,10 +34,6 @@ namespace lsp { class LSP_DSP_UNITS_PUBLIC Convolver { - private: - Convolver & operator = (const Convolver &); - Convolver(const Convolver &); - private: float *vDataBuffer; // Buffer for storing convolution tail data float *vFrame; // Pointer to the beginning of the input data frame @@ -62,8 +58,13 @@ namespace lsp public: explicit Convolver(); + Convolver(const Convolver &) = delete; + Convolver(Convolver &&) = delete; ~Convolver(); + Convolver & operator = (const Convolver &) = delete; + Convolver & operator = (Convolver &&) = delete; + /** Construct the convolver * */ @@ -111,7 +112,8 @@ namespace lsp */ void dump(IStateDumper *v) const; }; - } + + } /* namespace dspu */ } /* namespace lsp */ #endif /* LSP_PLUG_IN_DSP_UNITS_UTIL_CONVOLVER_H_ */ diff --git a/include/lsp-plug.in/dsp-units/util/Crossover.h b/include/lsp-plug.in/dsp-units/util/Crossover.h index 7f8b43e..29c294f 100644 --- a/include/lsp-plug.in/dsp-units/util/Crossover.h +++ b/include/lsp-plug.in/dsp-units/util/Crossover.h @@ -91,10 +91,6 @@ namespace lsp */ class LSP_DSP_UNITS_PUBLIC Crossover { - private: - Crossover & operator = (const Crossover &); - Crossover(const Crossover &); - protected: enum xover_type_t { @@ -103,6 +99,14 @@ namespace lsp FILTER_APF // All-pass filter }; + enum reconfigure_t + { + R_GAIN = 1 << 0, // We can reconfigure band gain in softer mode + R_SPLIT = 1 << 1, // Need to reconfigure filter order + + R_ALL = R_GAIN | R_SPLIT + }; + typedef struct split_t { Equalizer sLPF; // Lo-pass filter @@ -129,14 +133,6 @@ namespace lsp size_t nId; // Number of the band } band_t; - enum reconfigure_t - { - R_GAIN = 1 << 0, // We can reconfigure band gain in softer mode - R_SPLIT = 1 << 1, // Need to reconfigure filter order - - R_ALL = R_GAIN | R_SPLIT - } reconfigure_t; - protected: size_t nReconfigure; // Change flag size_t nSplits; // Number of splits @@ -157,8 +153,13 @@ namespace lsp public: explicit Crossover(); + Crossover(const Crossover &) = delete; + Crossover(Crossover &) = delete; ~Crossover(); + Crossover & operator = (const Crossover &) = delete; + Crossover & operator = (Crossover &&) = delete; + /** Construct crossover * */ diff --git a/include/lsp-plug.in/dsp-units/util/Depopper.h b/include/lsp-plug.in/dsp-units/util/Depopper.h index ee4338f..2000bec 100644 --- a/include/lsp-plug.in/dsp-units/util/Depopper.h +++ b/include/lsp-plug.in/dsp-units/util/Depopper.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2020 Linux Studio Plugins Project - * (C) 2020 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-dsp-units * Created on: 4 июл. 2020 г. @@ -292,7 +292,8 @@ namespace lsp */ inline size_t latency() const { return sFadeOut.nSamples; } }; - } + + } /* namespace dspu */ } /* namespace lsp */ #endif /* LSP_PLUG_IN_DSP_UNITS_UTIL_DEPOPPER_H_ */ diff --git a/include/lsp-plug.in/dsp-units/util/FFTCrossover.h b/include/lsp-plug.in/dsp-units/util/FFTCrossover.h index 93941a8..d52acd3 100644 --- a/include/lsp-plug.in/dsp-units/util/FFTCrossover.h +++ b/include/lsp-plug.in/dsp-units/util/FFTCrossover.h @@ -47,12 +47,6 @@ namespace lsp */ class LSP_DSP_UNITS_PUBLIC FFTCrossover { - private: - FFTCrossover & operator = (const FFTCrossover &); - FFTCrossover & operator = (FFTCrossover &&); - FFTCrossover(const Crossover &); - FFTCrossover(Crossover &&); - protected: typedef struct band_t { @@ -103,8 +97,13 @@ namespace lsp public: explicit FFTCrossover(); + FFTCrossover(const Crossover &) = delete; + FFTCrossover(Crossover &&) = delete; ~FFTCrossover(); + FFTCrossover & operator = (const FFTCrossover &) = delete; + FFTCrossover & operator = (FFTCrossover &&) = delete; + /** Construct crossover * */ diff --git a/include/lsp-plug.in/dsp-units/util/Oscillator.h b/include/lsp-plug.in/dsp-units/util/Oscillator.h index 68b8907..16e49cb 100644 --- a/include/lsp-plug.in/dsp-units/util/Oscillator.h +++ b/include/lsp-plug.in/dsp-units/util/Oscillator.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2020 Linux Studio Plugins Project - * (C) 2020 Stefano Tronci + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Stefano Tronci * * This file is part of lsp-dsp-units * Created on: 20 Mar 2017 @@ -45,15 +45,13 @@ namespace lsp FG_BL_SAWTOOTH, //10 FG_BL_TRAPEZOID, //11 FG_BL_PULSETRAIN, //12 - FG_BL_PARABOLIC, //13 - FG_MAX + FG_BL_PARABOLIC //13 }; enum dc_reference_t { DC_WAVEDC, // DC Offset with respect wave's natural DC (0 fDCOffset <=> Wave DC) - DC_ZERO, // DC Offset with respect 0 DC (0 fDCOffset <=> 0 Overall DC) - DC_MAX + DC_ZERO // DC Offset with respect 0 DC (0 fDCOffset <=> 0 Overall DC) }; class LSP_DSP_UNITS_PUBLIC Oscillator @@ -240,9 +238,6 @@ namespace lsp */ inline void set_function(fg_function_t function) { - if ((function < FG_SINE) || (function >= FG_MAX)) - return; - enFunction = function; bSync = true; } @@ -384,7 +379,8 @@ namespace lsp */ void dump(IStateDumper *v) const; }; - } -} + + } /* namespace dspu */ +} /* namespace lsp */ #endif /* LSP_PLUG_IN_DSP_UNITS_UTIL_OSCILLATOR_H_ */ diff --git a/include/lsp-plug.in/dsp-units/util/Oversampler.h b/include/lsp-plug.in/dsp-units/util/Oversampler.h index af67949..c18028a 100644 --- a/include/lsp-plug.in/dsp-units/util/Oversampler.h +++ b/include/lsp-plug.in/dsp-units/util/Oversampler.h @@ -104,10 +104,6 @@ namespace lsp */ class LSP_DSP_UNITS_PUBLIC Oversampler { - private: - Oversampler & operator = (const Oversampler &); - Oversampler(const Oversampler &); - protected: typedef void (*resample_func_t)(float *dst, const float *src, size_t count); @@ -139,8 +135,13 @@ namespace lsp public: explicit Oversampler(); + Oversampler(const Oversampler &) = delete; + Oversampler(Oversampler &&) = delete; ~Oversampler(); + Oversampler & operator = (const Oversampler &) = delete; + Oversampler & operator = (Oversampler &&) = delete; + void construct(); public: diff --git a/include/lsp-plug.in/dsp-units/util/Randomizer.h b/include/lsp-plug.in/dsp-units/util/Randomizer.h index 7344912..16b6c54 100644 --- a/include/lsp-plug.in/dsp-units/util/Randomizer.h +++ b/include/lsp-plug.in/dsp-units/util/Randomizer.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2020 Linux Studio Plugins Project - * (C) 2020 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-dsp-units * Created on: 23 марта 2016 г. @@ -40,10 +40,6 @@ namespace lsp class LSP_DSP_UNITS_PUBLIC Randomizer { - private: - Randomizer &operator = (const Randomizer &); - Randomizer(const Randomizer &); - private: static const uint32_t vMul1[]; static const uint32_t vMul2[]; @@ -65,8 +61,13 @@ namespace lsp public: explicit Randomizer(); + Randomizer(const Randomizer &) = delete; + Randomizer(Randomizer &&) = delete; ~Randomizer(); + Randomizer &operator = (const Randomizer &) = delete; + Randomizer &operator = (Randomizer &&) = delete; + /** * Construct the randomizer */ diff --git a/include/lsp-plug.in/dsp-units/util/ResponseTaker.h b/include/lsp-plug.in/dsp-units/util/ResponseTaker.h index b341fa1..0c0a6e2 100644 --- a/include/lsp-plug.in/dsp-units/util/ResponseTaker.h +++ b/include/lsp-plug.in/dsp-units/util/ResponseTaker.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2020 Linux Studio Plugins Project - * (C) 2020 Stefano Tronci + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Stefano Tronci * * This file is part of lsp-dsp-units * Created on: 30 Jul 2017 @@ -33,10 +33,6 @@ namespace lsp { class LSP_DSP_UNITS_PUBLIC ResponseTaker { - private: - ResponseTaker & operator = (const ResponseTaker &); - ResponseTaker(const ResponseTaker &); - protected: // Input processor state enumerator enum ip_state_t @@ -114,10 +110,14 @@ namespace lsp bool bSync; public: - explicit ResponseTaker(); + ResponseTaker(const ResponseTaker &) = delete; + ResponseTaker(ResponseTaker &&) = delete; ~ResponseTaker(); + ResponseTaker & operator = (const ResponseTaker &) = delete; + ResponseTaker & operator = (ResponseTaker &&) = delete; + /** Construct the ResponseTaker * */ diff --git a/include/lsp-plug.in/dsp-units/util/SyncChirpProcessor.h b/include/lsp-plug.in/dsp-units/util/SyncChirpProcessor.h index 1417611..e05b45a 100644 --- a/include/lsp-plug.in/dsp-units/util/SyncChirpProcessor.h +++ b/include/lsp-plug.in/dsp-units/util/SyncChirpProcessor.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2020 Linux Studio Plugins Project - * (C) 2020 Stefano Tronci + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Stefano Tronci * * This file is part of lsp-dsp-units * Created on: 12 Jul 2017 @@ -39,15 +39,13 @@ namespace lsp { SCP_SYNTH_SIMPLE, // Pure math chirp and inverse filter SCP_SYNTH_CHIRPBANDLIMITED, // Band limited chirp, pure math inverse filter - SCP_SYNTH_BANDLIMITED, // Band limited chirp and inverse filter - SCP_SYNTH_MAX + SCP_SYNTH_BANDLIMITED // Band limited chirp and inverse filter }; enum scp_fade_t { SCP_FADE_NONE, // No fade in - fade out - SCP_FADE_RAISED_COSINES, // Raised cosine like shapes for fade in and fade out - SCP_FADE_MAX + SCP_FADE_RAISED_COSINES // Raised cosine like shapes for fade in and fade out }; enum scp_rtcalc_t @@ -57,17 +55,12 @@ namespace lsp SCP_RT_T_10, // T 19 SCP_RT_T_20, // T 20 SCP_RT_T_30, // T 30 - SCP_RT_MAX, SCP_RT_DEFAULT = SCP_RT_EDT_0 }; class LSP_DSP_UNITS_PUBLIC SyncChirpProcessor { - private: - SyncChirpProcessor & operator = (const SyncChirpProcessor &); - SyncChirpProcessor(const SyncChirpProcessor &); - protected: // Chirp parameters: @@ -204,10 +197,14 @@ namespace lsp bool bSync; public: - explicit SyncChirpProcessor(); + SyncChirpProcessor(const SyncChirpProcessor &) = delete; + SyncChirpProcessor(SyncChirpProcessor &&) = delete; ~SyncChirpProcessor(); + SyncChirpProcessor & operator = (const SyncChirpProcessor &) = delete; + SyncChirpProcessor & operator = (SyncChirpProcessor &&) = delete; + void construct(); @@ -530,9 +527,6 @@ namespace lsp */ inline void set_chirp_synthesis_method(scp_method_t method) { - if ((method < SCP_SYNTH_SIMPLE) || (method >= SCP_SYNTH_MAX)) - return; - sChirpParams.enMethod = method; sChirpParams.bReconfigure = true; } @@ -602,9 +596,6 @@ namespace lsp */ inline void set_fader_fading_method(scp_fade_t method) { - if ((method < SCP_FADE_NONE) || (method >= SCP_FADE_MAX)) - return; - sFader.enMethod = method; sChirpParams.bReconfigure = true; } @@ -876,7 +867,8 @@ namespace lsp */ void dump(IStateDumper *v) const; }; - } -} + + } /* namespace dspu */ +} /* namespace lsp */ #endif /* LSP_PLUG_IN_DSP_UNITS_UTIL_SYNCCHIRPPROCESSOR_H_ */ diff --git a/include/lsp-plug.in/dsp-units/util/Trigger.h b/include/lsp-plug.in/dsp-units/util/Trigger.h index 920b1ba..992b356 100644 --- a/include/lsp-plug.in/dsp-units/util/Trigger.h +++ b/include/lsp-plug.in/dsp-units/util/Trigger.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2021 Linux Studio Plugins Project - * (C) 2021 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-dsp-units * Created on: 13 авг. 2021 г. @@ -33,8 +33,7 @@ namespace lsp { TRG_MODE_SINGLE, TRG_MODE_MANUAL, - TRG_MODE_REPEAT, - TRG_MODE_MAX + TRG_MODE_REPEAT }; enum trg_type_t @@ -43,16 +42,14 @@ namespace lsp TRG_TYPE_SIMPLE_RISING_EDGE, TRG_TYPE_SIMPLE_FALLING_EDGE, TRG_TYPE_ADVANCED_RISING_EDGE, - TRG_TYPE_ADVANCED_FALLING_EDGE, - TRG_TYPE_MAX + TRG_TYPE_ADVANCED_FALLING_EDGE }; enum trg_state_t { TRG_STATE_WAITING, TRG_STATE_ARMED, - TRG_STATE_FIRED, - TRG_STATE_MAX + TRG_STATE_FIRED }; class LSP_DSP_UNITS_PUBLIC Trigger @@ -160,7 +157,7 @@ namespace lsp */ inline void set_trigger_mode(trg_mode_t mode) { - if ((mode < TRG_MODE_SINGLE) || (mode >= TRG_MODE_MAX) || (enTriggerMode == mode)) + if (enTriggerMode == mode) return; enTriggerMode = mode; @@ -205,7 +202,7 @@ namespace lsp */ inline void set_trigger_type(trg_type_t type) { - if ((type < TRG_TYPE_NONE) || (type >= TRG_TYPE_MAX) || (enTriggerType == type)) + if (enTriggerType == type) return; enTriggerType = type; @@ -253,10 +250,8 @@ namespace lsp */ void dump(IStateDumper *v) const; }; - } -} - - + } /* namespace dspu */ +} /* namespace lsp */ #endif /* LSP_PLUG_IN_DSP_UNITS_UTIL_TRIGGER_H_ */ diff --git a/src/main/3d/RayTrace3D.cpp b/src/main/3d/RayTrace3D.cpp index e57091f..7b75f33 100644 --- a/src/main/3d/RayTrace3D.cpp +++ b/src/main/3d/RayTrace3D.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2021 Linux Studio Plugins Project - * (C) 2021 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-dsp-units * Created on: 10 авг. 2021 г. @@ -53,8 +53,9 @@ namespace lsp RayTrace3D::TaskThread::TaskThread(RayTrace3D *trace) { - this->trace = trace; - heavy_state = rt::S_SCAN_OBJECTS; + this->trace = trace; + clear_stats(&stats); + heavy_state = rt::S_SCAN_OBJECTS; } RayTrace3D::TaskThread::~TaskThread() @@ -1273,6 +1274,7 @@ namespace lsp fDetalization = 1e-10f; bNormalize = true; bCancelled = false; + bFailed = false; nQueueSize = 0; nProgressPoints = 0; nProgressMax = 0; @@ -1762,16 +1764,16 @@ namespace lsp size_t nin, nout; // Cull each triangle of bounding box with four scissor planes - for (size_t i=0, m = sizeof(bbox_map)/sizeof(size_t); i < m; ) + for (size_t i=0, m = sizeof(bbox_map)/sizeof(size_t); i < m; i += 3) { // Initialize input in = buf1; out = buf2; nin = 1; - in->v[0] = bbox->p[bbox_map[i++]]; - in->v[1] = bbox->p[bbox_map[i++]]; - in->v[2] = bbox->p[bbox_map[i++]]; + in->v[0] = bbox->p[bbox_map[i]]; + in->v[1] = bbox->p[bbox_map[i+1]]; + in->v[2] = bbox->p[bbox_map[i+2]]; pl = view->pl; // Cull triangle with planes @@ -1801,10 +1803,6 @@ namespace lsp return nout; } - } // namespace dspu -} // namespace lsp - - - - + } /* namespace dspu */ +} /* namespace lsp */ diff --git a/src/main/3d/Scene3D.cpp b/src/main/3d/Scene3D.cpp index ac9f945..f423fcc 100644 --- a/src/main/3d/Scene3D.cpp +++ b/src/main/3d/Scene3D.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2021 Linux Studio Plugins Project - * (C) 2021 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-dsp-units * Created on: 9 авг. 2021 г. @@ -506,14 +506,9 @@ namespace lsp status_t Scene3D::load_internal(io::IInStream *is, size_t flags, const char *charset) { - status_t res, res2; - res = load_scene_from_obj(this, is, charset); + status_t res = load_scene_from_obj(this, is, charset); if (flags & WRAP_CLOSE) - { - res2 = is->close(); - if (res == STATUS_OK) - res = res2; - } + res = update_status(res, is->close()); if (flags & WRAP_DELETE) delete is; @@ -522,21 +517,16 @@ namespace lsp status_t Scene3D::load_internal(io::IInSequence *is, size_t flags) { - status_t res, res2; - res = load_scene_from_obj(this, is); + status_t res = load_scene_from_obj(this, is); if (flags & WRAP_CLOSE) - { - res2 = is->close(); - if (res == STATUS_OK) - res = res2; - } + res = update_status(res, is->close()); if (flags & WRAP_DELETE) delete is; return res; } - } // namespace dspu -} // namespace lsp + } /* namespace dspu */ +} /* namespace lsp */ diff --git a/src/main/3d/rt/context.cpp b/src/main/3d/rt/context.cpp index 72c35fd..230df0a 100644 --- a/src/main/3d/rt/context.cpp +++ b/src/main/3d/rt/context.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2021 Linux Studio Plugins Project - * (C) 2021 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-dsp-units * Created on: 10 авг. 2021 г. @@ -427,9 +427,9 @@ namespace lsp dsp::raw_triangle_t *in = buf1; dsp::raw_triangle_t *out = buf2; - in->v[0] = *(t->v[0]); - in->v[1] = *(t->v[1]); - in->v[2] = *(t->v[2]); + in[0].v[0] = *(t->v[0]); + in[0].v[1] = *(t->v[1]); + in[0].v[2] = *(t->v[2]); const dsp::vector3d_t *pl = view.pl; @@ -1132,10 +1132,6 @@ namespace lsp case 0x15: // 1 1 1 // Triangle is on the plane, add and continue - if (!in.alloc(t)) - return STATUS_NO_MEM; - break; - case 0x16: // 1 1 2 case 0x19: // 1 2 1 case 0x1a: // 1 2 2 @@ -1443,9 +1439,9 @@ namespace lsp dsp::orient_plane_v1p1(&v, &view.s, &st->n); return cullback(&v); } - } // namespace rt - } // namespace dspu -} // namespace lsp + } /* namespace rt */ + } /* namespace dspu */ +} /* namespace lsp */ diff --git a/src/main/3d/rt/mesh.cpp b/src/main/3d/rt/mesh.cpp index c3569a6..8450553 100644 --- a/src/main/3d/rt/mesh.cpp +++ b/src/main/3d/rt/mesh.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2021 Linux Studio Plugins Project - * (C) 2021 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-dsp-units * Created on: 9 авг. 2021 г. @@ -827,6 +827,6 @@ namespace lsp return true; } - } // namespace rt - } // namespace dspu -} // namespace lsp + } /* namespace rt */ + } /* namespace dspu */ +} /* namespace lsp */ diff --git a/src/main/filters/ButterworthFilter.cpp b/src/main/filters/ButterworthFilter.cpp index d25b937..49e7f77 100644 --- a/src/main/filters/ButterworthFilter.cpp +++ b/src/main/filters/ButterworthFilter.cpp @@ -85,9 +85,6 @@ namespace lsp void ButterworthFilter::set_filter_type(bw_filt_type_t type) { - if ((type < BW_FLT_TYPE_LOWPASS) && (type >= BW_FLT_TYPE_MAX)) - return; - enFilterType = type; bSync = true; } diff --git a/src/main/filters/Filter.cpp b/src/main/filters/Filter.cpp index 537292a..166b1d5 100644 --- a/src/main/filters/Filter.cpp +++ b/src/main/filters/Filter.cpp @@ -1160,11 +1160,6 @@ namespace lsp c->b[0] = 1.0; c->b[1] = 1.0; c->b[2] = 0.0; - - if (type == FLT_BT_BWC_LOPASS) - c->t[0] = fp->fGain; - else - c->t[1] = fp->fGain; } for (size_t j=i; j < fp->nSlope; j += 2) @@ -2321,14 +2316,14 @@ namespace lsp float *p = (i) ? c->b : c->t; float *P = (i) ? B : T; - if (p[2] == 0.0) // Test polynom for second-order + if (p[2] == 0.0f) // Test polynom for second-order { - P[2] = 0.0; - if (p[1] == 0.0) // Test polynom for first order + P[2] = 0.0f; + if (p[1] == 0.0f) // Test polynom for first order { // Zero-order polynom P[0] = p[0]; - P[1] = 0.0; + P[1] = 0.0f; } else { @@ -2350,10 +2345,10 @@ namespace lsp // // Calculate the roots of the second-order polynom equation a*x^2 + b*x + c = 0 float k = p[2]; - float a = 1.0/(f*f); + float a = 1.0f/(f*f); float b = p[1]/(f*p[2]); float c = p[0]/p[2]; - float D = b*b - 4.0*a*c; + float D = b*b - 4.0f*a*c; if (D >= 0) { @@ -2361,8 +2356,8 @@ namespace lsp // Transformed form is: // P[z] = k*(1 - (exp(R0*T) + exp(R1*T))*z^-1 + exp((R0+R1)*T)*z^-2) D = sqrtf(D); - float R0 = (-b - D)/(2.0*a); - float R1 = (-b + D)/(2.0*a); + float R0 = (-b - D)/(2.0f*a); + float R1 = (-b + D)/(2.0f*a); P[0] = k; P[1] = -k * (expf(R0*TD) + expf(R1*TD)); P[2] = k * expf((R0+R1)*TD); @@ -2373,11 +2368,11 @@ namespace lsp // Transformed form is: // P[z] = k*(1 - 2*exp(R*T)*cos(K*T)*z^-1 + exp(2*R*T)*z^-2) D = sqrtf(-D); - float R = -b / (2.0*a); - float K = D / (2.0*a); + float R = -b / (2.0f*a); + float K = D / (2.0f*a); P[0] = k; - P[1] = -2.0 * k * expf(R*TD) * cosf(K*TD); - P[2] = k * expf(2.0*R*TD); + P[1] = -2.0f * k * expf(R*TD) * cosf(K*TD); + P[2] = k * expf(2.0f*R*TD); } } @@ -2390,9 +2385,9 @@ namespace lsp // For the normalized continuous transfer function it will be always 0.1 // Calculate the discrete transfer function part at specified frequency - double w = M_PI * 0.2 * sParams.fFreq / nSampleRate; - double re = P[0]*cos(2*w) + P[1]*cos(w) + P[2]; - double im = P[0]*sin(2*w) + P[1]*sin(w); + double w = M_PI * 0.2f * sParams.fFreq / nSampleRate; + double re = P[0]*cos(2.0*w) + P[1]*cos(w) + P[2]; + double im = P[0]*sin(2.0*w) + P[1]*sin(w); A[i] = sqrt(re*re + im*im); // Calculate the continuous transfer function part at 1 Hz diff --git a/src/main/filters/SpectralTilt.cpp b/src/main/filters/SpectralTilt.cpp index d90b186..28d1345 100644 --- a/src/main/filters/SpectralTilt.cpp +++ b/src/main/filters/SpectralTilt.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2021 Linux Studio Plugins Project - * (C) 2021 Stefano Tronci + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Stefano Tronci * * This file is part of lsp-dsp-units * Created on: 16 Sept 2021 @@ -122,9 +122,6 @@ namespace lsp void SpectralTilt::set_norm(stlt_norm_t norm) { - if ((norm < STLT_NORM_AT_DC) || (norm >= STLT_NORM_MAX)) - return; - enNorm = norm; bSync = true; } @@ -134,9 +131,6 @@ namespace lsp if ((slope == fSlopeVal) && (slopeType == enSlopeUnit)) return; - if ((slopeType < STLT_SLOPE_UNIT_NEPER_PER_NEPER) || (slopeType >= STLT_SLOPE_UNIT_MAX)) - return; - fSlopeVal = slope; enSlopeUnit = slopeType; bSync = true; @@ -547,5 +541,5 @@ namespace lsp v->write("bBypass", bBypass); v->write("bSync", bSync); } - } -} + } /* namespace dspu */ +} /* namespace lsp */ diff --git a/src/main/noise/Generator.cpp b/src/main/noise/Generator.cpp index 3889fdf..11f1e6c 100644 --- a/src/main/noise/Generator.cpp +++ b/src/main/noise/Generator.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2021 Linux Studio Plugins Project - * (C) 2021 Stefano Tronci + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Stefano Tronci * * This file is part of lsp-dsp-units * Created on: 31 May 2021 @@ -204,9 +204,6 @@ namespace lsp void NoiseGenerator::set_generator(ng_generator_t core) { - if ((core < NG_GEN_MLS) || (core >= NG_GEN_MAX)) - return; - if (core == enGenerator) return; @@ -215,9 +212,6 @@ namespace lsp void NoiseGenerator::set_noise_color(ng_color_t color) { - if ((color < NG_COLOR_WHITE) || (color >= NG_COLOR_MAX)) - return; - if (color == sColorParams.enColor) return; @@ -532,6 +526,6 @@ namespace lsp v->write("fAmplitude", fAmplitude); v->write("fOffset", fOffset); } - } -} + } /* namespace dspu */ +} /* namespace lsp */ diff --git a/src/main/noise/Velvet.cpp b/src/main/noise/Velvet.cpp index 6adb089..6eb7f49 100644 --- a/src/main/noise/Velvet.cpp +++ b/src/main/noise/Velvet.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2021 Linux Studio Plugins Project - * (C) 2021 Stefano Tronci + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Stefano Tronci * * This file is part of lsp-dsp-units * Created on: 27 Jun 2021 @@ -70,17 +70,11 @@ namespace lsp void Velvet::set_core_type(vn_core_t core) { - if ((core < VN_CORE_MLS) || (core >= VN_CORE_MAX)) - return; - enCore = core; } void Velvet::set_velvet_type(vn_velvet_type_t type) { - if ((type < VN_VELVET_OVN) || (type >= VN_VELVET_MAX)) - return; - enVelvetType = type; } @@ -258,7 +252,6 @@ namespace lsp break; default: - case VN_VELVET_MAX: dsp::fill_zero(dst, count); break; } @@ -345,5 +338,5 @@ namespace lsp v->write("fAmplitude", fAmplitude); v->write("fOffset", fOffset); } - } -} + } /* namespace dspu */ +} /* namespace lsp */ diff --git a/src/main/sampling/Playback.cpp b/src/main/sampling/Playback.cpp index 8056bfe..d5c395e 100644 --- a/src/main/sampling/Playback.cpp +++ b/src/main/sampling/Playback.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2022 Linux Studio Plugins Project - * (C) 2022 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-dsp-units * Created on: 18 нояб. 2022 г. @@ -89,6 +89,15 @@ namespace lsp return *this; } + Playback & Playback::operator = (Playback && src) + { + pPlayback = src.pPlayback; + nSerial = src.nSerial; + src.pPlayback = NULL; + src.nSerial = 0; + return *this; + } + bool Playback::valid() const { return (pPlayback != NULL) && (pPlayback->nSerial == nSerial); diff --git a/src/main/sampling/SamplePlayer.cpp b/src/main/sampling/SamplePlayer.cpp index 1e08ede..1dbfc11 100644 --- a/src/main/sampling/SamplePlayer.cpp +++ b/src/main/sampling/SamplePlayer.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2020 Linux Studio Plugins Project - * (C) 2020 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-plugins * Created on: 13 марта 2016 г. @@ -400,10 +400,6 @@ namespace lsp // lsp_trace("acquired playback %p", pb); - // Now we are ready to activate sample - if (settings == NULL) - settings = &PlaySettings::default_settings; - // Initialize playback state playback::start_playback(pb, acquire_sample(s), settings); @@ -519,5 +515,5 @@ namespace lsp } v->end_array(); } - } + } /* namespace dspu */ } /* namespace lsp */ diff --git a/src/main/sampling/helpers/playback.cpp b/src/main/sampling/helpers/playback.cpp index c83e195..c6537d6 100644 --- a/src/main/sampling/helpers/playback.cpp +++ b/src/main/sampling/helpers/playback.cpp @@ -272,9 +272,10 @@ namespace lsp { switch (pb->enLoopMode) { + case SAMPLE_LOOP_REVERSE_FULL_PP: case SAMPLE_LOOP_DIRECT_FULL_PP: - // If current batch is in direct direction, then we need to process - // one more batch in the reverse direction + // If current batch is in direct/reverse direction, then we need to process + // one more batch in the reverse/direct direction if (pb->bReverse) { if (s->nEnd < s->nStart) @@ -292,26 +293,6 @@ namespace lsp b->enType = BATCH_TAIL; return; - case SAMPLE_LOOP_REVERSE_FULL_PP: - // If current batch is in reverse direction, then we need to process - // one more batch in the direct direction - if (pb->bReverse) - { - if (s->nStart < s->nEnd) - break; - b->nStart = pb->nLoopStart; - b->nEnd = 0; - } - else - { - if (s->nEnd < s->nStart) - break; - b->nStart = pb->nLoopEnd; - b->nEnd = sample_len; - } - b->enType = BATCH_TAIL; - return; - case SAMPLE_LOOP_DIRECT_SMART_PP: case SAMPLE_LOOP_REVERSE_SMART_PP: // If current batch is in reverse direction, then we need to process diff --git a/src/main/util/Convolver.cpp b/src/main/util/Convolver.cpp index 17f0e32..9251e95 100644 --- a/src/main/util/Convolver.cpp +++ b/src/main/util/Convolver.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2020 Linux Studio Plugins Project - * (C) 2020 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-plugins * Created on: 29 янв. 2016 г. @@ -49,8 +49,8 @@ namespace lsp vFrame = NULL; vConvBuffer = NULL; vTaskData = NULL; - vDirectData = NULL; vConvData = NULL; + vDirectData = NULL; nDataBufferSize = 0; nDirectSize = 0; @@ -62,6 +62,9 @@ namespace lsp nBlocksDone = 0; nRank = 0; + nBlkInit = 0; + fBlkCoef = 0.0f; + vData = NULL; } @@ -163,7 +166,7 @@ namespace lsp nLevels = 0; for (; (count > 0) && (brank < rank); ++brank) { - size_t n = lsp_min(count, size_t(1 << (brank - 1))); + size_t n = lsp_min(count, size_t(1) << (brank - 1)); // Prepare raising convolution dsp::fill_zero(vConvBuffer, fft_buf_size); @@ -332,5 +335,6 @@ namespace lsp v->write("vData", vData); } - } + + } /* namespace dspu */ } /* namespace lsp */ diff --git a/src/main/util/Crossover.cpp b/src/main/util/Crossover.cpp index f371d36..f69962c 100644 --- a/src/main/util/Crossover.cpp +++ b/src/main/util/Crossover.cpp @@ -40,7 +40,7 @@ namespace lsp void Crossover::construct() { - nReconfigure = 0; + nReconfigure = R_ALL; nSplits = 0; nBufSize = 0; nSampleRate = LSP_DSP_UNITS_DEFAULT_SAMPLE_RATE; @@ -52,7 +52,6 @@ namespace lsp vLpfBuf = NULL; vHpfBuf = NULL; - pData = NULL; } diff --git a/src/main/util/Depopper.cpp b/src/main/util/Depopper.cpp index 718a0f5..72cdf05 100644 --- a/src/main/util/Depopper.cpp +++ b/src/main/util/Depopper.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2020 Linux Studio Plugins Project - * (C) 2020 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-plugins * Created on: 4 июл. 2020 г. @@ -50,12 +50,14 @@ namespace lsp nLookMin = 0; nLookMax = 0; nLookOff = 0; + nLookCount = 0; fRmsMax = 0.0f; fRmsLength = 0.0f; nRmsMin = 0; nRmsMax = 0; nRmsOff = 0; + nRmsLen = 0; fRmsNorm = 0.0f; nCounter = 0; @@ -606,5 +608,6 @@ namespace lsp v->write("bReconfigure", bReconfigure); } - } + + } /* namespace dspu */ } /* namespace lsp */ diff --git a/src/main/util/Oscillator.cpp b/src/main/util/Oscillator.cpp index 06d8010..a72ab43 100644 --- a/src/main/util/Oscillator.cpp +++ b/src/main/util/Oscillator.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2020 Linux Studio Plugins Project - * (C) 2020 Stefano Tronci + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Stefano Tronci * * This file is part of lsp-plugins * Created on: 20 Mar 2017 @@ -169,7 +169,6 @@ namespace lsp { case FG_SINE: case FG_COSINE: - case FG_MAX: fReferencedDC = fDCOffset; break; case FG_SQUARED_SINE: @@ -228,22 +227,13 @@ namespace lsp else sSawtooth.nWidthWord = sSawtooth.fWidth * (nPhaseAccMask + 1.0f); - sSawtooth.fCoeffs[0] = 2.0f * fAmplitude / sSawtooth.nWidthWord; - sSawtooth.fCoeffs[1] = -fAmplitude; - sSawtooth.fCoeffs[2] = (-2.0f * fAmplitude) / (nPhaseAccMask + 1.0f - sSawtooth.nWidthWord); - sSawtooth.fCoeffs[3] = fAmplitude * (nPhaseAccMask + 1.0f + sSawtooth.nWidthWord) / (nPhaseAccMask + 1.0f - sSawtooth.nWidthWord); - sSawtooth.fWaveDC = 0.0f; + sSawtooth.fCoeffs[0] = 2.0f * fAmplitude / sSawtooth.nWidthWord; + sSawtooth.fCoeffs[1] = -fAmplitude; + sSawtooth.fCoeffs[2] = (-2.0f * fAmplitude) / (nPhaseAccMask + 1.0f - sSawtooth.nWidthWord); + sSawtooth.fCoeffs[3] = fAmplitude * (nPhaseAccMask + 1.0f + sSawtooth.nWidthWord) / (nPhaseAccMask + 1.0f - sSawtooth.nWidthWord); + sSawtooth.fWaveDC = 0.0f; - switch (enDCReference) - { - case DC_ZERO: - fReferencedDC = fDCOffset; //sSawtooth.fWaveDC == 0.0f - break; - case DC_WAVEDC: - default: - fReferencedDC = fDCOffset; - break; - } + fReferencedDC = fDCOffset; //sSawtooth.fWaveDC == 0.0f // Gibbs starts being noticeable at 6% or 94% with, so we drop // linearly the amplitude. @@ -259,76 +249,61 @@ namespace lsp case FG_TRAPEZOID: case FG_BL_TRAPEZOID: { - sTrapezoid.nPoints[0] = sTrapezoid.fRaiseRatio * 0.5f * (nPhaseAccMask + 1.0f); - sTrapezoid.nPoints[1] = (1.0f - sTrapezoid.fFallRatio) * 0.5f * (nPhaseAccMask + 1.0f); + sTrapezoid.nPoints[0] = sTrapezoid.fRaiseRatio * 0.5f * (nPhaseAccMask + 1.0f); + sTrapezoid.nPoints[1] = (1.0f - sTrapezoid.fFallRatio) * 0.5f * (nPhaseAccMask + 1.0f); if (sTrapezoid.fFallRatio < 1.0f) // Prevent overflow - sTrapezoid.nPoints[2] = (1.0f + sTrapezoid.fFallRatio) * 0.5f * (nPhaseAccMask + 1.0f); + sTrapezoid.nPoints[2] = (1.0f + sTrapezoid.fFallRatio) * 0.5f * (nPhaseAccMask + 1.0f); else - sTrapezoid.nPoints[2] = nPhaseAccMask; + sTrapezoid.nPoints[2] = nPhaseAccMask; if (sTrapezoid.fRaiseRatio > 0.0f) // Prevent overflow - sTrapezoid.nPoints[3] = (2.0f - sTrapezoid.fRaiseRatio) * 0.5f * (nPhaseAccMask + 1.0f); + sTrapezoid.nPoints[3] = (2.0f - sTrapezoid.fRaiseRatio) * 0.5f * (nPhaseAccMask + 1.0f); else - sTrapezoid.nPoints[3] = nPhaseAccMask; + sTrapezoid.nPoints[3] = nPhaseAccMask; - sTrapezoid.fCoeffs[0] = fAmplitude / sTrapezoid.nPoints[0]; - sTrapezoid.fCoeffs[1] = -2.0f * fAmplitude / (sTrapezoid.nPoints[2] - sTrapezoid.nPoints[1]); - sTrapezoid.fCoeffs[2] = fAmplitude / sTrapezoid.fFallRatio; - sTrapezoid.fCoeffs[3] = -2.0f * fAmplitude / sTrapezoid.fRaiseRatio; - sTrapezoid.fWaveDC = 0.0f; + sTrapezoid.fCoeffs[0] = fAmplitude / sTrapezoid.nPoints[0]; + sTrapezoid.fCoeffs[1] = -2.0f * fAmplitude / (sTrapezoid.nPoints[2] - sTrapezoid.nPoints[1]); + sTrapezoid.fCoeffs[2] = fAmplitude / sTrapezoid.fFallRatio; + sTrapezoid.fCoeffs[3] = -2.0f * fAmplitude / sTrapezoid.fRaiseRatio; + sTrapezoid.fWaveDC = 0.0f; - switch (enDCReference) - { - case DC_ZERO: - fReferencedDC = fDCOffset; //sTrapezoid.fWaveDC == 0.0f - break; - case DC_WAVEDC: - default: - fReferencedDC = fDCOffset; - break; - } + fReferencedDC = fDCOffset; //sSawtooth.fWaveDC == 0.0f // Gibbs starts being noticeable at 6% or 94% with, so we drop // linearly the amplitude. float minRatio = (sTrapezoid.fRaiseRatio < sTrapezoid.fFallRatio) ? sTrapezoid.fRaiseRatio : sTrapezoid.fFallRatio; - if (minRatio < 0.40f) - sTrapezoid.fBLPeakAtten = minRatio + 0.6f; - else - sTrapezoid.fBLPeakAtten = 1.0f; + sTrapezoid.fBLPeakAtten = (minRatio < 0.4f) ? minRatio + 0.6f : 1.0f; } break; case FG_PULSETRAIN: case FG_BL_PULSETRAIN: { - sPulse.nTrainPoints[0] = sPulse.fPosWidthRatio * 0.5f * (nPhaseAccMask + 1.0f); - sPulse.nTrainPoints[1] = 0.5f * (nPhaseAccMask + 1.0f); + sPulse.nTrainPoints[0] = sPulse.fPosWidthRatio * 0.5f * (nPhaseAccMask + 1.0f); + sPulse.nTrainPoints[1] = 0.5f * (nPhaseAccMask + 1.0f); if (sPulse.fNegWidthRatio == 1.0f) // Prevent overflow sPulse.nTrainPoints[2] = nPhaseAccMask; else sPulse.nTrainPoints[2] = (1.0f + sPulse.fNegWidthRatio) * 0.5f * (nPhaseAccMask + 1.0f); - sPulse.fWaveDC = 0.5f * fAmplitude * (sPulse.fPosWidthRatio - sPulse.fNegWidthRatio); + sPulse.fWaveDC = 0.5f * fAmplitude * (sPulse.fPosWidthRatio - sPulse.fNegWidthRatio); switch (enDCReference) { case DC_ZERO: - fReferencedDC = fDCOffset - sPulse.fWaveDC; + fReferencedDC = fDCOffset - sPulse.fWaveDC; break; case DC_WAVEDC: default: - fReferencedDC = fDCOffset; + fReferencedDC = fDCOffset; break; } float maxRatio = (sPulse.fNegWidthRatio > sPulse.fPosWidthRatio) ? sPulse.fNegWidthRatio : sPulse.fPosWidthRatio; - if (maxRatio > 0.5f) - sPulse.fBLPeakAtten = 0.6f; - else - sPulse.fBLPeakAtten = M_SQRT1_2; + sPulse.fBLPeakAtten = (maxRatio > 0.5f) ? 0.6f : M_SQRT1_2; } break; @@ -797,9 +772,6 @@ namespace lsp void Oscillator::set_dc_reference(dc_reference_t dcReference) { - if ((dcReference < DC_WAVEDC) || (dcReference >= DC_MAX)) - return; - enDCReference = dcReference; bSync = true; } @@ -1009,5 +981,6 @@ namespace lsp v->write("nFreqCtrlWord_Over", nFreqCtrlWord_Over); v->write("bSync", bSync); } - } -} + + } /* namespace dspu */ +} /* namespace lsp */ diff --git a/src/main/util/Oversampler.cpp b/src/main/util/Oversampler.cpp index 78fbf68..03f4f5d 100644 --- a/src/main/util/Oversampler.cpp +++ b/src/main/util/Oversampler.cpp @@ -1054,10 +1054,6 @@ namespace lsp void Oversampler::set_mode(over_mode_t mode) { - if (mode < OM_NONE) - mode = OM_NONE; - else if (mode > OM_LANCZOS_8X24BIT) - mode = OM_LANCZOS_8X24BIT; if (nMode == mode) return; nMode = mode; diff --git a/src/main/util/Randomizer.cpp b/src/main/util/Randomizer.cpp index 6088f7f..997e22e 100644 --- a/src/main/util/Randomizer.cpp +++ b/src/main/util/Randomizer.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2020 Linux Studio Plugins Project - * (C) 2020 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-plugins * Created on: 23 марта 2016 г. @@ -87,7 +87,7 @@ namespace lsp { for (size_t i=0; i<4; ++i) { - uint32_t reseed = (seed << (i * 8)) | (seed >> ((sizeof(uint32_t) - i) * 8)); + uint32_t reseed = (i > 0) ? (seed << (i * 8)) | (seed >> ((sizeof(uint32_t) - i) * 8)) : seed; vRandom[i].vAdd = vAdders[reseed & 0x0f]; vRandom[i].vMul1 = vMul1[(reseed >> 4) & 0x0f]; @@ -161,5 +161,5 @@ namespace lsp v->write("nBufID", nBufID); } - } + } /* namespace dspu */ } /* namespace lsp */ diff --git a/src/main/util/ResponseTaker.cpp b/src/main/util/ResponseTaker.cpp index cda2a57..4fea0a9 100644 --- a/src/main/util/ResponseTaker.cpp +++ b/src/main/util/ResponseTaker.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2020 Linux Studio Plugins Project - * (C) 2020 Stefano Tronci + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Stefano Tronci * * This file is part of lsp-plugins * Created on: 30 Jul 2017 @@ -114,16 +114,21 @@ namespace lsp if (bReAllocate) { - delete pCapture; - pCapture = NULL; + if (pCapture != NULL) + { + delete pCapture; + pCapture = NULL; + } Sample *s = new Sample(); - if (s == NULL) return STATUS_NO_MEM; if (!s->init(nChannels, nCaptureLength, nCaptureLength)) + { + delete s; return STATUS_NO_MEM; + } pCapture = s; } @@ -419,5 +424,6 @@ namespace lsp v->write("bCycleComplete", bCycleComplete); v->write("bSync", bSync); } - } -} + + } /* namespace dspu */ +} /* namespace lsp */ diff --git a/src/main/util/RingBuffer.cpp b/src/main/util/RingBuffer.cpp index 7ce0f9f..e3ebd27 100644 --- a/src/main/util/RingBuffer.cpp +++ b/src/main/util/RingBuffer.cpp @@ -50,7 +50,7 @@ namespace lsp if (data == NULL) return false; - lsp::swap(pData, data); + pData = data; nCapacity = size; nHead = 0; diff --git a/src/main/util/SpectralSplitter.cpp b/src/main/util/SpectralSplitter.cpp index bcec022..93023f1 100644 --- a/src/main/util/SpectralSplitter.cpp +++ b/src/main/util/SpectralSplitter.cpp @@ -68,7 +68,6 @@ namespace lsp nRank = max_rank; nMaxRank = max_rank; fPhase = 0.0f; - bUpdate = true; vWnd = NULL; vInBuf = NULL; vFftBuf = NULL; diff --git a/src/main/util/SyncChirpProcessor.cpp b/src/main/util/SyncChirpProcessor.cpp index 756029a..16cf205 100644 --- a/src/main/util/SyncChirpProcessor.cpp +++ b/src/main/util/SyncChirpProcessor.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2020 Linux Studio Plugins Project - * (C) 2020 Stefano Tronci + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Stefano Tronci * * This file is part of lsp-plugins * Created on: 12 Jul 2017 @@ -174,7 +174,6 @@ namespace lsp vOverBuffer2 = ptr; ptr += OVER_BUF_LIMIT_SIZE; vEnvelopeBuffer = ptr; - ptr += ENVELOPE_BUF_LIMIT_SIZE; return sOver1.init() && sOver2.init(); } @@ -2315,5 +2314,6 @@ namespace lsp v->write("pData", pData); v->write("bSync", bSync); } - } -} + + } /* namespace dspu */ +} /* namespace lsp */ diff --git a/src/main/util/Trigger.cpp b/src/main/util/Trigger.cpp index fff2d81..4aa1de3 100644 --- a/src/main/util/Trigger.cpp +++ b/src/main/util/Trigger.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2021 Linux Studio Plugins Project - * (C) 2021 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-dsp-units * Created on: 13 авг. 2021 г. @@ -268,7 +268,8 @@ namespace lsp v->write("bSync", bSync); } - } // namespace dspu -} // namespace lsp + + } /* namespace dspu */ +} /* namespace lsp */