From bec26e40d259c7f388fbe6b322217386f8b36774 Mon Sep 17 00:00:00 2001 From: StoneyDSP Date: Fri, 22 Mar 2024 07:08:32 +0100 Subject: [PATCH] Still working out this parameter array (this will fail CI/CD)... Signed-off-by: StoneyDSP --- CMakeLists.txt | 228 +++++++++--- Sources/Biquads.cpp | 14 +- Sources/Biquads.hpp | 11 +- Sources/{ => Editor}/Editor.cpp | 0 Sources/{ => Editor}/Editor.hpp | 23 +- Sources/{ => Editor}/Editor.mm | 0 Sources/{ => Parameters}/Parameters.cpp | 0 Sources/{ => Parameters}/Parameters.hpp | 4 +- Sources/{ => Parameters}/Parameters.mm | 0 Sources/{ => Processor}/Processor.cpp | 6 +- Sources/{ => Processor}/Processor.hpp | 9 + Sources/{ => Processor}/Processor.mm | 0 Sources/Wrapper.cpp | 387 -------------------- Sources/Wrapper/Wrapper.cpp | 456 ++++++++++++++++++++++++ Sources/{ => Wrapper}/Wrapper.hpp | 71 ++-- Sources/{ => Wrapper}/Wrapper.mm | 0 VERSION | 2 +- 17 files changed, 723 insertions(+), 488 deletions(-) rename Sources/{ => Editor}/Editor.cpp (100%) rename Sources/{ => Editor}/Editor.hpp (75%) rename Sources/{ => Editor}/Editor.mm (100%) rename Sources/{ => Parameters}/Parameters.cpp (100%) rename Sources/{ => Parameters}/Parameters.hpp (97%) rename Sources/{ => Parameters}/Parameters.mm (100%) rename Sources/{ => Processor}/Processor.cpp (99%) rename Sources/{ => Processor}/Processor.hpp (96%) rename Sources/{ => Processor}/Processor.mm (100%) delete mode 100644 Sources/Wrapper.cpp create mode 100644 Sources/Wrapper/Wrapper.cpp rename Sources/{ => Wrapper}/Wrapper.hpp (76%) rename Sources/{ => Wrapper}/Wrapper.mm (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec43929..e6c396e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,9 @@ set_directory_properties (PROPERTIES set (STONEYDSP_BIQUADS_INCLUDEDIR "") set (STONEYDSP_BIQUADS_INCLUDEDIR "${STONEYDSP_BIQUADS_BINARY_DIR}/Sources") # dont CACHE FORCE this yet, it will change again soon... +set (STONEYDSP_BIQUADS_FILE_EXTENSIONS "") +list (APPEND STONEYDSP_BIQUADS_FILE_EXTENSIONS "hpp" "cpp" "mm") + set (STONEYDSP_BIQUADS_UNIT "Biquads") set (STONEYDSP_BIQUADS_UNIT_EDITOR "Editor") set (STONEYDSP_BIQUADS_UNIT_PARAMETERS "Parameters") @@ -95,22 +98,78 @@ set (STONEYDSP_BIQUADS_UNIT_WRAPPER "Wrapper") set (STONEYDSP_BIQUADS_UNIT_FILES "") list (APPEND STONEYDSP_BIQUADS_UNIT_FILES - "${STONEYDSP_BIQUADS_UNIT}" + # "${STONEYDSP_BIQUADS_UNIT}" "${STONEYDSP_BIQUADS_UNIT_EDITOR}" "${STONEYDSP_BIQUADS_UNIT_PARAMETERS}" "${STONEYDSP_BIQUADS_UNIT_PROCESSOR}" "${STONEYDSP_BIQUADS_UNIT_WRAPPER}" ) foreach (STONEYDSP_BIQUADS_UNIT_FILE IN LISTS STONEYDSP_BIQUADS_UNIT_FILES) - configure_file ( - "Sources/${STONEYDSP_BIQUADS_UNIT_FILE}.hpp" # SRC_DIR - "Sources/${STONEYDSP_BIQUADS_UNIT_FILE}.hpp" # BIN_DIR - ) + foreach (STONEYDSP_BIQUADS_FILE_EXTENSION IN LISTS STONEYDSP_BIQUADS_FILE_EXTENSIONS) + configure_file ( + "Sources/${STONEYDSP_BIQUADS_UNIT_FILE}/${STONEYDSP_BIQUADS_UNIT_FILE}.${STONEYDSP_BIQUADS_FILE_EXTENSION}" # SRC_DIR + "Biquads_Audio_Plugin_artefacts/Sources/${STONEYDSP_BIQUADS_UNIT_FILE}/${STONEYDSP_BIQUADS_UNIT_FILE}.${STONEYDSP_BIQUADS_FILE_EXTENSION}" # BIN_DIR + ) + endforeach () endforeach() +foreach (STONEYDSP_BIQUADS_UNIT_FILE IN LISTS STONEYDSP_BIQUADS_UNIT_FILES) + + add_library (${STONEYDSP_BIQUADS_UNIT_FILE} INTERFACE) + add_library (StoneyDSP::Biquads::${STONEYDSP_BIQUADS_UNIT_FILE} ALIAS ${STONEYDSP_BIQUADS_UNIT_FILE}) + + if (CMAKE_MAJOR_VERSION GREATER_EQUAL 3 AND (CMAKE_MINOR_VERSION LESS 23)) + + target_include_directories (${STONEYDSP_BIQUADS_UNIT_FILE} + INTERFACE + $ + $ + ) + + target_sources (${STONEYDSP_BIQUADS_UNIT_FILE} + INTERFACE + $ + $ + ) + + else () + + target_sources (${STONEYDSP_BIQUADS_UNIT_FILE} + + INTERFACE + FILE_SET biquads_${STONEYDSP_BIQUADS_UNIT_FILE}_HEADERS + TYPE HEADERS + BASE_DIRS + $ + $ + FILES + $ + $ + ) + + target_sources (${STONEYDSP_BIQUADS_UNIT_FILE} + + INTERFACE + # FILE_SET biquads_${STONEYDSP_BIQUADS_UNIT_FILE}_SOURCES + # TYPE CXX_MODULES + # BASE_DIRS + # $ + # $ + # FILES + $ + $ + ) + endif() + +endforeach () + +# target_link_libraries (Wrapper INTERFACE StoneyDSP::Biquads::Parameters) + +# target_link_libraries (Processor INTERFACE StoneyDSP::Biquads::Wrapper StoneyDSP::Biquads::Parameters StoneyDSP::Biquads::Editor) + unset (STONEYDSP_BIQUADS_INCLUDEDIR) set (STONEYDSP_BIQUADS_INCLUDEDIR - $ + $ $ ) @@ -192,11 +251,50 @@ foreach(STONEYDSP_BIQUADS_STONEYDSP_MODULE_DEPENDENCY IN LISTS STONEYDSP_BIQUADS ) endforeach() +# juce_add_modules( +# INSTALL_PATH "include/StoneyDSP/Biquads" +# ALIAS_NAMESPACE StoneyDSP + +# "${STONEYDSP_BIQUADS_SOURCE_DIR}/Sources/Biquads" +# ) + +# juce_add_modules( +# INSTALL_PATH "include/StoneyDSP/Biquads" +# ALIAS_NAMESPACE StoneyDSP::Biquads + +# "${STONEYDSP_BIQUADS_SOURCE_DIR}/Sources/Parameters" +# "${STONEYDSP_BIQUADS_SOURCE_DIR}/Sources/Wrapper" +# "${STONEYDSP_BIQUADS_SOURCE_DIR}/Sources/Editor" +# "${STONEYDSP_BIQUADS_SOURCE_DIR}/Sources/Processor" +# ) + +# target_link_libraries (Biquads_Audio_Plugin +# PRIVATE +# # StoneyDSP::Biquads +# StoneyDSP::Biquads::Parameters +# StoneyDSP::Biquads::Wrapper +# StoneyDSP::Biquads::Editor +# StoneyDSP::Biquads::Processor +# ) + +configure_file ( + "Sources/Biquads.hpp" + "Biquads_Audio_Plugin_artefacts/Sources/Biquads.hpp" +) +configure_file ( + "Sources/Biquads.cpp" + "Biquads_Audio_Plugin_artefacts/Sources/Biquads.cpp" +) +configure_file ( + "Sources/Biquads.mm" + "Biquads_Audio_Plugin_artefacts/Sources/Biquads.mm" +) + if (CMAKE_MAJOR_VERSION GREATER_EQUAL 3 AND (CMAKE_MINOR_VERSION LESS 23)) target_include_directories (Biquads_Audio_Plugin PUBLIC - $ + $ $ ) @@ -208,35 +306,67 @@ else () FILE_SET biquads_AUDIO_PLUGIN_HEADERS TYPE HEADERS BASE_DIRS - $ - $ + $ + $ FILES - $ - $ - - $ - $ - - $ - $ - - $ - $ - - $ - $ + $ + $ ) endif() target_sources (Biquads_Audio_Plugin PRIVATE - "Sources/${STONEYDSP_BIQUADS_UNIT_PARAMETERS}.cpp" - "Sources/${STONEYDSP_BIQUADS_UNIT_WRAPPER}.cpp" - "Sources/${STONEYDSP_BIQUADS_UNIT_PROCESSOR}.cpp" - "Sources/${STONEYDSP_BIQUADS_UNIT_EDITOR}.cpp" - "Sources/${STONEYDSP_BIQUADS_UNIT}.cpp" + $ + $ ) + + +# if (CMAKE_MAJOR_VERSION GREATER_EQUAL 3 AND (CMAKE_MINOR_VERSION LESS 23)) + +# target_include_directories (Biquads_Audio_Plugin +# PUBLIC +# $ +# $ +# ) + +# else () + +# target_sources (Biquads_Audio_Plugin + +# PUBLIC +# FILE_SET biquads_AUDIO_PLUGIN_HEADERS +# TYPE HEADERS +# BASE_DIRS +# $ +# $ +# FILES +# $ +# $ + +# $ +# $ + +# $ +# $ + +# $ +# $ + +# $ +# $ +# ) +# endif() + +# target_sources (Biquads_Audio_Plugin +# PRIVATE +# "Sources/${STONEYDSP_BIQUADS_UNIT_PARAMETERS}.cpp" +# "Sources/${STONEYDSP_BIQUADS_UNIT_WRAPPER}.cpp" +# "Sources/${STONEYDSP_BIQUADS_UNIT_PROCESSOR}.cpp" +# "Sources/${STONEYDSP_BIQUADS_UNIT_EDITOR}.cpp" +# "Sources/${STONEYDSP_BIQUADS_UNIT}.cpp" +# ) + set (STONEYDSP_BIQUADS_JUCE_FLAGS "") if (STONEYDSP_BIQUADS_USING_JUCE_RECOMMENDED_CONFIG_FLAGS) list (APPEND STONEYDSP_BIQUADS_JUCE_FLAGS juce_recommended_config_flags) @@ -250,7 +380,7 @@ endif () foreach (STONEYDSP_BIQUADS_JUCE_FLAG IN LISTS STONEYDSP_BIQUADS_JUCE_FLAGS) target_link_libraries (Biquads_Audio_Plugin - PUBLIC + PRIVATE juce::${STONEYDSP_BIQUADS_JUCE_FLAG} ) endforeach () @@ -279,14 +409,14 @@ target_compile_definitions (Biquads_Audio_Plugin # target_link_libraries (Biquads_Audio_Plugin # PRIVATE -# # StoneyDSP::Biquads_Audio_Plugin_Dependencies # MUST be PRIVATE! -# StoneyDSP::Biquads::Parameters -# StoneyDSP::Biquads::Wrapper -# StoneyDSP::Biquads::Editor -# StoneyDSP::Biquads::Processor -# # StoneyDSP::Biquads_Audio_Plugin_Library -# # INTERFACE -# # StoneyDSP::Biquads_Audio_Plugin_Interface # MUST be INTERFACE! + # StoneyDSP::Biquads_Audio_Plugin_Dependencies # MUST be PRIVATE! + # StoneyDSP::Biquads::Parameters + # StoneyDSP::Biquads::Wrapper + # StoneyDSP::Biquads::Editor + # StoneyDSP::Biquads::Processor + # StoneyDSP::Biquads_Audio_Plugin_Library + # INTERFACE + # StoneyDSP::Biquads_Audio_Plugin_Interface # MUST be INTERFACE! # ) #[=============================================================================[ @@ -314,7 +444,7 @@ include(CMakePackageConfigHelpers) include(GNUInstallDirs) write_basic_package_version_file( - "${STONEYDSP_BIQUADS_BINARY_DIR}/share/StoneyDSP/Biquads/StoneyDSPBiquadsConfigVersion.cmake" + "${STONEYDSP_BIQUADS_BINARY_DIR}/StoneyDSPBiquadsConfigVersion.cmake" VERSION ${STONEYDSP_BIQUADS_VERSION} COMPATIBILITY ExactVersion ) @@ -328,18 +458,18 @@ set(STONEYDSP_BIQUADS_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "I set(STONEYDSP_BIQUADS_INSTALL_CMAKEDIR "${STONEYDSP_BIQUADS_INSTALL_LIBDIR}/cmake/StoneyDSP/Biquads" CACHE STRING "The location, relative to the install prefix, where the StoneyDSP Biquads config file will be installed") -foreach (STONEYDSP_BIQUADS_UNIT_FILE IN LISTS STONEYDSP_BIQUADS_UNIT_FILES) - install(FILES - "${STONEYDSP_BIQUADS_BINARY_DIR}/Sources/${STONEYDSP_BIQUADS_UNIT_FILE}.hpp" - "${STONEYDSP_BIQUADS_BINARY_DIR}/Sources/${STONEYDSP_BIQUADS_UNIT_FILE}.cpp" - "${STONEYDSP_BIQUADS_BINARY_DIR}/Sources/${STONEYDSP_BIQUADS_UNIT_FILE}.mm" - DESTINATION "include/StoneyDSP/Biquads" - ) -endforeach () +# foreach (STONEYDSP_BIQUADS_UNIT_FILE IN LISTS STONEYDSP_BIQUADS_UNIT_FILES) +# install(FILES +# "${STONEYDSP_BIQUADS_BINARY_DIR}/include/StoneyDSP/Biquads/${STONEYDSP_BIQUADS_UNIT_FILE}.hpp" +# "${STONEYDSP_BIQUADS_BINARY_DIR}/include/StoneyDSP/Biquads/${STONEYDSP_BIQUADS_UNIT_FILE}.cpp" +# "${STONEYDSP_BIQUADS_BINARY_DIR}/include/StoneyDSP/Biquads/${STONEYDSP_BIQUADS_UNIT_FILE}.mm" +# DESTINATION "include/StoneyDSP/Biquads" +# ) +# endforeach () configure_package_config_file( "${STONEYDSP_BIQUADS_SOURCE_DIR}/share/StoneyDSP/Biquads/StoneyDSPBiquadsConfig.cmake.in" - "${STONEYDSP_BIQUADS_BINARY_DIR}/share/StoneyDSP/Biquads/StoneyDSPBiquadsConfig.cmake" + "${STONEYDSP_BIQUADS_BINARY_DIR}/StoneyDSPBiquadsConfig.cmake" INSTALL_DESTINATION "lib/cmake/StoneyDSP/Biquads" ) @@ -355,8 +485,8 @@ install ( ) install (FILES - "${STONEYDSP_BIQUADS_BINARY_DIR}/share/StoneyDSP/Biquads/StoneyDSPBiquadsConfigVersion.cmake" - "${STONEYDSP_BIQUADS_BINARY_DIR}/share/StoneyDSP/Biquads/StoneyDSPBiquadsConfig.cmake" + "${STONEYDSP_BIQUADS_BINARY_DIR}/StoneyDSPBiquadsConfigVersion.cmake" + "${STONEYDSP_BIQUADS_BINARY_DIR}/StoneyDSPBiquadsConfig.cmake" "${STONEYDSP_BIQUADS_SOURCE_DIR}/share/cmake/Modules/GetGitRevListCount.cmake" "${STONEYDSP_BIQUADS_SOURCE_DIR}/share/cmake/Modules/StoneyDSPBiquadsCPackIgnoreList.cmake" "${STONEYDSP_BIQUADS_SOURCE_DIR}/share/cmake/Modules/StoneyDSPBiquadsWriteVersionFile.cmake" diff --git a/Sources/Biquads.cpp b/Sources/Biquads.cpp index 81e3b81..e82b1e0 100644 --- a/Sources/Biquads.cpp +++ b/Sources/Biquads.cpp @@ -22,9 +22,9 @@ ******************************************************************************/ -#ifdef STONEYDSP_BIQUADS_HPP_INCLUDED - #error "Incorrect usage of 'Biquads.cpp'!" -#endif +// #ifdef STONEYDSP_BIQUADS_HPP_INCLUDED +// #error "Incorrect usage of 'Biquads.cpp'!" +// #endif #include "Biquads.hpp" @@ -49,10 +49,10 @@ namespace ProjectInfo } // namespace StoneyDSP // #ifdef STONEYDSP_BIQUADS_MODULE -// #include "Biquads/Parameters.cpp" -// #include "Biquads/Wrapper.cpp" -// #include "Biquads/Processor.cpp" -// #include "Biquads/Editor.cpp" + #include "Parameters/Parameters.cpp" + #include "Wrapper/Wrapper.cpp" + #include "Processor/Processor.cpp" + #include "Editor/Editor.cpp" // #endif //============================================================================== diff --git a/Sources/Biquads.hpp b/Sources/Biquads.hpp index 167ec1e..40c2b88 100644 --- a/Sources/Biquads.hpp +++ b/Sources/Biquads.hpp @@ -42,6 +42,7 @@ #include #include #include + #include #include @@ -63,7 +64,7 @@ namespace StoneyDSP namespace Biquads { -// class AudioPluginAudioProcessor; +class AudioPluginAudioProcessor; /** @addtogroup Biquads * @{ @@ -104,7 +105,7 @@ template struct Polar; /// @} group StoneyDSP } // namespace StoneyDSP -#include "Parameters.hpp" -#include "Wrapper.hpp" -#include "Processor.hpp" -#include "Editor.hpp" +#include "Parameters/Parameters.hpp" +#include "Wrapper/Wrapper.hpp" +#include "Processor/Processor.hpp" +#include "Editor/Editor.hpp" diff --git a/Sources/Editor.cpp b/Sources/Editor/Editor.cpp similarity index 100% rename from Sources/Editor.cpp rename to Sources/Editor/Editor.cpp diff --git a/Sources/Editor.hpp b/Sources/Editor/Editor.hpp similarity index 75% rename from Sources/Editor.hpp rename to Sources/Editor/Editor.hpp index 793a53f..ef60653 100644 --- a/Sources/Editor.hpp +++ b/Sources/Editor/Editor.hpp @@ -25,10 +25,23 @@ #pragma once #define STONEYDSP_BIQUADS_EDITOR_HPP_INCLUDED -// #include "Biquads.hpp" - -// #include "Processor.hpp" -// #include "Components/AutoComponent.hpp" +#ifndef STONEYDSP_BIQUADS_HPP_INCLUDED +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +// #include namespace StoneyDSP { /** @addtogroup StoneyDSP @{ */ @@ -36,6 +49,8 @@ namespace StoneyDSP { namespace Biquads { /** @addtogroup Biquads @{ */ +// class AudioPluginAudioProcessor; + //============================================================================== class JUCE_API AudioPluginAudioProcessorEditor final : public juce::AudioProcessorEditor { diff --git a/Sources/Editor.mm b/Sources/Editor/Editor.mm similarity index 100% rename from Sources/Editor.mm rename to Sources/Editor/Editor.mm diff --git a/Sources/Parameters.cpp b/Sources/Parameters/Parameters.cpp similarity index 100% rename from Sources/Parameters.cpp rename to Sources/Parameters/Parameters.cpp diff --git a/Sources/Parameters.hpp b/Sources/Parameters/Parameters.hpp similarity index 97% rename from Sources/Parameters.hpp rename to Sources/Parameters/Parameters.hpp index 0ba1d20..8b2fc18 100644 --- a/Sources/Parameters.hpp +++ b/Sources/Parameters/Parameters.hpp @@ -25,6 +25,7 @@ #pragma once #define STONEYDSP_BIQUADS_PARAMETERS_HPP_INCLUDED +#ifndef STONEYDSP_BIQUADS_HPP_INCLUDED #include // depends: juce_core #include // depends: juce_gui_extra, juce_audio_basics #include // @@ -33,8 +34,9 @@ #include // depends: juce_events #include // depends: juce_graphics, juce_data_structures #include // depends: juce_gui_basics +#endif // STONEYDSP_BIQUADS_HPP_INCLUDED -// #include "Biquads.hpp" +// #include namespace StoneyDSP { /** @addtogroup StoneyDSP @{ */ diff --git a/Sources/Parameters.mm b/Sources/Parameters/Parameters.mm similarity index 100% rename from Sources/Parameters.mm rename to Sources/Parameters/Parameters.mm diff --git a/Sources/Processor.cpp b/Sources/Processor/Processor.cpp similarity index 99% rename from Sources/Processor.cpp rename to Sources/Processor/Processor.cpp index f228b6b..c936a3f 100644 --- a/Sources/Processor.cpp +++ b/Sources/Processor/Processor.cpp @@ -22,9 +22,9 @@ ******************************************************************************/ -#ifdef STONEYDSP_BIQUADS_PROCESSOR_HPP_INCLUDED - #error "Incorrect usage of 'Processor.cpp'!" -#endif +// #ifdef STONEYDSP_BIQUADS_PROCESSOR_HPP_INCLUDED +// #error "Incorrect usage of 'Processor.cpp'!" +// #endif #include "Processor.hpp" diff --git a/Sources/Processor.hpp b/Sources/Processor/Processor.hpp similarity index 96% rename from Sources/Processor.hpp rename to Sources/Processor/Processor.hpp index 2f18fa8..39b884d 100644 --- a/Sources/Processor.hpp +++ b/Sources/Processor/Processor.hpp @@ -25,6 +25,7 @@ #pragma once #define STONEYDSP_BIQUADS_PROCESSOR_HPP_INCLUDED +#ifndef STONEYDSP_BIQUADS_HPP_INCLUDED #include // depends: juce_core #include // depends: juce_audio_basics #include // depends: juce_gui_extra, juce_audio_basics @@ -36,6 +37,14 @@ #include // depends: juce_graphics, juce_data_structures #include // depends: juce_gui_basics +#include +#include +#endif // STONEYDSP_BIQUADS_HPP_INCLUDED + +// #include +// #include +// #include + // #include "Biquads.hpp" // #include "Parameters.hpp" // #include "Wrapper.hpp" diff --git a/Sources/Processor.mm b/Sources/Processor/Processor.mm similarity index 100% rename from Sources/Processor.mm rename to Sources/Processor/Processor.mm diff --git a/Sources/Wrapper.cpp b/Sources/Wrapper.cpp deleted file mode 100644 index 3a85b96..0000000 --- a/Sources/Wrapper.cpp +++ /dev/null @@ -1,387 +0,0 @@ -/***************************************************************************//** - * @file Wrapper.cpp - * @author Nathan J. Hood (nathanjhood@googlemail.com) - * @brief Simple two-pole equalizer with variable oversampling. - * @version 1.2.3.155 - * @date 2024-03-16 - * - * @copyright Copyright (c) 2024 - Nathan J. Hood - - 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 3 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. If not, see . - - ******************************************************************************/ - -#ifdef STONEYDSP_BIQUADS_WRAPPER_HPP_INCLUDED - #error "Incorrect usage of 'Wrapper.cpp'!" -#endif - -#include "Wrapper.hpp" - -namespace StoneyDSP { -/** @addtogroup StoneyDSP @{ */ - -namespace Biquads { -/** @addtogroup Biquads @{ */ - -template -AudioPluginAudioProcessorWrapper::AudioPluginAudioProcessorWrapper(AudioPluginAudioProcessor& p, juce::AudioProcessorValueTreeState& apvts, juce::dsp::ProcessSpec& spec) -: audioProcessor(p) -, state(apvts) -, setup(spec) - -, mixer(std::make_unique>()) - -, biquadArraySize(static_cast(4)) // cannot ‘dynamic_cast’ this - target typeis not pointer or reference... - -, masterBypassPtr(dynamic_cast (apvts.getParameter("Master_bypassID"))) -, masterOutputPtr(dynamic_cast (apvts.getParameter("Master_outputID"))) -, masterMixPtr(dynamic_cast (apvts.getParameter("Master_mixID"))) -, masterOsPtr(dynamic_cast (apvts.getParameter("Master_osID"))) -, masterTransformPtr(dynamic_cast (apvts.getParameter("Master_transformID"))) - -, biquadsABypassPtr(dynamic_cast (apvts.getParameter("Band_A_bypassID"))) -, biquadsAFrequencyPtr(dynamic_cast (apvts.getParameter("Band_A_frequencyID"))) -, biquadsAResonancePtr(dynamic_cast (apvts.getParameter("Band_A_resonanceID"))) -, biquadsAGainPtr(dynamic_cast (apvts.getParameter("Band_A_gainID"))) -, biquadsATypePtr(dynamic_cast (apvts.getParameter("Band_A_typeID"))) - -, biquadsBBypassPtr(dynamic_cast (apvts.getParameter("Band_B_bypassID"))) -, biquadsBFrequencyPtr(dynamic_cast (apvts.getParameter("Band_B_frequencyID"))) -, biquadsBResonancePtr(dynamic_cast (apvts.getParameter("Band_B_resonanceID"))) -, biquadsBGainPtr(dynamic_cast (apvts.getParameter("Band_B_gainID"))) -, biquadsBTypePtr(dynamic_cast (apvts.getParameter("Band_B_typeID"))) - -, biquadsCBypassPtr(dynamic_cast (apvts.getParameter("Band_C_bypassID"))) -, biquadsCFrequencyPtr(dynamic_cast (apvts.getParameter("Band_C_frequencyID"))) -, biquadsCResonancePtr(dynamic_cast (apvts.getParameter("Band_C_resonanceID"))) -, biquadsCGainPtr(dynamic_cast (apvts.getParameter("Band_C_gainID"))) -, biquadsCTypePtr(dynamic_cast (apvts.getParameter("Band_C_typeID"))) - -, biquadsDBypassPtr(dynamic_cast (apvts.getParameter("Band_D_bypassID"))) -, biquadsDFrequencyPtr(dynamic_cast (apvts.getParameter("Band_D_frequencyID"))) -, biquadsDResonancePtr(dynamic_cast (apvts.getParameter("Band_D_resonanceID"))) -, biquadsDGainPtr(dynamic_cast (apvts.getParameter("Band_D_gainID"))) -, biquadsDTypePtr(dynamic_cast (apvts.getParameter("Band_D_typeID"))) - -, bypassState(dynamic_cast (apvts.getParameter("Master_bypassID"))) -{ - - masterBypassPtr = dynamic_cast (apvts.getParameter("Master_bypassID")); - masterOutputPtr = dynamic_cast (apvts.getParameter("Master_outputID")); - masterMixPtr = dynamic_cast (apvts.getParameter("Master_mixID")); - masterOsPtr = dynamic_cast (apvts.getParameter("Master_osID")); - masterTransformPtr = dynamic_cast (apvts.getParameter("Master_transformID")); - - biquadsABypassPtr = dynamic_cast (apvts.getParameter("Band_A_bypassID")); - biquadsAFrequencyPtr = dynamic_cast (apvts.getParameter("Band_A_frequencyID")); - biquadsAResonancePtr = dynamic_cast (apvts.getParameter("Band_A_resonanceID")); - biquadsAGainPtr = dynamic_cast (apvts.getParameter("Band_A_gainID")); - biquadsATypePtr = dynamic_cast (apvts.getParameter("Band_A_typeID")); - - biquadsBBypassPtr = dynamic_cast (apvts.getParameter("Band_B_bypassID")); - biquadsBFrequencyPtr = dynamic_cast (apvts.getParameter("Band_B_frequencyID")); - biquadsBResonancePtr = dynamic_cast (apvts.getParameter("Band_B_resonanceID")); - biquadsBGainPtr = dynamic_cast (apvts.getParameter("Band_B_gainID")); - biquadsBTypePtr = dynamic_cast (apvts.getParameter("Band_B_typeID")); - - biquadsCBypassPtr = dynamic_cast (apvts.getParameter("Band_C_bypassID")); - biquadsCFrequencyPtr = dynamic_cast (apvts.getParameter("Band_C_frequencyID")); - biquadsCResonancePtr = dynamic_cast (apvts.getParameter("Band_C_resonanceID")); - biquadsCGainPtr = dynamic_cast (apvts.getParameter("Band_C_gainID")); - biquadsCTypePtr = dynamic_cast (apvts.getParameter("Band_C_typeID")); - - biquadsDBypassPtr = dynamic_cast (apvts.getParameter("Band_D_bypassID")); - biquadsDFrequencyPtr = dynamic_cast (apvts.getParameter("Band_D_frequencyID")); - biquadsDResonancePtr = dynamic_cast (apvts.getParameter("Band_D_resonanceID")); - biquadsDGainPtr = dynamic_cast (apvts.getParameter("Band_D_gainID")); - biquadsDTypePtr = dynamic_cast (apvts.getParameter("Band_D_typeID")); - - bypassState = dynamic_cast (apvts.getParameter("Master_bypassID")); - - jassert(masterBypassPtr != nullptr); - jassert(masterOutputPtr != nullptr); - jassert(masterMixPtr != nullptr); - jassert(masterOsPtr != nullptr); - jassert(masterTransformPtr != nullptr); - - jassert(biquadsABypassPtr != nullptr); - jassert(biquadsAFrequencyPtr != nullptr); - jassert(biquadsAResonancePtr != nullptr); - jassert(biquadsAGainPtr != nullptr); - jassert(biquadsATypePtr != nullptr); - - jassert(biquadsBBypassPtr != nullptr); - jassert(biquadsBFrequencyPtr != nullptr); - jassert(biquadsBResonancePtr != nullptr); - jassert(biquadsBGainPtr != nullptr); - jassert(biquadsBTypePtr != nullptr); - - jassert(biquadsCBypassPtr != nullptr); - jassert(biquadsCFrequencyPtr != nullptr); - jassert(biquadsCResonancePtr != nullptr); - jassert(biquadsCGainPtr != nullptr); - jassert(biquadsCTypePtr != nullptr); - - jassert(biquadsDBypassPtr != nullptr); - jassert(biquadsDFrequencyPtr != nullptr); - jassert(biquadsDResonancePtr != nullptr); - jassert(biquadsDGainPtr != nullptr); - jassert(biquadsDTypePtr != nullptr); - - jassert(bypassState != nullptr); - - jassert(biquadArraySize != static_cast(0)); - - // auto osFilter = juce::dsp::Oversampling::filterHalfBandFIREquiripple; - - // for (int i = 0; i < 5; ++i) - // oversampler[i] = std::make_unique> - // (audioProcessor.getTotalNumInputChannels(), i, osFilter, true, false); - - for (std::size_t i = 0; i < biquadArraySize; ++i) - biquadArray[i] = std::make_unique>(); - - reset(static_cast(0.0)); -} - -template AudioPluginAudioProcessorWrapper::~AudioPluginAudioProcessorWrapper() -{ -} - -template -void AudioPluginAudioProcessorWrapper::prepare(juce::dsp::ProcessSpec& spec) -{ - jassert(spec.sampleRate > 0); - jassert(spec.numChannels > 0); - - // jassert((biquadArray.size() == biquadArraySize) && (biquadArraySize != static_cast(0))); - - sampleRate = spec.sampleRate; - - // oversamplingFactor = 1 << curOS; - // prevOS = curOS; - - // for (int i = 0; i < 5; ++i) - // oversampler[i]->initProcessing(spec.maximumBlockSize); - - // for (int i = 0; i < 5; ++i) - // oversampler[i]->numChannels = (size_t)spec.numChannels; - - reset(static_cast(0.0)); - - mixer->prepare(spec); - - for(auto& biquad : biquadArray) - biquad->prepare(spec); - - update(); -} - -template -void AudioPluginAudioProcessorWrapper::reset() -{ - SampleType initialValue = static_cast(0.0); - - mixer->reset(); - - for(auto& biquad : biquadArray) - biquad->reset(initialValue); - - // for (int i = 0; i < 5; ++i) - // oversampler[i]->reset(); -} - -template -void AudioPluginAudioProcessorWrapper::reset(SampleType initialValue) -{ - mixer->reset(); - - for(auto& biquad : biquadArray) - biquad->reset(initialValue); - - // for (int i = 0; i < 5; ++i) - // oversampler[i]->reset(); -} - -//============================================================================== -template -void AudioPluginAudioProcessorWrapper::process(juce::AudioBuffer& buffer, juce::MidiBuffer& midiMessages) -{ - auto totalNumInputChannels = audioProcessor.getTotalNumInputChannels(); - auto totalNumOutputChannels = audioProcessor.getTotalNumOutputChannels(); - auto numSamples = buffer.getNumSamples(); - - // In case we have more outputs than inputs, this code clears any output - // channels that didn't contain input data, (because these aren't - // guaranteed to be empty - they may contain garbage). - // This is here to avoid people getting screaming feedback - // when they first compile a plugin, but obviously you don't need to keep - // this code if your algorithm always overwrites all the output channels. - for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) - buffer.clear (i, 0, numSamples); - - // This is the place where you'd normally do the guts of your plugin's - // audio processing... - // Make sure to reset the state if your inner loop is processing - // the samples and the outer loop is handling the channels. - // Alternatively, you can process the samples with the channels - // interleaved by keeping the same state. - for (int channel = 0; channel < totalNumInputChannels; ++channel) - { - auto* channelData = buffer.getWritePointer (channel); - juce::ignoreUnused (channelData); - // ..do something to the data... (mixer push wet samples)? - } - - // setOversampling(); - update(); - - processBlock(buffer, midiMessages); - return; -} - -template -void AudioPluginAudioProcessorWrapper::processBlock(juce::AudioBuffer& buffer, juce::MidiBuffer& midiMessages) -{ - juce::ignoreUnused(midiMessages); - - juce::dsp::AudioBlock dryBlock(buffer); - juce::dsp::AudioBlock wetBlock(buffer); - - mixer->pushDrySamples(dryBlock); - - // wetBlock = oversampler[curOS]->processSamplesUp(dryBlock); - - // This context is intended for use in situations where two different blocks - // are being used as the input and output to the process algorithm, so the - // processor must read from the block returned by getInputBlock() and write - // its results to the block returned by getOutputBlock(). - auto context = juce::dsp::ProcessContextReplacing (wetBlock); - - for(auto& biquad : biquadArray) - biquad->process(context); - - // processContext(context); - - // oversampler[curOS]->processSamplesDown(wetBlock); - - // applyGain(buffer, static_cast(juce::Decibels::decibelsToGain(static_cast(masterOutputPtr->get()), static_cast(-120.00)))) - - mixer->mixWetSamples(wetBlock); - return; -} - -template -void AudioPluginAudioProcessorWrapper::processBypass(juce::AudioBuffer& buffer, juce::MidiBuffer& midiMessages) -{ - juce::ignoreUnused(midiMessages); - - juce::dsp::AudioBlock block(buffer); - - // This context is intended for use in situations where a single block is - // being used for both the input and output to the process algorithm, so it - // will return the same object for both its getInputBlock() and - // getOutputBlock() methods. - auto context = juce::dsp::ProcessContextReplacing(block); - - const auto& inputBlock = context.getInputBlock(); - auto& outputBlock = context.getOutputBlock(); - const auto numChannels = outputBlock.getNumChannels(); - const auto numSamples = outputBlock.getNumSamples(); - - jassert(inputBlock.getNumChannels() == numChannels); - jassert(inputBlock.getNumSamples() == numSamples); - - juce::ignoreUnused(numChannels); - juce::ignoreUnused(numSamples); - - outputBlock.copyFrom(inputBlock); - return; -} - -template -SampleType AudioPluginAudioProcessorWrapper::processSample(int channel, SampleType inputValue) -{ - juce::ignoreUnused(channel); - - auto& sample = inputValue; - return sample; - -} - -template -void AudioPluginAudioProcessorWrapper::snapToZero() noexcept -{ - // mixer->snapToZero(); // ? - - for(auto& biquad : biquadArray) - biquad->snapToZero(); -} - -template -void AudioPluginAudioProcessorWrapper::update() -{ - mixer->setWetMixProportion(static_cast (0.01f * masterMixPtr->get())); - - for(auto& biquad : biquadArray) - biquad->setTransformType(static_cast (masterTransformPtr->getIndex())); - - biquadArray[0]->setFrequency (static_cast (biquadsAFrequencyPtr->get())); - biquadArray[0]->setResonance (static_cast (biquadsAResonancePtr->get())); - biquadArray[0]->setGain (static_cast (biquadsAGainPtr->get())); - biquadArray[0]->setFilterType (static_cast (biquadsATypePtr->getIndex())); - - biquadArray[1]->setFrequency (static_cast (biquadsBFrequencyPtr->get())); - biquadArray[1]->setResonance (static_cast (biquadsBResonancePtr->get())); - biquadArray[1]->setGain (static_cast (biquadsBGainPtr->get())); - biquadArray[1]->setFilterType (static_cast (biquadsBTypePtr->getIndex())); - - biquadArray[2]->setFrequency (static_cast (biquadsCFrequencyPtr->get())); - biquadArray[2]->setResonance (static_cast (biquadsCResonancePtr->get())); - biquadArray[2]->setGain (static_cast (biquadsCGainPtr->get())); - biquadArray[2]->setFilterType (static_cast (biquadsCTypePtr->getIndex())); - - biquadArray[3]->setFrequency (static_cast (biquadsDFrequencyPtr->get())); - biquadArray[3]->setResonance (static_cast (biquadsDResonancePtr->get())); - biquadArray[3]->setGain (static_cast (biquadsDGainPtr->get())); - biquadArray[3]->setFilterType (static_cast (biquadsDTypePtr->getIndex())); -} - -// template -// void AudioPluginAudioProcessorWrapper::setOversampling() -// { -// curOS = (int)osPtr->getIndex(); -// if (curOS != prevOS) -// { -// oversamplingFactor = 1 << curOS; -// prevOS = curOS; -// mixer.reset(); -// // biquad.reset(); -// } -// } - -// template -// SampleType AudioPluginAudioProcessorWrapper::getLatencySamples() const noexcept -// { -// return oversampler[curOS]->getLatencyInSamples(); -// } -//============================================================================== -template class AudioPluginAudioProcessorWrapper; -template class AudioPluginAudioProcessorWrapper; - - /// @} group Biquads -} // namespace Biquads - - /// @} group StoneyDSP -} // namespace StoneyDSP diff --git a/Sources/Wrapper/Wrapper.cpp b/Sources/Wrapper/Wrapper.cpp new file mode 100644 index 0000000..07f7ef0 --- /dev/null +++ b/Sources/Wrapper/Wrapper.cpp @@ -0,0 +1,456 @@ +/***************************************************************************//** + * @file Wrapper.cpp + * @author Nathan J. Hood (nathanjhood@googlemail.com) + * @brief Simple two-pole equalizer with variable oversampling. + * @version 1.2.3.155 + * @date 2024-03-16 + * + * @copyright Copyright (c) 2024 - Nathan J. Hood + + 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 3 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. If not, see . + + ******************************************************************************/ + +// #ifdef STONEYDSP_BIQUADS_WRAPPER_HPP_INCLUDED +// #error "Incorrect usage of 'Wrapper.cpp'!" +// #endif + +#include "Wrapper.hpp" + +namespace StoneyDSP { +/** @addtogroup StoneyDSP @{ */ + +namespace Biquads { +/** @addtogroup Biquads @{ */ + +template +AudioPluginAudioProcessorWrapper::AudioPluginAudioProcessorWrapper(AudioPluginAudioProcessor& p, juce::AudioProcessorValueTreeState& apvts, juce::dsp::ProcessSpec& spec) +: audioProcessor(p) +, state(apvts) +, setup(spec) + +, mixer(std::make_unique>()) + +, biquadArraySize(static_cast(4)) // cannot ‘dynamic_cast’ this - target type is not pointer or reference... + +, masterBypassPtr(static_cast (apvts.getParameter("Master_bypassID"))) +, masterOutputPtr(static_cast (apvts.getParameter("Master_outputID"))) +, masterMixPtr(static_cast (apvts.getParameter("Master_mixID"))) +, masterOsPtr(static_cast (apvts.getParameter("Master_osID"))) +, masterTransformPtr(static_cast (apvts.getParameter("Master_transformID"))) + +, bypassState(static_cast (apvts.getParameter("Master_bypassID"))) +, biquadsBypassPtrArray() +, biquadsFrequencyPtrArray() +, biquadsResonancePtrArray() +, biquadsGainPtrArray() +, biquadsFilterTypePtrArray() +// , biquadsBypassPtrArray +// { +// dynamic_cast (apvts.getParameter("Band_A_bypassID")) +// , dynamic_cast (apvts.getParameter("Band_B_bypassID")) +// , dynamic_cast (apvts.getParameter("Band_C_bypassID")) +// , dynamic_cast (apvts.getParameter("Band_D_bypassID")) +// } +// , biquadsFrequencyPtrArray +// { +// dynamic_cast (apvts.getParameter("Band_A_frequencyID")) +// , dynamic_cast (apvts.getParameter("Band_B_frequencyID")) +// , dynamic_cast (apvts.getParameter("Band_C_frequencyID")) +// , dynamic_cast (apvts.getParameter("Band_D_frequencyID")) +// } +// , biquadsResonancePtrArray +// { +// dynamic_cast (apvts.getParameter("Band_A_resonanceID")) +// , dynamic_cast (apvts.getParameter("Band_B_resonanceID")) +// , dynamic_cast (apvts.getParameter("Band_C_resonanceID")) +// , dynamic_cast (apvts.getParameter("Band_D_resonanceID")) +// } +// , biquadsGainPtrArray +// { +// dynamic_cast (apvts.getParameter("Band_A_gainID")) +// , dynamic_cast (apvts.getParameter("Band_B_gainID")) +// , dynamic_cast (apvts.getParameter("Band_C_gainID")) +// , dynamic_cast (apvts.getParameter("Band_D_gainID")) +// } + +{ + + masterBypassPtr = static_cast (apvts.getParameter("Master_bypassID")); + masterOutputPtr = static_cast (apvts.getParameter("Master_outputID")); + masterMixPtr = static_cast (apvts.getParameter("Master_mixID")); + masterOsPtr = static_cast (apvts.getParameter("Master_osID")); + masterTransformPtr = static_cast (apvts.getParameter("Master_transformID")); + + // biquadsABypassPtr = dynamic_cast (apvts.getParameter("Band_A_bypassID")); + // biquadsAFrequencyPtr = dynamic_cast (apvts.getParameter("Band_A_frequencyID")); + // biquadsAResonancePtr = dynamic_cast (apvts.getParameter("Band_A_resonanceID")); + // biquadsAGainPtr = dynamic_cast (apvts.getParameter("Band_A_gainID")); + // biquadsATypePtr = dynamic_cast (apvts.getParameter("Band_A_typeID")); + + // biquadsBBypassPtr = dynamic_cast (apvts.getParameter("Band_B_bypassID")); + // biquadsBFrequencyPtr = dynamic_cast (apvts.getParameter("Band_B_frequencyID")); + // biquadsBResonancePtr = dynamic_cast (apvts.getParameter("Band_B_resonanceID")); + // biquadsBGainPtr = dynamic_cast (apvts.getParameter("Band_B_gainID")); + // biquadsBTypePtr = dynamic_cast (apvts.getParameter("Band_B_typeID")); + + // biquadsCBypassPtr = dynamic_cast (apvts.getParameter("Band_C_bypassID")); + // biquadsCFrequencyPtr = dynamic_cast (apvts.getParameter("Band_C_frequencyID")); + // biquadsCResonancePtr = dynamic_cast (apvts.getParameter("Band_C_resonanceID")); + // biquadsCGainPtr = dynamic_cast (apvts.getParameter("Band_C_gainID")); + // biquadsCTypePtr = dynamic_cast (apvts.getParameter("Band_C_typeID")); + + // biquadsDBypassPtr = dynamic_cast (apvts.getParameter("Band_D_bypassID")); + // biquadsDFrequencyPtr = dynamic_cast (apvts.getParameter("Band_D_frequencyID")); + // biquadsDResonancePtr = dynamic_cast (apvts.getParameter("Band_D_resonanceID")); + // biquadsDGainPtr = dynamic_cast (apvts.getParameter("Band_D_gainID")); + // biquadsDTypePtr = dynamic_cast (apvts.getParameter("Band_D_typeID")); + + bypassState = dynamic_cast (apvts.getParameter("Master_bypassID")); + + // biquadsBypassPtrArray = + // { + // dynamic_cast (apvts.getParameter("Band_A_bypassID")) + // , dynamic_cast (apvts.getParameter("Band_B_bypassID")) + // , dynamic_cast (apvts.getParameter("Band_C_bypassID")) + // , dynamic_cast (apvts.getParameter("Band_D_bypassID")) + // }; + + // biquadsFrequencyPtrArray = + // { + // dynamic_cast (apvts.getParameter("Band_A_frequencyID")) + // , dynamic_cast (apvts.getParameter("Band_B_frequencyID")) + // , dynamic_cast (apvts.getParameter("Band_C_frequencyID")) + // , dynamic_cast (apvts.getParameter("Band_D_frequencyID")) + // }; + + // biquadsResonancePtrArray = + // { + // dynamic_cast (apvts.getParameter("Band_A_resonanceID")) + // , dynamic_cast (apvts.getParameter("Band_B_resonanceID")) + // , dynamic_cast (apvts.getParameter("Band_C_resonanceID")) + // , dynamic_cast (apvts.getParameter("Band_D_resonanceID")) + // }; + + // biquadsGainPtrArray = + // { + // dynamic_cast (apvts.getParameter("Band_A_gainID")) + // , dynamic_cast (apvts.getParameter("Band_B_gainID")) + // , dynamic_cast (apvts.getParameter("Band_C_gainID")) + // , dynamic_cast (apvts.getParameter("Band_D_gainID")) + // }; + // biquadsFilterTypePtrArray = + // { + // dynamic_cast (apvts.getParameter("Band_A_typeID")) + // , dynamic_cast (apvts.getParameter("Band_A_typeID")) + // , dynamic_cast (apvts.getParameter("Band_A_typeID")) + // , dynamic_cast (apvts.getParameter("Band_A_typeID")) + // }; + + jassert(masterBypassPtr != nullptr); + jassert(masterOutputPtr != nullptr); + jassert(masterMixPtr != nullptr); + jassert(masterOsPtr != nullptr); + jassert(masterTransformPtr != nullptr); + + // jassert(biquadsABypassPtr != nullptr); + // jassert(biquadsAFrequencyPtr != nullptr); + // jassert(biquadsAResonancePtr != nullptr); + // jassert(biquadsAGainPtr != nullptr); + // jassert(biquadsATypePtr != nullptr); + + // jassert(biquadsBBypassPtr != nullptr); + // jassert(biquadsBFrequencyPtr != nullptr); + // jassert(biquadsBResonancePtr != nullptr); + // jassert(biquadsBGainPtr != nullptr); + // jassert(biquadsBTypePtr != nullptr); + + // jassert(biquadsCBypassPtr != nullptr); + // jassert(biquadsCFrequencyPtr != nullptr); + // jassert(biquadsCResonancePtr != nullptr); + // jassert(biquadsCGainPtr != nullptr); + // jassert(biquadsCTypePtr != nullptr); + + // jassert(biquadsDBypassPtr != nullptr); + // jassert(biquadsDFrequencyPtr != nullptr); + // jassert(biquadsDResonancePtr != nullptr); + // jassert(biquadsDGainPtr != nullptr); + // jassert(biquadsDTypePtr != nullptr); + + jassert(bypassState != nullptr); + + // jassert(biquadsBypassPtrArray != nullptr); + // jassert(biquadsFrequencyPtrArray != nullptr); + // jassert(biquadsResonancePtrArray != nullptr); + // jassert(biquadsGainPtrArray != nullptr); + // jassert(biquadsFilterTypePtrArray != nullptr); + + jassert(biquadArraySize != static_cast(0)); + + // auto osFilter = juce::dsp::Oversampling::filterHalfBandFIREquiripple; + + // for (int i = 0; i < 5; ++i) + // oversampler[i] = std::make_unique> + // (audioProcessor.getTotalNumInputChannels(), i, osFilter, true, false); + + for (std::size_t i = 0; i < biquadArraySize; ++i) + biquadArray[i] = std::make_unique>(); + + reset(static_cast(0.0)); +} + +template AudioPluginAudioProcessorWrapper::~AudioPluginAudioProcessorWrapper() +{ +} + +template +void AudioPluginAudioProcessorWrapper::prepare(juce::dsp::ProcessSpec& spec) +{ + jassert(spec.sampleRate > 0); + jassert(spec.numChannels > 0); + + // jassert((biquadArray.size() == biquadArraySize) && (biquadArraySize != static_cast(0))); + + sampleRate = spec.sampleRate; + + // oversamplingFactor = 1 << curOS; + // prevOS = curOS; + + // for (int i = 0; i < 5; ++i) + // oversampler[i]->initProcessing(spec.maximumBlockSize); + + // for (int i = 0; i < 5; ++i) + // oversampler[i]->numChannels = (size_t)spec.numChannels; + + reset(static_cast(0.0)); + + mixer->prepare(spec); + + for(auto& biquad : biquadArray) + biquad->prepare(spec); + + update(); +} + +template +void AudioPluginAudioProcessorWrapper::reset() +{ + SampleType initialValue = static_cast(0.0); + + mixer->reset(); + + for(auto& biquad : biquadArray) + biquad->reset(initialValue); + + // for (int i = 0; i < 5; ++i) + // oversampler[i]->reset(); +} + +template +void AudioPluginAudioProcessorWrapper::reset(SampleType initialValue) +{ + mixer->reset(); + + for(auto& biquad : biquadArray) + biquad->reset(initialValue); + + // for (int i = 0; i < 5; ++i) + // oversampler[i]->reset(); +} + +//============================================================================== +template +void AudioPluginAudioProcessorWrapper::process(juce::AudioBuffer& buffer, juce::MidiBuffer& midiMessages) +{ + auto totalNumInputChannels = audioProcessor.getTotalNumInputChannels(); + auto totalNumOutputChannels = audioProcessor.getTotalNumOutputChannels(); + auto numSamples = buffer.getNumSamples(); + + // In case we have more outputs than inputs, this code clears any output + // channels that didn't contain input data, (because these aren't + // guaranteed to be empty - they may contain garbage). + // This is here to avoid people getting screaming feedback + // when they first compile a plugin, but obviously you don't need to keep + // this code if your algorithm always overwrites all the output channels. + for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) + buffer.clear (i, 0, numSamples); + + // This is the place where you'd normally do the guts of your plugin's + // audio processing... + // Make sure to reset the state if your inner loop is processing + // the samples and the outer loop is handling the channels. + // Alternatively, you can process the samples with the channels + // interleaved by keeping the same state. + for (int channel = 0; channel < totalNumInputChannels; ++channel) + { + auto* channelData = buffer.getWritePointer (channel); + juce::ignoreUnused (channelData); + // ..do something to the data... (mixer push wet samples)? + } + + // setOversampling(); + update(); + + processBlock(buffer, midiMessages); + return; +} + +template +void AudioPluginAudioProcessorWrapper::processBlock(juce::AudioBuffer& buffer, juce::MidiBuffer& midiMessages) +{ + juce::ignoreUnused(midiMessages); + + juce::dsp::AudioBlock dryBlock(buffer); + juce::dsp::AudioBlock wetBlock(buffer); + + mixer->pushDrySamples(dryBlock); + + // wetBlock = oversampler[curOS]->processSamplesUp(dryBlock); + + // This context is intended for use in situations where two different blocks + // are being used as the input and output to the process algorithm, so the + // processor must read from the block returned by getInputBlock() and write + // its results to the block returned by getOutputBlock(). + auto context = juce::dsp::ProcessContextReplacing (wetBlock); + + for(auto& biquad : biquadArray) + biquad->process(context); + + // processContext(context); + + // oversampler[curOS]->processSamplesDown(wetBlock); + + // applyGain(buffer, static_cast(juce::Decibels::decibelsToGain(static_cast(masterOutputPtr->get()), static_cast(-120.00)))) + + mixer->mixWetSamples(wetBlock); + return; +} + +template +void AudioPluginAudioProcessorWrapper::processBypass(juce::AudioBuffer& buffer, juce::MidiBuffer& midiMessages) +{ + juce::ignoreUnused(midiMessages); + + juce::dsp::AudioBlock block(buffer); + + // This context is intended for use in situations where a single block is + // being used for both the input and output to the process algorithm, so it + // will return the same object for both its getInputBlock() and + // getOutputBlock() methods. + auto context = juce::dsp::ProcessContextReplacing(block); + + const auto& inputBlock = context.getInputBlock(); + auto& outputBlock = context.getOutputBlock(); + const auto numChannels = outputBlock.getNumChannels(); + const auto numSamples = outputBlock.getNumSamples(); + + jassert(inputBlock.getNumChannels() == numChannels); + jassert(inputBlock.getNumSamples() == numSamples); + + juce::ignoreUnused(numChannels); + juce::ignoreUnused(numSamples); + + outputBlock.copyFrom(inputBlock); + return; +} + +template +SampleType AudioPluginAudioProcessorWrapper::processSample(int channel, SampleType inputValue) +{ + juce::ignoreUnused(channel); + + auto& sample = inputValue; + return sample; + +} + +template +void AudioPluginAudioProcessorWrapper::snapToZero() noexcept +{ + // mixer->snapToZero(); // ? + + for(auto& biquad : biquadArray) + biquad->snapToZero(); +} + +template +void AudioPluginAudioProcessorWrapper::update() +{ + mixer->setWetMixProportion(static_cast (0.01f * masterMixPtr->get())); + + for(auto& biquad : biquadArray) + { + biquad->setTransformType(static_cast (masterTransformPtr->getIndex())); + + for(auto& biquadsFrequencyPtr : biquadsFrequencyPtrArray) + biquad->setFrequency(static_cast(biquadsFrequencyPtr->get())); + + for(auto& biquadsResonancePtr : biquadsResonancePtrArray) + biquad->setFrequency(static_cast(biquadsResonancePtr->get())); + + for(auto& biquadsGainPtr : biquadsGainPtrArray) + biquad->setGain(static_cast(biquadsGainPtr->get())); + + for(auto& biquadsTypePtr : biquadsFilterTypePtrArray) + biquad->setFilterType(static_cast(biquadsTypePtr->get())); + } + + // biquadArray[0]->setFrequency (static_cast (biquadsAFrequencyPtr->get())); + // biquadArray[0]->setResonance (static_cast (biquadsAResonancePtr->get())); + // biquadArray[0]->setGain (static_cast (biquadsAGainPtr->get())); + // biquadArray[0]->setFilterType (static_cast (biquadsATypePtr->getIndex())); + + // biquadArray[1]->setFrequency (static_cast (biquadsBFrequencyPtr->get())); + // biquadArray[1]->setResonance (static_cast (biquadsBResonancePtr->get())); + // biquadArray[1]->setGain (static_cast (biquadsBGainPtr->get())); + // biquadArray[1]->setFilterType (static_cast (biquadsBTypePtr->getIndex())); + + // biquadArray[2]->setFrequency (static_cast (biquadsCFrequencyPtr->get())); + // biquadArray[2]->setResonance (static_cast (biquadsCResonancePtr->get())); + // biquadArray[2]->setGain (static_cast (biquadsCGainPtr->get())); + // biquadArray[2]->setFilterType (static_cast (biquadsCTypePtr->getIndex())); + + // biquadArray[3]->setFrequency (static_cast (biquadsDFrequencyPtr->get())); + // biquadArray[3]->setResonance (static_cast (biquadsDResonancePtr->get())); + // biquadArray[3]->setGain (static_cast (biquadsDGainPtr->get())); + // biquadArray[3]->setFilterType (static_cast (biquadsDTypePtr->getIndex())); +} + +// template +// void AudioPluginAudioProcessorWrapper::setOversampling() +// { +// curOS = (int)osPtr->getIndex(); +// if (curOS != prevOS) +// { +// oversamplingFactor = 1 << curOS; +// prevOS = curOS; +// mixer.reset(); +// // biquad.reset(); +// } +// } + +// template +// SampleType AudioPluginAudioProcessorWrapper::getLatencySamples() const noexcept +// { +// return oversampler[curOS]->getLatencyInSamples(); +// } +//============================================================================== +template class AudioPluginAudioProcessorWrapper; +template class AudioPluginAudioProcessorWrapper; + + /// @} group Biquads +} // namespace Biquads + + /// @} group StoneyDSP +} // namespace StoneyDSP diff --git a/Sources/Wrapper.hpp b/Sources/Wrapper/Wrapper.hpp similarity index 76% rename from Sources/Wrapper.hpp rename to Sources/Wrapper/Wrapper.hpp index b232245..5735c9a 100644 --- a/Sources/Wrapper.hpp +++ b/Sources/Wrapper/Wrapper.hpp @@ -25,6 +25,7 @@ #pragma once #define STONEYDSP_BIQUADS_WRAPPER_HPP_INCLUDED +#ifndef STONEYDSP_BIQUADS_HPP_INCLUDED #include // depends: juce_core #include // depends: juce_audio_basics #include // depends: juce_gui_extra, juce_audio_basics @@ -38,8 +39,9 @@ #include #include +#endif // STONEYDSP_BIQUADS_HPP_INCLUDED -// #include "Biquads.hpp" +// #include namespace StoneyDSP { /** @addtogroup StoneyDSP @{ */ @@ -47,7 +49,7 @@ namespace StoneyDSP { namespace Biquads { /** @addtogroup Biquads @{ */ -class AudioPluginAudioProcessor; +// class AudioPluginAudioProcessor; template class AudioPluginAudioProcessorWrapper @@ -175,38 +177,45 @@ class AudioPluginAudioProcessorWrapper //========================================================================== /** Parameter pointers. */ - juce::AudioParameterBool* masterBypassPtr { nullptr }; - juce::AudioParameterFloat* masterOutputPtr { nullptr }; - juce::AudioParameterFloat* masterMixPtr { nullptr }; - juce::AudioParameterChoice* masterOsPtr { nullptr }; - juce::AudioParameterChoice* masterTransformPtr { nullptr }; - - juce::AudioParameterBool* biquadsABypassPtr { nullptr }; - juce::AudioParameterFloat* biquadsAFrequencyPtr { nullptr }; - juce::AudioParameterFloat* biquadsAResonancePtr { nullptr }; - juce::AudioParameterFloat* biquadsAGainPtr { nullptr }; - juce::AudioParameterChoice* biquadsATypePtr { nullptr }; - - juce::AudioParameterBool* biquadsBBypassPtr { nullptr }; - juce::AudioParameterFloat* biquadsBFrequencyPtr { nullptr }; - juce::AudioParameterFloat* biquadsBResonancePtr { nullptr }; - juce::AudioParameterFloat* biquadsBGainPtr { nullptr }; - juce::AudioParameterChoice* biquadsBTypePtr { nullptr }; - - juce::AudioParameterBool* biquadsCBypassPtr { nullptr }; - juce::AudioParameterFloat* biquadsCFrequencyPtr { nullptr }; - juce::AudioParameterFloat* biquadsCResonancePtr { nullptr }; - juce::AudioParameterFloat* biquadsCGainPtr { nullptr }; - juce::AudioParameterChoice* biquadsCTypePtr { nullptr }; - - juce::AudioParameterBool* biquadsDBypassPtr { nullptr }; - juce::AudioParameterFloat* biquadsDFrequencyPtr { nullptr }; - juce::AudioParameterFloat* biquadsDResonancePtr { nullptr }; - juce::AudioParameterFloat* biquadsDGainPtr { nullptr }; - juce::AudioParameterChoice* biquadsDTypePtr { nullptr }; + std::unique_ptr masterBypassPtr { nullptr }; + std::unique_ptr masterOutputPtr { nullptr }; + std::unique_ptr masterMixPtr { nullptr }; + std::unique_ptr masterOsPtr { nullptr }; + std::unique_ptr masterTransformPtr { nullptr }; + + // juce::AudioParameterBool* biquadsABypassPtr { nullptr }; + // juce::AudioParameterFloat* biquadsAFrequencyPtr { nullptr }; + // juce::AudioParameterFloat* biquadsAResonancePtr { nullptr }; + // juce::AudioParameterFloat* biquadsAGainPtr { nullptr }; + // juce::AudioParameterChoice* biquadsATypePtr { nullptr }; + + // juce::AudioParameterBool* biquadsBBypassPtr { nullptr }; + // juce::AudioParameterFloat* biquadsBFrequencyPtr { nullptr }; + // juce::AudioParameterFloat* biquadsBResonancePtr { nullptr }; + // juce::AudioParameterFloat* biquadsBGainPtr { nullptr }; + // juce::AudioParameterChoice* biquadsBTypePtr { nullptr }; + + // juce::AudioParameterBool* biquadsCBypassPtr { nullptr }; + // juce::AudioParameterFloat* biquadsCFrequencyPtr { nullptr }; + // juce::AudioParameterFloat* biquadsCResonancePtr { nullptr }; + // juce::AudioParameterFloat* biquadsCGainPtr { nullptr }; + // juce::AudioParameterChoice* biquadsCTypePtr { nullptr }; + + // juce::AudioParameterBool* biquadsDBypassPtr { nullptr }; + // juce::AudioParameterFloat* biquadsDFrequencyPtr { nullptr }; + // juce::AudioParameterFloat* biquadsDResonancePtr { nullptr }; + // juce::AudioParameterFloat* biquadsDGainPtr { nullptr }; + // juce::AudioParameterChoice* biquadsDTypePtr { nullptr }; juce::AudioParameterBool* bypassState { nullptr }; + std::unique_ptr biquadsBypassPtrArray[4]; + std::unique_ptr biquadsFrequencyPtrArray[4]; + std::unique_ptr biquadsResonancePtrArray[4]; + std::unique_ptr biquadsGainPtrArray[4]; + + std::unique_ptr biquadsFilterTypePtrArray[4]; + //============================================================================== /** Initialised constant */ double sampleRate = 0.0; diff --git a/Sources/Wrapper.mm b/Sources/Wrapper/Wrapper.mm similarity index 100% rename from Sources/Wrapper.mm rename to Sources/Wrapper/Wrapper.mm diff --git a/VERSION b/VERSION index afc2d3d..49ef5d3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.3.159 +1.2.3.162