├── .github └── workflows │ └── ci-main.yml ├── .gitignore ├── JuceLibraryCode └── AppConfig.h ├── LICENSE ├── MONSTR.jucer ├── README.md ├── Scripts ├── BuildLinux.sh ├── BuildMacOS.sh ├── BuildWindows.bat └── PluginvalLinux.sh └── Source ├── CrossoverInterface.cpp ├── CrossoverInterface.hpp ├── CrossoverMutators.cpp ├── CrossoverMutators.hpp ├── CrossoverProcessors.cpp ├── CrossoverProcessors.hpp ├── CrossoverState.hpp ├── Graphics ├── MONSTR Background.png └── Tex-white.jpg ├── MONSTRCrossoverImagerComponent.cpp ├── MONSTRCrossoverImagerComponent.h ├── MONSTRCrossoverMouseListener.cpp ├── MONSTRCrossoverMouseListener.h ├── MONSTRCrossoverParameterComponent.cpp ├── MONSTRCrossoverParameterComponent.h ├── MONSTRCrossoverWrapperComponent.cpp ├── MONSTRCrossoverWrapperComponent.h ├── MONSTRLookAndFeel.cpp ├── MONSTRLookAndFeel.h ├── MONSTRWidthLabel.cpp ├── MONSTRWidthLabel.h ├── ParameterData.h ├── PluginEditor.cpp ├── PluginEditor.h ├── PluginProcessor.cpp ├── PluginProcessor.h └── UIUtils.h /.github/workflows/ci-main.yml: -------------------------------------------------------------------------------- 1 | name: CI Main 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | BuildLinuxClang: 7 | runs-on: ubuntu-latest 8 | container: jackd13/audioplugins:clang 9 | 10 | steps: 11 | - uses: actions/checkout@v2 12 | with: 13 | submodules: true 14 | - name: RunBuild 15 | run: Scripts/BuildLinux.sh 16 | - name: RunPluginval 17 | run: Scripts/PluginvalLinux.sh 18 | - uses: actions/upload-artifact@v2 19 | if: ${{ success() }} 20 | with: 21 | name: monstr-linux-clang 22 | path: Builds/LinuxMakefile/build/*.vst3 23 | 24 | BuildLinuxGCC: 25 | runs-on: ubuntu-latest 26 | container: jackd13/audioplugins:gcc 27 | 28 | steps: 29 | - uses: actions/checkout@v2 30 | with: 31 | submodules: true 32 | - name: RunBuild 33 | run: Scripts/BuildLinux.sh 34 | - name: RunPluginval 35 | run: Scripts/PluginvalLinux.sh 36 | - uses: actions/upload-artifact@v2 37 | if: ${{ success() }} 38 | with: 39 | name: monstr-linux-gcc 40 | path: Builds/LinuxMakefile/build/*.vst3 41 | 42 | BuildMacOS: 43 | runs-on: macos-12 44 | 45 | steps: 46 | - uses: actions/checkout@v2 47 | with: 48 | submodules: true 49 | - name: RunBuild 50 | run: Scripts/BuildMacOS.sh 51 | - uses: actions/upload-artifact@v2 52 | if: ${{ success() }} 53 | with: 54 | name: monstr-macOS 55 | path: Scripts/dist 56 | 57 | BuildWindows: 58 | runs-on: windows-2019 59 | 60 | steps: 61 | - uses: actions/checkout@v2 62 | with: 63 | submodules: true 64 | - name: SetupMSBuild 65 | uses: microsoft/setup-msbuild@v1.0.2 66 | - name: RunBuild 67 | shell: cmd 68 | run: Scripts\BuildWindows.bat 69 | - uses: actions/upload-artifact@v2 70 | if: ${{ success() }} 71 | with: 72 | name: monstr-windows 73 | path: Builds/VisualStudio2019/x64/Debug/VST3/*.vst3 74 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Builds 2 | JuceLibraryCode/Binary* 3 | JuceLibraryCode/include* 4 | JuceLibraryCode/Juce*.h 5 | JuceLibraryCode/ReadMe.txt 6 | .DS_Store 7 | private 8 | Source/Graphics/Montserrat-*.ttf 9 | -------------------------------------------------------------------------------- /JuceLibraryCode/AppConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | IMPORTANT! This file is auto-generated each time you save your 4 | project - if you alter its contents, your changes may be overwritten! 5 | 6 | There's a section below where you can add your own custom code safely, and the 7 | Projucer will preserve the contents of that block, but the best way to change 8 | any of these definitions is by using the Projucer's project settings. 9 | 10 | Any commented-out settings will assume their default values. 11 | 12 | */ 13 | 14 | #pragma once 15 | 16 | //============================================================================== 17 | // [BEGIN_USER_CODE_SECTION] 18 | 19 | // (You can add your own code in this section, and the Projucer will not overwrite it) 20 | #define JUCE_VST3_CAN_REPLACE_VST2 0 21 | 22 | // [END_USER_CODE_SECTION] 23 | 24 | #include "JucePluginDefines.h" 25 | 26 | /* 27 | ============================================================================== 28 | 29 | In accordance with the terms of the JUCE 7 End-Use License Agreement, the 30 | JUCE Code in SECTION A cannot be removed, changed or otherwise rendered 31 | ineffective unless you have a JUCE Indie or Pro license, or are using JUCE 32 | under the GPL v3 license. 33 | 34 | End User License Agreement: www.juce.com/juce-7-licence 35 | 36 | ============================================================================== 37 | */ 38 | 39 | // BEGIN SECTION A 40 | 41 | #ifndef JUCE_DISPLAY_SPLASH_SCREEN 42 | #define JUCE_DISPLAY_SPLASH_SCREEN 0 43 | #endif 44 | 45 | // END SECTION A 46 | 47 | #define JUCE_USE_DARK_SPLASH_SCREEN 1 48 | 49 | #define JUCE_PROJUCER_VERSION 0x70009 50 | 51 | //============================================================================== 52 | #define JUCE_MODULE_AVAILABLE_juce_audio_basics 1 53 | #define JUCE_MODULE_AVAILABLE_juce_audio_devices 1 54 | #define JUCE_MODULE_AVAILABLE_juce_audio_formats 1 55 | #define JUCE_MODULE_AVAILABLE_juce_audio_plugin_client 1 56 | #define JUCE_MODULE_AVAILABLE_juce_audio_processors 1 57 | #define JUCE_MODULE_AVAILABLE_juce_audio_utils 1 58 | #define JUCE_MODULE_AVAILABLE_juce_box2d 1 59 | #define JUCE_MODULE_AVAILABLE_juce_core 1 60 | #define JUCE_MODULE_AVAILABLE_juce_cryptography 1 61 | #define JUCE_MODULE_AVAILABLE_juce_data_structures 1 62 | #define JUCE_MODULE_AVAILABLE_juce_dsp 1 63 | #define JUCE_MODULE_AVAILABLE_juce_events 1 64 | #define JUCE_MODULE_AVAILABLE_juce_graphics 1 65 | #define JUCE_MODULE_AVAILABLE_juce_gui_basics 1 66 | #define JUCE_MODULE_AVAILABLE_juce_gui_extra 1 67 | #define JUCE_MODULE_AVAILABLE_juce_opengl 1 68 | #define JUCE_MODULE_AVAILABLE_juce_osc 1 69 | #define JUCE_MODULE_AVAILABLE_juce_video 1 70 | 71 | #define JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED 1 72 | 73 | //============================================================================== 74 | // juce_audio_devices flags: 75 | 76 | #ifndef JUCE_USE_WINRT_MIDI 77 | //#define JUCE_USE_WINRT_MIDI 0 78 | #endif 79 | 80 | #ifndef JUCE_ASIO 81 | //#define JUCE_ASIO 0 82 | #endif 83 | 84 | #ifndef JUCE_WASAPI 85 | //#define JUCE_WASAPI 1 86 | #endif 87 | 88 | #ifndef JUCE_DIRECTSOUND 89 | //#define JUCE_DIRECTSOUND 1 90 | #endif 91 | 92 | #ifndef JUCE_ALSA 93 | //#define JUCE_ALSA 1 94 | #endif 95 | 96 | #ifndef JUCE_JACK 97 | //#define JUCE_JACK 0 98 | #endif 99 | 100 | #ifndef JUCE_BELA 101 | //#define JUCE_BELA 0 102 | #endif 103 | 104 | #ifndef JUCE_USE_ANDROID_OBOE 105 | //#define JUCE_USE_ANDROID_OBOE 1 106 | #endif 107 | 108 | #ifndef JUCE_USE_OBOE_STABILIZED_CALLBACK 109 | //#define JUCE_USE_OBOE_STABILIZED_CALLBACK 0 110 | #endif 111 | 112 | #ifndef JUCE_USE_ANDROID_OPENSLES 113 | //#define JUCE_USE_ANDROID_OPENSLES 0 114 | #endif 115 | 116 | #ifndef JUCE_DISABLE_AUDIO_MIXING_WITH_OTHER_APPS 117 | //#define JUCE_DISABLE_AUDIO_MIXING_WITH_OTHER_APPS 0 118 | #endif 119 | 120 | //============================================================================== 121 | // juce_audio_formats flags: 122 | 123 | #ifndef JUCE_USE_FLAC 124 | //#define JUCE_USE_FLAC 1 125 | #endif 126 | 127 | #ifndef JUCE_USE_OGGVORBIS 128 | //#define JUCE_USE_OGGVORBIS 1 129 | #endif 130 | 131 | #ifndef JUCE_USE_MP3AUDIOFORMAT 132 | //#define JUCE_USE_MP3AUDIOFORMAT 0 133 | #endif 134 | 135 | #ifndef JUCE_USE_LAME_AUDIO_FORMAT 136 | //#define JUCE_USE_LAME_AUDIO_FORMAT 0 137 | #endif 138 | 139 | #ifndef JUCE_USE_WINDOWS_MEDIA_FORMAT 140 | //#define JUCE_USE_WINDOWS_MEDIA_FORMAT 1 141 | #endif 142 | 143 | //============================================================================== 144 | // juce_audio_plugin_client flags: 145 | 146 | #ifndef JUCE_VST3_CAN_REPLACE_VST2 147 | //#define JUCE_VST3_CAN_REPLACE_VST2 1 148 | #endif 149 | 150 | #ifndef JUCE_FORCE_USE_LEGACY_PARAM_IDS 151 | //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 0 152 | #endif 153 | 154 | #ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 155 | //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 0 156 | #endif 157 | 158 | #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 159 | //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1 160 | #endif 161 | 162 | #ifndef JUCE_AU_WRAPPERS_SAVE_PROGRAM_STATES 163 | //#define JUCE_AU_WRAPPERS_SAVE_PROGRAM_STATES 0 164 | #endif 165 | 166 | #ifndef JUCE_STANDALONE_FILTER_WINDOW_USE_KIOSK_MODE 167 | //#define JUCE_STANDALONE_FILTER_WINDOW_USE_KIOSK_MODE 0 168 | #endif 169 | 170 | //============================================================================== 171 | // juce_audio_processors flags: 172 | 173 | #ifndef JUCE_PLUGINHOST_VST 174 | //#define JUCE_PLUGINHOST_VST 0 175 | #endif 176 | 177 | #ifndef JUCE_PLUGINHOST_VST3 178 | //#define JUCE_PLUGINHOST_VST3 0 179 | #endif 180 | 181 | #ifndef JUCE_PLUGINHOST_AU 182 | //#define JUCE_PLUGINHOST_AU 0 183 | #endif 184 | 185 | #ifndef JUCE_PLUGINHOST_LADSPA 186 | //#define JUCE_PLUGINHOST_LADSPA 0 187 | #endif 188 | 189 | #ifndef JUCE_PLUGINHOST_LV2 190 | //#define JUCE_PLUGINHOST_LV2 0 191 | #endif 192 | 193 | #ifndef JUCE_PLUGINHOST_ARA 194 | //#define JUCE_PLUGINHOST_ARA 0 195 | #endif 196 | 197 | #ifndef JUCE_CUSTOM_VST3_SDK 198 | //#define JUCE_CUSTOM_VST3_SDK 0 199 | #endif 200 | 201 | //============================================================================== 202 | // juce_audio_utils flags: 203 | 204 | #ifndef JUCE_USE_CDREADER 205 | //#define JUCE_USE_CDREADER 0 206 | #endif 207 | 208 | #ifndef JUCE_USE_CDBURNER 209 | //#define JUCE_USE_CDBURNER 0 210 | #endif 211 | 212 | //============================================================================== 213 | // juce_core flags: 214 | 215 | #ifndef JUCE_FORCE_DEBUG 216 | //#define JUCE_FORCE_DEBUG 0 217 | #endif 218 | 219 | #ifndef JUCE_LOG_ASSERTIONS 220 | //#define JUCE_LOG_ASSERTIONS 0 221 | #endif 222 | 223 | #ifndef JUCE_CHECK_MEMORY_LEAKS 224 | //#define JUCE_CHECK_MEMORY_LEAKS 1 225 | #endif 226 | 227 | #ifndef JUCE_DONT_AUTOLINK_TO_WIN32_LIBRARIES 228 | //#define JUCE_DONT_AUTOLINK_TO_WIN32_LIBRARIES 0 229 | #endif 230 | 231 | #ifndef JUCE_INCLUDE_ZLIB_CODE 232 | //#define JUCE_INCLUDE_ZLIB_CODE 1 233 | #endif 234 | 235 | #ifndef JUCE_USE_CURL 236 | #define JUCE_USE_CURL 0 237 | #endif 238 | 239 | #ifndef JUCE_LOAD_CURL_SYMBOLS_LAZILY 240 | //#define JUCE_LOAD_CURL_SYMBOLS_LAZILY 0 241 | #endif 242 | 243 | #ifndef JUCE_CATCH_UNHANDLED_EXCEPTIONS 244 | //#define JUCE_CATCH_UNHANDLED_EXCEPTIONS 0 245 | #endif 246 | 247 | #ifndef JUCE_ALLOW_STATIC_NULL_VARIABLES 248 | //#define JUCE_ALLOW_STATIC_NULL_VARIABLES 0 249 | #endif 250 | 251 | #ifndef JUCE_STRICT_REFCOUNTEDPOINTER 252 | //#define JUCE_STRICT_REFCOUNTEDPOINTER 0 253 | #endif 254 | 255 | #ifndef JUCE_ENABLE_ALLOCATION_HOOKS 256 | //#define JUCE_ENABLE_ALLOCATION_HOOKS 0 257 | #endif 258 | 259 | //============================================================================== 260 | // juce_dsp flags: 261 | 262 | #ifndef JUCE_ASSERTION_FIRFILTER 263 | //#define JUCE_ASSERTION_FIRFILTER 1 264 | #endif 265 | 266 | #ifndef JUCE_DSP_USE_INTEL_MKL 267 | //#define JUCE_DSP_USE_INTEL_MKL 0 268 | #endif 269 | 270 | #ifndef JUCE_DSP_USE_SHARED_FFTW 271 | //#define JUCE_DSP_USE_SHARED_FFTW 0 272 | #endif 273 | 274 | #ifndef JUCE_DSP_USE_STATIC_FFTW 275 | //#define JUCE_DSP_USE_STATIC_FFTW 0 276 | #endif 277 | 278 | #ifndef JUCE_DSP_ENABLE_SNAP_TO_ZERO 279 | //#define JUCE_DSP_ENABLE_SNAP_TO_ZERO 1 280 | #endif 281 | 282 | //============================================================================== 283 | // juce_events flags: 284 | 285 | #ifndef JUCE_EXECUTE_APP_SUSPEND_ON_BACKGROUND_TASK 286 | //#define JUCE_EXECUTE_APP_SUSPEND_ON_BACKGROUND_TASK 0 287 | #endif 288 | 289 | //============================================================================== 290 | // juce_graphics flags: 291 | 292 | #ifndef JUCE_USE_COREIMAGE_LOADER 293 | //#define JUCE_USE_COREIMAGE_LOADER 1 294 | #endif 295 | 296 | #ifndef JUCE_USE_DIRECTWRITE 297 | //#define JUCE_USE_DIRECTWRITE 1 298 | #endif 299 | 300 | #ifndef JUCE_DISABLE_COREGRAPHICS_FONT_SMOOTHING 301 | //#define JUCE_DISABLE_COREGRAPHICS_FONT_SMOOTHING 0 302 | #endif 303 | 304 | //============================================================================== 305 | // juce_gui_basics flags: 306 | 307 | #ifndef JUCE_ENABLE_REPAINT_DEBUGGING 308 | //#define JUCE_ENABLE_REPAINT_DEBUGGING 0 309 | #endif 310 | 311 | #ifndef JUCE_USE_XRANDR 312 | //#define JUCE_USE_XRANDR 1 313 | #endif 314 | 315 | #ifndef JUCE_USE_XINERAMA 316 | //#define JUCE_USE_XINERAMA 1 317 | #endif 318 | 319 | #ifndef JUCE_USE_XSHM 320 | //#define JUCE_USE_XSHM 1 321 | #endif 322 | 323 | #ifndef JUCE_USE_XRENDER 324 | //#define JUCE_USE_XRENDER 0 325 | #endif 326 | 327 | #ifndef JUCE_USE_XCURSOR 328 | //#define JUCE_USE_XCURSOR 1 329 | #endif 330 | 331 | #ifndef JUCE_WIN_PER_MONITOR_DPI_AWARE 332 | //#define JUCE_WIN_PER_MONITOR_DPI_AWARE 1 333 | #endif 334 | 335 | //============================================================================== 336 | // juce_gui_extra flags: 337 | 338 | #ifndef JUCE_WEB_BROWSER 339 | //#define JUCE_WEB_BROWSER 1 340 | #endif 341 | 342 | #ifndef JUCE_USE_WIN_WEBVIEW2 343 | //#define JUCE_USE_WIN_WEBVIEW2 0 344 | #endif 345 | 346 | #ifndef JUCE_ENABLE_LIVE_CONSTANT_EDITOR 347 | //#define JUCE_ENABLE_LIVE_CONSTANT_EDITOR 0 348 | #endif 349 | 350 | //============================================================================== 351 | // juce_video flags: 352 | 353 | #ifndef JUCE_USE_CAMERA 354 | //#define JUCE_USE_CAMERA 0 355 | #endif 356 | 357 | #ifndef JUCE_SYNC_VIDEO_VOLUME_WITH_OS_MEDIA_VOLUME 358 | //#define JUCE_SYNC_VIDEO_VOLUME_WITH_OS_MEDIA_VOLUME 1 359 | #endif 360 | 361 | //============================================================================== 362 | #ifndef JUCE_STANDALONE_APPLICATION 363 | #if defined(JucePlugin_Name) && defined(JucePlugin_Build_Standalone) 364 | #define JUCE_STANDALONE_APPLICATION JucePlugin_Build_Standalone 365 | #else 366 | #define JUCE_STANDALONE_APPLICATION 0 367 | #endif 368 | #endif 369 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /MONSTR.jucer: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 18 | 20 | 22 | 23 | 24 | 25 | 27 | 29 | 31 | 33 | 35 | 37 | 39 | 41 | 43 | 45 | 47 | 49 | 51 | 52 | 53 | 55 | 57 | 59 | 61 | 63 | 65 | 67 | 68 | 70 | 72 | 73 | 74 | 75 | 77 | 78 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 106 | 107 | 109 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![CI Main](https://github.com/jd-13/MONSTR-Stereo-Imaging/workflows/CI%20Main/badge.svg)](https://github.com/jd-13/MONSTR-Stereo-Imaging/actions?query=workflow%3A%22CI+Main%22) 2 | ![](https://img.shields.io/badge/C%2B%2B-17-informational) 3 | ![](https://img.shields.io/badge/license-GPLv3-informational) 4 | 5 | # MONSTR-Stereo-Imaging 6 | MONSTR is a multiband stereo imaging plugin, available in VST3 and Audio Unit formats. MONSTR allows the user to control the stereo width of a sound in up to 6 different frequency bands, and so can be used to perform common tasks such as narrowing the bass frequencies while adding width to the highs. 7 | 8 | For more details and a free download of the compiled plugin: https://www.whiteelephantaudio.com/plugins/monstr 9 | 10 | ![](https://whiteelephantaudio.com/images/thumbs/originals/monstrV2.0.0Animation.gif) 11 | 12 | ## Built using: 13 | 14 | JUCE: https://www.juce.com/ 15 | 16 | WECore: https://github.com/jd-13/WE-Core 17 | 18 | VST SDK: https://www.steinberg.net/en/company/developers.html 19 | -------------------------------------------------------------------------------- /Scripts/BuildLinux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null 2>&1 && pwd )" 6 | 7 | echo "=== Cloning WE-Core ===" 8 | WECORE_HOME=$SCRIPT_DIR/../WECore 9 | git clone --recurse-submodules https://github.com/jd-13/WE-Core $SCRIPT_DIR/../WECore 10 | 11 | cd $WECORE_HOME 12 | echo "=== Using WE-Core $(git log --pretty=format:'%h' -n 1) ===" 13 | cd - 14 | 15 | echo "=== Downloading fonts ===" 16 | wget https://github.com/JulietaUla/Montserrat/raw/master/fonts/ttf/Montserrat-Regular.ttf \ 17 | -P $SCRIPT_DIR/../Source/Graphics 18 | 19 | echo "=== Setting module paths ===" 20 | sed -i 's#../JUCE/modules#/home/JUCE/modules#g' $SCRIPT_DIR/../MONSTR.jucer 21 | 22 | echo "=== Generating makefile ===" 23 | $JUCE_PATH/Projucer --resave $SCRIPT_DIR/../MONSTR.jucer 24 | 25 | echo "=== Updating include paths ===" 26 | sed -i 's#-I$(HOME)/WEA/WECore/WECore#-I../../WECore/WECore#g' $SCRIPT_DIR/../Builds/LinuxMakefile/Makefile 27 | 28 | # TODO: this path gets set wrong, not sure why 29 | sed -i 's#-I$(HOME)/WWECore/DSPFilters/shared/DSPFilters/include#-I../../WECore/DSPFilters/shared/DSPFilters/include#g' $SCRIPT_DIR/../Builds/LinuxMakefile/Makefile 30 | 31 | echo "=== Starting build ===" 32 | cd $SCRIPT_DIR/../Builds/LinuxMakefile 33 | make 34 | -------------------------------------------------------------------------------- /Scripts/BuildMacOS.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null 2>&1 && pwd )" 6 | 7 | echo "=== Cloning WE-Core ===" 8 | WECORE_HOME=$SCRIPT_DIR/../WECore 9 | git clone --recurse-submodules https://github.com/jd-13/WE-Core $WECORE_HOME 10 | 11 | cd $WECORE_HOME 12 | echo "=== Using WE-Core $(git log --pretty=format:'%h' -n 1) ===" 13 | cd - 14 | 15 | echo "=== Downloading fonts ===" 16 | wget https://github.com/JulietaUla/Montserrat/raw/master/fonts/ttf/Montserrat-Regular.ttf \ 17 | -P $SCRIPT_DIR/../Source/Graphics 18 | 19 | echo "=== Downloading JUCE ===" 20 | JUCE_VERSION=7.0.9 21 | wget https://github.com/juce-framework/JUCE/releases/download/$JUCE_VERSION/juce-$JUCE_VERSION-osx.zip \ 22 | -P $SCRIPT_DIR/.. 23 | unzip $SCRIPT_DIR/../juce-$JUCE_VERSION-osx.zip 24 | 25 | echo "=== Setting module paths ===" 26 | sed -i '' -e 's#../../../../../SDKs/JUCE/modules#JUCE/modules#g' $SCRIPT_DIR/../MONSTR.jucer 27 | 28 | echo "=== Updating include paths ===" 29 | sed -i '' -e 's#../../../WECore/WECore#../../WECore/WECore#g' $SCRIPT_DIR/../MONSTR.jucer 30 | 31 | echo "=== Generating project ===" 32 | $SCRIPT_DIR/../JUCE/Projucer.app/Contents/MacOS/Projucer --resave $SCRIPT_DIR/../MONSTR.jucer 33 | 34 | echo "=== Starting build ===" 35 | cd $SCRIPT_DIR/../Builds/MacOSX 36 | xcodebuild -version 37 | xcodebuild -project MONSTR.xcodeproj -scheme "MONSTR - All" -configuration Debug 38 | 39 | echo "=== Collecting artefacts ===" 40 | mkdir -p $SCRIPT_DIR/dist 41 | cp -r ~/Library/Audio/Plug-Ins/VST3/MONSTR.vst3 $SCRIPT_DIR/dist 42 | cp -r ~/Library/Audio/Plug-Ins/Components/MONSTR.component $SCRIPT_DIR/dist 43 | -------------------------------------------------------------------------------- /Scripts/BuildWindows.bat: -------------------------------------------------------------------------------- 1 | set SCRIPT_DIR=%~dp0 2 | 3 | ECHO "=== Cloning WE-Core ===" 4 | set WECORE_HOME=%SCRIPT_DIR%..\WECore 5 | git clone --recurse-submodules https://github.com/jd-13/WE-Core %WECORE_HOME% 6 | 7 | pushd 8 | cd %WECORE_HOME% 9 | for /f %%i in ('git log --pretty^=format:'%%h' -n 1') do set WECORE_COMMIT=%%i 10 | ECHO "=== Using WE-Core %WECORE_COMMIT% ===" 11 | popd 12 | 13 | ECHO "=== Downloading fonts ===" 14 | powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest https://github.com/JulietaUla/Montserrat/raw/master/fonts/ttf/Montserrat-Regular.ttf -OutFile %SCRIPT_DIR%..\Source\Graphics\Montserrat-Regular.ttf}" 15 | 16 | ECHO "=== Downloading JUCE ===" 17 | set JUCE_VERSION=7.0.9 18 | powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest https://github.com/juce-framework/JUCE/releases/download/%JUCE_VERSION%/juce-%JUCE_VERSION%-windows.zip -OutFile %SCRIPT_DIR%..\juce-%JUCE_VERSION%-windows.zip}" 19 | powershell -Command "& {Expand-Archive -LiteralPath %SCRIPT_DIR%..\juce-%JUCE_VERSION%-windows.zip -DestinationPath %SCRIPT_DIR%..}" 20 | 21 | ECHO "=== Setting module paths ===" 22 | powershell -Command "& {$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'; (get-content %SCRIPT_DIR%..\MONSTR.jucer).replace(\"..\JUCE\modules\",\"JUCE\modules\") | out-file -filepath %SCRIPT_DIR%..\MONSTR.jucer}" 23 | 24 | ECHO "=== Updating include paths ===" 25 | powershell -Command "& {$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'; (get-content %SCRIPT_DIR%..\MONSTR.jucer).replace(\"%%USERPROFILE%%\WEA\WECore\WECore\",\"..\..\WECore\WECore\") | out-file -filepath %SCRIPT_DIR%..\MONSTR.jucer}" 26 | 27 | ECHO "=== Generating project ===" 28 | %SCRIPT_DIR%..\JUCE\Projucer --resave %SCRIPT_DIR%..\MONSTR.jucer 29 | 30 | ECHO "=== Starting build ===" 31 | cd %SCRIPT_DIR%..\Builds\VisualStudio2019 32 | msbuild -version 33 | msbuild MONSTR.sln /p:Configuration=Debug /p:Platform=x64 34 | -------------------------------------------------------------------------------- /Scripts/PluginvalLinux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null 2>&1 && pwd )" 6 | 7 | # Exclude tests that don't work on Linux 8 | cat << EOF >> $SCRIPT_DIR/disabled-tests.txt 9 | Basic bus 10 | EOF 11 | 12 | $PLUGINVAL --validate $SCRIPT_DIR/../Builds/LinuxMakefile/build/MONSTR.vst3 \ 13 | --strictness-level 10 \ 14 | --skip-gui-tests \ 15 | --disabled-tests $SCRIPT_DIR/disabled-tests.txt 16 | -------------------------------------------------------------------------------- /Source/CrossoverInterface.cpp: -------------------------------------------------------------------------------- 1 | #include "CrossoverInterface.hpp" 2 | #include "CrossoverMutators.hpp" 3 | #include "CrossoverProcessors.hpp" 4 | 5 | namespace CrossoverInterface { 6 | // Mutators 7 | void setIsBypassed(Crossover& crossover, size_t bandNumber, bool isBypassed) { 8 | std::scoped_lock lock(crossover.mutatorsMutex); 9 | if (crossover.state != nullptr) { 10 | CrossoverMutators::setIsBypassed(crossover.state, bandNumber, isBypassed); 11 | } 12 | } 13 | 14 | void setIsMuted(Crossover& crossover, size_t bandNumber, bool isMuted) { 15 | std::scoped_lock lock(crossover.mutatorsMutex); 16 | if (crossover.state != nullptr) { 17 | CrossoverMutators::setIsMuted(crossover.state, bandNumber, isMuted); 18 | } 19 | } 20 | 21 | void setIsSoloed(Crossover& crossover, size_t bandNumber, bool isSoloed) { 22 | std::scoped_lock lock(crossover.mutatorsMutex); 23 | if (crossover.state != nullptr) { 24 | CrossoverMutators::setIsSoloed(crossover.state, bandNumber, isSoloed); 25 | } 26 | } 27 | 28 | bool setCrossoverFrequency(Crossover& crossover, size_t crossoverNumber, double val) { 29 | std::scoped_lock lock(crossover.mutatorsMutex); 30 | if (crossover.state != nullptr) { 31 | return CrossoverMutators::setCrossoverFrequency(crossover.state, crossoverNumber, val); 32 | } 33 | 34 | return false; 35 | } 36 | 37 | void setWidth(Crossover& crossover, size_t bandNumber, float val) { 38 | std::scoped_lock lock(crossover.mutatorsMutex); 39 | if (crossover.state != nullptr) { 40 | CrossoverMutators::setWidth(crossover.state, bandNumber, val); 41 | } 42 | } 43 | 44 | bool getIsBypassed(Crossover& crossover, size_t bandNumber) { 45 | std::scoped_lock lock(crossover.mutatorsMutex); 46 | if (crossover.state != nullptr) { 47 | return CrossoverMutators::getIsBypassed(crossover.state, bandNumber); 48 | } 49 | 50 | return false; 51 | } 52 | 53 | bool getIsMuted(Crossover& crossover, size_t bandNumber) { 54 | std::scoped_lock lock(crossover.mutatorsMutex); 55 | if (crossover.state != nullptr) { 56 | return CrossoverMutators::getIsMuted(crossover.state, bandNumber); 57 | } 58 | 59 | return false; 60 | } 61 | 62 | bool getIsSoloed(Crossover& crossover, size_t bandNumber) { 63 | std::scoped_lock lock(crossover.mutatorsMutex); 64 | if (crossover.state != nullptr) { 65 | return CrossoverMutators::getIsSoloed(crossover.state, bandNumber); 66 | } 67 | 68 | return false; 69 | } 70 | 71 | double getCrossoverFrequency(Crossover& crossover, size_t crossoverNumber) { 72 | std::scoped_lock lock(crossover.mutatorsMutex); 73 | if (crossover.state != nullptr) { 74 | return CrossoverMutators::getCrossoverFrequency(crossover.state, crossoverNumber); 75 | } 76 | 77 | return 0.0f; 78 | } 79 | 80 | float getWidth(Crossover& crossover, size_t bandNumber) { 81 | std::scoped_lock lock(crossover.mutatorsMutex); 82 | if (crossover.state != nullptr) { 83 | return CrossoverMutators::getWidth(crossover.state, bandNumber); 84 | } 85 | 86 | return 0.0f; 87 | } 88 | 89 | std::vector getWidthMeterValues(Crossover& crossover) { 90 | std::scoped_lock lock(crossover.mutatorsMutex); 91 | if (crossover.state != nullptr) { 92 | return CrossoverMutators::getWidthMeterValues(crossover.state); 93 | } 94 | 95 | return std::vector(); 96 | } 97 | 98 | size_t getNumBands(Crossover& crossover) { 99 | std::scoped_lock lock(crossover.mutatorsMutex); 100 | if (crossover.state != nullptr) { 101 | return CrossoverMutators::getNumBands(crossover.state); 102 | } 103 | 104 | return 0; 105 | } 106 | 107 | void addBand(Crossover& crossover) { 108 | std::scoped_lock lock(crossover.mutatorsMutex); 109 | WECore::AudioSpinLock sharedLock(crossover.sharedMutex); 110 | 111 | if (crossover.state != nullptr) { 112 | CrossoverMutators::addBand(crossover.state); 113 | } 114 | } 115 | 116 | void removeBand(Crossover& crossover) { 117 | std::scoped_lock lock(crossover.mutatorsMutex); 118 | WECore::AudioSpinLock sharedLock(crossover.sharedMutex); 119 | 120 | if (crossover.state != nullptr) { 121 | CrossoverMutators::removeBand(crossover.state, CrossoverMutators::getNumBands(crossover.state) - 1); 122 | } 123 | } 124 | 125 | void forEachBand(Crossover& crossover, std::function callback) { 126 | std::scoped_lock lock(crossover.mutatorsMutex); 127 | if (crossover.state != nullptr) { 128 | for (int bandNumber {0}; bandNumber < CrossoverMutators::getNumBands(crossover.state); bandNumber++) { 129 | callback(bandNumber); 130 | } 131 | } 132 | } 133 | 134 | void forEachCrossover(Crossover& crossover, std::function callback) { 135 | std::scoped_lock lock(crossover.mutatorsMutex); 136 | if (crossover.state != nullptr) { 137 | for (int crossoverNumber {0}; crossoverNumber < CrossoverMutators::getNumBands(crossover.state) - 1; crossoverNumber++) { 138 | callback(crossoverNumber, CrossoverMutators::getCrossoverFrequency(crossover.state, crossoverNumber)); 139 | } 140 | } 141 | } 142 | 143 | // Processors 144 | void prepareToPlay(Crossover& crossover, double sampleRate, int samplesPerBlock) { 145 | WECore::AudioSpinLock lock(crossover.sharedMutex); 146 | if (crossover.state != nullptr) { 147 | CrossoverProcessors::prepareToPlay(*crossover.state.get(), sampleRate, samplesPerBlock); 148 | } 149 | } 150 | 151 | void reset(Crossover& crossover) { 152 | WECore::AudioSpinLock lock(crossover.sharedMutex); 153 | if (crossover.state != nullptr) { 154 | CrossoverProcessors::reset(*crossover.state.get()); 155 | } 156 | } 157 | 158 | void processBlock(Crossover& crossover, juce::AudioBuffer& buffer) { 159 | // Use the try lock on the audio thread 160 | WECore::AudioSpinTryLock lock(crossover.sharedMutex); 161 | if (lock.isLocked() && crossover.state != nullptr) { 162 | CrossoverProcessors::processBlock(*crossover.state.get(), buffer); 163 | } 164 | } 165 | } -------------------------------------------------------------------------------- /Source/CrossoverInterface.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "CrossoverState.hpp" 5 | #include "General/AudioSpinMutex.h" 6 | 7 | namespace CrossoverInterface { 8 | struct Crossover { 9 | // Internal representation of the crossover 10 | std::shared_ptr state; 11 | 12 | // This mutex must be locked by all mutators before attempting to read or write to or from 13 | // data model. Its purpose is to stop a mutator being called on one thread from changing the 14 | // data model in a way that would crash a mutator being called on another thread. 15 | // 16 | // Recursive because the application code may call something via the mutator forEach methods 17 | // that tries to take the lock on the same thread as the forEach method itself 18 | std::recursive_mutex mutatorsMutex; 19 | 20 | // This mutex must be locked by mutators which change the structure of the data model, and 21 | // also by the processors. Its purpose is to stop a mutator being called on one thread from 22 | // changing the data model in a way that would crash a processor being called on another 23 | // thread. 24 | // 25 | // Mutators reading from the data model or writing only primitive values don't need to lock 26 | // this 27 | WECore::AudioSpinMutex sharedMutex; 28 | 29 | Crossover() : state(createDefaultCrossoverState()) {} 30 | }; 31 | 32 | // Mutators 33 | void setIsBypassed(Crossover& crossover, size_t bandNumber, bool isBypassed); 34 | void setIsMuted(Crossover& crossover, size_t bandNumber, bool isMuted); 35 | void setIsSoloed(Crossover& crossover, size_t bandNumber, bool isSoloed); 36 | bool setCrossoverFrequency(Crossover& crossover, size_t crossoverNumber, double val); 37 | void setWidth(Crossover& crossover, size_t bandNumber, float val); 38 | 39 | bool getIsBypassed(Crossover& crossover, size_t bandNumber); 40 | bool getIsMuted(Crossover& crossover, size_t bandNumber); 41 | bool getIsSoloed(Crossover& crossover, size_t bandNumber); 42 | double getCrossoverFrequency(Crossover& crossover, size_t crossoverNumber); 43 | float getWidth(Crossover& crossover, size_t bandNumber); 44 | std::vector getWidthMeterValues(Crossover& crossover); 45 | size_t getNumBands(Crossover& crossover); 46 | 47 | void addBand(Crossover& crossover); 48 | void removeBand(Crossover& crossover); 49 | 50 | void forEachBand(Crossover& crossover, std::function callback); 51 | void forEachCrossover(Crossover& crossover, std::function callback); 52 | 53 | // Processors 54 | void prepareToPlay(Crossover& crossover, double sampleRate, int samplesPerBlock); 55 | void reset(Crossover& crossover); 56 | void processBlock(Crossover& crossover, juce::AudioBuffer& buffer); 57 | } -------------------------------------------------------------------------------- /Source/CrossoverMutators.cpp: -------------------------------------------------------------------------------- 1 | #include "CrossoverMutators.hpp" 2 | #include "CrossoverProcessors.hpp" 3 | 4 | namespace { 5 | constexpr int MAX_FREQ {20000}; 6 | } 7 | 8 | namespace CrossoverMutators { 9 | void setIsBypassed(std::shared_ptr state, size_t bandNumber, bool isBypassed) { 10 | if (state->bands.size() > bandNumber) { 11 | state->bands[bandNumber].isBypassed = isBypassed; 12 | } 13 | } 14 | 15 | void setIsMuted(std::shared_ptr state, size_t bandNumber, bool isMuted) { 16 | if (state->bands.size() > bandNumber) { 17 | state->bands[bandNumber].isMuted = isMuted; 18 | } 19 | } 20 | 21 | void setIsSoloed(std::shared_ptr state, size_t bandNumber, bool isSoloed) { 22 | if (state->bands.size() > bandNumber) { 23 | if (state->bands[bandNumber].isSoloed != isSoloed) { 24 | state->bands[bandNumber].isSoloed = isSoloed; 25 | 26 | if (isSoloed) { 27 | state->numBandsSoloed++; 28 | } else { 29 | state->numBandsSoloed--; 30 | } 31 | } 32 | } 33 | } 34 | 35 | bool setCrossoverFrequency(std::shared_ptr state, size_t crossoverNumber, double val) { 36 | if (val > MAX_FREQ) { 37 | return false; 38 | } 39 | 40 | if (state->lowpassFilters.size() > crossoverNumber) { 41 | state->lowpassFilters[crossoverNumber].setCutoffFrequency(val); 42 | state->highpassFilters[crossoverNumber].setCutoffFrequency(val); 43 | 44 | // We might also have an allpass filter to set 45 | if (state->allpassFilters.size() > crossoverNumber - 1) { 46 | state->allpassFilters[crossoverNumber - 1].setCutoffFrequency(val); 47 | } 48 | 49 | 50 | // Make sure the crossover frequencies are still in the correct order 51 | for (size_t otherCrossoverIndex {0}; otherCrossoverIndex < state->lowpassFilters.size(); otherCrossoverIndex++) { 52 | const double otherCrossoverFrequency {getCrossoverFrequency(state, otherCrossoverIndex)}; 53 | 54 | const bool needsCrossoverUpdate { 55 | // We've moved the crossover frequency of index below another one that should be 56 | // below it - move the other one to the new value 57 | (val < otherCrossoverFrequency && otherCrossoverIndex < crossoverNumber) || 58 | 59 | // We've moved the crossover frequency of index above another one that should be 60 | // above it - move the other one to the new value 61 | (otherCrossoverFrequency > val && crossoverNumber > otherCrossoverIndex) 62 | }; 63 | 64 | if (needsCrossoverUpdate) { 65 | // We've moved the crossover frequency of index below another one that should be 66 | // below it - move the other one to the new value 67 | setCrossoverFrequency(state, otherCrossoverIndex, val); 68 | } 69 | } 70 | 71 | return true; 72 | } 73 | 74 | return false; 75 | } 76 | 77 | void setWidth(std::shared_ptr state, size_t bandNumber, float val) { 78 | if (state->bands.size() > bandNumber) { 79 | state->bands[bandNumber].width = val; 80 | } 81 | } 82 | 83 | bool getIsBypassed(std::shared_ptr state, size_t bandNumber) { 84 | if (state->bands.size() > bandNumber) { 85 | return state->bands[bandNumber].isBypassed; 86 | } 87 | 88 | return false; 89 | } 90 | 91 | bool getIsMuted(std::shared_ptr state, size_t bandNumber) { 92 | if (state->bands.size() > bandNumber) { 93 | return state->bands[bandNumber].isMuted; 94 | } 95 | 96 | return false; 97 | } 98 | 99 | bool getIsSoloed(std::shared_ptr state, size_t bandNumber) { 100 | if (state->bands.size() > bandNumber) { 101 | return state->bands[bandNumber].isSoloed; 102 | } 103 | 104 | return false; 105 | } 106 | 107 | double getCrossoverFrequency(std::shared_ptr state, size_t crossoverNumber) { 108 | if (state->lowpassFilters.size() > crossoverNumber) { 109 | return state->lowpassFilters[crossoverNumber].getCutoffFrequency(); 110 | } 111 | 112 | return 0; 113 | } 114 | 115 | float getWidth(std::shared_ptr state, size_t bandNumber) { 116 | if (state->bands.size() > bandNumber) { 117 | return state->bands[bandNumber].width; 118 | } 119 | 120 | return 0; 121 | } 122 | 123 | std::vector getWidthMeterValues(std::shared_ptr state) { 124 | std::vector retVal; 125 | 126 | for (int bandNumber {0}; bandNumber < CrossoverMutators::getNumBands(state); bandNumber++) { 127 | retVal.push_back(state->bands[bandNumber].env->getLastOutput()); 128 | } 129 | 130 | return retVal; 131 | } 132 | 133 | size_t getNumBands(std::shared_ptr state) { 134 | return state->bands.size(); 135 | } 136 | 137 | void addBand(std::shared_ptr state) { 138 | const double oldHighestCrossover {CrossoverMutators::getCrossoverFrequency(state, state->lowpassFilters.size() - 1)}; 139 | 140 | // Add all the new state 141 | state->lowpassFilters.emplace_back(); 142 | state->lowpassFilters[state->lowpassFilters.size() - 1].setType(juce::dsp::LinkwitzRileyFilterType::lowpass); 143 | 144 | state->highpassFilters.emplace_back(); 145 | state->highpassFilters[state->highpassFilters.size() - 1].setType(juce::dsp::LinkwitzRileyFilterType::highpass); 146 | 147 | state->allpassFilters.emplace_back(); 148 | state->allpassFilters[state->allpassFilters.size() - 1].setType(juce::dsp::LinkwitzRileyFilterType::allpass); 149 | 150 | state->buffers.emplace_back(); 151 | 152 | state->bands.emplace_back(); 153 | 154 | // Set the crossover frequency of the new band and make room for it if needed 155 | if (oldHighestCrossover < MAX_FREQ) { 156 | // The old highest crossover frequency is below the maximum, insert the new one halfway 157 | // between it and the maximum 158 | const double topBandWidth {MAX_FREQ - oldHighestCrossover}; 159 | const double newCrossoverFreq {oldHighestCrossover + (topBandWidth / 2)}; 160 | setCrossoverFrequency(state, state->lowpassFilters.size() - 1, newCrossoverFreq); 161 | } else { 162 | // The old highest crossover is at the maximum, move it halfway down to the one below 163 | // and place the new one at the maximum 164 | const double thirdHighestCrossover {CrossoverMutators::getCrossoverFrequency(state, state->lowpassFilters.size() - 3)}; 165 | const double bandWidth {MAX_FREQ - thirdHighestCrossover}; 166 | const double adjustedCrossoverFreq {thirdHighestCrossover + (bandWidth / 2)}; 167 | 168 | setCrossoverFrequency(state, state->lowpassFilters.size() - 2, adjustedCrossoverFreq); 169 | setCrossoverFrequency(state, state->lowpassFilters.size() - 1, MAX_FREQ); 170 | } 171 | 172 | CrossoverProcessors::prepareToPlay(*state.get(), state->sampleRate, state->samplesPerBlock); 173 | CrossoverProcessors::reset(*state.get()); 174 | } 175 | 176 | void removeBand(std::shared_ptr state, size_t bandNumber) { 177 | if (state->lowpassFilters.size() > bandNumber - 1 && state->lowpassFilters.size() > 1) { 178 | state->lowpassFilters.erase(state->lowpassFilters.begin() + bandNumber - 1); 179 | state->highpassFilters.erase(state->highpassFilters.begin() + bandNumber - 1); 180 | 181 | // We might also have an allpass filter to delete 182 | if (state->allpassFilters.size() > bandNumber - 2) { 183 | state->allpassFilters.erase(state->allpassFilters.begin() + bandNumber - 2); 184 | } 185 | 186 | state->buffers.erase(state->buffers.begin() + bandNumber - 1); 187 | 188 | state->bands.erase(state->bands.begin() + bandNumber); 189 | 190 | CrossoverProcessors::reset(*state.get()); 191 | } 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /Source/CrossoverMutators.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CrossoverState.hpp" 4 | 5 | namespace CrossoverMutators { 6 | void setIsBypassed(std::shared_ptr state, size_t bandNumber, bool isBypassed); 7 | void setIsMuted(std::shared_ptr state, size_t bandNumber, bool isMuted); 8 | void setIsSoloed(std::shared_ptr state, size_t bandNumber, bool isSoloed); 9 | bool setCrossoverFrequency(std::shared_ptr state, size_t crossoverNumber, double val); 10 | void setWidth(std::shared_ptr state, size_t bandNumber, float val); 11 | 12 | bool getIsBypassed(std::shared_ptr state, size_t bandNumber); 13 | bool getIsMuted(std::shared_ptr state, size_t bandNumber); 14 | bool getIsSoloed(std::shared_ptr state, size_t bandNumber); 15 | double getCrossoverFrequency(std::shared_ptr state, size_t crossoverNumber); 16 | float getWidth(std::shared_ptr state, size_t bandNumber); 17 | std::vector getWidthMeterValues(std::shared_ptr state); 18 | size_t getNumBands(std::shared_ptr state); 19 | 20 | void addBand(std::shared_ptr state); 21 | void removeBand(std::shared_ptr state, size_t bandNumber); 22 | } 23 | -------------------------------------------------------------------------------- /Source/CrossoverProcessors.cpp: -------------------------------------------------------------------------------- 1 | #include "CrossoverProcessors.hpp" 2 | 3 | namespace { 4 | void processBand(BandState& band, juce::AudioBuffer& buffer) { 5 | if (band.isMuted) { 6 | buffer.clear(); 7 | } else { 8 | float* leftSamples {buffer.getWritePointer(0)}; 9 | float* rightSamples {buffer.getWritePointer(1)}; 10 | 11 | // Do the processing 12 | if (!band.isBypassed) { 13 | for (size_t index {0}; index < buffer.getNumSamples(); index++) { 14 | const double mid {(leftSamples[index] + rightSamples[index]) * 0.5}; 15 | const double side {(rightSamples[index] - leftSamples[index]) * (band.width / 2)}; 16 | 17 | leftSamples[index] = mid - side; 18 | rightSamples[index] = mid + side; 19 | } 20 | } 21 | 22 | // Update the envelope 23 | for (size_t index {0}; index < buffer.getNumSamples(); index++) { 24 | band.env->getNextOutput(leftSamples[index] - rightSamples[index]); 25 | } 26 | } 27 | } 28 | } 29 | 30 | namespace CrossoverProcessors { 31 | void prepareToPlay(CrossoverState& state, double sampleRate, int samplesPerBlock) { 32 | // We don't filter sidechain channels but do copy them to each buffer - so filters may need less channels than the buffers do 33 | for (juce::dsp::LinkwitzRileyFilter& filter : state.lowpassFilters) { 34 | filter.prepare({sampleRate, static_cast(samplesPerBlock), static_cast(2)}); 35 | } 36 | 37 | for (juce::dsp::LinkwitzRileyFilter& filter : state.highpassFilters) { 38 | filter.prepare({sampleRate, static_cast(samplesPerBlock), static_cast(2)}); 39 | } 40 | 41 | for (juce::dsp::LinkwitzRileyFilter& filter : state.allpassFilters) { 42 | filter.prepare({sampleRate, static_cast(samplesPerBlock), static_cast(2)}); 43 | } 44 | 45 | for (juce::AudioBuffer& buffer : state.buffers) { 46 | buffer.setSize(2, samplesPerBlock); 47 | } 48 | 49 | for (BandState& band : state.bands) { 50 | band.env->setSampleRate(sampleRate); 51 | } 52 | 53 | state.sampleRate = sampleRate; 54 | state.samplesPerBlock = samplesPerBlock; 55 | } 56 | 57 | void reset(CrossoverState& state) { 58 | for (juce::dsp::LinkwitzRileyFilter& filter : state.lowpassFilters) { 59 | filter.reset(); 60 | } 61 | 62 | for (juce::dsp::LinkwitzRileyFilter& filter : state.highpassFilters) { 63 | filter.reset(); 64 | } 65 | 66 | for (juce::dsp::LinkwitzRileyFilter& filter : state.allpassFilters) { 67 | filter.reset(); 68 | } 69 | 70 | for (juce::AudioBuffer& buffer : state.buffers) { 71 | buffer.clear(); 72 | } 73 | 74 | for (BandState& band : state.bands) { 75 | band.env->reset(); 76 | } 77 | } 78 | 79 | void processBlock(CrossoverState& state, juce::AudioBuffer& buffer) { 80 | const size_t numCrossovers {state.bands.size() - 1}; 81 | 82 | // First split everything into bands and apply the processing 83 | for (int crossoverNumber {0}; crossoverNumber < numCrossovers; crossoverNumber++) { 84 | // We need to make a copy of the input buffer before processing 85 | // lowBuffer will be lowpassed, highBuffer will be highpassed 86 | juce::AudioBuffer& lowBuffer = crossoverNumber == 0 ? buffer : state.buffers[crossoverNumber - 1]; 87 | juce::AudioBuffer& highBuffer = state.buffers[crossoverNumber]; 88 | 89 | highBuffer.makeCopyOf(lowBuffer); 90 | 91 | { 92 | juce::dsp::AudioBlock block(juce::dsp::AudioBlock(lowBuffer).getSubsetChannelBlock(0, 2)); 93 | juce::dsp::ProcessContextReplacing context(block); 94 | state.lowpassFilters[crossoverNumber].process(context); 95 | 96 | // Crop the internal buffer in case the DAW has provided a buffer smaller than the specified block size in prepareToPlay 97 | juce::AudioBuffer lowBufferCropped(lowBuffer.getArrayOfWritePointers(), lowBuffer.getNumChannels(), buffer.getNumSamples()); 98 | processBand(state.bands[crossoverNumber], lowBufferCropped); 99 | } 100 | 101 | { 102 | juce::dsp::AudioBlock block(juce::dsp::AudioBlock(highBuffer).getSubsetChannelBlock(0, 2)); 103 | juce::dsp::ProcessContextReplacing context(block); 104 | state.highpassFilters[crossoverNumber].process(context); 105 | 106 | // If this is the last band we need to apply the processing 107 | if (crossoverNumber + 1 == numCrossovers) { 108 | // Crop the internal buffer in case the DAW has provided a buffer smaller than the specified block size in prepareToPlay 109 | juce::AudioBuffer highBufferCropped(highBuffer.getArrayOfWritePointers(), highBuffer.getNumChannels(), buffer.getNumSamples()); 110 | processBand(state.bands[crossoverNumber + 1], highBufferCropped); 111 | } 112 | } 113 | } 114 | 115 | // Finally add the bands back together 116 | if (state.numBandsSoloed > 0 && !state.bands[0].isSoloed) { 117 | buffer.clear(); 118 | } 119 | 120 | for (int crossoverNumber {0}; crossoverNumber < numCrossovers; crossoverNumber++) { 121 | // If there is another crossover after this one, we need to use an allpass to rotate the phase of the lower bands 122 | if (crossoverNumber + 1 < numCrossovers) { 123 | juce::dsp::AudioBlock block(juce::dsp::AudioBlock(buffer).getSubsetChannelBlock(0, 2)); 124 | juce::dsp::ProcessContextReplacing context(block); 125 | state.allpassFilters[crossoverNumber].process(context); 126 | } 127 | 128 | if (state.numBandsSoloed == 0 || state.bands[crossoverNumber + 1].isSoloed) { 129 | for (int channelNumber {0}; channelNumber < 2; channelNumber++) { 130 | buffer.addFrom(channelNumber, 0, state.buffers[crossoverNumber], channelNumber, 0, buffer.getNumSamples()); 131 | } 132 | } 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /Source/CrossoverProcessors.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CrossoverState.hpp" 4 | 5 | namespace CrossoverProcessors { 6 | void prepareToPlay(CrossoverState& state, double sampleRate, int samplesPerBlock); 7 | void reset(CrossoverState& state); 8 | void processBlock(CrossoverState& state, juce::AudioBuffer& buffer); 9 | } 10 | -------------------------------------------------------------------------------- /Source/CrossoverState.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "MONSTRFilters/MONSTRParameters.h" 5 | #include "WEFilters/AREnvelopeFollowerSquareLaw.h" 6 | #include "WEFilters/StereoWidthProcessorParameters.h" 7 | 8 | struct BandState { 9 | bool isBypassed; 10 | bool isMuted; 11 | bool isSoloed; 12 | float width; 13 | 14 | std::unique_ptr env; 15 | 16 | BandState() : isBypassed(false), 17 | isMuted(false), 18 | isSoloed(false), 19 | width(WECore::StereoWidth::Parameters::WIDTH.defaultValue), 20 | env(std::make_unique()) { 21 | env->setAttackTimeMs(200); 22 | env->setReleaseTimeMs(500); 23 | } 24 | }; 25 | 26 | class CrossoverState { 27 | public: 28 | // Num low/highpass filters = num bands - 1 (= num crossovers) 29 | std::vector> lowpassFilters; 30 | std::vector> highpassFilters; 31 | 32 | // Num allpass filters = num bands - 2 33 | std::vector> allpassFilters; 34 | 35 | // Num buffers = num bands - 1 (= num crossovers) 36 | std::vector> buffers; 37 | 38 | std::vector bands; 39 | 40 | int numBandsSoloed; 41 | 42 | double sampleRate; 43 | int samplesPerBlock; 44 | 45 | CrossoverState() : numBandsSoloed(0), sampleRate(44100), samplesPerBlock(32) {} 46 | }; 47 | 48 | inline std::shared_ptr createDefaultCrossoverState() { 49 | auto state = std::make_shared(); 50 | 51 | state->lowpassFilters.emplace_back(); 52 | state->lowpassFilters[0].setType(juce::dsp::LinkwitzRileyFilterType::lowpass); 53 | state->lowpassFilters[0].setCutoffFrequency(WECore::MONSTR::Parameters::CROSSOVER_FREQUENCY.defaultValue); 54 | 55 | state->highpassFilters.emplace_back(); 56 | state->highpassFilters[0].setType(juce::dsp::LinkwitzRileyFilterType::highpass); 57 | state->highpassFilters[0].setCutoffFrequency(WECore::MONSTR::Parameters::CROSSOVER_FREQUENCY.defaultValue); 58 | 59 | state->buffers.emplace_back(); 60 | 61 | state->bands.emplace_back(); 62 | state->bands.emplace_back(); 63 | 64 | return state; 65 | } 66 | -------------------------------------------------------------------------------- /Source/Graphics/MONSTR Background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jd-13/MONSTR-Stereo-Imaging/7071f938813a879397726aaa1a8374e9cfdaf59b/Source/Graphics/MONSTR Background.png -------------------------------------------------------------------------------- /Source/Graphics/Tex-white.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jd-13/MONSTR-Stereo-Imaging/7071f938813a879397726aaa1a8374e9cfdaf59b/Source/Graphics/Tex-white.jpg -------------------------------------------------------------------------------- /Source/MONSTRCrossoverImagerComponent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: MONSTRCrossoverImagerComponent.cpp 3 | * 4 | * Created: 06/02/2021 5 | * 6 | * This file is part of MONSTR. 7 | * 8 | * MONSTR is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * MONSTR is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with MONSTR. If not, see . 20 | * 21 | */ 22 | 23 | #include "MONSTRCrossoverImagerComponent.h" 24 | 25 | #include "UIUtils.h" 26 | 27 | MONSTRCrossoverImagerComponent::MONSTRCrossoverImagerComponent(MonstrAudioProcessor* processor) 28 | : _processor(processor) { 29 | } 30 | 31 | void MONSTRCrossoverImagerComponent::paint(Graphics& g) { 32 | 33 | double currentXPos {0}; 34 | const int numBands {_processor->numBands->get()}; 35 | 36 | const std::vector widthValues { 37 | CrossoverInterface::getWidthMeterValues(_processor->crossover) 38 | }; 39 | 40 | for (int bandNumber {0}; bandNumber < widthValues.size(); bandNumber++) { 41 | // For the last band use the value of getWidth() rather than the next crossover as there 42 | // isn't one 43 | const double nextCrossoverXPos { 44 | (bandNumber < numBands - 1) ? 45 | UIUtils::sliderValueToXPos(_processor->crossoverParameters[bandNumber]->get(), getWidth()) : 46 | getWidth() 47 | }; 48 | 49 | const float rectHeight {(getHeight() / 2.0f) * static_cast(widthValues[bandNumber])}; 50 | 51 | g.setColour(UIUtils::imagerColour); 52 | 53 | // Draw the top rectangle 54 | g.fillRect(currentXPos, 55 | getHeight() / 2.0 - rectHeight, 56 | nextCrossoverXPos - currentXPos, 57 | rectHeight); 58 | 59 | // Draw the bottom rectangle 60 | g.fillRect(currentXPos, 61 | getHeight() / 2.0, 62 | nextCrossoverXPos - currentXPos, 63 | rectHeight); 64 | 65 | currentXPos = nextCrossoverXPos; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Source/MONSTRCrossoverImagerComponent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: MONSTRCrossoverImagerComponent.h 3 | * 4 | * Created: 06/02/2021 5 | * 6 | * This file is part of MONSTR. 7 | * 8 | * MONSTR is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * MONSTR is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with MONSTR. If not, see . 20 | * 21 | */ 22 | 23 | #pragma once 24 | 25 | #include "../JuceLibraryCode/JuceHeader.h" 26 | 27 | #include "PluginProcessor.h" 28 | 29 | /** 30 | * Draws the calculated width for each band behind the crossover controls. 31 | */ 32 | class MONSTRCrossoverImagerComponent : public Component { 33 | public: 34 | MONSTRCrossoverImagerComponent(MonstrAudioProcessor* processor); 35 | 36 | void paint(Graphics& g) override; 37 | 38 | private: 39 | MonstrAudioProcessor* _processor; 40 | }; 41 | -------------------------------------------------------------------------------- /Source/MONSTRCrossoverMouseListener.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: MONSTRCrossoverMouseListener.cpp 3 | * 4 | * Created: 21/01/2021 5 | * 6 | * This file is part of MONSTR. 7 | * 8 | * MONSTR is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * MONSTR is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with MONSTR. If not, see . 20 | * 21 | */ 22 | 23 | #include "MONSTRCrossoverMouseListener.h" 24 | 25 | #include 26 | 27 | #include "UIUtils.h" 28 | #include "WEFilters/StereoWidthProcessorParameters.h" 29 | 30 | MONSTRCrossoverMouseListener::MONSTRCrossoverMouseListener(MonstrAudioProcessor* newAudioProcessor) 31 | : _processor(newAudioProcessor), 32 | _widthValueLabel(nullptr), 33 | _tooltipLabel(nullptr) { 34 | 35 | // Initialise the parameter interactions 36 | 37 | const double defaultWidth {WECore::StereoWidth::Parameters::WIDTH.defaultValue}; 38 | 39 | for (int bandIndex {0}; bandIndex < WECore::MONSTR::Parameters::NUM_BANDS.maxValue; bandIndex++) { 40 | 41 | _bandWidths[bandIndex] = FloatParameterInteraction( 42 | [bandIndex, this](const MouseEvent& event) { 43 | _processor->setParameterValueInternal(_processor->bandParameters[bandIndex].width, UIUtils::YPosToWidthValue(event.getPosition().getY(), event.eventComponent->getHeight())); 44 | }, 45 | [bandIndex, defaultWidth, this]() { _processor->setParameterValueInternal(_processor->bandParameters[bandIndex].width, defaultWidth); }, 46 | [bandIndex, this]() { _processor->bandParameters[bandIndex].width->beginChangeGesture(); }, 47 | [bandIndex, this]() { _processor->bandParameters[bandIndex].width->endChangeGesture(); } 48 | ); 49 | } 50 | 51 | for (int bandIndex {0}; bandIndex < WECore::MONSTR::Parameters::NUM_BANDS.maxValue - 1; bandIndex++) { 52 | 53 | _crossoverFrequencies[bandIndex] = FloatParameterInteraction( 54 | [bandIndex, this](const MouseEvent& event) { 55 | constexpr double MIN_SPACING { 56 | 2 * UIUtils::SLIDER_THUMB_RADIUS + UIUtils::BAND_BUTTON_WIDTH 57 | }; 58 | 59 | const int currentXPos {event.getPosition().getX()}; 60 | const int componentWidth {event.eventComponent->getWidth()}; 61 | 62 | _processor->setCrossoverFrequency(bandIndex, UIUtils::XPosToSliderValue(currentXPos, componentWidth)); 63 | 64 | // Check if this crossover handle is getting too close to another and move it if 65 | // needed 66 | for (int crossoverIndex {0}; crossoverIndex < _processor->numBands->get() - 1; crossoverIndex++) { 67 | const double otherXPos { 68 | UIUtils::sliderValueToXPos(_processor->crossoverParameters[crossoverIndex]->get(), componentWidth) 69 | }; 70 | 71 | const double requiredGap {MIN_SPACING * std::abs(bandIndex - crossoverIndex)}; 72 | const double actualGap {std::abs(currentXPos - otherXPos)}; 73 | 74 | if (crossoverIndex < bandIndex && actualGap < requiredGap) { 75 | _processor->setCrossoverFrequency(crossoverIndex, UIUtils::XPosToSliderValue(currentXPos - requiredGap, componentWidth)); 76 | } else if (crossoverIndex > bandIndex && actualGap < requiredGap) { 77 | _processor->setCrossoverFrequency(crossoverIndex, UIUtils::XPosToSliderValue(currentXPos + requiredGap, componentWidth)); 78 | } 79 | } 80 | }, 81 | []() { /* Do nothing - doesn't have a default to reset to */ }, 82 | [bandIndex, this]() { /* Do nothing - parameter isn't public so no need to send change gesture */ }, 83 | [bandIndex, this]() { /* Do nothing - parameter isn't public so no need to send change gesture */ } 84 | ); 85 | } 86 | 87 | } 88 | 89 | MONSTRCrossoverMouseListener::~MONSTRCrossoverMouseListener() { 90 | } 91 | 92 | void MONSTRCrossoverMouseListener::mouseMove(const MouseEvent& event) { 93 | _updateWidthValueLabel(event); 94 | _updateTooltip(event); 95 | } 96 | 97 | void MONSTRCrossoverMouseListener::mouseExit(const MouseEvent& /*event*/) { 98 | // Clear the width label if the cursor isn't inside the component 99 | if (_widthValueLabel != nullptr) { 100 | _widthValueLabel->stop(); 101 | } 102 | } 103 | 104 | void MONSTRCrossoverMouseListener::mouseDown(const MouseEvent& event) { 105 | _dragParameter = _resolveParameterInteraction(event); 106 | _dragParameter.beginGesture(); 107 | } 108 | 109 | void MONSTRCrossoverMouseListener::mouseDrag(const MouseEvent& event) { 110 | _dragParameter.dragCallback(event); 111 | } 112 | 113 | void MONSTRCrossoverMouseListener::mouseUp(const MouseEvent& /*event*/) { 114 | _dragParameter.endGesture(); 115 | _dragParameter = FloatParameterInteraction(); 116 | } 117 | 118 | void MONSTRCrossoverMouseListener::mouseDoubleClick(const MouseEvent& event) { 119 | // This implements "double click to default" for the width parameters 120 | _resolveParameterInteraction(event).resetToDefault(); 121 | } 122 | 123 | MONSTRCrossoverMouseListener::FloatParameterInteraction MONSTRCrossoverMouseListener::_resolveParameterInteraction(const MouseEvent& event) { 124 | const int mouseDownX {event.getMouseDownX()}; 125 | const int mouseDownY {event.getMouseDownY()}; 126 | 127 | // For each available band, check if the cursor landed on a crossover frequency handle or on 128 | // the gaps in between 129 | const int numBands {_processor->numBands->get()}; 130 | 131 | for (size_t bandIndex {0}; bandIndex < numBands; bandIndex++) { 132 | const double crossoverXPos {bandIndex < numBands - 1 ? 133 | UIUtils::sliderValueToXPos(_processor->crossoverParameters[bandIndex]->get(), event.eventComponent->getWidth()) : 134 | event.eventComponent->getWidth() 135 | }; 136 | 137 | if (UIUtils::getButtonBounds(crossoverXPos, 0).contains(mouseDownX, mouseDownY)) { 138 | // Landed on the bypass button 139 | AudioParameterBool* thisParameter = _processor->bandParameters[bandIndex].isActive; 140 | _processor->setParameterValueInternal(thisParameter, !thisParameter->get()); 141 | break; 142 | 143 | } else if (UIUtils::getButtonBounds(crossoverXPos, 1).contains(mouseDownX, mouseDownY)) { 144 | // Landed on the mute button 145 | AudioParameterBool* thisParameter = _processor->bandParameters[bandIndex].isMuted; 146 | _processor->setParameterValueInternal(thisParameter, !thisParameter->get()); 147 | break; 148 | 149 | } else if (UIUtils::getButtonBounds(crossoverXPos, 2).contains(mouseDownX, mouseDownY)) { 150 | // Landed on the solo button 151 | AudioParameterBool* thisParameter = _processor->bandParameters[bandIndex].isSoloed; 152 | _processor->setParameterValueInternal(thisParameter, !thisParameter->get()); 153 | break; 154 | 155 | } else if (mouseDownX < crossoverXPos - UIUtils::SLIDER_THUMB_TARGET_WIDTH) { 156 | // Click landed below a crossover handle but outside a button, so must be on the width 157 | return _bandWidths[bandIndex]; 158 | } else if (mouseDownX < crossoverXPos + UIUtils::SLIDER_THUMB_TARGET_WIDTH) { 159 | // Click landed on a crossover handle 160 | return _crossoverFrequencies[bandIndex]; 161 | } 162 | } 163 | 164 | return FloatParameterInteraction(); 165 | } 166 | 167 | void MONSTRCrossoverMouseListener::_updateWidthValueLabel(const MouseEvent& event) { 168 | const int mouseDownX {event.getMouseDownX()}; 169 | 170 | // For each available band, check if the cursor is currently inside it 171 | const int numBands {_processor->numBands->get()}; 172 | 173 | for (size_t bandIndex {0}; bandIndex < numBands; bandIndex++) { 174 | const double crossoverXPos {bandIndex < numBands - 1 ? 175 | UIUtils::sliderValueToXPos(_processor->crossoverParameters[bandIndex]->get(), event.eventComponent->getWidth()) : 176 | event.eventComponent->getWidth() 177 | }; 178 | 179 | if (mouseDownX < crossoverXPos) { 180 | // Pass the parameter to the value label 181 | if (_widthValueLabel != nullptr) { 182 | _widthValueLabel->setTargetParameter(_processor->bandParameters[bandIndex].width); 183 | } 184 | 185 | if (_tooltipLabel != nullptr) { 186 | _tooltipLabel->setText("Band " + juce::String(bandIndex), juce::NotificationType::dontSendNotification); 187 | } 188 | break; 189 | } 190 | } 191 | } 192 | 193 | void MONSTRCrossoverMouseListener::_updateTooltip(const MouseEvent& event) { 194 | const int mouseDownX {event.getMouseDownX()}; 195 | const int mouseDownY {event.getMouseDownY()}; 196 | 197 | // For each available band, check if the cursor landed on a crossover frequency handle or on 198 | // the gaps in between 199 | const int numBands {_processor->numBands->get()}; 200 | 201 | for (size_t bandIndex {0}; bandIndex < numBands; bandIndex++) { 202 | const double crossoverXPos {bandIndex < numBands - 1 ? 203 | UIUtils::sliderValueToXPos(_processor->crossoverParameters[bandIndex]->get(), event.eventComponent->getWidth()) : 204 | event.eventComponent->getWidth() 205 | }; 206 | 207 | if (UIUtils::getButtonBounds(crossoverXPos, 0).contains(mouseDownX, mouseDownY)) { 208 | // Landed on the bypass button 209 | if (_tooltipLabel != nullptr) { 210 | _tooltipLabel->setText("Bypasses the width processing for this band", juce::NotificationType::dontSendNotification); 211 | } 212 | break; 213 | 214 | } else if (UIUtils::getButtonBounds(crossoverXPos, 1).contains(mouseDownX, mouseDownY)) { 215 | // Landed on the mute button 216 | if (_tooltipLabel != nullptr) { 217 | _tooltipLabel->setText("Mutes this band", juce::NotificationType::dontSendNotification); 218 | } 219 | break; 220 | 221 | } else if (UIUtils::getButtonBounds(crossoverXPos, 2).contains(mouseDownX, mouseDownY)) { 222 | // Landed on the solo button 223 | if (_tooltipLabel != nullptr) { 224 | _tooltipLabel->setText("Soloes this band", juce::NotificationType::dontSendNotification); 225 | } 226 | break; 227 | 228 | } else if (mouseDownX < crossoverXPos - UIUtils::SLIDER_THUMB_TARGET_WIDTH) { 229 | // Landed below a crossover handle but outside a button, so must be on the width 230 | if (_tooltipLabel != nullptr) { 231 | _tooltipLabel->setText("Drag up or down to increase or decrease the stereo width of this band", juce::NotificationType::dontSendNotification); 232 | } 233 | break; 234 | 235 | } else if (mouseDownX < crossoverXPos + UIUtils::SLIDER_THUMB_TARGET_WIDTH) { 236 | // Landed on a crossover handle 237 | if (_tooltipLabel != nullptr) { 238 | _tooltipLabel->setText("Drag left or right to change the crossover frequency", juce::NotificationType::dontSendNotification); 239 | } 240 | break; 241 | } 242 | } 243 | } 244 | 245 | -------------------------------------------------------------------------------- /Source/MONSTRCrossoverMouseListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: MONSTRCrossoverMouseListener.h 3 | * 4 | * Created: 21/01/2021 5 | * 6 | * This file is part of MONSTR. 7 | * 8 | * MONSTR is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * MONSTR is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with MONSTR. If not, see . 20 | * 21 | */ 22 | 23 | #pragma once 24 | 25 | #include 26 | #include 27 | 28 | #include "../JuceLibraryCode/JuceHeader.h" 29 | #include "MONSTRWidthLabel.h" 30 | #include "PluginProcessor.h" 31 | #include "ParameterData.h" 32 | 33 | class MONSTRCrossoverMouseListener : public MouseListener { 34 | public: 35 | 36 | MONSTRCrossoverMouseListener(MonstrAudioProcessor* newAudioProcessor); 37 | virtual ~MONSTRCrossoverMouseListener(); 38 | 39 | void mouseMove(const MouseEvent& event) override; 40 | 41 | void mouseExit(const MouseEvent& event) override; 42 | 43 | void mouseDown(const MouseEvent& event) override; 44 | 45 | void mouseDrag(const MouseEvent& event) override; 46 | 47 | void mouseUp(const MouseEvent& event) override; 48 | 49 | void mouseDoubleClick(const MouseEvent& event) override; 50 | 51 | void start(MONSTRWidthLabel* widthValueLabel, juce::Label* tooltipLabel) { 52 | _widthValueLabel = widthValueLabel; 53 | _tooltipLabel = tooltipLabel; 54 | } 55 | 56 | void stop() { 57 | _widthValueLabel = nullptr; 58 | _tooltipLabel = nullptr; 59 | } 60 | 61 | private: 62 | 63 | struct FloatParameterInteraction { 64 | std::function dragCallback; 65 | std::function resetToDefault; 66 | std::function beginGesture; 67 | std::function endGesture; 68 | 69 | FloatParameterInteraction() : 70 | dragCallback([](const MouseEvent&) {}), 71 | resetToDefault([]() {}), 72 | beginGesture([]() {}), 73 | endGesture([]() {}) { } 74 | 75 | FloatParameterInteraction( 76 | std::function newDragCallback, 77 | std::function newResetToDefault, 78 | std::function newBeginGesture, 79 | std::function newEndGesture) : 80 | dragCallback(newDragCallback), 81 | resetToDefault(newResetToDefault), 82 | beginGesture(newBeginGesture), 83 | endGesture(newEndGesture) { } 84 | }; 85 | 86 | std::array _bandWidths; 87 | std::array _crossoverFrequencies; 88 | 89 | MonstrAudioProcessor* _processor; 90 | 91 | FloatParameterInteraction _dragParameter; 92 | 93 | MONSTRWidthLabel* _widthValueLabel; 94 | 95 | juce::Label* _tooltipLabel; 96 | 97 | /** 98 | * If the mouse event occured inside a button the function will handle it and return null, 99 | * if the event occured inside a slider it will return the corresponding 100 | * FloatParameterInteraction for it to be handled by the appropriate event handlers. 101 | */ 102 | FloatParameterInteraction _resolveParameterInteraction(const MouseEvent& event); 103 | 104 | void _updateWidthValueLabel(const MouseEvent& event); 105 | void _updateTooltip(const MouseEvent& event); 106 | }; 107 | -------------------------------------------------------------------------------- /Source/MONSTRCrossoverParameterComponent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: MONSTRCrossoverParameterComponent.cpp 3 | * 4 | * Created: 06/03/2016 5 | * 6 | * This file is part of MONSTR. 7 | * 8 | * MONSTR is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * MONSTR is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with MONSTR. If not, see . 20 | * 21 | */ 22 | 23 | #include "MONSTRCrossoverParameterComponent.h" 24 | 25 | #include 26 | #include "WEFilters/StereoWidthProcessorParameters.h" 27 | #include "UIUtils.h" 28 | 29 | namespace { 30 | 31 | void drawBandButton(String text, const Colour& colour, Graphics& g, double crossoverXPos, double index) { 32 | 33 | constexpr int CORNER_RADIUS {2}; 34 | constexpr int LINE_THICKNESS {1}; 35 | 36 | const Rectangle buttonRectange = UIUtils::getButtonBounds(crossoverXPos, index); 37 | 38 | const Colour buttonBackground(static_cast(0), 0, 0, 0.5f); 39 | g.setColour(buttonBackground); 40 | g.fillRoundedRectangle(buttonRectange, CORNER_RADIUS); 41 | 42 | g.setColour(colour); 43 | g.drawRoundedRectangle(buttonRectange, CORNER_RADIUS, LINE_THICKNESS); 44 | 45 | g.drawText(text, buttonRectange, Justification::centred); 46 | } 47 | } 48 | 49 | MONSTRCrossoverParameterComponent::MONSTRCrossoverParameterComponent(MonstrAudioProcessor* newAudioProcessor) 50 | : _processor(newAudioProcessor) { 51 | } 52 | 53 | void MONSTRCrossoverParameterComponent::paint(Graphics &g) { 54 | 55 | _drawNeutralLine(g); 56 | _drawWidthRectangles(g); 57 | _drawSliderThumbs(g); 58 | _drawFrequencyText(g); 59 | _drawBandButtons(g); 60 | } 61 | 62 | void MONSTRCrossoverParameterComponent::_drawNeutralLine(Graphics &g) { 63 | 64 | Path p; 65 | p.addLineSegment(Line(0, 66 | getHeight() / 2, 67 | getWidth(), 68 | getHeight() / 2), 69 | 1); 70 | 71 | g.setColour(UIUtils::lightGrey); 72 | g.strokePath(p, PathStrokeType(0.5f)); 73 | } 74 | 75 | void MONSTRCrossoverParameterComponent::_drawSliderThumbs(Graphics& g) { 76 | 77 | for (int bandIndex {0}; bandIndex < _processor->numBands->get() - 1; bandIndex++) { 78 | const double crossoverXPos { 79 | UIUtils::sliderValueToXPos(_processor->crossoverParameters[bandIndex]->get(), getWidth()) 80 | }; 81 | 82 | 83 | Path p; 84 | constexpr float LINE_WIDTH {1.0f}; 85 | 86 | g.setColour(UIUtils::darkGrey); 87 | p.addLineSegment(Line(crossoverXPos, 0, crossoverXPos, getHeight()), 88 | 1); 89 | g.strokePath(p, PathStrokeType(LINE_WIDTH)); 90 | } 91 | } 92 | 93 | void MONSTRCrossoverParameterComponent::_drawWidthRectangles(Graphics &g) { 94 | 95 | double currentXPos {0}; 96 | const int numBands {_processor->numBands->get()}; 97 | 98 | // Check if any bands are soloed 99 | bool isSomethingSoloed {false}; 100 | for (int bandIndex {0}; bandIndex < numBands; bandIndex++) { 101 | if (_processor->bandParameters[bandIndex].isSoloed->get()) { 102 | isSomethingSoloed = true; 103 | } 104 | } 105 | 106 | for (int bandIndex {0}; bandIndex < numBands; bandIndex++) { 107 | 108 | // For the last band use the value of getWidth() rather than the next crossover as there 109 | // isn't one 110 | const double nextCrossoverXPos { 111 | (bandIndex < numBands - 1) ? 112 | UIUtils::sliderValueToXPos(_processor->crossoverParameters[bandIndex]->get(), getWidth()) : 113 | getWidth() 114 | }; 115 | 116 | // Band is grey if inactive 117 | const bool bandActive { 118 | _processor->bandParameters[bandIndex].isActive->get() && 119 | !_processor->bandParameters[bandIndex].isMuted->get() && 120 | (!isSomethingSoloed || _processor->bandParameters[bandIndex].isSoloed->get()) 121 | }; 122 | 123 | float rectYPos {0}; 124 | float rectHeight {0}; 125 | float lineHeight {0}; 126 | 127 | // Move the width value to the range -0.5:0.5 128 | const double widthValue {_processor->bandParameters[bandIndex].width->get() / 2 - 0.5}; 129 | 130 | if (widthValue > 0) { 131 | rectHeight = (getHeight() / 2.0) * widthValue; 132 | rectYPos = getHeight() / 2.0 - rectHeight; 133 | lineHeight = rectYPos; 134 | } else { 135 | rectYPos = getHeight() / 2.0; 136 | rectHeight = (getHeight() / 2.0) * std::abs(widthValue); 137 | lineHeight = rectYPos + rectHeight; 138 | } 139 | 140 | if (bandActive) { 141 | g.setColour(UIUtils::mainHighlight); 142 | g.drawLine(currentXPos, lineHeight, nextCrossoverXPos, lineHeight, 0.5f); 143 | 144 | g.setColour(UIUtils::transHighlight); 145 | } else { 146 | g.setColour(UIUtils::lightGreyTrans); 147 | } 148 | 149 | g.fillRect(currentXPos, rectYPos, nextCrossoverXPos - currentXPos, rectHeight); 150 | 151 | currentXPos = nextCrossoverXPos; 152 | } 153 | } 154 | 155 | void MONSTRCrossoverParameterComponent::_drawFrequencyText(Graphics &g) { 156 | constexpr double fractionOfHeight {0.85}; 157 | constexpr int spacing {10}; 158 | 159 | for (int bandIndex {0}; bandIndex < _processor->numBands->get() - 1; bandIndex++) { 160 | g.setColour(UIUtils::mainHighlight); 161 | 162 | const float crossoverValue {_processor->crossoverParameters[bandIndex]->get()}; 163 | 164 | const double crossoverXPos { 165 | UIUtils::sliderValueToXPos(crossoverValue, getWidth()) 166 | }; 167 | 168 | GlyphArrangement ga; 169 | ga.addLineOfText(Font(16.0f), String(static_cast(crossoverValue)) + " Hz", 0, 0); 170 | 171 | Path p; 172 | ga.createPath(p); 173 | 174 | Rectangle pathBounds = p.getBounds(); 175 | 176 | p.applyTransform( 177 | AffineTransform().rotated(WECore::CoreMath::DOUBLE_PI / 2, 178 | pathBounds.getCentreX(), 179 | pathBounds.getCentreY()).translated(crossoverXPos - pathBounds.getWidth() / 2.0 + spacing, 180 | getHeight() * fractionOfHeight) 181 | 182 | 183 | ); 184 | 185 | g.fillPath(p); 186 | } 187 | } 188 | 189 | void MONSTRCrossoverParameterComponent::_drawBandButtons(Graphics &g) { 190 | 191 | const Colour bypassColour(252, 252, 22); 192 | const Colour muteColour(252, 0, 0); 193 | const Colour soloColour(252, 137, 22); 194 | 195 | for (int bandIndex {0}; bandIndex < _processor->numBands->get(); bandIndex++) { 196 | const double crossoverXPos {bandIndex < _processor->numBands->get() - 1 ? 197 | UIUtils::sliderValueToXPos(_processor->crossoverParameters[bandIndex]->get(), getWidth()) : 198 | getWidth() 199 | }; 200 | 201 | drawBandButton("B", 202 | !_processor->bandParameters[bandIndex].isActive->get() ? bypassColour : UIUtils::lightGrey, 203 | g, 204 | crossoverXPos, 205 | 0); 206 | 207 | drawBandButton("M", 208 | _processor->bandParameters[bandIndex].isMuted->get() ? muteColour : UIUtils::lightGrey, 209 | g, 210 | crossoverXPos, 211 | 1); 212 | 213 | drawBandButton("S", 214 | _processor->bandParameters[bandIndex].isSoloed->get() ? soloColour : UIUtils::lightGrey, 215 | g, 216 | crossoverXPos, 217 | 2); 218 | } 219 | } 220 | -------------------------------------------------------------------------------- /Source/MONSTRCrossoverParameterComponent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: MONSTRCrossoverParameterComponent.h 3 | * 4 | * Created: 06/03/2016 5 | * 6 | * This file is part of MONSTR. 7 | * 8 | * MONSTR is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * MONSTR is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with MONSTR. If not, see . 20 | * 21 | */ 22 | 23 | #pragma once 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include "../JuceLibraryCode/JuceHeader.h" 30 | #include "PluginProcessor.h" 31 | 32 | class MONSTRWidthLabel; 33 | 34 | 35 | /** 36 | * Draws the clickable parts of the crossover component. 37 | */ 38 | class MONSTRCrossoverParameterComponent : public Component { 39 | public: 40 | 41 | MONSTRCrossoverParameterComponent(MonstrAudioProcessor* newAudioProcessor); 42 | virtual ~MONSTRCrossoverParameterComponent() = default; 43 | 44 | void paint(Graphics& g) override; 45 | 46 | private: 47 | MonstrAudioProcessor* _processor; 48 | 49 | void _drawNeutralLine(Graphics& g); 50 | 51 | void _drawSliderThumbs(Graphics& g); 52 | 53 | void _drawWidthRectangles(Graphics& g); 54 | 55 | void _drawFrequencyText(Graphics& g); 56 | 57 | void _drawBandButtons(Graphics& g); 58 | }; 59 | -------------------------------------------------------------------------------- /Source/MONSTRCrossoverWrapperComponent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: MONSTRCrossoverWrapperComponent.cpp 3 | * 4 | * Created: 06/02/2021 5 | * 6 | * This file is part of MONSTR. 7 | * 8 | * MONSTR is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * MONSTR is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with MONSTR. If not, see . 20 | * 21 | */ 22 | 23 | #include "MONSTRCrossoverWrapperComponent.h" 24 | 25 | MONSTRCrossoverWrapperComponent::MONSTRCrossoverWrapperComponent( 26 | MonstrAudioProcessor* processor) { 27 | 28 | _parameterComponent.reset(new MONSTRCrossoverParameterComponent(processor)); 29 | addAndMakeVisible(_parameterComponent.get()); 30 | 31 | _imagerComponent.reset(new MONSTRCrossoverImagerComponent(processor)); 32 | addAndMakeVisible(_imagerComponent.get()); 33 | _imagerComponent->toBack(); 34 | 35 | _mouseListener = std::make_unique(processor); 36 | _parameterComponent->addMouseListener(_mouseListener.get(), false); 37 | } 38 | 39 | void MONSTRCrossoverWrapperComponent::resized() { 40 | _parameterComponent->setBounds(getLocalBounds()); 41 | _imagerComponent->setBounds(getLocalBounds()); 42 | } 43 | 44 | void MONSTRCrossoverWrapperComponent::start(MONSTRWidthLabel* widthValueLabel, juce::Label* tooltipLabel) { 45 | _mouseListener->start(widthValueLabel, tooltipLabel); 46 | } 47 | 48 | void MONSTRCrossoverWrapperComponent::stop() { 49 | _mouseListener->stop(); 50 | } 51 | 52 | void MONSTRCrossoverWrapperComponent::onImagerUpdate() { 53 | _imagerComponent->repaint(); 54 | } 55 | 56 | void MONSTRCrossoverWrapperComponent::onParameterUpdate() { 57 | _parameterComponent->repaint(); 58 | } 59 | -------------------------------------------------------------------------------- /Source/MONSTRCrossoverWrapperComponent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: MONSTRCrossoverWrapperComponent.h 3 | * 4 | * Created: 06/02/2021 5 | * 6 | * This file is part of MONSTR. 7 | * 8 | * MONSTR is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * MONSTR is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with MONSTR. If not, see . 20 | * 21 | */ 22 | 23 | #pragma once 24 | 25 | #include "../JuceLibraryCode/JuceHeader.h" 26 | 27 | #include 28 | 29 | #include "MONSTRCrossoverImagerComponent.h" 30 | #include "MONSTRCrossoverMouseListener.h" 31 | #include "MONSTRCrossoverParameterComponent.h" 32 | 33 | class MONSTRCrossoverWrapperComponent : public Component { 34 | public: 35 | 36 | MONSTRCrossoverWrapperComponent(MonstrAudioProcessor* processor); 37 | virtual ~MONSTRCrossoverWrapperComponent() = default; 38 | 39 | void resized() override; 40 | 41 | void start(MONSTRWidthLabel* widthValueLabel, juce::Label* tooltipLabel); 42 | void stop(); 43 | 44 | void onImagerUpdate(); 45 | void onParameterUpdate(); 46 | 47 | private: 48 | std::unique_ptr _imagerComponent; 49 | std::unique_ptr _parameterComponent; 50 | std::unique_ptr _mouseListener; 51 | 52 | }; 53 | -------------------------------------------------------------------------------- /Source/MONSTRLookAndFeel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: MONSTRLookAndFeel.cpp 3 | * 4 | * Created: 01/03/2016 5 | * 6 | * This file is part of MONSTR. 7 | * 8 | * MONSTR is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * MONSTR is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with MONSTR. If not, see . 20 | * 21 | */ 22 | 23 | #include "MONSTRLookAndFeel.h" 24 | 25 | #include "UIUtils.h" 26 | 27 | MONSTRLookAndFeel::MONSTRLookAndFeel() { 28 | _regularFont = Font(Typeface::createSystemTypefaceFor(BinaryData::MontserratRegular_ttf, 29 | BinaryData::MontserratRegular_ttfSize)); 30 | 31 | jassert(_regularFont.getTypefaceName().isNotEmpty()); 32 | } 33 | 34 | MONSTRLookAndFeel::~MONSTRLookAndFeel() { 35 | } 36 | 37 | void MONSTRLookAndFeel::drawButtonBackground(Graphics& /*g*/, 38 | Button& /*textButton*/, 39 | const Colour& /*backgroundColour*/, 40 | bool /*shouldDrawButtonAsHighlighted*/, 41 | bool /*shouldDrawButtonAsDown*/) { 42 | // Do nothing 43 | } 44 | 45 | void MONSTRLookAndFeel::drawButtonText(Graphics& g, 46 | TextButton& textButton, 47 | bool /*shouldDrawButtonAsHighlighted*/, 48 | bool /*shouldDrawButtonAsDown*/) { 49 | 50 | if (textButton.isEnabled()) { 51 | g.setColour(textButton.findColour(TextButton::textColourOnId)); 52 | } else { 53 | g.setColour(textButton.findColour(TextButton::textColourOffId)); 54 | } 55 | 56 | Font font; 57 | font.setTypefaceName(getTypefaceForFont(font)->getName()); 58 | g.setFont(font); 59 | 60 | g.drawFittedText(textButton.getButtonText(), 61 | 0, 62 | 0, 63 | textButton.getWidth(), 64 | textButton.getHeight(), 65 | Justification::centred, 66 | 0); 67 | } 68 | 69 | void MONSTRLookAndFeel::drawTooltip(Graphics& g, 70 | const String& text, 71 | int width, 72 | int height) { 73 | g.setColour(UIUtils::lightGrey); 74 | g.fillRect(0, 0, width, height); 75 | 76 | g.setColour(UIUtils::darkGrey); 77 | g.drawFittedText(text, 0, 0, width, height, Justification::centred, 3); 78 | } 79 | 80 | Typeface::Ptr MONSTRLookAndFeel::getTypefaceForFont(const Font& /*font*/) { 81 | return _regularFont.getTypeface(); 82 | } 83 | -------------------------------------------------------------------------------- /Source/MONSTRLookAndFeel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: MONSTRLookAndFeel.h 3 | * 4 | * Created: 01/03/2016 5 | * 6 | * This file is part of MONSTR. 7 | * 8 | * MONSTR is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * MONSTR is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with MONSTR. If not, see . 20 | * 21 | */ 22 | 23 | #ifndef MONSTRLOOKANDFEEL_H_INCLUDED 24 | #define MONSTRLOOKANDFEEL_H_INCLUDED 25 | 26 | #define _USE_MATH_DEFINES 27 | 28 | #include "../JuceLibraryCode/JuceHeader.h" 29 | #include "math.h" 30 | 31 | class MONSTRLookAndFeel : public LookAndFeel_V2 { 32 | public: 33 | MONSTRLookAndFeel(); 34 | 35 | ~MONSTRLookAndFeel(); 36 | 37 | virtual void drawButtonBackground (Graphics& g, 38 | Button& textButton, 39 | const Colour& backgroundColour, 40 | bool shouldDrawButtonAsHighlighted, 41 | bool shouldDrawButtonAsDown) override; 42 | 43 | virtual void drawButtonText (Graphics& g, 44 | TextButton& textButton, 45 | bool shouldDrawButtonAsHighlighted, 46 | bool shouldDrawButtonAsDown) override; 47 | 48 | virtual void drawTooltip(Graphics& g, 49 | const String& text, 50 | int width, 51 | int height) override; 52 | 53 | virtual Typeface::Ptr getTypefaceForFont(const Font& font) override; 54 | 55 | private: 56 | Font _regularFont; 57 | 58 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MONSTRLookAndFeel) 59 | }; 60 | 61 | 62 | 63 | #endif // MONSTRLOOKANDFEEL_H_INCLUDED 64 | -------------------------------------------------------------------------------- /Source/MONSTRWidthLabel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * File: MONSTRWidthLabel.cpp 3 | * 4 | * Created: 30/01/2021 5 | * 6 | * This file is part of MONSTR. 7 | * 8 | * MONSTR is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * MONSTR is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with MONSTR. If not, see . 20 | * 21 | */ 22 | 23 | #include "MONSTRWidthLabel.h" 24 | 25 | namespace { 26 | double widthValueToLabelValue(double value) { 27 | return value - 1; 28 | } 29 | } 30 | 31 | MONSTRWidthLabel::MONSTRWidthLabel(const String& /*componentName*/, const String& /*labelText*/) : 32 | _targetParameter(nullptr) { 33 | } 34 | 35 | void MONSTRWidthLabel::refreshValue() { 36 | 37 | String newValue(""); 38 | 39 | // Check if there is a parameter to retrieve a value from 40 | if (_targetParameter != nullptr) { 41 | newValue = String(widthValueToLabelValue(_targetParameter->get()), 2); 42 | } 43 | 44 | // If the value has changed redraw the component 45 | if (_lastValue != newValue) { 46 | 47 | setText(newValue, dontSendNotification); 48 | _lastValue = newValue; 49 | 50 | repaint(); 51 | } 52 | } 53 | 54 | void MONSTRWidthLabel::setTargetParameter(AudioParameterFloat* parameter) { 55 | _targetParameter = parameter; 56 | }; 57 | 58 | void MONSTRWidthLabel::stop() { 59 | _targetParameter = nullptr; 60 | } 61 | -------------------------------------------------------------------------------- /Source/MONSTRWidthLabel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: MONSTRWidthLabel.h 3 | * 4 | * Created: 30/01/2021 5 | * 6 | * This file is part of MONSTR. 7 | * 8 | * MONSTR is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * MONSTR is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with MONSTR. If not, see . 20 | * 21 | */ 22 | 23 | #pragma once 24 | 25 | 26 | #include "../JuceLibraryCode/JuceHeader.h" 27 | 28 | /** 29 | * A custom label which when refreshValue is called will read in the value from the specified 30 | * parameter and displays its value. 31 | * 32 | * The reason it is done this way rather than using the LabelReadoutSlider as in other plugins, is 33 | * that updating the label value continuously for every parameter change causes the crossover 34 | * component to repaint at a much slower rate and makes the UI feel a little laggy. 35 | */ 36 | class MONSTRWidthLabel : public Label { 37 | public: 38 | 39 | MONSTRWidthLabel(const String& componentName = String(), const String& labelText = String()); 40 | virtual ~MONSTRWidthLabel() = default; 41 | 42 | void refreshValue(); 43 | 44 | void setTargetParameter(AudioParameterFloat* parameter); 45 | 46 | void stop(); 47 | 48 | private: 49 | 50 | AudioParameterFloat* _targetParameter; 51 | String _lastValue; 52 | }; 53 | -------------------------------------------------------------------------------- /Source/ParameterData.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ParameterData.h 3 | * 4 | * Created: 21/01/2016 5 | * 6 | * This file is part of MONSTR. 7 | * 8 | * MONSTR is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * MONSTR is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with MONSTR. If not, see . 20 | * 21 | */ 22 | 23 | #ifndef PARAMETERDATA_H_INCLUDED 24 | #define PARAMETERDATA_H_INCLUDED 25 | 26 | #include 27 | 28 | #include "../JuceLibraryCode/JuceHeader.h" 29 | #include "General/ParameterDefinition.h" 30 | #include "MONSTRFilters/MONSTRParameters.h" 31 | 32 | const String NUMBANDS_STR = "NumBands"; 33 | 34 | struct BandStrings { 35 | String isActive; 36 | String isMuted; 37 | String isSoloed; 38 | String width; 39 | }; 40 | 41 | const std::array BAND_STRINGS {{ 42 | {"Band1Bypass", "Band1Mute", "Band1Solo", "Band1Width"}, 43 | {"Band2Bypass", "Band2Mute", "Band2Solo", "Band2Width"}, 44 | {"Band3Bypass", "Band3Mute", "Band3Solo", "Band3Width"}, 45 | {"Band4Bypass", "Band4Mute", "Band4Solo", "Band4Width"}, 46 | {"Band5Bypass", "Band5Mute", "Band5Solo", "Band5Width"}, 47 | {"Band6Bypass", "Band6Mute", "Band6Solo", "Band6Width"} 48 | }}; 49 | 50 | const std::array CROSSOVER_STRINGS { 51 | "Crossover1Frequency", 52 | "Crossover2Frequency", 53 | "Crossover3Frequency", 54 | "Crossover4Frequency", 55 | "Crossover5Frequency" 56 | }; 57 | 58 | #endif // PARAMETERDATA_H_INCLUDED 59 | -------------------------------------------------------------------------------- /Source/PluginEditor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This is an automatically generated GUI class created by the Projucer! 5 | 6 | Be careful when adding custom code to these files, as only the code within 7 | the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded 8 | and re-saved. 9 | 10 | Created with Projucer version: 7.0.9 11 | 12 | ------------------------------------------------------------------------------ 13 | 14 | The Projucer is part of the JUCE library. 15 | Copyright (c) 2020 - Raw Material Software Limited. 16 | 17 | ============================================================================== 18 | */ 19 | 20 | //[Headers] You can add your own extra header files here... 21 | //[/Headers] 22 | 23 | #include "PluginEditor.h" 24 | 25 | 26 | //[MiscUserDefs] You can add your own user definitions and misc code here... 27 | #include "UIUtils.h" 28 | //[/MiscUserDefs] 29 | 30 | //============================================================================== 31 | MonstrAudioProcessorEditor::MonstrAudioProcessorEditor (MonstrAudioProcessor& ownerFilter) 32 | : CoreProcessorEditor(ownerFilter) 33 | { 34 | //[Constructor_pre] You can add your own custom stuff here.. 35 | //[/Constructor_pre] 36 | 37 | crossoverWrapper.reset (new MONSTRCrossoverWrapperComponent (getProcessor())); 38 | addAndMakeVisible (crossoverWrapper.get()); 39 | crossoverWrapper->setName ("Crossover View"); 40 | 41 | crossoverWrapper->setBounds (16, 40, 608, 210); 42 | 43 | AddBandBtn.reset (new juce::TextButton ("Add Band Button")); 44 | addAndMakeVisible (AddBandBtn.get()); 45 | AddBandBtn->setTooltip (TRANS ("Adds a new band")); 46 | AddBandBtn->setButtonText (TRANS ("Add Band")); 47 | AddBandBtn->addListener (this); 48 | 49 | AddBandBtn->setBounds (365, 256, 275, 34); 50 | 51 | RemoveBandBtn.reset (new juce::TextButton ("Remove Band Button")); 52 | addAndMakeVisible (RemoveBandBtn.get()); 53 | RemoveBandBtn->setTooltip (TRANS ("Removes the highest band")); 54 | RemoveBandBtn->setButtonText (TRANS ("Remove Band")); 55 | RemoveBandBtn->addListener (this); 56 | 57 | RemoveBandBtn->setBounds (0, 256, 275, 34); 58 | 59 | widthValueLbl.reset (new MONSTRWidthLabel ("Width Value Label", 60 | juce::String())); 61 | addAndMakeVisible (widthValueLbl.get()); 62 | widthValueLbl->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular")); 63 | widthValueLbl->setJustificationType (juce::Justification::centred); 64 | widthValueLbl->setEditable (false, false, false); 65 | widthValueLbl->setColour (juce::TextEditor::textColourId, juce::Colours::black); 66 | widthValueLbl->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000)); 67 | 68 | widthValueLbl->setBounds (288, 261, 64, 24); 69 | 70 | tooltipLbl.reset (new juce::Label ("Tooltip Label", 71 | juce::String())); 72 | addAndMakeVisible (tooltipLbl.get()); 73 | tooltipLbl->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular")); 74 | tooltipLbl->setJustificationType (juce::Justification::centred); 75 | tooltipLbl->setEditable (false, false, false); 76 | tooltipLbl->setColour (juce::TextEditor::textColourId, juce::Colours::black); 77 | tooltipLbl->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000)); 78 | 79 | tooltipLbl->setBounds (8, 294, 624, 24); 80 | 81 | 82 | //[UserPreSize] 83 | //[/UserPreSize] 84 | 85 | setSize (640, 318); 86 | 87 | 88 | //[Constructor] You can add your own custom stuff here.. 89 | startTimer(40); 90 | 91 | _assignLookAndFeelToAllChildren(customLookAndFeel); 92 | 93 | // This is needed for the fonts to be applied 94 | MONSTRLookAndFeel::setDefaultLookAndFeel(&customLookAndFeel); 95 | 96 | // Start tooltip label 97 | addMouseListener(&_tooltipLabelUpdater, true); 98 | _tooltipLabelUpdater.start(tooltipLbl.get(), getAudioProcessor()->wrapperType); 99 | tooltipLbl->setColour(Label::textColourId, UIUtils::lightGrey); 100 | 101 | AddBandBtn->setColour(TextButton::textColourOnId, UIUtils::mainHighlight); 102 | RemoveBandBtn->setColour(TextButton::textColourOnId, UIUtils::mainHighlight); 103 | 104 | AddBandBtn->setColour(TextButton::textColourOffId, UIUtils::lightGrey); 105 | RemoveBandBtn->setColour(TextButton::textColourOffId, UIUtils::lightGrey); 106 | 107 | widthValueLbl->setColour(Label::textColourId, UIUtils::mainHighlight); 108 | crossoverWrapper->start(widthValueLbl.get(), tooltipLbl.get()); 109 | 110 | // Call this manually once to make sure the UI reflects the parameters' states correctly 111 | _onParameterUpdate(); 112 | //[/Constructor] 113 | } 114 | 115 | MonstrAudioProcessorEditor::~MonstrAudioProcessorEditor() 116 | { 117 | //[Destructor_pre]. You can add your own custom destruction code here.. 118 | crossoverWrapper->stop(); 119 | widthValueLbl->stop(); 120 | _tooltipLabelUpdater.stop(); 121 | //[/Destructor_pre] 122 | 123 | crossoverWrapper = nullptr; 124 | AddBandBtn = nullptr; 125 | RemoveBandBtn = nullptr; 126 | widthValueLbl = nullptr; 127 | tooltipLbl = nullptr; 128 | 129 | 130 | //[Destructor]. You can add your own custom destruction code here.. 131 | _removeLookAndFeelFromAllChildren(); 132 | //[/Destructor] 133 | } 134 | 135 | //============================================================================== 136 | void MonstrAudioProcessorEditor::paint (juce::Graphics& g) 137 | { 138 | //[UserPrePaint] Add your own custom painting code here.. 139 | //[/UserPrePaint] 140 | 141 | g.fillAll (juce::Colours::white); 142 | 143 | //[UserPaint] Add your own custom painting code here.. 144 | 145 | Image bg {ImageCache::getFromMemory(BinaryData::MONSTR_Background_png, BinaryData::MONSTR_Background_pngSize)}; 146 | g.drawImage(bg, 0, 0, 640, 318, 0, 0, 2 * 640, 2 * 318); 147 | 148 | //[/UserPaint] 149 | } 150 | 151 | void MonstrAudioProcessorEditor::resized() 152 | { 153 | //[UserPreResize] Add your own custom resize code here.. 154 | //[/UserPreResize] 155 | 156 | //[UserResized] Add your own custom resize handling here.. 157 | //[/UserResized] 158 | } 159 | 160 | void MonstrAudioProcessorEditor::buttonClicked (juce::Button* buttonThatWasClicked) 161 | { 162 | //[UserbuttonClicked_Pre] 163 | MonstrAudioProcessor* ourProcessor {getProcessor()}; 164 | //[/UserbuttonClicked_Pre] 165 | 166 | if (buttonThatWasClicked == AddBandBtn.get()) 167 | { 168 | //[UserButtonCode_AddBandBtn] -- add your button handler code here.. 169 | ourProcessor->addBand(); 170 | //[/UserButtonCode_AddBandBtn] 171 | } 172 | else if (buttonThatWasClicked == RemoveBandBtn.get()) 173 | { 174 | //[UserButtonCode_RemoveBandBtn] -- add your button handler code here.. 175 | ourProcessor->removeBand(); 176 | //[/UserButtonCode_RemoveBandBtn] 177 | } 178 | 179 | //[UserbuttonClicked_Post] 180 | crossoverWrapper->onParameterUpdate(); 181 | //[/UserbuttonClicked_Post] 182 | } 183 | 184 | 185 | 186 | //[MiscUserCode] You can add your own definitions of your custom methods or any other code here... 187 | void MonstrAudioProcessorEditor::timerCallback() { 188 | widthValueLbl->refreshValue(); 189 | crossoverWrapper->onImagerUpdate(); 190 | } 191 | 192 | void MonstrAudioProcessorEditor::_onParameterUpdate() { 193 | crossoverWrapper->onParameterUpdate(); 194 | 195 | MonstrAudioProcessor* ourProcessor {getProcessor()}; 196 | 197 | // Disable the buttons when at the minimum/maximum number of bands 198 | 199 | if (ourProcessor->numBands->get() == WECore::MONSTR::Parameters::NUM_BANDS.minValue) { 200 | AddBandBtn->setEnabled(true); 201 | RemoveBandBtn->setEnabled(false); 202 | } else if (ourProcessor->numBands->get() == WECore::MONSTR::Parameters::NUM_BANDS.maxValue) { 203 | AddBandBtn->setEnabled(false); 204 | RemoveBandBtn->setEnabled(true); 205 | } else { 206 | AddBandBtn->setEnabled(true); 207 | RemoveBandBtn->setEnabled(true); 208 | } 209 | } 210 | //[/MiscUserCode] 211 | 212 | 213 | //============================================================================== 214 | #if 0 215 | /* -- Projucer information section -- 216 | 217 | This is where the Projucer stores the metadata that describe this GUI layout, so 218 | make changes in here at your peril! 219 | 220 | BEGIN_JUCER_METADATA 221 | 222 | 227 | 228 | 231 | 234 | 238 | 249 | 250 | END_JUCER_METADATA 251 | */ 252 | #endif 253 | 254 | 255 | //[EndFile] You can add extra defines here... 256 | //[/EndFile] 257 | 258 | -------------------------------------------------------------------------------- /Source/PluginEditor.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This is an automatically generated GUI class created by the Projucer! 5 | 6 | Be careful when adding custom code to these files, as only the code within 7 | the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded 8 | and re-saved. 9 | 10 | Created with Projucer version: 7.0.9 11 | 12 | ------------------------------------------------------------------------------ 13 | 14 | The Projucer is part of the JUCE library. 15 | Copyright (c) 2020 - Raw Material Software Limited. 16 | 17 | ============================================================================== 18 | */ 19 | 20 | #pragma once 21 | 22 | //[Headers] -- You can add your own extra header files here -- 23 | #include "JuceHeader.h" 24 | #include "PluginProcessor.h" 25 | #include "MONSTRLookAndFeel.h" 26 | #include "MONSTRCrossoverWrapperComponent.h" 27 | #include "CoreJUCEPlugin/CoreProcessorEditor.h" 28 | #include "CoreJUCEPlugin/TooltipLabelUpdater.h" 29 | //[/Headers] 30 | 31 | 32 | 33 | //============================================================================== 34 | /** 35 | //[Comments] 36 | An auto-generated component, created by the Introjucer. 37 | 38 | Describe your class and how it works here! 39 | //[/Comments] 40 | */ 41 | class MonstrAudioProcessorEditor : public WECore::JUCEPlugin::CoreProcessorEditor, 42 | public Timer, 43 | public juce::Button::Listener 44 | { 45 | public: 46 | //============================================================================== 47 | MonstrAudioProcessorEditor (MonstrAudioProcessor& ownerFilter); 48 | ~MonstrAudioProcessorEditor() override; 49 | 50 | //============================================================================== 51 | //[UserMethods] -- You can add your own custom methods in this section. 52 | void timerCallback() override; 53 | MonstrAudioProcessor* getProcessor() const { 54 | return static_cast(getAudioProcessor()); 55 | } 56 | //[/UserMethods] 57 | 58 | void paint (juce::Graphics& g) override; 59 | void resized() override; 60 | void buttonClicked (juce::Button* buttonThatWasClicked) override; 61 | 62 | 63 | 64 | private: 65 | //[UserVariables] -- You can add your own custom variables in this section. 66 | MONSTRLookAndFeel customLookAndFeel; 67 | WECore::JUCEPlugin::TooltipLabelUpdater _tooltipLabelUpdater; 68 | 69 | virtual void _onParameterUpdate() override; 70 | //[/UserVariables] 71 | 72 | //============================================================================== 73 | std::unique_ptr crossoverWrapper; 74 | std::unique_ptr AddBandBtn; 75 | std::unique_ptr RemoveBandBtn; 76 | std::unique_ptr widthValueLbl; 77 | std::unique_ptr tooltipLbl; 78 | 79 | 80 | //============================================================================== 81 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MonstrAudioProcessorEditor) 82 | }; 83 | 84 | //[EndFile] You can add extra defines here... 85 | //[/EndFile] 86 | 87 | -------------------------------------------------------------------------------- /Source/PluginProcessor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file was auto-generated by the Introjucer! 5 | 6 | It contains the basic framework code for a JUCE plugin processor. 7 | 8 | ============================================================================== 9 | */ 10 | 11 | #include "PluginProcessor.h" 12 | 13 | #include "PluginEditor.h" 14 | #include "WEFilters/StereoWidthProcessorParameters.h" 15 | 16 | //============================================================================== 17 | MonstrAudioProcessor::MonstrAudioProcessor() 18 | { 19 | namespace MP = WECore::MONSTR::Parameters; 20 | namespace SP = WECore::StereoWidth::Parameters; 21 | 22 | constexpr float WIDTH_PRECISION {0.01f}; 23 | constexpr float FREQ_PRECISION {0.0001f}; 24 | 25 | // numBands must be restored first (otherwise we can't set the band parameters) 26 | auto restoreBands = [&](int val) { 27 | while (CrossoverInterface::getNumBands(crossover) < val) { 28 | CrossoverInterface::addBand(crossover); 29 | } 30 | 31 | numBands->setValueNotifyingHost( 32 | numBands->getNormalisableRange().convertTo0to1(CrossoverInterface::getNumBands(crossover)) 33 | ); 34 | _refreshCrossoverParameters(); 35 | }; 36 | 37 | registerPrivateParameter(numBands, NUMBANDS_STR, &MP::NUM_BANDS, MP::NUM_BANDS.defaultValue, restoreBands); 38 | 39 | registerParameter(bandParameters[0].isActive, BAND_STRINGS[0].isActive, MP::BANDSWITCH_DEFAULT); 40 | registerParameter(bandParameters[0].isMuted, BAND_STRINGS[0].isMuted, MP::BANDMUTED_DEFAULT); 41 | registerParameter(bandParameters[0].isSoloed, BAND_STRINGS[0].isSoloed, MP::BANDSOLO_DEFAULT); 42 | registerParameter(bandParameters[0].width, BAND_STRINGS[0].width, &SP::WIDTH, SP::WIDTH.defaultValue, WIDTH_PRECISION); 43 | registerPrivateParameter(crossoverParameters[0], CROSSOVER_STRINGS[0], &MP::CROSSOVER_FREQUENCY, MP::CROSSOVER_FREQUENCY.defaultValue, FREQ_PRECISION, [&](float val) { setCrossoverFrequency(0, val); }); 44 | 45 | registerParameter(bandParameters[1].isActive, BAND_STRINGS[1].isActive, MP::BANDSWITCH_DEFAULT); 46 | registerParameter(bandParameters[1].isMuted, BAND_STRINGS[1].isMuted, MP::BANDMUTED_DEFAULT); 47 | registerParameter(bandParameters[1].isSoloed, BAND_STRINGS[1].isSoloed, MP::BANDSOLO_DEFAULT); 48 | registerParameter(bandParameters[1].width, BAND_STRINGS[1].width, &SP::WIDTH, SP::WIDTH.defaultValue, WIDTH_PRECISION); 49 | registerPrivateParameter(crossoverParameters[1], CROSSOVER_STRINGS[1], &MP::CROSSOVER_FREQUENCY, MP::CROSSOVER_FREQUENCY.defaultValue, FREQ_PRECISION, [&](float val) { setCrossoverFrequency(1, val); }); 50 | 51 | registerParameter(bandParameters[2].isActive, BAND_STRINGS[2].isActive, MP::BANDSWITCH_DEFAULT); 52 | registerParameter(bandParameters[2].isMuted, BAND_STRINGS[2].isMuted, MP::BANDMUTED_DEFAULT); 53 | registerParameter(bandParameters[2].isSoloed, BAND_STRINGS[2].isSoloed, MP::BANDSOLO_DEFAULT); 54 | registerParameter(bandParameters[2].width, BAND_STRINGS[2].width, &SP::WIDTH, SP::WIDTH.defaultValue, WIDTH_PRECISION); 55 | registerPrivateParameter(crossoverParameters[2], CROSSOVER_STRINGS[2], &MP::CROSSOVER_FREQUENCY, MP::CROSSOVER_FREQUENCY.defaultValue, FREQ_PRECISION, [&](float val) { setCrossoverFrequency(2, val); }); 56 | 57 | registerParameter(bandParameters[3].isActive, BAND_STRINGS[3].isActive, MP::BANDSWITCH_DEFAULT); 58 | registerParameter(bandParameters[3].isMuted, BAND_STRINGS[3].isMuted, MP::BANDMUTED_DEFAULT); 59 | registerParameter(bandParameters[3].isSoloed, BAND_STRINGS[3].isSoloed, MP::BANDSOLO_DEFAULT); 60 | registerParameter(bandParameters[3].width, BAND_STRINGS[3].width, &SP::WIDTH, SP::WIDTH.defaultValue, WIDTH_PRECISION); 61 | registerPrivateParameter(crossoverParameters[3], CROSSOVER_STRINGS[3], &MP::CROSSOVER_FREQUENCY, MP::CROSSOVER_FREQUENCY.defaultValue, FREQ_PRECISION, [&](float val) { setCrossoverFrequency(3, val); }); 62 | 63 | registerParameter(bandParameters[4].isActive, BAND_STRINGS[4].isActive, MP::BANDSWITCH_DEFAULT); 64 | registerParameter(bandParameters[4].isMuted, BAND_STRINGS[4].isMuted, MP::BANDMUTED_DEFAULT); 65 | registerParameter(bandParameters[4].isSoloed, BAND_STRINGS[4].isSoloed, MP::BANDSOLO_DEFAULT); 66 | registerParameter(bandParameters[4].width, BAND_STRINGS[4].width, &SP::WIDTH, SP::WIDTH.defaultValue, WIDTH_PRECISION); 67 | registerPrivateParameter(crossoverParameters[4], CROSSOVER_STRINGS[4], &MP::CROSSOVER_FREQUENCY, MP::CROSSOVER_FREQUENCY.defaultValue, FREQ_PRECISION, [&](float val) { setCrossoverFrequency(4, val); }); 68 | 69 | registerParameter(bandParameters[5].isActive, BAND_STRINGS[5].isActive, MP::BANDSWITCH_DEFAULT); 70 | registerParameter(bandParameters[5].isMuted, BAND_STRINGS[5].isMuted, MP::BANDMUTED_DEFAULT); 71 | registerParameter(bandParameters[5].isSoloed, BAND_STRINGS[5].isSoloed, MP::BANDSOLO_DEFAULT); 72 | registerParameter(bandParameters[5].width, BAND_STRINGS[5].width, &SP::WIDTH, SP::WIDTH.defaultValue, WIDTH_PRECISION); 73 | } 74 | 75 | MonstrAudioProcessor::~MonstrAudioProcessor() 76 | { 77 | } 78 | 79 | //============================================================================== 80 | const String MonstrAudioProcessor::getName() const 81 | { 82 | return JucePlugin_Name; 83 | } 84 | 85 | const String MonstrAudioProcessor::getInputChannelName (int channelIndex) const 86 | { 87 | return String (channelIndex + 1); 88 | } 89 | 90 | const String MonstrAudioProcessor::getOutputChannelName (int channelIndex) const 91 | { 92 | return String (channelIndex + 1); 93 | } 94 | 95 | bool MonstrAudioProcessor::isInputChannelStereoPair (int index) const 96 | { 97 | return true; 98 | } 99 | 100 | bool MonstrAudioProcessor::isOutputChannelStereoPair (int index) const 101 | { 102 | return true; 103 | } 104 | 105 | bool MonstrAudioProcessor::acceptsMidi() const 106 | { 107 | #if JucePlugin_WantsMidiInput 108 | return true; 109 | #else 110 | return false; 111 | #endif 112 | } 113 | 114 | bool MonstrAudioProcessor::producesMidi() const 115 | { 116 | #if JucePlugin_ProducesMidiOutput 117 | return true; 118 | #else 119 | return false; 120 | #endif 121 | } 122 | 123 | bool MonstrAudioProcessor::silenceInProducesSilenceOut() const 124 | { 125 | return true; 126 | } 127 | 128 | double MonstrAudioProcessor::getTailLengthSeconds() const 129 | { 130 | return 0.0; 131 | } 132 | 133 | int MonstrAudioProcessor::getNumPrograms() 134 | { 135 | return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, 136 | // so this should be at least 1, even if you're not really implementing programs. 137 | } 138 | 139 | int MonstrAudioProcessor::getCurrentProgram() 140 | { 141 | return 0; 142 | } 143 | 144 | void MonstrAudioProcessor::setCurrentProgram (int index) 145 | { 146 | } 147 | 148 | const String MonstrAudioProcessor::getProgramName (int index) 149 | { 150 | return String(); 151 | } 152 | 153 | void MonstrAudioProcessor::changeProgramName (int index, const String& newName) 154 | { 155 | } 156 | 157 | //============================================================================== 158 | void MonstrAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) 159 | { 160 | CrossoverInterface::prepareToPlay(crossover, getSampleRate(), getBlockSize()); 161 | } 162 | 163 | void MonstrAudioProcessor::releaseResources() 164 | { 165 | // When playback stops, you can use this as an opportunity to free up any 166 | // spare memory, etc. 167 | } 168 | 169 | void MonstrAudioProcessor::reset() 170 | { 171 | CrossoverInterface::reset(crossover); 172 | } 173 | 174 | void MonstrAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) 175 | { 176 | // In case we have more outputs than inputs, this code clears any output 177 | // channels that didn't contain input data, (because these aren't 178 | // guaranteed to be empty - they may contain garbage). 179 | // I've added this to avoid people getting screaming feedback 180 | // when they first compile the plugin, but obviously you don't need to 181 | // this code if your algorithm already fills all the output channels. 182 | for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i) { 183 | buffer.clear (i, 0, buffer.getNumSamples()); 184 | } 185 | 186 | // This is the place where you'd normally do the guts of your plugin's 187 | // audio processing... 188 | CrossoverInterface::processBlock(crossover, buffer); 189 | } 190 | 191 | //============================================================================== 192 | bool MonstrAudioProcessor::hasEditor() const 193 | { 194 | return true; // (change this to false if you choose to not supply an editor) 195 | } 196 | 197 | AudioProcessorEditor* MonstrAudioProcessor::createEditor() 198 | { 199 | return new MonstrAudioProcessorEditor (*this); 200 | } 201 | 202 | //============================================================================== 203 | void MonstrAudioProcessor::addBand() { 204 | CrossoverInterface::addBand(crossover); 205 | numBands->setValueNotifyingHost( 206 | numBands->getNormalisableRange().convertTo0to1(CrossoverInterface::getNumBands(crossover)) 207 | ); 208 | 209 | // The crossover may rearrange some crossover frequencies to make the new band fit, as well as 210 | // parameters of the new band having been reset to their defaults - we need to make sure the UI 211 | // and host parameters are kept in sync 212 | _refreshCrossoverParameters(); 213 | } 214 | void MonstrAudioProcessor::removeBand() { 215 | CrossoverInterface::removeBand(crossover); 216 | numBands->setValueNotifyingHost( 217 | numBands->getNormalisableRange().convertTo0to1(CrossoverInterface::getNumBands(crossover)) 218 | ); 219 | } 220 | 221 | void MonstrAudioProcessor::setCrossoverFrequency(size_t index, float val) { 222 | if (CrossoverInterface::setCrossoverFrequency(crossover, index, val)) { 223 | // Changing the frequency of one crossover may affect others if they also need to be moved - 224 | // make sure the UI and host parameters are updated 225 | _refreshCrossoverParameters(); 226 | } 227 | } 228 | 229 | void MonstrAudioProcessor::_refreshCrossoverParameters() { 230 | CrossoverInterface::forEachCrossover(crossover, [&](int crossoverNumber, double crossoverFreq) { 231 | const double normalisedFrequency { 232 | WECore::MONSTR::Parameters::CROSSOVER_FREQUENCY.InternalToNormalised( 233 | crossoverFreq) 234 | }; 235 | 236 | crossoverParameters[crossoverNumber]->setValueNotifyingHost(normalisedFrequency); 237 | }); 238 | } 239 | 240 | std::vector MonstrAudioProcessor::_provideParamNamesForMigration() { 241 | return std::vector { 242 | BAND_STRINGS[0].isActive, 243 | BAND_STRINGS[0].width, 244 | CROSSOVER_STRINGS[0], 245 | 246 | BAND_STRINGS[1].isActive, 247 | BAND_STRINGS[1].width, 248 | CROSSOVER_STRINGS[1], 249 | 250 | BAND_STRINGS[2].isActive, 251 | BAND_STRINGS[2].width 252 | }; 253 | } 254 | 255 | void MonstrAudioProcessor::_migrateParamValues(std::vector& paramValues) { 256 | if (paramValues.size() == 8) { 257 | const ParameterDefinition::RangedParameter CROSSOVERLOWER(40, 500, 100); 258 | const ParameterDefinition::RangedParameter CROSSOVERUPPER(3000, 19500, 5000); 259 | 260 | paramValues[1] = WECore::StereoWidth::Parameters::WIDTH.NormalisedToInternal(paramValues[1]); 261 | paramValues[2] = CROSSOVERLOWER.NormalisedToInternal(paramValues[2]); 262 | 263 | paramValues[4] = WECore::StereoWidth::Parameters::WIDTH.NormalisedToInternal(paramValues[4]); 264 | paramValues[5] = CROSSOVERUPPER.NormalisedToInternal(paramValues[5]); 265 | 266 | paramValues[7] = WECore::StereoWidth::Parameters::WIDTH.NormalisedToInternal(paramValues[7]); 267 | } 268 | } 269 | 270 | void MonstrAudioProcessor::_onParameterUpdate() { 271 | CrossoverInterface::forEachBand(crossover, [&](int bandNumber) { 272 | CrossoverInterface::setIsBypassed(crossover, bandNumber, !bandParameters[bandNumber].isActive->get()); 273 | CrossoverInterface::setIsMuted(crossover, bandNumber, bandParameters[bandNumber].isMuted->get()); 274 | CrossoverInterface::setIsSoloed(crossover, bandNumber, bandParameters[bandNumber].isSoloed->get()); 275 | CrossoverInterface::setWidth(crossover, bandNumber, bandParameters[bandNumber].width->get()); 276 | }); 277 | 278 | // We can't update the crossover frequencies here, as we would need to call 279 | // _refreshCrossoverParameters() which would cause this to be called again, which would call 280 | // _refreshCrossoverParameters() again, etc 281 | } 282 | 283 | //============================================================================== 284 | // This creates new instances of the plugin.. 285 | AudioProcessor* JUCE_CALLTYPE createPluginFilter() 286 | { 287 | return new MonstrAudioProcessor(); 288 | } 289 | -------------------------------------------------------------------------------- /Source/PluginProcessor.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file was auto-generated by the Introjucer! 5 | 6 | It contains the basic framework code for a JUCE plugin processor. 7 | 8 | ============================================================================== 9 | */ 10 | 11 | #ifndef PLUGINPROCESSOR_H_INCLUDED 12 | #define PLUGINPROCESSOR_H_INCLUDED 13 | 14 | #include "../JuceLibraryCode/JuceHeader.h" 15 | #include "ParameterData.h" 16 | #include "CoreJUCEPlugin/CoreAudioProcessor.h" 17 | #include "CrossoverInterface.hpp" 18 | 19 | //============================================================================== 20 | /** 21 | */ 22 | class MonstrAudioProcessor : public WECore::JUCEPlugin::CoreAudioProcessor 23 | { 24 | public: 25 | CrossoverInterface::Crossover crossover; 26 | 27 | //============================================================================== 28 | MonstrAudioProcessor(); 29 | ~MonstrAudioProcessor(); 30 | 31 | //============================================================================== 32 | void prepareToPlay (double sampleRate, int samplesPerBlock) override; 33 | void releaseResources() override; 34 | void reset() override; 35 | 36 | void processBlock (AudioSampleBuffer&, MidiBuffer&) override; 37 | 38 | //============================================================================== 39 | AudioProcessorEditor* createEditor() override; 40 | bool hasEditor() const override; 41 | 42 | //============================================================================== 43 | const String getName() const override; 44 | 45 | const String getInputChannelName (int channelIndex) const override; 46 | const String getOutputChannelName (int channelIndex) const override; 47 | bool isInputChannelStereoPair (int index) const override; 48 | bool isOutputChannelStereoPair (int index) const override; 49 | 50 | bool acceptsMidi() const override; 51 | bool producesMidi() const override; 52 | bool silenceInProducesSilenceOut() const override; 53 | double getTailLengthSeconds() const override; 54 | 55 | //============================================================================== 56 | int getNumPrograms() override; 57 | int getCurrentProgram() override; 58 | void setCurrentProgram (int index) override; 59 | const String getProgramName (int index) override; 60 | void changeProgramName (int index, const String& newName) override; 61 | 62 | //============================================================================== 63 | /** 64 | * Parameter setters. 65 | * 66 | * For float parameters a value in the internal parameter range is expected. 67 | * 68 | 69 | */ 70 | /** @{ */ 71 | void addBand(); 72 | void removeBand(); 73 | void setCrossoverFrequency(size_t index, float val); 74 | /** @} */ 75 | 76 | struct BandParametersWrapper { 77 | AudioParameterBool* isActive; 78 | AudioParameterBool* isMuted; 79 | AudioParameterBool* isSoloed; 80 | AudioParameterFloat* width; 81 | }; 82 | 83 | // Parameters (public for beginChangeGesture/endChangeGesture/get) 84 | AudioParameterInt* numBands; 85 | std::array bandParameters; 86 | std::array crossoverParameters; 87 | 88 | private: 89 | void _refreshCrossoverParameters(); 90 | 91 | std::vector _provideParamNamesForMigration() override; 92 | void _migrateParamValues(std::vector& paramValues) override; 93 | 94 | void _onParameterUpdate() override; 95 | 96 | //============================================================================== 97 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MonstrAudioProcessor) 98 | }; 99 | 100 | 101 | #endif // PLUGINPROCESSOR_H_INCLUDED 102 | -------------------------------------------------------------------------------- /Source/UIUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: UIUtils.h 3 | * 4 | * Created: 21/01/2021 5 | * 6 | * This file is part of MONSTR. 7 | * 8 | * MONSTR is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * MONSTR is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with MONSTR. If not, see . 20 | * 21 | */ 22 | 23 | #pragma once 24 | 25 | #include "../JuceLibraryCode/JuceHeader.h" 26 | 27 | #include "MONSTRFilters/MONSTRParameters.h" 28 | #include "WEFilters/StereoWidthProcessorParameters.h" 29 | 30 | namespace { 31 | // These are tuned experimentally to get the desired log curve and crossings close to 0,0 and 1,1. 32 | constexpr double LOG_SCALE {3.00043}; 33 | constexpr double LOG_OFFSET_1 {0.001}; 34 | constexpr double LOG_OFFSET_2 {3}; 35 | } 36 | 37 | namespace UIUtils { 38 | // The radius is used for drawing, and the target width for mouse events 39 | constexpr int SLIDER_THUMB_RADIUS {6}; 40 | constexpr int SLIDER_THUMB_TARGET_WIDTH {SLIDER_THUMB_RADIUS * 2}; 41 | 42 | constexpr int BAND_BUTTON_WIDTH {20}; 43 | constexpr int BAND_BUTTON_PADDING {4}; 44 | 45 | const Colour lightGrey(200, 200, 200); 46 | const Colour darkGrey(107, 107, 107); 47 | const Colour lightGreyTrans(static_cast(200), 200, 200, 0.5f); 48 | const Colour mainHighlight(135, 252, 2); 49 | const Colour transHighlight(static_cast(135), 252, 2, 0.5f); 50 | const Colour imagerColour(static_cast(255), 255, 255, 0.2f); 51 | 52 | /** 53 | * Maps a linear scaled value in the range 0:1 to a log scaled value in the same range. 54 | */ 55 | inline double sliderValueToInternalLog(double sliderValue) { 56 | return std::pow(10, LOG_SCALE * sliderValue - LOG_OFFSET_2) - LOG_OFFSET_1; 57 | } 58 | 59 | /** 60 | * Maps a log scaled value in the range 0:1 to a linear scaled value in the same range. 61 | */ 62 | inline double internalLogToSliderValue(double internalValue) { 63 | return (std::log10(internalValue + LOG_OFFSET_1) + LOG_OFFSET_2) / LOG_SCALE; 64 | } 65 | 66 | /** 67 | * Converts a crossover frequency value between in the internal parameter range to an x coordinate. 68 | */ 69 | inline double sliderValueToXPos(double sliderValue, int componentWidth) { 70 | const double MARGIN_PX {componentWidth * 0.05}; 71 | const double realRange {componentWidth - 2 * MARGIN_PX}; 72 | 73 | const double normalisedSliderValue {WECore::MONSTR::Parameters::CROSSOVER_FREQUENCY.InternalToNormalised(sliderValue)}; 74 | 75 | return (internalLogToSliderValue(normalisedSliderValue) * realRange) + MARGIN_PX; 76 | } 77 | 78 | /** 79 | * Converts an x coordinate to a crossover frequency parameter value in the internal parameter range. 80 | */ 81 | inline double XPosToSliderValue(int XPos, int componentWidth) { 82 | const double MARGIN_PX {componentWidth * 0.05}; 83 | const double realRange {componentWidth - 2 * MARGIN_PX}; 84 | 85 | return WECore::MONSTR::Parameters::CROSSOVER_FREQUENCY.NormalisedToInternal(sliderValueToInternalLog(std::max(XPos - MARGIN_PX, 0.0) / realRange)); 86 | } 87 | 88 | /** 89 | * Converts a y coordinate to a width parameter value in the internal parameter range. 90 | */ 91 | inline double YPosToWidthValue(int YPos, int componentHeight) { 92 | return WECore::StereoWidth::Parameters::WIDTH.NormalisedToInternal(1 - std::min(std::max(0.0, YPos - componentHeight / 4.0) / (componentHeight / 2.0), 1.0)); 93 | } 94 | 95 | /** 96 | * Returns a rectangle representing the position of a button for the given crossover position 97 | * and index. 98 | */ 99 | inline Rectangle getButtonBounds(double crossoverXPos, int index) { 100 | return Rectangle(crossoverXPos - BAND_BUTTON_WIDTH - SLIDER_THUMB_RADIUS, 101 | BAND_BUTTON_PADDING + index * (BAND_BUTTON_PADDING + BAND_BUTTON_WIDTH), 102 | BAND_BUTTON_WIDTH, 103 | BAND_BUTTON_WIDTH); 104 | } 105 | } 106 | --------------------------------------------------------------------------------