├── .gitignore ├── Attila.jucer ├── LICENSE ├── README.md ├── Resources ├── coolvetica.otf ├── floppyIcon.svg ├── hack.ttf ├── logo.png ├── logo.svg ├── switchIcon.svg └── trashIcon.svg ├── Source ├── APVTSParameter.h ├── DSPParameters.h ├── FilteredParameter.h ├── Filters.h ├── GuiComponents.cpp ├── GuiComponents.h ├── LookAndFeel.h ├── MultibandDistortion.cpp ├── MultibandDistortion.h ├── PluginEditor.cpp ├── PluginEditor.h ├── PluginProcessor.cpp ├── PluginProcessor.h ├── PresetManager.h ├── SpectrumAnalyzer.h └── Utils.h └── preview.png /.gitignore: -------------------------------------------------------------------------------- 1 | **/Builds 2 | **/JuceLibraryCode 3 | 4 | ## Ignore Visual Studio temporary files, build results, and 5 | ## files generated by popular Visual Studio add-ons. 6 | ## 7 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore 8 | 9 | # User-specific files 10 | *.rsuser 11 | *.suo 12 | *.user 13 | *.userosscache 14 | *.sln.docstates 15 | 16 | # User-specific files (MonoDevelop/Xamarin Studio) 17 | *.userprefs 18 | 19 | # Mono auto generated files 20 | mono_crash.* 21 | 22 | # Build results 23 | [Dd]ebug/ 24 | [Dd]ebugPublic/ 25 | [Rr]elease/ 26 | [Rr]eleases/ 27 | x64/ 28 | x86/ 29 | [Ww][Ii][Nn]32/ 30 | [Aa][Rr][Mm]/ 31 | [Aa][Rr][Mm]64/ 32 | bld/ 33 | [Bb]in/ 34 | [Oo]bj/ 35 | [Ll]og/ 36 | [Ll]ogs/ 37 | 38 | # Visual Studio 2015/2017 cache/options directory 39 | .vs/ 40 | # Uncomment if you have tasks that create the project's static files in wwwroot 41 | #wwwroot/ 42 | 43 | # Visual Studio 2017 auto generated files 44 | Generated\ Files/ 45 | 46 | # MSTest test Results 47 | [Tt]est[Rr]esult*/ 48 | [Bb]uild[Ll]og.* 49 | 50 | # NUnit 51 | *.VisualState.xml 52 | TestResult.xml 53 | nunit-*.xml 54 | 55 | # Build Results of an ATL Project 56 | [Dd]ebugPS/ 57 | [Rr]eleasePS/ 58 | dlldata.c 59 | 60 | # Benchmark Results 61 | BenchmarkDotNet.Artifacts/ 62 | 63 | # .NET Core 64 | project.lock.json 65 | project.fragment.lock.json 66 | artifacts/ 67 | 68 | # ASP.NET Scaffolding 69 | ScaffoldingReadMe.txt 70 | 71 | # StyleCop 72 | StyleCopReport.xml 73 | 74 | # Files built by Visual Studio 75 | *_i.c 76 | *_p.c 77 | *_h.h 78 | *.ilk 79 | *.meta 80 | *.obj 81 | *.iobj 82 | *.pch 83 | *.pdb 84 | *.ipdb 85 | *.pgc 86 | *.pgd 87 | *.rsp 88 | *.sbr 89 | *.tlb 90 | *.tli 91 | *.tlh 92 | *.tmp 93 | *.tmp_proj 94 | *_wpftmp.csproj 95 | *.log 96 | *.tlog 97 | *.vspscc 98 | *.vssscc 99 | .builds 100 | *.pidb 101 | *.svclog 102 | *.scc 103 | 104 | # Chutzpah Test files 105 | _Chutzpah* 106 | 107 | # Visual C++ cache files 108 | ipch/ 109 | *.aps 110 | *.ncb 111 | *.opendb 112 | *.opensdf 113 | *.sdf 114 | *.cachefile 115 | *.VC.db 116 | *.VC.VC.opendb 117 | 118 | # Visual Studio profiler 119 | *.psess 120 | *.vsp 121 | *.vspx 122 | *.sap 123 | 124 | # Visual Studio Trace Files 125 | *.e2e 126 | 127 | # TFS 2012 Local Workspace 128 | $tf/ 129 | 130 | # Guidance Automation Toolkit 131 | *.gpState 132 | 133 | # ReSharper is a .NET coding add-in 134 | _ReSharper*/ 135 | *.[Rr]e[Ss]harper 136 | *.DotSettings.user 137 | 138 | # TeamCity is a build add-in 139 | _TeamCity* 140 | 141 | # DotCover is a Code Coverage Tool 142 | *.dotCover 143 | 144 | # AxoCover is a Code Coverage Tool 145 | .axoCover/* 146 | !.axoCover/settings.json 147 | 148 | # Coverlet is a free, cross platform Code Coverage Tool 149 | coverage*.json 150 | coverage*.xml 151 | coverage*.info 152 | 153 | # Visual Studio code coverage results 154 | *.coverage 155 | *.coveragexml 156 | 157 | # NCrunch 158 | _NCrunch_* 159 | .*crunch*.local.xml 160 | nCrunchTemp_* 161 | 162 | # MightyMoose 163 | *.mm.* 164 | AutoTest.Net/ 165 | 166 | # Web workbench (sass) 167 | .sass-cache/ 168 | 169 | # Installshield output folder 170 | [Ee]xpress/ 171 | 172 | # DocProject is a documentation generator add-in 173 | DocProject/buildhelp/ 174 | DocProject/Help/*.HxT 175 | DocProject/Help/*.HxC 176 | DocProject/Help/*.hhc 177 | DocProject/Help/*.hhk 178 | DocProject/Help/*.hhp 179 | DocProject/Help/Html2 180 | DocProject/Help/html 181 | 182 | # Click-Once directory 183 | publish/ 184 | 185 | # Publish Web Output 186 | *.[Pp]ublish.xml 187 | *.azurePubxml 188 | # Note: Comment the next line if you want to checkin your web deploy settings, 189 | # but database connection strings (with potential passwords) will be unencrypted 190 | *.pubxml 191 | *.publishproj 192 | 193 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 194 | # checkin your Azure Web App publish settings, but sensitive information contained 195 | # in these scripts will be unencrypted 196 | PublishScripts/ 197 | 198 | # NuGet Packages 199 | *.nupkg 200 | # NuGet Symbol Packages 201 | *.snupkg 202 | # The packages folder can be ignored because of Package Restore 203 | **/[Pp]ackages/* 204 | # except build/, which is used as an MSBuild target. 205 | !**/[Pp]ackages/build/ 206 | # Uncomment if necessary however generally it will be regenerated when needed 207 | #!**/[Pp]ackages/repositories.config 208 | # NuGet v3's project.json files produces more ignorable files 209 | *.nuget.props 210 | *.nuget.targets 211 | 212 | # Microsoft Azure Build Output 213 | csx/ 214 | *.build.csdef 215 | 216 | # Microsoft Azure Emulator 217 | ecf/ 218 | rcf/ 219 | 220 | # Windows Store app package directories and files 221 | AppPackages/ 222 | BundleArtifacts/ 223 | Package.StoreAssociation.xml 224 | _pkginfo.txt 225 | *.appx 226 | *.appxbundle 227 | *.appxupload 228 | 229 | # Visual Studio cache files 230 | # files ending in .cache can be ignored 231 | *.[Cc]ache 232 | # but keep track of directories ending in .cache 233 | !?*.[Cc]ache/ 234 | 235 | # Others 236 | ClientBin/ 237 | ~$* 238 | *~ 239 | *.dbmdl 240 | *.dbproj.schemaview 241 | *.jfm 242 | *.pfx 243 | *.publishsettings 244 | orleans.codegen.cs 245 | 246 | # Including strong name files can present a security risk 247 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 248 | #*.snk 249 | 250 | # Since there are multiple workflows, uncomment next line to ignore bower_components 251 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 252 | #bower_components/ 253 | 254 | # RIA/Silverlight projects 255 | Generated_Code/ 256 | 257 | # Backup & report files from converting an old project file 258 | # to a newer Visual Studio version. Backup files are not needed, 259 | # because we have git ;-) 260 | _UpgradeReport_Files/ 261 | Backup*/ 262 | UpgradeLog*.XML 263 | UpgradeLog*.htm 264 | ServiceFabricBackup/ 265 | *.rptproj.bak 266 | 267 | # SQL Server files 268 | *.mdf 269 | *.ldf 270 | *.ndf 271 | 272 | # Business Intelligence projects 273 | *.rdl.data 274 | *.bim.layout 275 | *.bim_*.settings 276 | *.rptproj.rsuser 277 | *- [Bb]ackup.rdl 278 | *- [Bb]ackup ([0-9]).rdl 279 | *- [Bb]ackup ([0-9][0-9]).rdl 280 | 281 | # Microsoft Fakes 282 | FakesAssemblies/ 283 | 284 | # GhostDoc plugin setting file 285 | *.GhostDoc.xml 286 | 287 | # Node.js Tools for Visual Studio 288 | .ntvs_analysis.dat 289 | node_modules/ 290 | 291 | # Visual Studio 6 build log 292 | *.plg 293 | 294 | # Visual Studio 6 workspace options file 295 | *.opt 296 | 297 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 298 | *.vbw 299 | 300 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 301 | *.vbp 302 | 303 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 304 | *.dsw 305 | *.dsp 306 | 307 | # Visual Studio 6 technical files 308 | *.ncb 309 | *.aps 310 | 311 | # Visual Studio LightSwitch build output 312 | **/*.HTMLClient/GeneratedArtifacts 313 | **/*.DesktopClient/GeneratedArtifacts 314 | **/*.DesktopClient/ModelManifest.xml 315 | **/*.Server/GeneratedArtifacts 316 | **/*.Server/ModelManifest.xml 317 | _Pvt_Extensions 318 | 319 | # Paket dependency manager 320 | .paket/paket.exe 321 | paket-files/ 322 | 323 | # FAKE - F# Make 324 | .fake/ 325 | 326 | # CodeRush personal settings 327 | .cr/personal 328 | 329 | # Python Tools for Visual Studio (PTVS) 330 | __pycache__/ 331 | *.pyc 332 | 333 | # Cake - Uncomment if you are using it 334 | # tools/** 335 | # !tools/packages.config 336 | 337 | # Tabs Studio 338 | *.tss 339 | 340 | # Telerik's JustMock configuration file 341 | *.jmconfig 342 | 343 | # BizTalk build output 344 | *.btp.cs 345 | *.btm.cs 346 | *.odx.cs 347 | *.xsd.cs 348 | 349 | # OpenCover UI analysis results 350 | OpenCover/ 351 | 352 | # Azure Stream Analytics local run output 353 | ASALocalRun/ 354 | 355 | # MSBuild Binary and Structured Log 356 | *.binlog 357 | 358 | # NVidia Nsight GPU debugger configuration file 359 | *.nvuser 360 | 361 | # MFractors (Xamarin productivity tool) working folder 362 | .mfractor/ 363 | 364 | # Local History for Visual Studio 365 | .localhistory/ 366 | 367 | # Visual Studio History (VSHistory) files 368 | .vshistory/ 369 | 370 | # BeatPulse healthcheck temp database 371 | healthchecksdb 372 | 373 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 374 | MigrationBackup/ 375 | 376 | # Ionide (cross platform F# VS Code tools) working folder 377 | .ionide/ 378 | 379 | # Fody - auto-generated XML schema 380 | FodyWeavers.xsd 381 | 382 | # VS Code files for those working on multiple tools 383 | .vscode/* 384 | !.vscode/settings.json 385 | !.vscode/tasks.json 386 | !.vscode/launch.json 387 | !.vscode/extensions.json 388 | *.code-workspace 389 | 390 | # Local History for Visual Studio Code 391 | .history/ 392 | 393 | # Windows Installer files from build outputs 394 | *.cab 395 | *.msi 396 | *.msix 397 | *.msm 398 | *.msp 399 | 400 | # JetBrains Rider 401 | *.sln.iml -------------------------------------------------------------------------------- /Attila.jucer: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | 13 | 15 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 31 | 33 | 35 | 37 | 38 | 39 | 41 | 42 | 43 | 44 | 45 | 47 | 49 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 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 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /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 | 635 | Copyright (C) 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 | Copyright (C) 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Attila 2 | 3 | ![attila-preview](preview.png) 4 | 5 | Attila is an open-source multiband distortion and bitcrushing plug-in. Within each band, you can completely tweak various parameters such as drive amount, drive knee and bit resolution, allowing you to create a wide range of effects—from the most wholesome 🤗♥ soft saturation ✨🥰 to full-on ear-piearcing sound demolition. 6 | 7 | It is made with JUCE and it's available for Windows, MacOS and Linux in VST, AU and LV2 formats. 8 | 9 | --- 10 | 11 | ## To-do 12 | 13 | * Improve performance 14 | 15 | --- 16 | 17 | ## License 18 | 19 | `attila` is [GPLv3 licensed](https://github.com/glafiro/attila/blob/main/LICENSE). 20 | -------------------------------------------------------------------------------- /Resources/coolvetica.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glafiro/attila/6e9b03730f410292beab66cc441c3ee0e1a4ece0/Resources/coolvetica.otf -------------------------------------------------------------------------------- /Resources/floppyIcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Resources/hack.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glafiro/attila/6e9b03730f410292beab66cc441c3ee0e1a4ece0/Resources/hack.ttf -------------------------------------------------------------------------------- /Resources/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glafiro/attila/6e9b03730f410292beab66cc441c3ee0e1a4ece0/Resources/logo.png -------------------------------------------------------------------------------- /Resources/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Resources/switchIcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Resources/trashIcon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Source/APVTSParameter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct IAPVTSParameter 6 | { 7 | juce::ParameterID id{ "" }; 8 | juce::String displayValue{ "" }; 9 | float defaultValue{ 0.0f }; 10 | 11 | IAPVTSParameter(const juce::String& stringID = "", const juce::String& val = "", float def = 0.0f) 12 | : id(stringID, 1), displayValue(val), defaultValue(def) {} 13 | 14 | virtual ~IAPVTSParameter() = default; 15 | 16 | virtual void castParameter(juce::AudioProcessorValueTreeState& apvts) = 0; 17 | virtual float get() const = 0; 18 | virtual float getDefault() { return defaultValue; } 19 | }; 20 | 21 | 22 | struct APVTSParameterFloat : public IAPVTSParameter 23 | { 24 | juce::AudioParameterFloat* paramPointer = nullptr; 25 | 26 | APVTSParameterFloat(const juce::String& stringID = "", const juce::String& val = "", float def = 0.0f) 27 | : IAPVTSParameter(stringID, val, def) 28 | { 29 | } 30 | 31 | void castParameter(juce::AudioProcessorValueTreeState& apvts) override { 32 | paramPointer = dynamic_cast(apvts.getParameter(id.getParamID())); 33 | jassert(paramPointer); 34 | } 35 | 36 | float get() const override { 37 | return paramPointer->get(); 38 | } 39 | }; 40 | 41 | 42 | struct APVTSParameterInt : public IAPVTSParameter 43 | { 44 | juce::AudioParameterInt* paramPointer = nullptr; 45 | 46 | APVTSParameterInt(const juce::String& stringID, const juce::String& val, float def) 47 | : IAPVTSParameter(stringID, val, def) 48 | { 49 | } 50 | 51 | void castParameter(juce::AudioProcessorValueTreeState& apvts) override { 52 | paramPointer = dynamic_cast(apvts.getParameter(id.getParamID())); 53 | jassert(paramPointer); 54 | } 55 | 56 | float get() const override { 57 | return static_cast(paramPointer->get()); 58 | } 59 | }; 60 | 61 | struct APVTSParameterBool : public IAPVTSParameter 62 | { 63 | juce::AudioParameterBool* paramPointer = nullptr; 64 | 65 | APVTSParameterBool(const juce::String& stringID, const juce::String& val, float def) 66 | : IAPVTSParameter(stringID, val, def) 67 | { 68 | } 69 | 70 | void castParameter(juce::AudioProcessorValueTreeState& apvts) override { 71 | paramPointer = dynamic_cast(apvts.getParameter(id.getParamID())); 72 | jassert(paramPointer); 73 | } 74 | 75 | float get() const override { 76 | return static_cast(paramPointer->get()); 77 | } 78 | }; 79 | 80 | struct APVTSParameterChoice : public IAPVTSParameter 81 | { 82 | juce::AudioParameterChoice* paramPointer = nullptr; 83 | 84 | APVTSParameterChoice(const juce::String& stringID, const juce::String& val, float def) 85 | : IAPVTSParameter(stringID, val, def) 86 | { 87 | } 88 | 89 | void castParameter(juce::AudioProcessorValueTreeState& apvts) override { 90 | paramPointer = dynamic_cast(apvts.getParameter(id.getParamID())); 91 | jassert(paramPointer); 92 | } 93 | 94 | float get() const override { 95 | return static_cast(paramPointer->getIndex()); 96 | } 97 | }; 98 | 99 | -------------------------------------------------------------------------------- /Source/DSPParameters.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | using std::unordered_map; 6 | using std::string; 7 | 8 | template 9 | class DSPParameters 10 | { 11 | public: 12 | unordered_map parameters; 13 | 14 | T operator[] (string key) { 15 | if (parameters.find(key) != parameters.end()) { 16 | return parameters[key]; 17 | } 18 | else { 19 | return 1.0f; 20 | } 21 | } 22 | 23 | void set(string key, T value) { 24 | parameters[key] = value; 25 | } 26 | 27 | }; 28 | 29 | 30 | -------------------------------------------------------------------------------- /Source/FilteredParameter.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #define DEFAULT_FILTER_FREQ 3.5f 5 | #define DEFAULT_SR 44100.0f 6 | #define M_PI 3.14159265358979323846 7 | #include 8 | 9 | // Utility functions 10 | template 11 | T lengthToSamples(T sr, T n) noexcept { 12 | return sr * n * static_cast(0.001); 13 | } 14 | 15 | class OnePoleFilter 16 | { 17 | public: 18 | OnePoleFilter() : a0(1.0f), b1(0.0f), z1(0.0f) {} 19 | OnePoleFilter(float freq) : z1(0.0f) { } 20 | ~OnePoleFilter() {}; 21 | 22 | void setSampleRate(float sr) { 23 | sampleRate = sr; 24 | } 25 | 26 | void setFrequency(float freq) { 27 | b1 = exp(-2.0f * M_PI * (freq)); 28 | a0 = 1.0f - b1; 29 | } 30 | 31 | void prepare(float sr, float f) { 32 | setSampleRate(sr); 33 | setFrequency(f); 34 | } 35 | 36 | 37 | float process(float in) { 38 | z1 = in * a0 + z1 * b1; 39 | return z1; 40 | } 41 | 42 | float updateAndProcess(float freq, float in) { 43 | setFrequency(freq); 44 | return process(in); 45 | } 46 | 47 | protected: 48 | float a0{ 1.0 }, b1{ 0.0 }, z1{ 0.0 }; 49 | float sampleRate{ DEFAULT_SR }; 50 | }; 51 | 52 | class FilteredParameter 53 | { 54 | OnePoleFilter filter{ DEFAULT_FILTER_FREQ }; 55 | float sampleRate{ DEFAULT_SR }; 56 | float value{ 0.0f }; 57 | float frequency{ DEFAULT_FILTER_FREQ }; 58 | 59 | public: 60 | 61 | FilteredParameter(float sr = DEFAULT_SR) : sampleRate(sr) { 62 | } 63 | 64 | void prepare(float sr) { 65 | sampleRate = sr; 66 | filter.prepare(sr, DEFAULT_FILTER_FREQ / sr); 67 | } 68 | 69 | void update(float v) { 70 | value = v; 71 | } 72 | 73 | // Filter then return current value 74 | float next() { 75 | return filter.process(value); 76 | } 77 | 78 | // Just return current value 79 | float read() { 80 | return value; 81 | } 82 | 83 | }; 84 | 85 | 86 | #define SILENCE 0.000001f 87 | 88 | class SmoothLogParameter 89 | { 90 | float currentGain, targetGain, multiplier; 91 | float attackTime, releaseTime, fadeSize{ 1.0f }; 92 | float sampleRate{ DEFAULT_SR }; 93 | 94 | public: 95 | SmoothLogParameter(float atk = 150.0f, float rls = 150.0f) : attackTime(atk), releaseTime(rls), currentGain(SILENCE), targetGain(SILENCE), multiplier(1.0) {} 96 | 97 | void prepare(float sr, float v) { 98 | sampleRate = sr; 99 | currentGain = v; 100 | setValue(v); 101 | } 102 | 103 | void setValue(float v) { 104 | targetGain = v + SILENCE; 105 | if (targetGain < currentGain) fadeSize = lengthToSamples(releaseTime, sampleRate); 106 | else if (targetGain > currentGain) fadeSize = lengthToSamples(attackTime, sampleRate); 107 | multiplier = std::pow(targetGain / currentGain, 1.0f / fadeSize); 108 | } 109 | 110 | float next() { 111 | if (std::abs(currentGain - targetGain) > 0.0001f) { 112 | currentGain *= multiplier; 113 | if ((multiplier > 1.0f && currentGain >= targetGain) || (multiplier < 1.0f && currentGain <= targetGain)) { 114 | currentGain = targetGain; 115 | } 116 | } 117 | return currentGain; 118 | } 119 | 120 | float read() { 121 | return currentGain; 122 | } 123 | }; 124 | 125 | #undef DEFAULT_SR 126 | #undef M_PI -------------------------------------------------------------------------------- /Source/Filters.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define M_PI 3.14159265358979323846 6 | #define DEFAULT_SR 44100.0f 7 | 8 | template 9 | struct LRFilter 10 | { 11 | juce::dsp::LinkwitzRileyFilter filter; 12 | int type{ 0 }; 13 | T frequency{ 0.0f }; 14 | 15 | float sampleRate{ DEFAULT_SR }; 16 | float blockSize{ 0.0f }; 17 | int nChannels{ 1 }; 18 | 19 | LRFilter() { 20 | filter.setType(juce::dsp::LinkwitzRileyFilterType::allpass); 21 | } 22 | 23 | void setFrequency(T f) { 24 | frequency = f; 25 | filter.setCutoffFrequency(frequency); 26 | } 27 | 28 | void prepare(float sr, float numSamples, int numChannels) { 29 | sampleRate = sr; 30 | blockSize = numSamples; 31 | nChannels = numChannels; 32 | juce::dsp::ProcessSpec spec; 33 | spec.sampleRate = sampleRate; 34 | spec.maximumBlockSize = blockSize; 35 | spec.numChannels = nChannels; 36 | 37 | filter.prepare(spec); 38 | } 39 | 40 | void processSample(int ch, T sample, T& sampleOutLow, T& sampleOutHigh) { 41 | filter.processSample(ch, sample, sampleOutLow, sampleOutHigh); 42 | } 43 | }; 44 | 45 | #undef DEFAULT_SR 46 | #undef M_PI -------------------------------------------------------------------------------- /Source/GuiComponents.cpp: -------------------------------------------------------------------------------- 1 | #include "GuiComponents.h" 2 | 3 | 4 | Knob::Knob(IAPVTSParameter* param, int w, int h, AudioProcessorValueTreeState& apvts, Band type) : 5 | width(w), height(h), state(apvts) 6 | { 7 | 8 | // Create the Slider component. Set TextBox style as "NoTextBox", as 9 | // it will be manually created later. 10 | slider.setSliderStyle(Slider::SliderStyle::RotaryVerticalDrag); 11 | slider.setTextBoxStyle(Slider::NoTextBox, false, w, h * 0.186); 12 | slider.setBounds(0, 0, w, h); 13 | // "type" identifies the frequency band the knob operates on, as 14 | // each band has a different color. 15 | slider.getProperties().set("type", type); 16 | addAndMakeVisible(slider); 17 | 18 | label.setText(param->displayValue, NotificationType::dontSendNotification); 19 | label.setJustificationType(Justification::horizontallyCentred); 20 | label.setBorderSize(BorderSize(0)); 21 | label.attachToComponent(&slider, false); 22 | addAndMakeVisible(label); 23 | 24 | // Height is double to account for the label. Since width and height are usually 25 | // passed with the same value, the aspect ratio of this component is effectively 1:2. 26 | setSize(w, h * 2.0f); 27 | setLookAndFeel(KnobLookAndFeel::get()); 28 | 29 | // Attach GUI component to AudioProcessorValueTreeState 30 | attachment = std::make_unique( 31 | state, param->id.getParamID(), slider 32 | ); 33 | } 34 | 35 | Knob::~Knob() {} 36 | 37 | void Knob::resized() { 38 | slider.setBounds(0, label.getHeight(), width, height); 39 | } 40 | 41 | Switch::Switch(IAPVTSParameter* param, AudioProcessorValueTreeState& apvts, Band type, GroupComponent& gr) : 42 | state(apvts), group(gr) 43 | { 44 | btn.getProperties().set("type", type); 45 | btn.onClick = [this]() {buttonClicked(); }; 46 | addAndMakeVisible(btn); 47 | 48 | setLookAndFeel(SwitchLookAndFeel::get()); 49 | 50 | attachment = std::make_unique( 51 | state, param->id.getParamID(), btn 52 | ); 53 | 54 | // Set initial value for group 55 | group.setEnabled(!btn.getToggleState()); 56 | 57 | } 58 | 59 | void Switch::buttonClicked() { 60 | group.setEnabled(!btn.getToggleState()); 61 | } 62 | 63 | void Switch::resized() { 64 | auto bounds = getLocalBounds(); 65 | btn.setBounds(bounds); 66 | } 67 | 68 | PresetMenu::PresetMenu(Rectangle a, PresetManager& pm) : area(a), presetManager(pm) { 69 | 70 | createButton(saveBtn, "SAVE", PresetBtnType::SAVE); 71 | createButton(deleteBtn, " DELETE", PresetBtnType::DELETE); // hackiest hack 72 | createButton(nextBtn, ">", PresetBtnType::NEXT); 73 | createButton(prevBtn, "<", PresetBtnType::PREV); 74 | 75 | presetList.setTextWhenNothingSelected("No preset selected"); 76 | addAndMakeVisible(presetList); 77 | presetList.addListener(this); 78 | 79 | loadPresetList(); 80 | 81 | setBounds(area.toNearestInt()); 82 | setSize(area.getWidth(), area.getHeight()); 83 | 84 | setLookAndFeel(PresetMenuLookAndFeel::get()); 85 | 86 | } 87 | 88 | PresetMenu::~PresetMenu() { 89 | saveBtn.removeListener(this); 90 | deleteBtn.removeListener(this); 91 | nextBtn.removeListener(this); 92 | prevBtn.removeListener(this); 93 | } 94 | 95 | void PresetMenu::resized() { 96 | 97 | auto bounds = getLocalBounds(); 98 | 99 | auto buttonSize = bounds.getHeight(); 100 | auto presetListWidth = bounds.getWidth() * 0.7f; 101 | 102 | deleteBtn.setBounds(bounds.getX(), bounds.getY(), buttonSize, buttonSize); 103 | prevBtn.setBounds(bounds.getX() + buttonSize, bounds.getY(), buttonSize, buttonSize); 104 | presetList.setBounds(bounds.getX() + buttonSize * 2, bounds.getY(), presetListWidth, bounds.getHeight()); 105 | nextBtn.setBounds(bounds.getX() + buttonSize * 2 + presetListWidth, bounds.getY(), buttonSize, buttonSize); 106 | saveBtn.setBounds(bounds.getX() + buttonSize * 3 + presetListWidth, bounds.getY(), buttonSize, buttonSize); 107 | } 108 | 109 | void PresetMenu::buttonClicked(Button* btn) { 110 | if (btn == &saveBtn) { 111 | fileChooser = std::make_unique( 112 | "Preset name:", 113 | presetManager.defaultDir, 114 | "*." + presetManager.ext 115 | ); 116 | fileChooser->launchAsync(FileBrowserComponent::saveMode, [&](const FileChooser& chooser) { 117 | const auto result = chooser.getResult(); 118 | presetManager.savePreset(result.getFileNameWithoutExtension()); 119 | loadPresetList(); 120 | } 121 | ); 122 | } 123 | if (btn == &nextBtn) { 124 | const auto idx = presetManager.next(); 125 | presetList.setSelectedItemIndex(idx, dontSendNotification); 126 | } 127 | if (btn == &prevBtn) { 128 | const auto idx = presetManager.prev(); 129 | presetList.setSelectedItemIndex(idx, dontSendNotification); 130 | } 131 | 132 | if (btn == &deleteBtn) { 133 | 134 | NativeMessageBox::showYesNoCancelBox( 135 | MessageBoxIconType::QuestionIcon, 136 | "Delete Confirmation", 137 | "Are you sure you want to delete this item?", 138 | nullptr, 139 | ModalCallbackFunction::create([this](int result) { 140 | if (result == 1) { 141 | const auto text = presetManager.getCurrent(); 142 | presetManager.deletePreset(text); 143 | loadPresetList(); 144 | } 145 | }) 146 | ); 147 | } 148 | } 149 | 150 | void PresetMenu::comboBoxChanged(ComboBox* box) { 151 | 152 | if (box == &presetList) { 153 | presetManager.loadPreset(presetList.getItemText(presetList.getSelectedItemIndex())); 154 | } 155 | } 156 | 157 | void PresetMenu::createButton(Button& btn, const String& text, PresetBtnType type) { 158 | 159 | btn.setButtonText(text); 160 | btn.getProperties().set("type", type); 161 | addAndMakeVisible(btn); 162 | btn.addListener(this); 163 | } 164 | 165 | void PresetMenu::loadPresetList() { 166 | 167 | presetList.clear(dontSendNotification); 168 | const auto allPresets = presetManager.getPresetList(); 169 | const auto currentPreset = presetManager.getCurrent(); 170 | presetList.addItemList(presetManager.getPresetList(), 1); 171 | presetList.setSelectedItemIndex(allPresets.indexOf(currentPreset), dontSendNotification); 172 | 173 | } 174 | 175 | 176 | void LevelMeter::timerCallback() { 177 | updateLevel(linearLevelL.load(), levelL, dbLevelL); 178 | updateLevel(linearLevelR.load(), levelR, dbLevelR); 179 | 180 | repaint(); 181 | } 182 | 183 | // Get the y position based on the db value. 184 | int LevelMeter::getYPosition(float level) const noexcept { 185 | int val = int(std::round(jmap(level, maxdB, mindB, maxPos, minPos))); 186 | if (val < maxPos) val = maxPos; 187 | if (val > minPos) val = minPos; 188 | return val; 189 | } 190 | 191 | // If the new peak is higher than the oldest peak, then we update the 192 | // new value immediately. Otherwise, we use a one-pole filter for a 193 | // smoother animation. 194 | void LevelMeter::updateLevel(float newLevel, float& smooth, float& leveldB) const { 195 | if (newLevel > smooth) smooth = newLevel; 196 | else smooth += (newLevel - smooth) * decay; 197 | if (smooth > clampLevel) leveldB = linearToDb(smooth); 198 | else leveldB = clampDB; 199 | } 200 | 201 | void LevelMeter::drawLevel(juce::Graphics& g, float level, int x, int width) 202 | { 203 | // Create color gradient 204 | ColourGradient gradient{ 205 | Colors::blue, 0.0f, float(getHeight()), 206 | Colors::red, 0.0f, 0.0f, false 207 | }; 208 | gradient.addColour(0.2, Colors::green); 209 | gradient.addColour(0.8, Colors::yellow); 210 | gradient.addColour(0.9, Colors::red); 211 | 212 | int y = getYPosition(level); 213 | int y0 = getYPosition(maxdB); 214 | g.setColour(Colors::veryDarkGrey); 215 | g.fillRect(x, y0, width, int(minPos) - y0); 216 | g.setGradientFill(gradient); 217 | g.fillRect(x, y, width, int(minPos) - y); 218 | } 219 | 220 | LevelMeter::LevelMeter(std::atomic& measureL, std::atomic& measureR) : 221 | linearLevelL(measureL), linearLevelR(measureR), dbLevelL(clampDB), dbLevelR(clampDB) 222 | { 223 | startTimerHz(refreshRate); 224 | decay = 1.0f - std::exp(-1.0f / (float(refreshRate) * 0.2f)); 225 | } 226 | 227 | LevelMeter::~LevelMeter() {} 228 | 229 | void LevelMeter::paint(Graphics& g) { 230 | auto bounds = getLocalBounds(); 231 | auto padding = getHeight() * 0.02f; 232 | 233 | int lineWidth = bounds.getWidth() * 0.6f; 234 | int meterWidth = lineWidth * 0.4f; 235 | 236 | drawLevel(g, dbLevelL, 0, meterWidth); 237 | drawLevel(g, dbLevelR, meterWidth + lineWidth * 0.2f, meterWidth); 238 | 239 | int y = getYPosition(0.0f); 240 | g.setColour(Colors::darkGrey); 241 | g.fillRect(0, y, lineWidth, int(padding / 2.0f)); 242 | } 243 | 244 | void LevelMeter::resized() { 245 | auto bounds = getLocalBounds(); 246 | padding = getHeight() * 0.015f; 247 | 248 | maxPos = padding; 249 | minPos = bounds.getHeight() - padding; 250 | } 251 | 252 | SpectrumAnalyzerGroup::SpectrumAnalyzerGroup(IAPVTSParameter* freq1Param, IAPVTSParameter* freq2Param, 253 | AudioProcessorValueTreeState& apvts, SpectrumAnalyzer& analyzer, 254 | Knob& k1, Knob& k2, Knob& k3 255 | ) : 256 | state(apvts), spectrumAnalyzer(analyzer), 257 | driveKnob1(k1), driveKnob2(k2), driveKnob3(k3) 258 | { 259 | 260 | // The group also includes two knobs for controlling the bands. 261 | lowMidSlider.setSliderStyle(Slider::SliderStyle::RotaryVerticalDrag); 262 | lowMidSlider.setTextBoxStyle(Slider::NoTextBox, false, 0, 0); 263 | lowMidSlider.getProperties().set("type", FreqKnobBand::LOWMID); 264 | lowMidSlider.onValueChange = [this]() {lowMidSliderChanged(); }; 265 | addAndMakeVisible(lowMidSlider); 266 | 267 | midHighSlider.setSliderStyle(Slider::SliderStyle::RotaryVerticalDrag); 268 | midHighSlider.setTextBoxStyle(Slider::NoTextBox, false, 0, 0); 269 | midHighSlider.getProperties().set("type", FreqKnobBand::MIDHIGH); 270 | midHighSlider.onValueChange = [this]() {midHighSliderChanged(); }; 271 | addAndMakeVisible(midHighSlider); 272 | 273 | driveKnob1.slider.onValueChange = [this]() {driveChanged(); }; 274 | driveKnob2.slider.onValueChange = [this]() {driveChanged(); }; 275 | driveKnob3.slider.onValueChange = [this]() {driveChanged(); }; 276 | 277 | addAndMakeVisible(spectrumAnalyzer); 278 | 279 | freq1Attachment = std::make_unique( 280 | state, freq1Param->id.getParamID(), lowMidSlider 281 | ); 282 | 283 | freq2Attachment = std::make_unique( 284 | state, freq2Param->id.getParamID(), midHighSlider 285 | ); 286 | 287 | setLookAndFeel(SpectrumAnalyzerGroupLookAndFeel::get()); 288 | } 289 | 290 | void SpectrumAnalyzerGroup::driveChanged() { 291 | spectrumAnalyzer.updateDriveValues( 292 | jmap(float(driveKnob1.slider.getValue()), 0.0f, 36.0f, 0.0f, 1.0f), 293 | jmap(float(driveKnob2.slider.getValue()), 0.0f, 36.0f, 0.0f, 1.0f), 294 | jmap(float(driveKnob3.slider.getValue()), 0.0f, 36.0f, 0.0f, 1.0f) 295 | ); 296 | } 297 | 298 | // Ensure low/mid cut frequency stays below the mid/high cut frequency 299 | // to prevent overlap and unwanted interactions between the knobs. 300 | // If low/mid > mid/high, then changing low/mid will also change mid/high 301 | void SpectrumAnalyzerGroup::lowMidSliderChanged() { 302 | if (lowMidSlider.getValue() > midHighSlider.getValue()) { 303 | midHighSlider.setValue(lowMidSlider.getValue()); 304 | } 305 | 306 | spectrumAnalyzer.lowMidCut = lowMidSlider.getValue(); 307 | } 308 | 309 | // ...and vice versa. 310 | void SpectrumAnalyzerGroup::midHighSliderChanged() { 311 | if (midHighSlider.getValue() < lowMidSlider.getValue()) { 312 | lowMidSlider.setValue(midHighSlider.getValue()); 313 | } 314 | 315 | spectrumAnalyzer.midHighCut = midHighSlider.getValue(); 316 | } 317 | 318 | void SpectrumAnalyzerGroup::resized() { 319 | auto bounds = getLocalBounds(); 320 | float width = bounds.getWidth(); 321 | float height = bounds.getHeight(); 322 | float spectrumHeight = height * 0.865; 323 | float sliderSize = height - spectrumHeight; 324 | float textBoxWidth = width * 0.15f; 325 | 326 | spectrumAnalyzer.setBounds(bounds.getX(), bounds.getY(), width, spectrumHeight); 327 | lowMidSlider.setBounds(bounds.getX() + width * 0.1f, spectrumHeight, sliderSize + textBoxWidth * 2, sliderSize); 328 | midHighSlider.setBounds(bounds.getX() + width * 0.5f, spectrumHeight, sliderSize + textBoxWidth * 2, sliderSize); 329 | } 330 | -------------------------------------------------------------------------------- /Source/GuiComponents.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "APVTSParameter.h" 5 | #include "SpectrumAnalyzer.h" 6 | #include "PresetManager.h" 7 | #include "LookAndFeel.h" 8 | #include "Utils.h" 9 | 10 | #include 11 | using std::array; 12 | 13 | #ifndef MAX_DB 14 | #define MAX_DB 6.0f 15 | #endif 16 | 17 | #ifndef MIN_DB 18 | #define MIN_DB -60.0f 19 | #endif 20 | 21 | class Knob : public Component 22 | { 23 | private: 24 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Knob); 25 | 26 | Label label; 27 | String labelText; 28 | int width, height; 29 | AudioProcessorValueTreeState& state; 30 | std::unique_ptr attachment; 31 | 32 | public: 33 | Slider slider; 34 | Knob(IAPVTSParameter* param, int w, int h, AudioProcessorValueTreeState& apvts, Band type); 35 | ~Knob(); 36 | void resized(); 37 | }; 38 | 39 | class Switch : public Component 40 | { 41 | private: 42 | ToggleButton btn; 43 | int width, height; 44 | AudioProcessorValueTreeState& state; 45 | std::unique_ptr attachment; 46 | 47 | // Since the only use for switches in these plug-in is for bypass buttons, 48 | // we take a reference to a group (which correspond to a band in the multiband processor) 49 | // so that we can mute a whole group. 50 | GroupComponent& group; 51 | 52 | public: 53 | 54 | Switch(IAPVTSParameter* param, AudioProcessorValueTreeState& apvts, Band type, GroupComponent& gr); 55 | void buttonClicked(); 56 | void resized() override; 57 | }; 58 | 59 | 60 | class PresetMenu : public Component, public Button::Listener, public ComboBox::Listener 61 | { 62 | TextButton saveBtn, deleteBtn, nextBtn, prevBtn; 63 | ComboBox presetList; 64 | PresetManager presetManager; 65 | std::unique_ptr fileChooser; 66 | 67 | void buttonClicked(Button* btn); 68 | void comboBoxChanged(ComboBox* box) override; 69 | void createButton(Button& btn, const String& text, PresetBtnType type); 70 | void loadPresetList(); 71 | 72 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PresetMenu); 73 | public: 74 | 75 | Rectangle area; 76 | PresetMenu(Rectangle a, PresetManager& pm); 77 | ~PresetMenu(); 78 | void resized() override; 79 | 80 | }; 81 | 82 | // Inspired from Holleman's audio Plug-in book 83 | class LevelMeter : public Component, private Timer 84 | { 85 | private: 86 | std::atomic& linearLevelL; 87 | std::atomic& linearLevelR; 88 | 89 | static constexpr float maxdB = MAX_DB; 90 | static constexpr float mindB = MIN_DB; 91 | static constexpr float stepdB = 6.0f; 92 | static constexpr float clampDB = -120.0f; 93 | static constexpr float clampLevel = 0.000001f; 94 | static constexpr int refreshRate = 60; 95 | 96 | float maxPos = 0.0f; 97 | float minPos = 0.0f; 98 | float dbLevelL{ mindB }; 99 | float dbLevelR{ mindB }; 100 | 101 | float padding{}; 102 | 103 | float decay = 0.0f; 104 | float levelL = clampLevel; 105 | float levelR = clampLevel; 106 | 107 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LevelMeter) 108 | 109 | void timerCallback() override; 110 | int getYPosition(float level) const noexcept; 111 | void updateLevel(float newLevel, float& smooth, float& leveldB) const; 112 | void drawLevel(juce::Graphics& g, float level, int x, int width); 113 | 114 | public: 115 | LevelMeter(std::atomic& measureL, std::atomic& measureR); 116 | ~LevelMeter(); 117 | void paint(Graphics& g) override; 118 | void resized() override; 119 | }; 120 | 121 | class SpectrumAnalyzerGroup : public Component 122 | { 123 | AudioProcessorValueTreeState& state; 124 | std::unique_ptr freq1Attachment; 125 | std::unique_ptr freq2Attachment; 126 | Slider lowMidSlider; 127 | Slider midHighSlider; 128 | SpectrumAnalyzer& spectrumAnalyzer; 129 | 130 | // We need a reference to the drive knobs, so that we can update 131 | // the visual response in the analyzer. 132 | // In the analyzer, the drive will be represented by a horizontal line 133 | // of the chosen band color, which will map [0..maxDrive] to [bottom..top] 134 | Knob& driveKnob1; 135 | Knob& driveKnob2; 136 | Knob& driveKnob3; 137 | 138 | public: 139 | SpectrumAnalyzerGroup( 140 | IAPVTSParameter* freq1Param, IAPVTSParameter* freq2Param, 141 | AudioProcessorValueTreeState& apvts, SpectrumAnalyzer& analyzer, 142 | Knob& k1, Knob& k2, Knob& k3 143 | ); 144 | void driveChanged(); 145 | 146 | void lowMidSliderChanged(); 147 | void midHighSliderChanged(); 148 | 149 | void resized() override; 150 | }; -------------------------------------------------------------------------------- /Source/LookAndFeel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | using std::array; 6 | 7 | enum Band { LOW, MID, HIGH, GLOBAL}; 8 | enum PresetBtnType { DELETE, PREV, NEXT, SAVE}; 9 | enum FreqKnobBand { LOWMID, MIDHIGH }; 10 | 11 | namespace Colors 12 | { 13 | const Colour pitchBlack{ 0, 0, 0 }; 14 | const Colour black{43, 40, 40}; 15 | const Colour veryDarkGrey{63, 61, 62}; 16 | const Colour gradientTop{ 70, 70, 70 }; 17 | const Colour darkGrey{87, 84, 85}; 18 | const Colour grey{114, 110, 111}; 19 | const Colour lightGrey{120, 121, 124}; 20 | const Colour cream{ 239, 218, 187 }; 21 | 22 | const Colour red{212, 64, 9}; 23 | const Colour yellow{229, 179, 74}; 24 | const Colour green{118, 175, 158}; 25 | const Colour blue{95, 140, 176}; 26 | } 27 | 28 | static array primaryColors{ Colors::red, Colors::yellow, Colors::green, Colors::blue }; 29 | 30 | class GroupComponentLookAndFeel : public LookAndFeel_V4 31 | { 32 | Font mainFont; 33 | public: 34 | 35 | GroupComponentLookAndFeel(float w, float h) : screenWidth(w), screenHeight(h) { 36 | mainFont = Font(Typeface::createSystemTypefaceFor(BinaryData::coolvetica_otf, BinaryData::coolvetica_otfSize)); 37 | } 38 | 39 | private: 40 | float screenWidth, screenHeight; 41 | 42 | void drawGroupComponentOutline(Graphics& g, int w, int h, const String& text, const Justification& just, GroupComponent& group) override { 43 | int cornerSize = w * 0.03f; 44 | 45 | auto padding = screenWidth * 0.005f; 46 | auto rectBounds = group.getLocalBounds().reduced(padding); 47 | DropShadow shadow{ Colors::black, cornerSize, Point{0, 0}}; 48 | shadow.drawForRectangle(g, rectBounds); 49 | g.setColour(Colors::darkGrey); 50 | g.fillRoundedRectangle(rectBounds.toFloat(), w * 0.03f); 51 | 52 | int type = group.getProperties().getWithDefault("type", Band::GLOBAL); 53 | bool state = group.isEnabled(); 54 | 55 | if (type != Band::GLOBAL) { 56 | Colour mainColor = primaryColors[static_cast(group.getProperties().getWithDefault("type", Band::GLOBAL))]; 57 | Path topBandPath; 58 | auto topBandBounds = rectBounds.removeFromTop(h * 0.12f); 59 | topBandPath.addRoundedRectangle( 60 | topBandBounds.getX(), topBandBounds.getY(), 61 | topBandBounds.getWidth(), topBandBounds.getHeight(), 62 | cornerSize, cornerSize, true, true, false, false 63 | ); 64 | if (state) { 65 | g.setColour(mainColor); 66 | } 67 | else { 68 | g.setColour(Colors::grey); 69 | } 70 | g.fillPath(topBandPath); 71 | 72 | auto fontSize = topBandBounds.getHeight() * 0.7f; 73 | g.setColour(Colors::veryDarkGrey); 74 | g.setFont(mainFont.withHeight(fontSize)); 75 | g.drawText(text, topBandBounds.removeFromRight(w * 0.8f), Justification::left, false); 76 | } 77 | 78 | 79 | } 80 | }; 81 | 82 | 83 | class KnobLookAndFeel : public LookAndFeel_V4 84 | { 85 | float rotaryStart, rotaryEnd; 86 | Font labelFont, textBoxFont; 87 | 88 | public: 89 | KnobLookAndFeel() { 90 | // Shorten the ends of the rotary slider 91 | float pi = MathConstants::pi; 92 | rotaryStart = 1.25f * pi; 93 | rotaryEnd = 2.75f * pi; 94 | 95 | labelFont = Font(Typeface::createSystemTypefaceFor(BinaryData::coolvetica_otf, BinaryData::coolvetica_otfSize)); 96 | textBoxFont = Font(Typeface::createSystemTypefaceFor(BinaryData::hack_ttf, BinaryData::hack_ttfSize)); 97 | } 98 | 99 | static KnobLookAndFeel* get() { 100 | static KnobLookAndFeel inst; 101 | return &inst; 102 | } 103 | 104 | void drawLabel(Graphics& g, Label& l ) override { 105 | auto bounds = l.getLocalBounds(); 106 | auto fontSize = bounds.getHeight() * 0.9f; 107 | g.setColour(Colors::cream); 108 | g.setFont(labelFont.withHeight(fontSize)); 109 | g.drawText(l.getText(), bounds, Justification::centred, false); 110 | } 111 | 112 | void drawRotarySlider(Graphics& g, int x, int y, int w, int h, float pos, float startAngle, float endAngle, Slider& slider) override { 113 | 114 | slider.setRotaryParameters(rotaryStart, rotaryEnd, true); 115 | 116 | // The slider colors are: 117 | // Red - low band parameters 118 | // Yellow - mid band parameters 119 | // Green/Turquoise - high band parameters 120 | // Blue - global parameters 121 | Colour mainColor = primaryColors[static_cast(slider.getProperties().getWithDefault("type", Band::GLOBAL))]; 122 | Colour dialColor = Colors::cream; 123 | 124 | auto bounds = slider.getLocalBounds().reduced(w * 0.04f); 125 | 126 | auto center = Point{bounds.getX() + bounds.getWidth() / 2, bounds.getY() + bounds.getWidth() / 2}; 127 | auto radius = bounds.getWidth() / 2.0f; 128 | 129 | // dialRadius is the size of the circle that appears on the knob. 130 | // bottomLineWidth is the line width of the bottom (dark) arc around the knob. 131 | // The colored part of the arc is always a multiple of the dark line. 132 | float dialRadius, bottomLineWidth; 133 | dialRadius = w * 0.07f; 134 | auto halfDialRadius = dialRadius / 2.0f; 135 | bottomLineWidth = w * 0.06f; 136 | 137 | auto knobRadius = radius * 0.75f; 138 | auto innerKnobRadius = knobRadius * 0.9f; 139 | 140 | // --- Draw the dial 141 | auto dialBounds = bounds.reduced(dialRadius * 2.0f); 142 | // innerRadius goes from the center to the end of the dial. 143 | auto innerRadius = dialBounds.getWidth() / 2.0f - halfDialRadius; 144 | auto toAngle = startAngle + pos * (endAngle - startAngle); 145 | 146 | // The dial circle 147 | Point dialPos( 148 | center.getX() + innerKnobRadius * 0.8f * std::sin(toAngle), 149 | center.getY() - innerKnobRadius * 0.8f * std::cos(toAngle) 150 | ); 151 | 152 | 153 | auto arcRadius = radius * 0.95f; 154 | 155 | // --- Draw the background arc 156 | Path backgroundArc; 157 | backgroundArc.addCentredArc(center.x, 158 | center.y, 159 | arcRadius, 160 | arcRadius, 161 | 0.0f, 162 | startAngle, 163 | endAngle, 164 | true); 165 | auto strokeType = PathStrokeType( 166 | bottomLineWidth, PathStrokeType::curved, PathStrokeType::rounded); 167 | g.setColour(Colors::grey); 168 | g.strokePath(backgroundArc, strokeType); 169 | 170 | // --- Draw the foreground (colored) arc 171 | float topLineWidth = bottomLineWidth + 1; 172 | 173 | strokeType = PathStrokeType( 174 | topLineWidth, PathStrokeType::curved, PathStrokeType::rounded); 175 | 176 | if (slider.isEnabled()) { 177 | Path valueArc; 178 | valueArc.addCentredArc(center.x, 179 | center.y, 180 | arcRadius, 181 | arcRadius, 182 | 0.0f, 183 | startAngle, 184 | toAngle, 185 | true); 186 | g.setColour(mainColor); 187 | g.strokePath(valueArc, strokeType); 188 | } 189 | 190 | // The knob 191 | Path knobPath, innerKnobPath; 192 | int shadowOffset = h * 0.1f; 193 | DropShadow knobShadow{ Colors::black, static_cast(w * 0.35f), Point{0, shadowOffset} }; 194 | knobPath.addEllipse(center.getX() - knobRadius, center.getY() - knobRadius, knobRadius * 2, knobRadius * 2); 195 | innerKnobPath.addEllipse(center.getX() - innerKnobRadius, center.getY() - innerKnobRadius, innerKnobRadius * 2, innerKnobRadius * 2); 196 | 197 | auto backGradient = ColourGradient( 198 | Colors::black, 0.0f, center.getY() + knobRadius, 199 | Colors::veryDarkGrey, 0.0f, center.getY() - knobRadius , false); 200 | auto topGradient = ColourGradient( 201 | Colors::black, center.getX(), center.getY(), 202 | Colors::gradientTop, 0.0f, center.getY() - knobRadius * 2.0f , true); 203 | 204 | knobShadow.drawForPath(g, knobPath); 205 | g.setGradientFill(backGradient); 206 | g.fillPath(knobPath); 207 | 208 | g.setGradientFill(topGradient); 209 | g.fillPath(innerKnobPath); 210 | 211 | 212 | // The dial circle 213 | Path knobDialPath; 214 | knobDialPath.addEllipse(dialPos.getX() - halfDialRadius, dialPos.getY() - halfDialRadius, dialRadius, dialRadius); 215 | g.setColour(dialColor); 216 | g.fillPath(knobDialPath); 217 | 218 | float textBoxHeight = bounds.getHeight() * 0.25f; 219 | auto textBoxBounds = Rectangle(bounds.getX(), bounds.getY() + bounds.getHeight() - textBoxHeight, bounds.getWidth(), textBoxHeight).reduced(0.9f); 220 | auto textBoxCenter = textBoxBounds.getCentre(); 221 | 222 | g.setColour(Colors::gradientTop); 223 | g.fillRoundedRectangle(textBoxBounds, w * 0.06f); 224 | 225 | auto fontSize = textBoxBounds.getHeight() * 0.75f; 226 | g.setColour(Colors::cream); 227 | g.setFont(textBoxFont.withHeight(fontSize)); 228 | g.drawText(slider.getTextFromValue(slider.getValue()), textBoxBounds, Justification::centred, false); 229 | 230 | } 231 | 232 | Slider::SliderLayout getSliderLayout(Slider& slider) override 233 | { 234 | Slider::SliderLayout layout; 235 | auto bounds = slider.getLocalBounds(); 236 | auto sliderBounds = Rectangle(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight() * 0.75f); 237 | layout.sliderBounds = sliderBounds; 238 | auto textBoxBounds = Rectangle(bounds.getX(), sliderBounds.getY() + sliderBounds.getHeight(), bounds.getWidth(), bounds.getHeight() * 0.25f); 239 | layout.textBoxBounds = textBoxBounds; 240 | return layout; 241 | } 242 | }; 243 | 244 | 245 | class SwitchLookAndFeel : public LookAndFeel_V4 246 | { 247 | public: 248 | SwitchLookAndFeel() { 249 | 250 | } 251 | 252 | static SwitchLookAndFeel* get() { 253 | static SwitchLookAndFeel inst; 254 | return &inst; 255 | } 256 | 257 | void drawToggleButton(Graphics& g, ToggleButton& btn, bool highlighted, bool down) override { 258 | auto bounds = btn.getLocalBounds().reduced(btn.getLocalBounds().getWidth() * 0.05f); 259 | auto iconBounds = bounds.reduced(bounds.getWidth() * 0.18f); 260 | auto toggle = btn.getToggleState(); 261 | int type = btn.getProperties().getWithDefault("type", Band::GLOBAL); 262 | Colour mainColor = primaryColors[type]; 263 | 264 | if (type != Band::GLOBAL) { 265 | g.setColour(Colors::darkGrey); 266 | Path switchPath; 267 | switchPath.addEllipse(bounds.toFloat()); 268 | g.fillEllipse(bounds.toFloat()); 269 | 270 | int shadowRadius = jmin(1, static_cast(bounds.getWidth() * 0.1f)); 271 | DropShadow shadow{ Colors::black, shadowRadius, Point{0, 0}}; 272 | shadow.drawForPath(g, switchPath); 273 | } 274 | 275 | // Draw icon 276 | auto icon = Drawable::createFromImageData(BinaryData::switchIcon_svg, BinaryData::switchIcon_svgSize); 277 | Colour iconColor; 278 | bool state = !btn.getToggleState(); 279 | if (highlighted) { 280 | iconColor = state ? Colour{ 200, 200, 200 } : Colors::grey; 281 | } 282 | else { 283 | iconColor = state ? Colors::cream : Colors::darkGrey; 284 | } 285 | icon->replaceColour(Colour{ 0, 0, 0 }, iconColor); 286 | icon->drawWithin(g, iconBounds.toFloat(), RectanglePlacement::centred, 1.0f); 287 | } 288 | 289 | private: 290 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SwitchLookAndFeel) 291 | }; 292 | 293 | 294 | class PresetMenuLookAndFeel : public LookAndFeel_V4 295 | { 296 | public: 297 | PresetMenuLookAndFeel() { 298 | //btnFont = Font(Typeface::createSystemTypefaceFor(BinaryData::arial_narrow_7_ttf, BinaryData::arial_narrow_7_ttfSize)); 299 | //presetFont = Font(Typeface::createSystemTypefaceFor(BinaryData::game_over_ttf, BinaryData::game_over_ttfSize)); 300 | menuFont = Font(Typeface::createSystemTypefaceFor(BinaryData::hack_ttf, BinaryData::hack_ttfSize)); 301 | 302 | } 303 | 304 | static PresetMenuLookAndFeel* get() { 305 | static PresetMenuLookAndFeel inst; 306 | return &inst; 307 | } 308 | 309 | void drawButtonBackground(Graphics& g, Button& btn, const Colour& bg, bool highlight, bool down) override { 310 | auto bounds = btn.getLocalBounds().reduced(btn.getLocalBounds().getHeight() * 0.1f); 311 | int cornerSize = bounds.getHeight() * 0.16f; 312 | int shadowRadius = (btn.getLocalBounds().getWidth() - bounds.getWidth()) * 2; 313 | 314 | Path btnPath; 315 | btnPath.addRoundedRectangle(bounds, cornerSize); 316 | DropShadow btnShadow{ Colors::black, shadowRadius, {0, 0} }; 317 | btnShadow.drawForPath(g, btnPath); 318 | g.setColour(highlight ? Colors::cream : Colors::lightGrey); 319 | g.fillRoundedRectangle(bounds.toFloat(), cornerSize); 320 | } 321 | 322 | void drawButtonText(Graphics& g, TextButton& btn, bool highlight, bool down) override { 323 | auto bounds = btn.getLocalBounds().reduced(btn.getLocalBounds().getHeight() * 0.2f); 324 | 325 | auto trashIcon = Drawable::createFromImageData(BinaryData::trashIcon_svg, BinaryData::trashIcon_svgSize); 326 | auto floppyIcon = Drawable::createFromImageData(BinaryData::floppyIcon_svg, BinaryData::floppyIcon_svgSize); 327 | 328 | int type = btn.getProperties().getWithDefault("type", PresetBtnType::DELETE); 329 | 330 | auto iconColor = highlight ? Colors::grey : Colors::cream; 331 | 332 | if (type == PresetBtnType::DELETE) { 333 | trashIcon->replaceColour(Colour{ 0, 0, 0 }, iconColor); 334 | trashIcon->drawWithin(g, bounds.toFloat(), RectanglePlacement::centred, 1.0f); 335 | } 336 | else if (type == PresetBtnType::SAVE) { 337 | floppyIcon->replaceColour(Colour{ 0, 0, 0 }, iconColor); 338 | floppyIcon->drawWithin(g, bounds.toFloat(), RectanglePlacement::centred, 1.0f); 339 | } 340 | else { 341 | float fontSize = btn.getLocalBounds().getHeight(); 342 | g.setColour(iconColor); 343 | g.setFont(menuFont.withHeight(fontSize)); 344 | g.drawFittedText(btn.getButtonText(), bounds, juce::Justification::centred, 1); 345 | } 346 | 347 | } 348 | 349 | Font getComboBoxFont(ComboBox& comboBox) override 350 | { 351 | return presetFont; 352 | } 353 | 354 | void positionComboBoxText(ComboBox&, Label& labelToPosition) override {} 355 | 356 | void drawComboBox(Graphics& g, int w, int h, bool down, int buttonX, int buttonY, int buttonW, int buttonH, ComboBox& box) override { 357 | const float textAreaWProportion = 0.88f; 358 | 359 | auto bounds = box.getLocalBounds().reduced(box.getLocalBounds().getHeight() * 0.1f); 360 | const auto textArea = box.getLocalBounds().reduced(box.getLocalBounds().proportionOfHeight(0.3f)); 361 | const auto text = box.getText(); 362 | 363 | g.setColour(Colors::lightGrey); 364 | int cornerSize = bounds.getHeight() * 0.16f; 365 | g.fillRoundedRectangle(bounds.toFloat(), cornerSize); 366 | 367 | g.setColour(Colors::cream); 368 | g.setFont(presetFont); 369 | g.setFont(0.6f * h); 370 | g.drawText(text, textArea, Justification::left); 371 | 372 | 373 | const auto arrowArea = Rectangle(w * textAreaWProportion, h * 0.38f, w * 0.065f, h * 0.25f); 374 | Path arrow; 375 | arrow.addTriangle(arrowArea.getX(), arrowArea.getY(), 376 | arrowArea.getX() + arrowArea.getWidth() / 2.0f, arrowArea.getY() + arrowArea.getHeight(), 377 | arrowArea.getX() + arrowArea.getWidth(), arrowArea.getY()); 378 | 379 | PathStrokeType stroke{ 2.0f }; 380 | 381 | g.setColour(Colors::cream); 382 | g.strokePath(arrow, stroke); 383 | } 384 | 385 | void drawComboBoxTextWhenNothingSelected(Graphics& g, ComboBox& box, Label&) override { 386 | const auto textArea = box.getLocalBounds().reduced(box.getLocalBounds().proportionOfHeight(0.3f)); 387 | const auto fontSize = box.getLocalBounds().getHeight() * 0.6f; 388 | const auto text = box.getTextWhenNothingSelected(); 389 | g.setColour(Colors::darkGrey); 390 | g.setFont(presetFont); 391 | g.setFont(fontSize); 392 | g.drawText(text, textArea, Justification::left); 393 | } 394 | 395 | void drawPopupMenuBackground(Graphics& g, int width, int height) override 396 | { 397 | g.fillAll(Colors::lightGrey); 398 | } 399 | 400 | void drawPopupMenuItem(Graphics& g, const Rectangle& area, bool isSeparator, bool isActive, 401 | bool isHighlighted, bool isTicked, bool hasSubMenu, const String& text, 402 | const String& shortcutKeyText, const Drawable* icon, const Colour* textColour) override 403 | { 404 | 405 | g.setColour(isTicked ? Colors::cream : Colour{200, 200, 200}); // Text color 406 | g.setFont(menuFont); 407 | g.drawFittedText(text, area.reduced(5), Justification::centredLeft, 1); 408 | } 409 | 410 | private: 411 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PresetMenuLookAndFeel) 412 | 413 | Font btnFont; 414 | Font presetFont; 415 | Font menuFont; 416 | }; 417 | 418 | 419 | 420 | class SpectrumAnalyzerGroupLookAndFeel : public LookAndFeel_V4 421 | { 422 | Font labelFont, textBoxFont; 423 | 424 | public: 425 | SpectrumAnalyzerGroupLookAndFeel() { 426 | labelFont = Font(Typeface::createSystemTypefaceFor(BinaryData::coolvetica_otf, BinaryData::coolvetica_otfSize)); 427 | textBoxFont = Font(Typeface::createSystemTypefaceFor(BinaryData::hack_ttf, BinaryData::hack_ttfSize)); 428 | } 429 | 430 | static SpectrumAnalyzerGroupLookAndFeel* get() { 431 | static SpectrumAnalyzerGroupLookAndFeel inst; 432 | return &inst; 433 | } 434 | 435 | void drawRotarySlider(Graphics& g, int x, int y, int w, int h, float pos, float startAngle, float endAngle, Slider& slider) override { 436 | 437 | Colour dialColor = Colors::cream; 438 | 439 | auto bounds = slider.getLocalBounds().reduced(w * 0.03f); 440 | 441 | auto labelArea = Rectangle{ x, int(y + h / 5), int(w * 0.38f), h }; 442 | 443 | auto center = bounds.getCentre(); 444 | auto radius = bounds.getHeight() / 2.0f; 445 | 446 | // dialRadius is the size of the circle that appears on the knob. 447 | // bottomLineWidth is the line width of the bottom (dark) arc around the knob. 448 | // The colored part of the arc is always a multiple of the dark line. 449 | float dialRadius; 450 | dialRadius = bounds.getHeight() * 0.07f; 451 | auto halfDialRadius = dialRadius / 2.0f; 452 | 453 | int type = slider.getProperties().getWithDefault("type", 0); 454 | auto fontSize = h * 0.6f; 455 | g.setColour(Colors::cream); 456 | g.setFont(labelFont.withHeight(fontSize)); 457 | if (type == FreqKnobBand::LOWMID) { 458 | g.drawFittedText("low / mid", labelArea, Justification::right, false); 459 | } 460 | else if (type == FreqKnobBand::MIDHIGH) { 461 | g.drawFittedText("mid / high", labelArea, Justification::right, false); 462 | } 463 | 464 | // --- Draw the dial 465 | auto dialBounds = bounds.reduced(dialRadius * 2.0f); 466 | // innerRadius goes from the center to the end of the dial. 467 | auto innerRadius = dialBounds.getWidth() / 2.0f - halfDialRadius; 468 | auto toAngle = startAngle + pos * (endAngle - startAngle); 469 | 470 | // The dial circle 471 | Point dialPos( 472 | center.getX() + radius * 0.8f * std::sin(toAngle), 473 | center.getY() - radius * 0.8f * std::cos(toAngle) 474 | ); 475 | 476 | // The knob 477 | Path knobPath, innerKnobPath; 478 | int shadowOffset = bounds.getHeight() * 0.1f; 479 | DropShadow knobShadow{ Colors::black, static_cast(h * 0.35f), Point{0, shadowOffset} }; 480 | knobPath.addEllipse(center.getX() - radius, center.getY() - radius, radius * 2, radius * 2); 481 | 482 | knobShadow.drawForPath(g, knobPath); 483 | g.setColour(Colors::black); 484 | g.fillPath(knobPath); 485 | 486 | // The dial circle 487 | Path knobDialPath; 488 | knobDialPath.addEllipse(dialPos.getX() - halfDialRadius, dialPos.getY() - halfDialRadius, dialRadius, dialRadius); 489 | g.setColour(dialColor); 490 | g.fillPath(knobDialPath); 491 | 492 | float textBoxHeight = bounds.getHeight() * 0.25f; 493 | auto textBoxBounds = Rectangle(labelArea.getWidth() + radius * 3, 494 | y + (h * 0.4f), w * 0.4f, h * 0.6f).reduced(0.9f); 495 | 496 | g.setColour(Colors::grey); 497 | g.fillRoundedRectangle(textBoxBounds, w * 0.01f); 498 | 499 | fontSize = textBoxBounds.getHeight() * 0.75f; 500 | g.setColour(Colors::cream); 501 | g.setFont(textBoxFont.withHeight(fontSize)); 502 | g.drawText(slider.getTextFromValue(slider.getValue()), textBoxBounds, Justification::centred, false); 503 | 504 | } 505 | 506 | Slider::SliderLayout getSliderLayout(Slider& slider) override 507 | { 508 | Slider::SliderLayout layout; 509 | auto bounds = slider.getLocalBounds(); 510 | auto sliderBounds = Rectangle(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight() * 0.75f); 511 | layout.sliderBounds = sliderBounds; 512 | auto textBoxBounds = Rectangle(bounds.getX(), sliderBounds.getY() + sliderBounds.getHeight(), bounds.getWidth(), bounds.getHeight() * 0.25f); 513 | layout.textBoxBounds = textBoxBounds; 514 | return layout; 515 | } 516 | }; 517 | -------------------------------------------------------------------------------- /Source/MultibandDistortion.cpp: -------------------------------------------------------------------------------- 1 | #include "MultibandDistortion.h" 2 | 3 | 4 | void Distortion::prepare(DSPParameters& params) { 5 | sampleRate = params["sampleRate"]; 6 | blockSize = params["blockSize"]; 7 | nChannels = params["nChannels"]; 8 | 9 | inputGain.prepare(sampleRate); 10 | outputGain.prepare(sampleRate); 11 | drive.prepare(sampleRate); 12 | mix.prepare(sampleRate); 13 | knee.prepare(sampleRate); 14 | } 15 | 16 | void Distortion::update(DSPParameters& params) { 17 | inputGain.update(dbToLinear(params["inputGain"])); 18 | outputGain.update(dbToLinear(params["outputGain"])); 19 | drive.update(dbToLinear(params["drive"])); 20 | knee.update(params["knee"]); 21 | bit = static_cast(params["bit"]); 22 | mix.update(params["mix"] * 0.01f); 23 | } 24 | 25 | void Distortion::processBlock(float* const* inputBuffer, int numChannels, int numSamples) { 26 | for (int ch = 0; ch < numChannels; ++ch) { 27 | for (auto s = 0; s < numSamples; ++s) { 28 | auto sample = inputBuffer[ch][s]; 29 | inputBuffer[ch][s] = processSample(sample); 30 | } 31 | } 32 | } 33 | 34 | float Distortion::processSample(float sample) { 35 | float output = clip(sample * inputGain.next(), drive.next(), knee.next()); 36 | output = bitcrush(output, bit); 37 | return limit(output) * outputGain.next(); 38 | } 39 | 40 | 41 | float Distortion::bitcrush(float sample, int bit) { 42 | float QL = 2.0 / (pow(2.0, bit) - 1.0); 43 | return QL * static_cast(sample / QL); 44 | 45 | } 46 | 47 | // https://www.musicdsp.org/en/latest/Effects/104-variable-hardness-clipping-function.html 48 | float Distortion::clip(float input, float drive, float knee) { 49 | input *= drive; 50 | return sign(input) * pow(fastatan(pow(fabs(input), knee)), (1.0f / knee)); 51 | } 52 | 53 | float Distortion::limit(float sample) { 54 | if (sample > 4.0f) return 4.0f; 55 | if (sample < -4.0f) return -4.0f; 56 | return sample; 57 | } 58 | 59 | void MultibandDistortion::prepare(DSPParameters& params) { 60 | sampleRate = params["sampleRate"]; 61 | blockSize = params["blockSize"]; 62 | nChannels = params["nChannels"]; 63 | 64 | lowDist.prepare(params); 65 | midDist.prepare(params); 66 | highDist.prepare(params); 67 | 68 | lowMidFilter.prepare(sampleRate, blockSize, nChannels); 69 | midHighFilter.prepare(sampleRate, blockSize, nChannels); 70 | lowMidCut.update(params["lowMidCut"]); 71 | midHighCut.update(params["midHighCut"]); 72 | 73 | update(params); 74 | } 75 | 76 | void MultibandDistortion::update(DSPParameters& params) { 77 | // Band specific parameters 78 | lowParams.set("inputGain", params["inputGain1"]); 79 | lowParams.set("outputGain", params["outputGain1"]); 80 | lowParams.set("drive", params["drive1"]); 81 | lowParams.set("knee", params["knee1"]); 82 | lowParams.set("bit", params["bit1"]); 83 | lowParams.set("bypass", params["bypass1"]); 84 | lowDist.update(lowParams); 85 | midParams.set("inputGain", params["inputGain2"]); 86 | midParams.set("outputGain", params["outputGain2"]); 87 | midParams.set("drive", params["drive2"]); 88 | midParams.set("knee", params["knee2"]); 89 | midParams.set("bit", params["bit2"]); 90 | midParams.set("bypass", params["bypass2"]); 91 | midDist.update(midParams); 92 | highParams.set("inputGain", params["inputGain3"]); 93 | highParams.set("outputGain", params["outputGain3"]); 94 | highParams.set("drive", params["drive3"]); 95 | highParams.set("knee", params["knee3"]); 96 | highParams.set("bit", params["bit3"]); 97 | highParams.set("bypass", params["bypass3"]); 98 | highDist.update(highParams); 99 | 100 | // Global 101 | lowEnabled.setValue(1.0f - params["bypass1"]); 102 | midEnabled.setValue(1.0f - params["bypass2"]); 103 | highEnabled.setValue(1.0f - params["bypass3"]); 104 | allEnabled.setValue(1.0f - params["bypass"]); 105 | inputGain.update(dbToLinear(params["inputGain"])); 106 | outputGain.update(dbToLinear(params["outputGain"])); 107 | bypass = static_cast(params["bypass"]); 108 | mix.update(params["mix"] * 0.01f); 109 | lowMidCut.update(params["lowMidCut"]); 110 | midHighCut.update(params["midHighCut"]); 111 | } 112 | 113 | void MultibandDistortion::processBlock(float* const* inputBuffer, int numChannels, int numSamples) { 114 | for (int ch = 0; ch < numChannels; ++ch) { 115 | for (auto s = 0; s < numSamples; ++s) { 116 | auto sample = inputGain.next() * inputBuffer[ch][s]; 117 | 118 | float lowBandFiltered, midBandFiltered, highBandFiltered; 119 | float lowBandDistorted, midBandDistorted, highBandDistorted; 120 | 121 | lowMidFilter.setFrequency(lowMidCut.next()); 122 | midHighFilter.setFrequency(midHighCut.next()); 123 | 124 | lowMidFilter.processSample(ch, sample, lowBandFiltered, midBandFiltered); 125 | midHighFilter.processSample(ch, midBandFiltered, midBandFiltered, highBandFiltered); 126 | 127 | lowBandDistorted = lowDist.processSample(lowBandFiltered) * lowEnabled.next(); 128 | midBandDistorted = midDist.processSample(midBandFiltered) * midEnabled.next(); 129 | highBandDistorted = highDist.processSample(highBandFiltered) * highEnabled.next(); 130 | 131 | auto wet = mix.next() * (lowBandDistorted + midBandDistorted + highBandDistorted); 132 | auto dry = (1.0f - mix.read()) * sample; 133 | auto amplitude = allEnabled.next(); 134 | 135 | auto output = sample * (1.0f - amplitude) + ((wet + dry) * amplitude * outputGain.next()); 136 | inputBuffer[ch][s] = output; 137 | } 138 | } 139 | } 140 | 141 | 142 | -------------------------------------------------------------------------------- /Source/MultibandDistortion.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Utils.h" 4 | #include "DSPParameters.h" 5 | #include "Filters.h" 6 | #include "FilteredParameter.h" 7 | 8 | #define DEFAULT_SR 44100.0f 9 | 10 | class Distortion 11 | { 12 | float sampleRate{ DEFAULT_SR }; 13 | int blockSize{ 0 }; 14 | float nChannels{ 2.0f }; 15 | 16 | FilteredParameter inputGain{}; 17 | FilteredParameter outputGain{}; 18 | FilteredParameter drive{}; 19 | FilteredParameter mix{}; 20 | FilteredParameter knee{}; 21 | int bit{}; 22 | 23 | float bitcrush(float sample, int bit); 24 | float clip(float input, float drive, float knee); 25 | float limit(float sample); 26 | 27 | public: 28 | 29 | void prepare(DSPParameters& params); 30 | void update(DSPParameters& params); 31 | void processBlock(float* const* inputBuffer, int numChannels, int numSamples); 32 | float processSample(float sample); 33 | 34 | }; 35 | 36 | class MultibandDistortion { 37 | float sampleRate{ DEFAULT_SR }; 38 | int blockSize{ 0 }; 39 | float nChannels{ 1.0f }; 40 | 41 | Distortion lowDist; 42 | Distortion midDist; 43 | Distortion highDist; 44 | 45 | DSPParameters lowParams; 46 | DSPParameters midParams; 47 | DSPParameters highParams; 48 | 49 | FilteredParameter inputGain{}; 50 | FilteredParameter outputGain{}; 51 | FilteredParameter mix{1.0f}; 52 | bool bypass{ false }; 53 | 54 | LRFilter lowMidFilter; 55 | LRFilter midHighFilter; 56 | FilteredParameter lowMidCut{}; 57 | FilteredParameter midHighCut{}; 58 | 59 | SmoothLogParameter lowEnabled; 60 | SmoothLogParameter midEnabled; 61 | SmoothLogParameter highEnabled; 62 | SmoothLogParameter allEnabled; 63 | 64 | public: 65 | 66 | void prepare(DSPParameters& params); 67 | void update(DSPParameters& params); 68 | void processBlock(float* const* inputBuffer, int numChannels, int numSamples); 69 | 70 | }; -------------------------------------------------------------------------------- /Source/PluginEditor.cpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "PluginEditor.h" 4 | 5 | using Track = Grid::TrackInfo; 6 | using Fr = Grid::Fr; 7 | 8 | //============================================================================== 9 | AttilaAudioProcessorEditor::AttilaAudioProcessorEditor (AttilaAudioProcessor& p) : 10 | AudioProcessorEditor (&p), 11 | audioProcessor (p), 12 | levelMeter(p.levelL, p.levelR) 13 | { 14 | lowBandGroup.setText("LOW"); 15 | lowBandGroup.setTextLabelPosition(Justification::horizontallyCentred); 16 | lowBandGroup.addAndMakeVisible(lowInputGain); 17 | lowBandGroup.addAndMakeVisible(lowOutputGain); 18 | lowBandGroup.addAndMakeVisible(lowDrive); 19 | lowBandGroup.addAndMakeVisible(lowKnee); 20 | lowBandGroup.addAndMakeVisible(lowBit); 21 | 22 | midBandGroup.setText("MID"); 23 | midBandGroup.setTextLabelPosition(Justification::horizontallyCentred); 24 | midBandGroup.addAndMakeVisible(midInputGain); 25 | midBandGroup.addAndMakeVisible(midOutputGain); 26 | midBandGroup.addAndMakeVisible(midDrive); 27 | midBandGroup.addAndMakeVisible(midKnee); 28 | midBandGroup.addAndMakeVisible(midBit); 29 | highBandGroup.setText("HIGH"); 30 | highBandGroup.setTextLabelPosition(Justification::horizontallyCentred); 31 | highBandGroup.addAndMakeVisible(highInputGain); 32 | highBandGroup.addAndMakeVisible(highOutputGain); 33 | highBandGroup.addAndMakeVisible(highDrive); 34 | highBandGroup.addAndMakeVisible(highKnee); 35 | highBandGroup.addAndMakeVisible(highBit); 36 | 37 | globalGroup.setText("GLOBAL"); 38 | globalGroup.setTextLabelPosition(Justification::horizontallyCentred); 39 | globalGroup.addAndMakeVisible(globalInputGain); 40 | globalGroup.addAndMakeVisible(globalOutputGain); 41 | globalGroup.addAndMakeVisible(mix); 42 | 43 | addAndMakeVisible(lowBandGroup); 44 | addAndMakeVisible(midBandGroup); 45 | addAndMakeVisible(highBandGroup); 46 | addAndMakeVisible(globalGroup); 47 | addAndMakeVisible(globalBypass); 48 | addAndMakeVisible(presetMenu); 49 | 50 | addAndMakeVisible(lowBypass); 51 | addAndMakeVisible(midBypass); 52 | addAndMakeVisible(highBypass); 53 | 54 | lowBandGroup.getProperties().set("type", Band::LOW); 55 | lowBandGroup.setLookAndFeel(&groupComponentLookAndFeel); 56 | midBandGroup.getProperties().set("type", Band::MID); 57 | midBandGroup.setLookAndFeel(&groupComponentLookAndFeel); 58 | highBandGroup.getProperties().set("type", Band::HIGH); 59 | highBandGroup.setLookAndFeel(&groupComponentLookAndFeel); 60 | globalGroup.setLookAndFeel(&groupComponentLookAndFeel); 61 | 62 | addAndMakeVisible(levelMeter); 63 | addAndMakeVisible(analyzerGroup); 64 | 65 | setSize (screenWidth, screenHeight); 66 | } 67 | 68 | AttilaAudioProcessorEditor::~AttilaAudioProcessorEditor() 69 | { 70 | lowBandGroup.setLookAndFeel(nullptr); 71 | midBandGroup.setLookAndFeel(nullptr); 72 | highBandGroup.setLookAndFeel(nullptr); 73 | globalGroup.setLookAndFeel(nullptr); 74 | } 75 | 76 | //============================================================================== 77 | void AttilaAudioProcessorEditor::paint (Graphics& g) 78 | { 79 | g.fillAll (Colors::veryDarkGrey); 80 | 81 | float logoHeight = screenHeight * 0.04f; 82 | float logoWidth = logoHeight * 7.58f; 83 | float margin = screenHeight * 0.01f; 84 | float xOffset = screenWidth - logoWidth - margin; 85 | float yOffset = margin; 86 | auto bounds = Rectangle{ xOffset, yOffset, logoWidth, logoHeight }; 87 | logo->drawWithin(g, bounds, RectanglePlacement::centred, 1.0f); 88 | } 89 | 90 | void AttilaAudioProcessorEditor::resized() 91 | { 92 | auto bounds = getLocalBounds().reduced(getWidth() * 0.005f); 93 | 94 | auto topRowHeight = bounds.getHeight() * 0.06f; 95 | auto midRowHeight = bounds.getHeight() * 0.52f; 96 | auto bottomRowHeight = bounds.getHeight() * 0.43f; 97 | 98 | auto bandGroupWidth = bounds.getWidth() * 0.333f; 99 | auto globalGroupWidth = bounds.getWidth() * 0.19f; 100 | auto padding = bandGroupWidth * 0.06f; 101 | auto bandTopHeight = bottomRowHeight * 0.18f; 102 | auto bandGroupHeight = bottomRowHeight - bandTopHeight; 103 | 104 | auto switchSize = bandTopHeight * 0.5f; 105 | 106 | lowBandGroup.setBounds(bounds.getX(), topRowHeight + midRowHeight, bandGroupWidth, bottomRowHeight); 107 | midBandGroup.setBounds(lowBandGroup.getX() + bandGroupWidth, topRowHeight + midRowHeight, bandGroupWidth, bottomRowHeight); 108 | highBandGroup.setBounds(midBandGroup.getX() + bandGroupWidth, topRowHeight + midRowHeight, bandGroupWidth, bottomRowHeight); 109 | 110 | globalGroup.setBounds(bounds.getX(), topRowHeight, globalGroupWidth, midRowHeight); 111 | auto globalGroupBounds = globalGroup.getLocalBounds().reduced(padding); 112 | levelMeter.setBounds(globalGroupBounds.getX() + knobW + padding, topRowHeight + padding, globalGroupWidth * 0.44f, globalGroupBounds.getHeight()); 113 | presetMenu.setBounds(switchSize * 1.8f, bounds.getY(), bounds.getWidth() * 0.6f, topRowHeight - padding / 2.0f); 114 | analyzerGroup.setBounds(bounds.getWidth() * 0.2f, topRowHeight * 1.04f, bounds.getWidth() * 0.8f, midRowHeight * 0.99f); 115 | 116 | Grid lowBandGrid; 117 | Grid midBandGrid; 118 | Grid highBandGrid; 119 | Grid globalGrid; 120 | 121 | lowBandGrid.templateRows = { Track(Fr(1)), Track(Fr(1)) }; 122 | lowBandGrid.templateColumns = { Track(Fr(1)), Track(Fr(1)), Track(Fr(1)) }; 123 | midBandGrid.templateRows = { Track(Fr(1)), Track(Fr(1)) }; 124 | midBandGrid.templateColumns = { Track(Fr(1)), Track(Fr(1)), Track(Fr(1)) }; 125 | highBandGrid.templateRows = { Track(Fr(1)), Track(Fr(1)) }; 126 | highBandGrid.templateColumns = { Track(Fr(1)), Track(Fr(1)), Track(Fr(1)) }; 127 | globalGrid.templateRows = { Track(Fr(1)), Track(Fr(1)), Track(Fr(1))}; 128 | globalGrid.templateColumns = { Track(Fr(1)) }; 129 | 130 | lowBandGrid.items = { 131 | GridItem(lowDrive), 132 | GridItem(lowKnee), 133 | GridItem(lowBit), 134 | GridItem(lowInputGain), 135 | GridItem(lowOutputGain) 136 | }; 137 | 138 | 139 | midBandGrid.items = { 140 | GridItem(midDrive), 141 | GridItem(midKnee), 142 | GridItem(midBit), 143 | GridItem(midInputGain), 144 | GridItem(midOutputGain) 145 | }; 146 | 147 | highBandGrid.items = { 148 | GridItem(highDrive), 149 | GridItem(highKnee), 150 | GridItem(highBit), 151 | GridItem(highInputGain), 152 | GridItem(highOutputGain) 153 | }; 154 | 155 | 156 | globalGrid.items = { 157 | GridItem(globalInputGain), 158 | GridItem(globalOutputGain), 159 | GridItem(mix), 160 | }; 161 | 162 | lowBandGrid.performLayout(lowBandGroup.getLocalBounds(). 163 | removeFromBottom(bandGroupHeight). 164 | removeFromRight(bandGroupWidth - padding)); 165 | midBandGrid.performLayout(midBandGroup.getLocalBounds(). 166 | removeFromBottom(bandGroupHeight). 167 | removeFromRight(bandGroupWidth - padding)); 168 | highBandGrid.performLayout(highBandGroup.getLocalBounds(). 169 | removeFromBottom(bandGroupHeight). 170 | removeFromRight(bandGroupWidth - padding)); 171 | 172 | 173 | globalGrid.performLayout(globalGroup.getLocalBounds().reduced(padding)); 174 | 175 | lowBypass.setBounds(padding, topRowHeight + midRowHeight + padding * 0.5f, switchSize, switchSize); 176 | midBypass.setBounds(padding + bandGroupWidth, topRowHeight + midRowHeight + padding * 0.5f, switchSize, switchSize); 177 | highBypass.setBounds(padding + bandGroupWidth * 2, topRowHeight + midRowHeight + padding * 0.5f, switchSize, switchSize); 178 | globalBypass.setBounds(bounds.getX(), 0.0f, switchSize * 1.5f, switchSize * 1.5f); 179 | 180 | } 181 | -------------------------------------------------------------------------------- /Source/PluginEditor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "PluginProcessor.h" 5 | #include "GuiComponents.h" 6 | #include "LookAndFeel.h" 7 | 8 | #define BTN_SIZE 15 9 | 10 | //============================================================================== 11 | /** 12 | */ 13 | class AttilaAudioProcessorEditor : public AudioProcessorEditor 14 | { 15 | public: 16 | AttilaAudioProcessorEditor (AttilaAudioProcessor&); 17 | ~AttilaAudioProcessorEditor() override; 18 | 19 | //============================================================================== 20 | void paint (Graphics&) override; 21 | void resized() override; 22 | 23 | private: 24 | AttilaAudioProcessor& audioProcessor; 25 | 26 | Rectangle screenSize = Desktop::getInstance().getDisplays().getMainDisplay().userArea; 27 | int screenHeight = screenSize.getHeight() * 0.75f; 28 | int screenWidth = screenHeight * 1.125f; 29 | 30 | int knobW = screenWidth * 0.089f; 31 | int knobH = knobW * 1.275; 32 | 33 | // GUI Components 34 | Knob lowInputGain { apvtsParameters[INPUT_GAIN_1].get(), knobW, knobH, audioProcessor.apvts, Band::LOW}; 35 | Knob lowOutputGain { apvtsParameters[OUTPUT_GAIN_1].get(), knobW, knobH, audioProcessor.apvts, Band::LOW}; 36 | Knob lowDrive { apvtsParameters[DRIVE_1].get(), knobW, knobH, audioProcessor.apvts, Band::LOW}; 37 | Knob lowKnee { apvtsParameters[KNEE_1].get(), knobW, knobH, audioProcessor.apvts, Band::LOW}; 38 | Knob lowBit { apvtsParameters[BIT_1].get(), knobW, knobH, audioProcessor.apvts, Band::LOW}; 39 | 40 | Knob midInputGain { apvtsParameters[INPUT_GAIN_2].get(), knobW, knobH, audioProcessor.apvts, Band::MID}; 41 | Knob midOutputGain { apvtsParameters[OUTPUT_GAIN_2].get(), knobW, knobH, audioProcessor.apvts, Band::MID}; 42 | Knob midDrive { apvtsParameters[DRIVE_2].get(), knobW, knobH, audioProcessor.apvts, Band::MID}; 43 | Knob midKnee { apvtsParameters[KNEE_2].get(), knobW, knobH, audioProcessor.apvts, Band::MID}; 44 | Knob midBit { apvtsParameters[BIT_2].get(), knobW, knobH, audioProcessor.apvts, Band::MID}; 45 | 46 | Knob highInputGain { apvtsParameters[INPUT_GAIN_3].get(), knobW, knobH, audioProcessor.apvts, Band::HIGH}; 47 | Knob highOutputGain { apvtsParameters[OUTPUT_GAIN_3].get(),knobW, knobH, audioProcessor.apvts, Band::HIGH}; 48 | Knob highDrive { apvtsParameters[DRIVE_3].get(), knobW, knobH, audioProcessor.apvts, Band::HIGH}; 49 | Knob highKnee { apvtsParameters[KNEE_3].get(), knobW, knobH, audioProcessor.apvts, Band::HIGH}; 50 | Knob highBit { apvtsParameters[BIT_3].get(), knobW, knobH, audioProcessor.apvts, Band::HIGH}; 51 | 52 | Knob globalInputGain { apvtsParameters[INPUT_GLOBAL].get(), knobW, knobH, audioProcessor.apvts, Band::GLOBAL}; 53 | Knob globalOutputGain { apvtsParameters[OUTPUT_GLOBAL].get(), knobW, knobH, audioProcessor.apvts, Band::GLOBAL}; 54 | Knob mix { apvtsParameters[MIX].get(), knobW, knobH, audioProcessor.apvts, Band::GLOBAL}; 55 | 56 | PresetMenu presetMenu{ {0, 0, getLocalBounds().getWidth() * 0.6f, getLocalBounds().getHeight() * 0.06f}, audioProcessor.getPresetManager()}; 57 | 58 | GroupComponent lowBandGroup; 59 | GroupComponent midBandGroup; 60 | GroupComponent highBandGroup; 61 | GroupComponent globalGroup; 62 | 63 | GroupComponentLookAndFeel groupComponentLookAndFeel{ static_cast(screenWidth), static_cast(screenHeight) }; 64 | 65 | Switch lowBypass { apvtsParameters[BYPASS_1].get(), audioProcessor.apvts, Band::LOW, lowBandGroup}; 66 | Switch midBypass { apvtsParameters[BYPASS_2].get(), audioProcessor.apvts, Band::MID, midBandGroup}; 67 | Switch highBypass { apvtsParameters[BYPASS_3].get(), audioProcessor.apvts, Band::HIGH, highBandGroup}; 68 | Switch globalBypass { apvtsParameters[BYPASS].get(), audioProcessor.apvts, Band::GLOBAL, globalGroup}; 69 | 70 | std::unique_ptr logo = Drawable::createFromImageData(BinaryData::logo_svg, BinaryData::logo_svgSize); 71 | 72 | LevelMeter levelMeter; 73 | 74 | SpectrumAnalyzerGroup analyzerGroup{ 75 | apvtsParameters[LOW_MID_CUT].get() , 76 | apvtsParameters[MID_HIGH_CUT].get(), 77 | audioProcessor.apvts, 78 | audioProcessor.spectrumAnalyzer, 79 | lowDrive, 80 | midDrive, 81 | highDrive 82 | }; 83 | 84 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AttilaAudioProcessorEditor) 85 | }; 86 | -------------------------------------------------------------------------------- /Source/PluginProcessor.cpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "PluginProcessor.h" 4 | #include "PluginEditor.h" 5 | 6 | //============================================================================== 7 | AttilaAudioProcessor::AttilaAudioProcessor() 8 | #ifndef JucePlugin_PreferredChannelConfigurations 9 | : AudioProcessor(BusesProperties() 10 | #if ! JucePlugin_IsMidiEffect 11 | #if ! JucePlugin_IsSynth 12 | .withInput("Input", AudioChannelSet::stereo(), true) 13 | #endif 14 | .withOutput("Output", AudioChannelSet::stereo(), true) 15 | #endif 16 | ), 17 | apvts(*this, nullptr, "Parameters", createParameterLayout()), 18 | distortion(), 19 | spectrumAnalyzer(getSampleRate(), apvtsParameters[LOW_MID_CUT]->getDefault(), apvtsParameters[MID_HIGH_CUT]->getDefault()) 20 | #endif 21 | { 22 | if (!apvts.state.isValid()) { 23 | DBG("Invalid value tree"); 24 | jassertfalse; 25 | } 26 | apvts.state.setProperty("presetName", "", nullptr); 27 | apvts.state.addListener(this); 28 | presetManager = std::make_unique(apvts); 29 | 30 | for (auto& param : apvtsParameters) { 31 | param->castParameter(apvts); 32 | } 33 | } 34 | AttilaAudioProcessor::~AttilaAudioProcessor() 35 | { 36 | apvts.state.removeListener(this); 37 | } 38 | 39 | //============================================================================== 40 | const String AttilaAudioProcessor::getName() const 41 | { 42 | return JucePlugin_Name; 43 | } 44 | 45 | bool AttilaAudioProcessor::acceptsMidi() const 46 | { 47 | #if JucePlugin_WantsMidiInput 48 | return true; 49 | #else 50 | return false; 51 | #endif 52 | } 53 | 54 | bool AttilaAudioProcessor::producesMidi() const 55 | { 56 | #if JucePlugin_ProducesMidiOutput 57 | return true; 58 | #else 59 | return false; 60 | #endif 61 | } 62 | 63 | bool AttilaAudioProcessor::isMidiEffect() const 64 | { 65 | #if JucePlugin_IsMidiEffect 66 | return true; 67 | #else 68 | return false; 69 | #endif 70 | } 71 | 72 | double AttilaAudioProcessor::getTailLengthSeconds() const 73 | { 74 | return 0.0; 75 | } 76 | 77 | int AttilaAudioProcessor::getNumPrograms() 78 | { 79 | return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, 80 | // so this should be at least 1, even if you're not really implementing programs. 81 | } 82 | 83 | int AttilaAudioProcessor::getCurrentProgram() 84 | { 85 | return 0; 86 | } 87 | 88 | void AttilaAudioProcessor::setCurrentProgram (int index) 89 | { 90 | } 91 | 92 | const String AttilaAudioProcessor::getProgramName (int index) 93 | { 94 | return {}; 95 | } 96 | 97 | void AttilaAudioProcessor::changeProgramName (int index, const String& newName) 98 | { 99 | } 100 | 101 | //============================================================================== 102 | void AttilaAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) 103 | { 104 | int nChannels = getTotalNumInputChannels(); 105 | 106 | oversampling.numChannels = getTotalNumInputChannels(); 107 | oversampling.initProcessing(samplesPerBlock); 108 | oversampling.reset(); 109 | 110 | setLatencySamples(oversampling.getLatencyInSamples()); 111 | 112 | distortionParameters.set("sampleRate", sampleRate * (pow(2, oversampleFactor))); 113 | distortionParameters.set("blockSize", samplesPerBlock); 114 | distortionParameters.set("nChannels", nChannels); 115 | 116 | spectrumAnalyzer.setSampleRate(sampleRate); 117 | 118 | for (auto& param : apvtsParameters) { 119 | distortionParameters.set(param->id.getParamID().toStdString(), param->getDefault()); 120 | } 121 | 122 | distortion.prepare(distortionParameters); 123 | 124 | levelL.store(0.0f); 125 | levelR.store(0.0f); 126 | } 127 | 128 | void AttilaAudioProcessor::updateDSP() 129 | { 130 | for (auto& param : apvtsParameters) { 131 | distortionParameters.set(param->id.getParamID().toStdString(), param->get()); 132 | } 133 | 134 | distortion.update(distortionParameters); 135 | } 136 | 137 | void AttilaAudioProcessor::releaseResources() 138 | { 139 | oversampling.reset(); // Make sure you reset oversampling 140 | } 141 | 142 | #ifndef JucePlugin_PreferredChannelConfigurations 143 | bool AttilaAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const 144 | { 145 | #if JucePlugin_IsMidiEffect 146 | ignoreUnused (layouts); 147 | return true; 148 | #else 149 | // This is the place where you check if the layout is supported. 150 | // In this template code we only support mono or stereo. 151 | // Some plugin hosts, such as certain GarageBand versions, will only 152 | // load plugins that support stereo bus layouts. 153 | if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() 154 | && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) 155 | return false; 156 | 157 | // This checks if the input layout matches the output layout 158 | #if ! JucePlugin_IsSynth 159 | if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) 160 | return false; 161 | #endif 162 | 163 | return true; 164 | #endif 165 | } 166 | #endif 167 | 168 | void AttilaAudioProcessor::processBlock (AudioBuffer& buffer, MidiBuffer& midiMessages) 169 | { 170 | ScopedNoDenormals noDenormals; 171 | auto totalNumInputChannels = getTotalNumInputChannels(); 172 | auto totalNumOutputChannels = getTotalNumOutputChannels(); 173 | 174 | for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) 175 | buffer.clear (i, 0, buffer.getNumSamples()); 176 | 177 | bool expected = true; 178 | 179 | if (isNonRealtime() || parametersChanged.compare_exchange_strong(expected, false)) { 180 | updateDSP(); 181 | } 182 | 183 | dsp::AudioBlock block(buffer); 184 | auto oversampledBlock = oversampling.processSamplesUp(block); 185 | 186 | float* outputBuffers[2] = { nullptr, nullptr }; 187 | outputBuffers[0] = oversampledBlock.getChannelPointer(0); 188 | if (totalNumOutputChannels > 1) outputBuffers[1] = oversampledBlock.getChannelPointer(1); 189 | 190 | distortion.processBlock( 191 | outputBuffers, 192 | buffer.getNumChannels(), 193 | oversampledBlock.getNumSamples() 194 | ); 195 | 196 | oversampling.processSamplesDown(block); 197 | 198 | auto maxL = 0.0f, maxR = 0.0f; 199 | 200 | for (int s = 0; s < buffer.getNumSamples(); ++s) { 201 | auto sample = block.getChannelPointer(0)[s]; 202 | maxL = std::max(maxL, block.getChannelPointer(0)[s]); 203 | spectrumAnalyzer.pushNextSampleIntoFifo(sample); 204 | 205 | if (buffer.getNumChannels() > 1) { 206 | maxR = std::max(maxR, block.getChannelPointer(1)[s]); 207 | } 208 | } 209 | 210 | levelL.store(maxL); 211 | levelR.store(maxR); 212 | 213 | } 214 | 215 | //============================================================================== 216 | bool AttilaAudioProcessor::hasEditor() const 217 | { 218 | return true; // (change this to false if you choose to not supply an editor) 219 | } 220 | 221 | AudioProcessorEditor* AttilaAudioProcessor::createEditor() 222 | { 223 | return new AttilaAudioProcessorEditor (*this); 224 | //return new GenericAudioProcessorEditor(*this); 225 | } 226 | 227 | 228 | void AttilaAudioProcessor::getStateInformation(MemoryBlock& destData) 229 | { 230 | copyXmlToBinary(*apvts.copyState().createXml(), destData); 231 | } 232 | 233 | void AttilaAudioProcessor::setStateInformation(const void* data, int sizeInBytes) 234 | { 235 | std::unique_ptr xml(getXmlFromBinary(data, sizeInBytes)); 236 | if (xml.get() != nullptr && xml->hasTagName(apvts.state.getType())) { 237 | apvts.replaceState(ValueTree::fromXml(*xml)); 238 | parametersChanged.store(true); 239 | } 240 | } 241 | 242 | 243 | //============================================================================== 244 | // This creates new instances of the plugin.. 245 | AudioProcessor* JUCE_CALLTYPE createPluginFilter() 246 | { 247 | return new AttilaAudioProcessor(); 248 | } 249 | 250 | AudioProcessorValueTreeState::ParameterLayout AttilaAudioProcessor::createParameterLayout() 251 | { 252 | AudioProcessorValueTreeState::ParameterLayout layout; 253 | 254 | auto dbStringFromValue = [](float value, int) { return String(value) + " dB"; }; 255 | auto truncateDecimals = [](float value, int) { return String(value, 2); }; 256 | auto percentStringFromValue = [](float value, int) { 257 | return value > 0.0f ? String(value, 1) + " %" : "OFF"; 258 | }; 259 | auto hzStringFromValue = [](float value, int) { return String(value) + " Hz"; }; 260 | 261 | layout.add(std::make_unique ( 262 | apvtsParameters[ParameterNames::INPUT_GAIN_1]->id, 263 | apvtsParameters[ParameterNames::INPUT_GAIN_1]->displayValue, 264 | NormalisableRange{ MIN_DB, MAX_DB, 0.02f }, 265 | apvtsParameters[ParameterNames::INPUT_GAIN_1]->getDefault(), 266 | AudioParameterFloatAttributes().withStringFromValueFunction(dbStringFromValue) 267 | )); 268 | 269 | layout.add(std::make_unique ( 270 | apvtsParameters[ParameterNames::OUTPUT_GAIN_1]->id, 271 | apvtsParameters[ParameterNames::OUTPUT_GAIN_1]->displayValue, 272 | NormalisableRange{ MIN_DB, MAX_DB, 0.02f }, 273 | apvtsParameters[ParameterNames::OUTPUT_GAIN_1]->getDefault(), 274 | AudioParameterFloatAttributes().withStringFromValueFunction(dbStringFromValue) 275 | )); 276 | 277 | layout.add(std::make_unique ( 278 | apvtsParameters[ParameterNames::DRIVE_1]->id, 279 | apvtsParameters[ParameterNames::DRIVE_1]->displayValue, 280 | NormalisableRange{ 0.0f, 36.0f, 0.01f }, 281 | apvtsParameters[ParameterNames::DRIVE_1]->getDefault(), 282 | AudioParameterFloatAttributes().withStringFromValueFunction(dbStringFromValue) 283 | )); 284 | 285 | layout.add(std::make_unique ( 286 | apvtsParameters[ParameterNames::KNEE_1]->id, 287 | apvtsParameters[ParameterNames::KNEE_1]->displayValue, 288 | NormalisableRange{ 1.0f, MAX_KNEE, 0.01f }, 289 | apvtsParameters[ParameterNames::KNEE_1]->getDefault(), 290 | AudioParameterFloatAttributes().withStringFromValueFunction(truncateDecimals) 291 | )); 292 | 293 | layout.add(std::make_unique ( 294 | apvtsParameters[ParameterNames::BIT_1]->id, 295 | apvtsParameters[ParameterNames::BIT_1]->displayValue, 296 | 1, 32, 297 | apvtsParameters[ParameterNames::BIT_1]->getDefault() 298 | )); 299 | 300 | layout.add(std::make_unique ( 301 | apvtsParameters[ParameterNames::BYPASS_1]->id, 302 | apvtsParameters[ParameterNames::BYPASS_1]->displayValue, 303 | apvtsParameters[ParameterNames::BYPASS_1]->getDefault() 304 | )); 305 | 306 | layout.add(std::make_unique ( 307 | apvtsParameters[ParameterNames::INPUT_GAIN_2]->id, 308 | apvtsParameters[ParameterNames::INPUT_GAIN_2]->displayValue, 309 | NormalisableRange{ MIN_DB, MAX_DB, 1.0f }, 310 | apvtsParameters[ParameterNames::INPUT_GAIN_2]->getDefault(), 311 | AudioParameterFloatAttributes().withStringFromValueFunction(dbStringFromValue) 312 | )); 313 | 314 | layout.add(std::make_unique ( 315 | apvtsParameters[ParameterNames::OUTPUT_GAIN_2]->id, 316 | apvtsParameters[ParameterNames::OUTPUT_GAIN_2]->displayValue, 317 | NormalisableRange{ MIN_DB, MAX_DB, 1.0f }, 318 | apvtsParameters[ParameterNames::OUTPUT_GAIN_2]->getDefault(), 319 | AudioParameterFloatAttributes().withStringFromValueFunction(dbStringFromValue) 320 | )); 321 | 322 | layout.add(std::make_unique ( 323 | apvtsParameters[ParameterNames::DRIVE_2]->id, 324 | apvtsParameters[ParameterNames::DRIVE_2]->displayValue, 325 | NormalisableRange{ 0.0f, 36.0f, 0.01f }, 326 | apvtsParameters[ParameterNames::DRIVE_2]->getDefault(), 327 | AudioParameterFloatAttributes().withStringFromValueFunction(dbStringFromValue) 328 | )); 329 | 330 | layout.add(std::make_unique ( 331 | apvtsParameters[ParameterNames::KNEE_2]->id, 332 | apvtsParameters[ParameterNames::KNEE_2]->displayValue, 333 | NormalisableRange{ 1.0f, MAX_KNEE, 0.001f }, 334 | apvtsParameters[ParameterNames::KNEE_2]->getDefault(), 335 | AudioParameterFloatAttributes().withStringFromValueFunction(truncateDecimals) 336 | 337 | )); 338 | 339 | layout.add(std::make_unique ( 340 | apvtsParameters[ParameterNames::BIT_2]->id, 341 | apvtsParameters[ParameterNames::BIT_2]->displayValue, 342 | 1, 32, 343 | apvtsParameters[ParameterNames::BIT_2]->getDefault() 344 | )); 345 | 346 | layout.add(std::make_unique ( 347 | apvtsParameters[ParameterNames::BYPASS_2]->id, 348 | apvtsParameters[ParameterNames::BYPASS_2]->displayValue, 349 | apvtsParameters[ParameterNames::BYPASS_2]->getDefault() 350 | )); 351 | 352 | 353 | layout.add(std::make_unique ( 354 | apvtsParameters[ParameterNames::INPUT_GAIN_3]->id, 355 | apvtsParameters[ParameterNames::INPUT_GAIN_3]->displayValue, 356 | NormalisableRange{ MIN_DB, MAX_DB, 1.0f }, 357 | apvtsParameters[ParameterNames::INPUT_GAIN_3]->getDefault(), 358 | AudioParameterFloatAttributes().withStringFromValueFunction(dbStringFromValue) 359 | )); 360 | 361 | layout.add(std::make_unique ( 362 | apvtsParameters[ParameterNames::OUTPUT_GAIN_3]->id, 363 | apvtsParameters[ParameterNames::OUTPUT_GAIN_3]->displayValue, 364 | NormalisableRange{ MIN_DB, MAX_DB, 1.0f }, 365 | apvtsParameters[ParameterNames::OUTPUT_GAIN_3]->getDefault(), 366 | AudioParameterFloatAttributes().withStringFromValueFunction(dbStringFromValue) 367 | )); 368 | 369 | layout.add(std::make_unique ( 370 | apvtsParameters[ParameterNames::DRIVE_3]->id, 371 | apvtsParameters[ParameterNames::DRIVE_3]->displayValue, 372 | NormalisableRange{ 0.0f, 36.0f, 0.01f }, 373 | apvtsParameters[ParameterNames::DRIVE_3]->getDefault(), 374 | AudioParameterFloatAttributes().withStringFromValueFunction(dbStringFromValue) 375 | )); 376 | 377 | layout.add(std::make_unique ( 378 | apvtsParameters[ParameterNames::KNEE_3]->id, 379 | apvtsParameters[ParameterNames::KNEE_3]->displayValue, 380 | NormalisableRange{ 1.0f, MAX_KNEE, 0.001f }, 381 | apvtsParameters[ParameterNames::KNEE_3]->getDefault(), 382 | AudioParameterFloatAttributes().withStringFromValueFunction(truncateDecimals) 383 | 384 | )); 385 | 386 | layout.add(std::make_unique ( 387 | apvtsParameters[ParameterNames::BIT_3]->id, 388 | apvtsParameters[ParameterNames::BIT_3]->displayValue, 389 | 1, 32, 390 | apvtsParameters[ParameterNames::BIT_3]->getDefault() 391 | )); 392 | 393 | layout.add(std::make_unique ( 394 | apvtsParameters[ParameterNames::BYPASS_3]->id, 395 | apvtsParameters[ParameterNames::BYPASS_3]->displayValue, 396 | apvtsParameters[ParameterNames::BYPASS_3]->getDefault() 397 | )); 398 | 399 | layout.add(std::make_unique ( 400 | apvtsParameters[ParameterNames::MIX]->id, 401 | apvtsParameters[ParameterNames::MIX]->displayValue, 402 | NormalisableRange{ 0.0f, 100.0f, 0.01f }, 403 | apvtsParameters[ParameterNames::MIX]->getDefault(), 404 | AudioParameterFloatAttributes().withStringFromValueFunction(percentStringFromValue) 405 | )); 406 | 407 | layout.add(std::make_unique ( 408 | apvtsParameters[ParameterNames::INPUT_GLOBAL]->id, 409 | apvtsParameters[ParameterNames::INPUT_GLOBAL]->displayValue, 410 | NormalisableRange{ MIN_DB, MAX_DB, 1.0f }, 411 | apvtsParameters[ParameterNames::INPUT_GLOBAL]->getDefault(), 412 | AudioParameterFloatAttributes().withStringFromValueFunction(dbStringFromValue) 413 | )); 414 | 415 | layout.add(std::make_unique ( 416 | apvtsParameters[ParameterNames::OUTPUT_GLOBAL]->id, 417 | apvtsParameters[ParameterNames::OUTPUT_GLOBAL]->displayValue, 418 | NormalisableRange{ MIN_DB, MAX_DB, 1.0f }, 419 | apvtsParameters[ParameterNames::OUTPUT_GLOBAL]->getDefault(), 420 | AudioParameterFloatAttributes().withStringFromValueFunction(dbStringFromValue) 421 | )); 422 | 423 | layout.add(std::make_unique ( 424 | apvtsParameters[ParameterNames::BYPASS]->id, 425 | apvtsParameters[ParameterNames::BYPASS]->displayValue, 426 | apvtsParameters[ParameterNames::BYPASS]->getDefault() 427 | )); 428 | 429 | layout.add(std::make_unique ( 430 | apvtsParameters[ParameterNames::LOW_MID_CUT]->id, 431 | apvtsParameters[ParameterNames::LOW_MID_CUT]->displayValue, 432 | NormalisableRange{ 20.0f, 20000.0f, 1.0f, 0.3f }, 433 | apvtsParameters[ParameterNames::LOW_MID_CUT]->getDefault(), 434 | AudioParameterFloatAttributes().withStringFromValueFunction(hzStringFromValue) 435 | )); 436 | 437 | layout.add(std::make_unique ( 438 | apvtsParameters[ParameterNames::MID_HIGH_CUT]->id, 439 | apvtsParameters[ParameterNames::MID_HIGH_CUT]->displayValue, 440 | NormalisableRange{ 20.0f, 20000.0f, 1.0f, 0.3f }, 441 | apvtsParameters[ParameterNames::MID_HIGH_CUT]->getDefault(), 442 | AudioParameterFloatAttributes().withStringFromValueFunction(hzStringFromValue) 443 | )); 444 | 445 | return layout; 446 | } 447 | 448 | -------------------------------------------------------------------------------- /Source/PluginProcessor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | using std::vector; 9 | using std::array; 10 | using std::unordered_map; 11 | 12 | #include "DSPParameters.h" 13 | #include "MultibandDistortion.h" 14 | #include "APVTSParameter.h" 15 | #include "PresetManager.h" 16 | #include "SpectrumAnalyzer.h" 17 | 18 | #define MIN_DB -60.0f 19 | #define MAX_DB 6.0f 20 | #define MAX_KNEE 24.0f 21 | 22 | 23 | enum ParameterNames{ 24 | INPUT_GAIN_1, OUTPUT_GAIN_1, 25 | DRIVE_1, KNEE_1, 26 | BIT_1, 27 | BYPASS_1, 28 | 29 | INPUT_GAIN_2, OUTPUT_GAIN_2, 30 | DRIVE_2, KNEE_2, 31 | BIT_2, 32 | BYPASS_2, 33 | 34 | INPUT_GAIN_3, OUTPUT_GAIN_3, 35 | DRIVE_3, KNEE_3, 36 | BIT_3, 37 | BYPASS_3, 38 | 39 | MIX, 40 | INPUT_GLOBAL, OUTPUT_GLOBAL, 41 | BYPASS, 42 | 43 | LOW_MID_CUT, MID_HIGH_CUT, 44 | PARAMETER_COUNT 45 | }; 46 | 47 | static std::array, ParameterNames::PARAMETER_COUNT> apvtsParameters{ 48 | std::make_unique ("inputGain1", "in gain", 0.0f), 49 | std::make_unique ("outputGain1", "out gain", 0.0f), 50 | std::make_unique ("drive1", "drive", 0.0f), 51 | std::make_unique ("knee1", "knee", 1.0f), 52 | std::make_unique ("bit1", "bit", 32), 53 | std::make_unique ("bypass1", "LOW", false), 54 | std::make_unique ("inputGain2", "in gain", 0.0f), 55 | std::make_unique ("outputGain2", "out gain", 0.0f), 56 | std::make_unique ("drive2", "drive", 0.0f), 57 | std::make_unique ("knee2", "knee", 1.0f), 58 | std::make_unique ("bit2", "bit", 32), 59 | std::make_unique ("bypass2", "MID", false), 60 | std::make_unique ("inputGain3", "in gain", 0.0f), 61 | std::make_unique ("outputGain3", "out gain", 0.0f), 62 | std::make_unique ("drive3", "drive", 0.0f), 63 | std::make_unique ("knee3", "knee", 1.0f), 64 | std::make_unique ("bit3", "bit", 32), 65 | std::make_unique ("bypass3", "HIGH", false), 66 | std::make_unique ("mix", "mix", 100.0f), 67 | std::make_unique ("inputGain", "input", 0.0f), 68 | std::make_unique ("outputGain", "output", 0.0f), 69 | std::make_unique ("bypass", "bypass", false), 70 | std::make_unique ("lowMidCut", "Low/Mid Cut", 440.0f), 71 | std::make_unique ("midHighCut", "Mid/high Cut", 5000.0f) 72 | }; 73 | 74 | class AttilaAudioProcessor : 75 | public juce::AudioProcessor, 76 | public ValueTree::Listener 77 | { 78 | public: 79 | //============================================================================== 80 | AttilaAudioProcessor(); 81 | ~AttilaAudioProcessor() override; 82 | 83 | //============================================================================== 84 | void prepareToPlay (double sampleRate, int samplesPerBlock) override; 85 | void releaseResources() override; 86 | 87 | #ifndef JucePlugin_PreferredChannelConfigurations 88 | bool isBusesLayoutSupported (const BusesLayout& layouts) const override; 89 | #endif 90 | 91 | void processBlock (juce::AudioBuffer&, juce::MidiBuffer&) override; 92 | 93 | //============================================================================== 94 | juce::AudioProcessorEditor* createEditor() override; 95 | bool hasEditor() const override; 96 | 97 | //============================================================================== 98 | const juce::String getName() const override; 99 | 100 | bool acceptsMidi() const override; 101 | bool producesMidi() const override; 102 | bool isMidiEffect() const override; 103 | double getTailLengthSeconds() const override; 104 | 105 | //============================================================================== 106 | int getNumPrograms() override; 107 | int getCurrentProgram() override; 108 | void setCurrentProgram (int index) override; 109 | const juce::String getProgramName (int index) override; 110 | void changeProgramName (int index, const juce::String& newName) override; 111 | 112 | //============================================================================== 113 | void getStateInformation (juce::MemoryBlock& destData) override; 114 | void setStateInformation (const void* data, int sizeInBytes) override; 115 | 116 | AudioProcessorValueTreeState apvts; 117 | PresetManager& getPresetManager() { return *presetManager; } 118 | SpectrumAnalyzer spectrumAnalyzer; 119 | 120 | // Used for meters 121 | std::atomic levelL, levelR; 122 | 123 | 124 | private: 125 | //============================================================================== 126 | AudioProcessorValueTreeState::ParameterLayout createParameterLayout(); 127 | 128 | std::atomic parametersChanged{ false }; 129 | 130 | void valueTreePropertyChanged(ValueTree&, const Identifier&) override { 131 | parametersChanged.store(true); 132 | } 133 | 134 | void updateDSP(); 135 | DSPParameters distortionParameters; 136 | 137 | MultibandDistortion distortion; 138 | 139 | size_t oversampleFactor = 2; 140 | dsp::Oversampling oversampling{ 2, oversampleFactor, juce::dsp::Oversampling::filterHalfBandPolyphaseIIR, false}; 141 | 142 | std::unique_ptrpresetManager; 143 | 144 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AttilaAudioProcessor) 145 | }; 146 | -------------------------------------------------------------------------------- /Source/PresetManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class PresetManager : juce::ValueTree::Listener 6 | { 7 | public: 8 | const juce::File defaultDir{ juce::File::getSpecialLocation( 9 | PRESET_FOLDER) 10 | .getChildFile(ProjectInfo::companyName) 11 | .getChildFile(ProjectInfo::projectName) }; 12 | 13 | 14 | const juce::String ext{ "spchili" }; 15 | const juce::String presetNameProperty{ "presetName" }; 16 | 17 | PresetManager(juce::AudioProcessorValueTreeState& state) : apvts(state) { 18 | if (!defaultDir.exists()) { 19 | const auto hasCreatedDirectory = defaultDir.createDirectory(); 20 | if (hasCreatedDirectory.failed()) { 21 | DBG("Could not create directory: " + hasCreatedDirectory.getErrorMessage()); 22 | jassertfalse; 23 | } 24 | } 25 | 26 | apvts.state.addListener(this); 27 | current = apvts.state.getPropertyAsValue("presetName", nullptr).toString(); 28 | 29 | // The program will crash if we get a preset from a saved state that has been deleted. 30 | // In that case, just assing current to an empty preset. 31 | auto srcFile = defaultDir.getChildFile(current + "." + ext); 32 | if (!srcFile.existsAsFile()) { 33 | current = ""; 34 | } 35 | } 36 | 37 | void savePreset(const juce::String& name) { 38 | if (name.isEmpty()) return; 39 | 40 | current = name; 41 | const auto xml = apvts.copyState().createXml(); 42 | auto destFile = defaultDir.getChildFile(name + "." + ext); 43 | if (!xml->writeTo(destFile)) { 44 | DBG("Could not create preset: " + destFile.getFullPathName()); 45 | jassertfalse; 46 | } 47 | 48 | } 49 | 50 | void deletePreset(const juce::String& name) { 51 | if (name.isEmpty()) return; 52 | 53 | auto srcFile = defaultDir.getChildFile(name + "." + ext); 54 | if (!srcFile.existsAsFile()) { 55 | DBG("Could not open file: " + srcFile.getFullPathName()); 56 | jassertfalse; 57 | } 58 | if (!srcFile.deleteFile()) { 59 | DBG("Could not delete file: " + srcFile.getFullPathName()); 60 | jassertfalse; 61 | } 62 | current = ""; 63 | } 64 | void loadPreset(const juce::String& name) { 65 | if (name.isEmpty()) return; 66 | 67 | auto srcFile = defaultDir.getChildFile(name + "." + ext); 68 | if (!srcFile.existsAsFile()) { 69 | DBG("Could not open file: " + srcFile.getFullPathName()); 70 | jassertfalse; 71 | } 72 | 73 | juce::XmlDocument xmlDocument{ srcFile }; 74 | const auto newValueTree = juce::ValueTree::fromXml(*xmlDocument.getDocumentElement()); 75 | 76 | apvts.replaceState(newValueTree); 77 | current = name; 78 | } 79 | int next() { 80 | const auto allPresets = getPresetList(); 81 | if (allPresets.isEmpty()) return -1; 82 | const auto currentIndex = allPresets.indexOf(current); 83 | const auto nextIndex = (currentIndex + 1) % allPresets.size(); 84 | loadPreset(allPresets.getReference(nextIndex)); 85 | return nextIndex; 86 | } 87 | int prev() { 88 | const auto allPresets = getPresetList(); 89 | if (allPresets.isEmpty()) return -1; 90 | const auto currentIndex = allPresets.indexOf(current); 91 | const auto prevIndex = currentIndex - 1 < 0 ? allPresets.size() - 1 : currentIndex - 1; 92 | loadPreset(allPresets.getReference(prevIndex)); 93 | return prevIndex; 94 | } 95 | 96 | juce::StringArray getPresetList() const { 97 | juce::StringArray presets; 98 | const auto files = defaultDir.findChildFiles(juce::File::TypesOfFileToFind::findFiles, false, "*." + ext); 99 | for (const auto& file : files) { 100 | presets.add(file.getFileNameWithoutExtension()); 101 | } 102 | return presets; 103 | } 104 | juce::String getCurrent() const { 105 | return current; 106 | } 107 | 108 | private: 109 | void valueTreeRedirected(juce::ValueTree& tree) override { 110 | current = tree.getPropertyAsValue("presetName", nullptr).toString(); 111 | auto srcFile = defaultDir.getChildFile(current + "." + ext); 112 | if (!srcFile.existsAsFile()) { 113 | current = ""; 114 | } 115 | } 116 | 117 | juce::AudioProcessorValueTreeState& apvts; 118 | juce::String current; 119 | }; 120 | -------------------------------------------------------------------------------- /Source/SpectrumAnalyzer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Utils.h" 5 | #include "LookAndFeel.h" 6 | 7 | class SpectrumAnalyzer : public Component, private Timer 8 | { 9 | enum FFTParams { 10 | FFT_ORDER = 11, 11 | FFT_SIZE = 1 << FFT_ORDER, 12 | SCOPE_SIZE = 2048 13 | }; 14 | 15 | dsp::FFT forwardFFT; 16 | dsp::WindowingFunction window; 17 | 18 | array fftData{}; 19 | array prev{}; 20 | array scopeData{}; 21 | array fifo{}; 22 | int fifoIndex{}; 23 | bool nextFFTBlockReady{ false }; 24 | 25 | float decay{}; 26 | int refreshRate{ 60 }; 27 | float sampleRate; 28 | 29 | Path fftPath; 30 | float drive1{}; 31 | float drive2{}; 32 | float drive3{}; 33 | 34 | public: 35 | float lowMidCut{}; 36 | float midHighCut{}; 37 | 38 | 39 | SpectrumAnalyzer(float sr, float lm, float mh) 40 | : sampleRate(sr), forwardFFT(FFTParams::FFT_ORDER), window(FFTParams::FFT_SIZE, dsp::WindowingFunction::hann), 41 | lowMidCut(lm) , midHighCut(mh) 42 | { 43 | startTimerHz(refreshRate); 44 | decay = 1.0f - std::exp(-1.0f / (float(refreshRate) * 0.2f)); 45 | 46 | } 47 | 48 | ~SpectrumAnalyzer() {} 49 | 50 | void pushNextSampleIntoFifo(float sample) noexcept { 51 | if (fifoIndex == FFTParams::FFT_SIZE) { 52 | if (!nextFFTBlockReady) { 53 | std::copy_n(fifo.begin(), fifo.size(), fftData.begin()); 54 | nextFFTBlockReady = true; 55 | } 56 | 57 | fifoIndex = 0; 58 | } 59 | 60 | fifo[fifoIndex++] = sample; 61 | } 62 | 63 | void setSampleRate(float sr) { 64 | sampleRate = sr; 65 | } 66 | 67 | void updateDriveValues(float d1, float d2, float d3) { 68 | drive1 = d1; 69 | drive2 = d2; 70 | drive3 = d3; 71 | } 72 | 73 | void getNextFFTData() { 74 | window.multiplyWithWindowingTable(fftData.data(), FFTParams::FFT_SIZE); 75 | forwardFFT.performFrequencyOnlyForwardTransform(fftData.data()); 76 | } 77 | 78 | void timerCallback() override { 79 | if (nextFFTBlockReady) { 80 | getNextFFTData(); 81 | nextFFTBlockReady = false; 82 | repaint(); 83 | } 84 | } 85 | 86 | void paint(Graphics& g) override { 87 | auto bounds = getLocalBounds().reduced(2.0f); 88 | auto top = bounds.getY(); 89 | auto bottom = bounds.getHeight() + top; 90 | auto width = bounds.getWidth(); 91 | auto height = bounds.getHeight(); 92 | 93 | int lowMidPos = mapFromLog10(lowMidCut, 20.f, 20000.f) * width; 94 | int midHighPos = mapFromLog10(midHighCut, 20.f, 20000.f) * width; 95 | 96 | g.setColour(Colors::black); 97 | g.fillRoundedRectangle(bounds.toFloat(), 5); 98 | 99 | g.setColour(Colors::grey); 100 | g.drawRoundedRectangle(bounds.toFloat(), 5, 3.0f); 101 | 102 | drawFrame(g); 103 | 104 | 105 | if (drive1 > 0.0f) { 106 | auto bandArea = Rectangle(bounds.getX(), bottom - drive1 * height, lowMidPos, height * drive1); 107 | g.setColour(Colors::red.withAlpha(0.3f * drive1)); 108 | g.fillRect(bandArea); 109 | g.setColour(Colors::red); 110 | g.fillRect(bandArea.withHeight(3)); 111 | } 112 | 113 | if (drive2 > 0.0f) { 114 | auto bandArea = Rectangle(lowMidPos, bottom - drive2 * height, midHighPos - lowMidPos, height * drive2); 115 | g.setColour(Colors::yellow.withAlpha(0.3f * drive2)); 116 | g.fillRect(bandArea); 117 | g.setColour(Colors::yellow); 118 | g.fillRect(bandArea.withHeight(3)); 119 | } 120 | 121 | if (drive3 > 0.0f) { 122 | auto bandArea = Rectangle(midHighPos, bottom - drive3 * height, lowMidPos, height * drive3); 123 | g.setColour(Colors::green.withAlpha(0.3f * drive3)); 124 | g.fillRect(bandArea); 125 | g.setColour(Colors::green); 126 | g.fillRect(bandArea.withHeight(3)); 127 | } 128 | 129 | g.setColour(Colors::cream); 130 | g.fillRect(lowMidPos, bounds.getY(), 3, bounds.getHeight()); 131 | g.fillRect(midHighPos, bounds.getY(), 3, bounds.getHeight()); 132 | } 133 | 134 | void drawFrame(Graphics& g) { 135 | auto bounds = getLocalBounds(); 136 | auto width = bounds.getWidth(); 137 | auto height = bounds.getHeight(); 138 | auto top = bounds.getY(); 139 | auto minDb = -60.0f; 140 | auto maxDb = 6.0f; 141 | 142 | const auto binW = sampleRate / FFTParams::FFT_SIZE; 143 | const auto bins = FFTParams::FFT_SIZE * 0.5f; 144 | 145 | Path spectrumPath; 146 | spectrumPath.preallocateSpace(3 * width); 147 | 148 | float y = top + height; 149 | 150 | float lastX = 0.0f; 151 | float lastY = y; 152 | spectrumPath.startNewSubPath(0, y); 153 | 154 | for (int i = 1; i < bins; ++i) { 155 | if (fftData[i] > prev[i]) prev[i] = fftData[i]; 156 | else prev[i] += (fftData[i] - prev[i]) * decay; 157 | 158 | auto level = prev[i]; 159 | 160 | auto levelDb = linearToDb(level) - linearToDb(float(FFTParams::FFT_SIZE)); 161 | auto y = jmap(levelDb, minDb, 6.f, float(top + height), float(top)); 162 | 163 | if (!std::isnan(y) && !std::isinf(y)) { 164 | auto freq = i * binW; 165 | auto x = mapFromLog10(freq, 20.f, 20000.f) * width; 166 | 167 | if (i > 1) { 168 | float midX = (lastX + x) * 0.5f; 169 | float midY = (lastY + y) * 0.5f; 170 | 171 | spectrumPath.quadraticTo(lastX, lastY, midX, midY); 172 | } 173 | 174 | lastX = x; 175 | lastY = y; 176 | } 177 | } 178 | 179 | spectrumPath.lineTo(lastX, float(top + height)); 180 | 181 | g.setColour(Colors::cream.withAlpha(0.3f)); 182 | g.fillPath(spectrumPath); 183 | 184 | g.setColour(Colors::cream); 185 | g.strokePath(spectrumPath, PathStrokeType(2.0f, PathStrokeType::curved, PathStrokeType::rounded)); 186 | 187 | } 188 | 189 | }; -------------------------------------------------------------------------------- /Source/Utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | template 7 | inline static void castParameter(AudioProcessorValueTreeState& apvts, 8 | const ParameterID& id, T& destination) 9 | { 10 | destination = dynamic_cast(apvts.getParameter(id.getParamID())); 11 | jassert(destination); 12 | // parameter does not exist or wrong type 13 | } 14 | 15 | inline float linearToDb(float input) { 16 | return 20.0f * log10f(fabsf(input) + 0.000001f); 17 | } 18 | 19 | inline float dbToLinear(float input) { 20 | return powf(10.0f, input / 20.0f); 21 | } 22 | 23 | inline float sign(float x) { 24 | return x < 0.0f ? -1.0f : 1.0f; 25 | } 26 | 27 | // https://www.musicdsp.org/en/latest/Effects/104-variable-hardness-clipping-function.html 28 | 29 | inline float fastatan(float x) 30 | { 31 | return (x / (1.0f + 0.28f * (x * x))); 32 | } -------------------------------------------------------------------------------- /preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glafiro/attila/6e9b03730f410292beab66cc441c3ee0e1a4ece0/preview.png --------------------------------------------------------------------------------