Browse Source

Merge pull request #78 from jpcima/swanky-amp

Add port: SwankyAmp
tags/2021-03-15
Filipe Coelho GitHub 4 years ago
parent
commit
98bf0de20a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
78 changed files with 24574 additions and 0 deletions
  1. +1
    -0
      meson_options.txt
  2. +1
    -0
      ports/meson.build
  3. +674
    -0
      ports/swankyamp/LICENSE
  4. +308
    -0
      ports/swankyamp/README.md
  5. +34
    -0
      ports/swankyamp/meson.build
  6. +94
    -0
      ports/swankyamp/resources/PTSans/OFL.txt
  7. BIN
      ports/swankyamp/resources/PTSans/PTSans-Bold.ttf
  8. BIN
      ports/swankyamp/resources/PTSans/PTSans-Regular.ttf
  9. +94
    -0
      ports/swankyamp/resources/PTSansNarrow/OFL.txt
  10. BIN
      ports/swankyamp/resources/PTSansNarrow/PTSansNarrow-Regular.ttf
  11. +679
    -0
      ports/swankyamp/resources/license.rtf
  12. +99
    -0
      ports/swankyamp/resources/logo.svg
  13. +243
    -0
      ports/swankyamp/resources/presets.xml
  14. +64
    -0
      ports/swankyamp/resources/tooltips.xml
  15. +9871
    -0
      ports/swankyamp/source/BinaryData.cpp
  16. +45
    -0
      ports/swankyamp/source/BinaryData.h
  17. +109
    -0
      ports/swankyamp/source/Components/AmpGroup.cpp
  18. +58
    -0
      ports/swankyamp/source/Components/AmpGroup.h
  19. +104
    -0
      ports/swankyamp/source/Components/CabGroup.cpp
  20. +53
    -0
      ports/swankyamp/source/Components/CabGroup.h
  21. +149
    -0
      ports/swankyamp/source/Components/LevelMeter.cpp
  22. +87
    -0
      ports/swankyamp/source/Components/LevelMeter.h
  23. +139
    -0
      ports/swankyamp/source/Components/LevelsGroup.cpp
  24. +59
    -0
      ports/swankyamp/source/Components/LevelsGroup.h
  25. +109
    -0
      ports/swankyamp/source/Components/ParameterGroup.cpp
  26. +79
    -0
      ports/swankyamp/source/Components/ParameterGroup.h
  27. +91
    -0
      ports/swankyamp/source/Components/PowerAmpGroup.cpp
  28. +50
    -0
      ports/swankyamp/source/Components/PowerAmpGroup.h
  29. +92
    -0
      ports/swankyamp/source/Components/PreAmpGroup.cpp
  30. +50
    -0
      ports/swankyamp/source/Components/PreAmpGroup.h
  31. +135
    -0
      ports/swankyamp/source/Components/PresetGroup.cpp
  32. +70
    -0
      ports/swankyamp/source/Components/PresetGroup.h
  33. +29
    -0
      ports/swankyamp/source/Components/RButton.cpp
  34. +50
    -0
      ports/swankyamp/source/Components/RButton.h
  35. +118
    -0
      ports/swankyamp/source/Components/RSlider.cpp
  36. +93
    -0
      ports/swankyamp/source/Components/RSlider.h
  37. +81
    -0
      ports/swankyamp/source/Components/RSliderLabel.cpp
  38. +60
    -0
      ports/swankyamp/source/Components/RSliderLabel.h
  39. +105
    -0
      ports/swankyamp/source/Components/StagingGroup.cpp
  40. +52
    -0
      ports/swankyamp/source/Components/StagingGroup.h
  41. +101
    -0
      ports/swankyamp/source/Components/ToneStackGroup.cpp
  42. +52
    -0
      ports/swankyamp/source/Components/ToneStackGroup.h
  43. +33
    -0
      ports/swankyamp/source/JuceHeader.h
  44. +52
    -0
      ports/swankyamp/source/JucePluginCharacteristics.h
  45. +0
    -0
      ports/swankyamp/source/NewComponent.cpp
  46. +0
    -0
      ports/swankyamp/source/NewComponent.h
  47. +209
    -0
      ports/swankyamp/source/PluginEditor.cpp
  48. +98
    -0
      ports/swankyamp/source/PluginEditor.h
  49. +484
    -0
      ports/swankyamp/source/PluginProcessor.cpp
  50. +131
    -0
      ports/swankyamp/source/PluginProcessor.h
  51. +629
    -0
      ports/swankyamp/source/PresetManager.cpp
  52. +100
    -0
      ports/swankyamp/source/PresetManager.h
  53. +684
    -0
      ports/swankyamp/source/SwankyAmpLAF.cpp
  54. +89
    -0
      ports/swankyamp/source/SwankyAmpLAF.h
  55. +46
    -0
      ports/swankyamp/source/TooltipsData.cpp
  56. +34
    -0
      ports/swankyamp/source/TooltipsData.h
  57. +161
    -0
      ports/swankyamp/source/Utils.cpp
  58. +195
    -0
      ports/swankyamp/source/Utils.h
  59. +388
    -0
      ports/swankyamp/source/dsp/Cabinet.h
  60. +1198
    -0
      ports/swankyamp/source/dsp/CabinetFaust.h
  61. +79
    -0
      ports/swankyamp/source/dsp/FaustImpl.h
  62. +34
    -0
      ports/swankyamp/source/dsp/Meta.h
  63. +504
    -0
      ports/swankyamp/source/dsp/PushPullAmp.h
  64. +116
    -0
      ports/swankyamp/source/dsp/TetrodeGrid.h
  65. +246
    -0
      ports/swankyamp/source/dsp/TetrodeGridFaust.h
  66. +204
    -0
      ports/swankyamp/source/dsp/TetrodePlate.h
  67. +425
    -0
      ports/swankyamp/source/dsp/TetrodePlateFaust.h
  68. +92
    -0
      ports/swankyamp/source/dsp/ToneStack.h
  69. +84
    -0
      ports/swankyamp/source/dsp/ToneStackF.h
  70. +355
    -0
      ports/swankyamp/source/dsp/ToneStackFFaust.h
  71. +479
    -0
      ports/swankyamp/source/dsp/ToneStackFaust.h
  72. +84
    -0
      ports/swankyamp/source/dsp/ToneStackM.h
  73. +367
    -0
      ports/swankyamp/source/dsp/ToneStackMFaust.h
  74. +260
    -0
      ports/swankyamp/source/dsp/Triode.h
  75. +413
    -0
      ports/swankyamp/source/dsp/TriodeFaust.h
  76. +105
    -0
      ports/swankyamp/source/dsp/UI.h
  77. +23
    -0
      ports/swankyamp/thirdparty/optional-lite/LICENSE.txt
  78. +1791
    -0
      ports/swankyamp/thirdparty/optional-lite/include/nonstd/optional.hpp

+ 1
- 0
meson_options.txt View File

@@ -60,6 +60,7 @@ option('plugins',
'pitchedDelay',
'refine',
'stereosourceseparation',
'swankyamp',
'tal-dub-3',
'tal-filter',
'tal-filter-2',


+ 1
- 0
ports/meson.build View File

@@ -7,6 +7,7 @@ else
plugins = [
'chow',
'vitalium',
'swankyamp',
]
endif



+ 674
- 0
ports/swankyamp/LICENSE View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The GNU General Public License is a free, copyleft license for
software and other kinds of works.

The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.

When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.

Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

The precise terms and conditions for copying, distribution and
modification follow.

TERMS AND CONDITIONS

0. Definitions.

"This License" refers to version 3 of the GNU General Public License.

"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.

To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

A "covered work" means either the unmodified Program or a work based
on the Program.

To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

1. Source Code.

The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.

A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

The Corresponding Source for a work in source code form is that
same work.

2. Basic Permissions.

All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.

3. Protecting Users' Legal Rights From Anti-Circumvention Law.

No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

4. Conveying Verbatim Copies.

You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

5. Conveying Modified Source Versions.

You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.

b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".

c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.

d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.

A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

6. Conveying Non-Source Forms.

You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.

b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.

c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.

d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.

e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.

A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

7. Additional Terms.

"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or

b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or

c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or

d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or

e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or

f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.

All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

8. Termination.

You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

9. Acceptance Not Required for Having Copies.

You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

10. Automatic Licensing of Downstream Recipients.

Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.

An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

11. Patents.

A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".

A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

12. No Surrender of Others' Freedom.

If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

13. Use with the GNU Affero General Public License.

Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

14. Revised Versions of this License.

The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

15. Disclaimer of Warranty.

THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

16. Limitation of Liability.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

17. Interpretation of Sections 15 and 16.

If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.

The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

+ 308
- 0
ports/swankyamp/README.md View File

@@ -0,0 +1,308 @@
# Swanky Amp
Swanky Amp is a tube amplifier simulation DSP plugin which aims to capture the details in the dynamics of tube amplifiers.
You can find the installers on the website:
<https://www.resonantdsp.com/swankyamp/>
![Swanky Amp](https://www.resonantdsp.com/images/swanky-amp.jpg)
## Demo
[![Swanky Amp Demo](https://img.youtube.com/vi/pz3v87VMQfk/0.jpg)](https://www.youtube.com/watch?v=pz3v87VMQfk)
## Usage
Load the plugin into your favorite VST host or DAW (into a mono or stereo track), and have fun!
Hover over a parameter to get a tooltip giving you information on how to use it.
In general, you will want to first gain stage, then set the drive according to your needs, and then fine tune.
## The model
The model was developed by running finite-difference simulation methods (spice), storing the outputs, developing empirical models using a mix of python and C++, and then fitting the model paramters to the simulation results. That code is very experimental and outside the scope of this repository.
Some more information about the process can be found here:
<https://www.resonantdsp.com/blog/tube-emulation/tube-emulation-4.html>
## Building
The DSP is primarily written in [FAUST](https://faust.grame.fr/), whereas the UI is written in C++ using the [JUCE](https://www.juce.com) toolkit.
This repository includes code to:
* Build the VST3 or AAX using Visual Studio 2019
* Build the AU using Xcode
* Create the Windows installer using [WiX](https://wixtoolset.org/)
* Create the Mac installers using a drag-and-drop DMG image.
### For Windows
You will need the following softare to compile the plugin for windows:
* Visual Studio 2019
* The VST3 SDK
* The JUCE SDK
The project is configured assuming the VST3 SDK is found at: `C:\SDKs\VST_SDK\VST3_SDK\`, and that the JUCE SDK is found at `C:\JUCE\modules`. This can be changed in the VS solution files.
* Open the VS solution file at: `Builds\VisualStudio2019\SwankyAmp.sln`
* Change the target in VS to the x64 Release.
* Build the VST3 target.
* Move the VST3 to your VST3 system directory (usually `C:\Program Files\Common Files\VST3`)
To build the installer:
* Move into the `package` directory
* Run `bash build-win.sh` (probably want to do that using WSL)
### For Mac
To build the installer:
* Open the project in Xcode
* Choose the desired solution (VST3 or AU) in the top menu
* Re-open the menu and choose "Edit Scheme"
* Change the build target to "Release"
* From the project room in a terminal:
`bash build-mach.sh`
* When you are prompted to edit the images:
* Mount the images
* Open the mounted images
* Right click in the window, choose "Show View Options"
* Choose the background image (to show hidden files "cmd + shift + .")
* Re-size the window and place the icons appropriately
* Unmount the images and press enter to finish the process
### Testing
Only available with VisualStudio at the moment.
* Open the solution
* Build the `SwanyAmp_SharedCode` project
* Open the `SwankyAmp_Tests` project
* Build the Debug version
* Run `Builds\VisualStudio\x64\Debug\SwankyAmp.exe`
## Change log
Version 1.4.0:
* rework staging in pre-amp: move pre-amp into FAUST and use multiplexing to mix stages
* rework low cut: increase range, add non-linearity
* rework state loading, convert on XML load and avoid making changes to memory in the audio thread (instead use a flag to indicate state changed)
* add vst ID registered with Steinberg to avoid registry problems
* review the plugin state reset and loading to avoid issues
* fix dmg installer issue for older macos releases
Version 1.3.1:
* fix issue where processor thread calls editor and can hang the audio for a bit
* processor sets a flag when the state is changed
* the editor monitors that on a timer
* eventually should implement a better message queue / state system
* fix issue where pre amp drive would go too low and start getting digital artifacts
* improve pre amp drive range mapping
Version 1.3.0:
* re-worked the preset manager to fix issues with re-loading preset names
* added an AC30-like tone stack with mids control
Version 1.2.0:
* re-wokred drive ranges
* re-worked sag slightly
* use sinh transformation to make central range more sensitive
* changed windows installer to MSI
* changes to the layout
Version 1.1.0:
* Added ability to blend the tone stacks
Version 1.0.0:
* add Marshall-like tone stack
* reduce default power amp drive
Version 0.10.2:
* rework sag onset
Version 0.10.1:
* preset name will restore correctly after re-loading the plugin host
* pre amp drive no longer affects the power amp drive
* the power amp drive is easier to tune, and has an improved range
* the sag range has been improved
* the overall level normalization has been improved
Version 0.10.0:
* dynamic cabinet
* cabinet rework
* using a new tone stack provided by Dave Clark
* rework of dsp functionality: each part of the amp is now its own class, compiled in a separate project to the header files
* possibly fixed issue with rumble building up over time
* preset save icon now un-greys when creating a new preset or renaming a preset
* improved version string parsing
Version 0.9.0:
* fix bug that would cause audio level to decrease and vanish over time
* preset management can now be done fully from the directory
* preset names are now picked up from file names
* preset numbers for re-ordering are handled in a more intuitive way
* changing the preset name will now prompt for making a new preset or renaming
* small improvements to pre amp model and filtering
* small stability improvements to pre amp
Version 0.8.1:
* add mac support
Version 0.8.0:
* add variance to pre amp stages
* change preset management to directory sort order
* add button to open preset directory
* new presets are discovered on start
* no need to save preset to preserve order
Version 0.7.3:
* renamed to swanky amp
* allow reordering presets using preset names
* fixed possible issue with preset chaning causing bad state
* fixed issue with saving presets
Version 0.7.2:
* improved preset management: can now re-order, rename and remove presets from a single file `presetMaster.xml`
* added preset navigation buttons
Version 0.7.1:
* added decimal places to knob values when adjusting
* improved knob sensitivity
Version 0.7.0:
* improve filtering
* improve power amp drive and sag
Version 0.6.2:
* add tooltips
Version 0.6.1:
* fix multiple issues with preset management
Version 0.6.0:
* imporved preset management: save and remove icons, icons are disabled when the action is unavailable
* added version number to the bottom right of the UI
Version 0.5.3:
* tweaked sag ranged based on power amp drive to get more steady level
* tweaked presets accordingly
Version 0.5.2:
* fix pre amp drive calibration so that it doesn't get louder at higher levels
* updated presets to accomodate change
Version 0.5.1:
* modify tone stack so that the upper lows stay cut when mids change
* additional mids boost is now narrower
Version 0.5.0:
* preset management
* reworked sag model
* imporved high gain behaviour
* minor pass on the UI
Version 0.4.2:
* Reworked the sag parameter range to increase useable range and allow finer control
* Moved the `filter` control from the Staging section to the Pre Amp section and renamed it `low cut` to make it more intuitive
Version 0.4.1:
* The pre amp tight control is now easier to work with as it automatically adjusts based on pre amp drive to a suitable value
* Likewise for the sag control, based on the power amp drive.
Version 0.4.0:
* Introduced voltage sag
* Small changes to the default power amp model to accomodate the voltage sag
* Overall the new power amp model is a better representation of the underlying amp
Version 0.3.0:
* New cabinet model is a more accurate depiction of a 4x12 cabinet into a dynamic mic.
* New cabinet controls to get more variation out of the final sound.
* Touch controls re-wired into tight controls.
Version 0.2.1:
* Added some texturing to the dials and buttons
* Technical changes to support further UI developement
Version 0.2.0:
* Add grit control to pre amp
Version 0.1.0:
* Built a proper UI
* Improved the parameter ranges, especially the drive
* Simplified the drive tone control
* Reduced the mids control slightly
Version 0.0.6:
* Rework the power amp again, capture slow dynamics
* In particular capturing bias drift contributing to distorted compression
* Improvements transfered over also to the pre amp section
* Some of the dsp code was streamlined to be more efficient
Version 0.0.5:
* Reworked tone stack to behave more like a normal amp
* Don't normalize tone stack levels (pushing up levels will increase distortion)
Version 0.0.4:
* Stability fixes
* Minor tweaks to power amp model
* Improvement to the pre amp model
Version 0.0.3:
* Added a parameter smooth cross over distortion
* Adjusted drive range for less spinal tap level 11
* Fixed issue with gain stage parameter not working as intended
Version 0.0.2:
* The power amplifier model is re-written and is a better representation of the simulation.
* The perceived volume of the plugin is more invariant to changes in the drive parameters.
* All model fits have been improved, default parameters should better ressemble the simulated circuits.
* Parameter ranges have been refined to give better control over the distortion sound.
* The cabinet mix has been made into a toggle for clarity.
## JUCE usage in code
* Following the JUCE guidelines loosely, with the notable change that the code uses tabs specifically to avoid visual indentation.
* Components should have sensible defaults so that a default conctructor can be provided, otherwise the no copy convention causes problems.
* The Look and Feel (LAF) contains defintions that can change on-the-fly (mainly colours). Default dimensions should be defined in component classes, as those don't need to be looked-up at each paint call.

+ 34
- 0
ports/swankyamp/meson.build View File

@@ -0,0 +1,34 @@
###############################################################################

plugin_extra_include_dirs = include_directories([
'source',
'thirdparty/optional-lite/include',
])

plugin_srcs = files([
'source/BinaryData.cpp',
'source/NewComponent.cpp',
'source/PluginEditor.cpp',
'source/PluginProcessor.cpp',
'source/PresetManager.cpp',
'source/SwankyAmpLAF.cpp',
'source/TooltipsData.cpp',
'source/Utils.cpp',
'source/Components/AmpGroup.cpp',
'source/Components/CabGroup.cpp',
'source/Components/LevelMeter.cpp',
'source/Components/LevelsGroup.cpp',
'source/Components/ParameterGroup.cpp',
'source/Components/PowerAmpGroup.cpp',
'source/Components/PreAmpGroup.cpp',
'source/Components/PresetGroup.cpp',
'source/Components/RButton.cpp',
'source/Components/RSlider.cpp',
'source/Components/RSliderLabel.cpp',
'source/Components/StagingGroup.cpp',
'source/Components/ToneStackGroup.cpp',
])

plugin_name = 'SwankyAmp'

###############################################################################

+ 94
- 0
ports/swankyamp/resources/PTSans/OFL.txt View File

@@ -0,0 +1,94 @@
Copyright (c) 2010, ParaType Ltd. (http://www.paratype.com/public),
with Reserved Font Names "PT Sans" and "ParaType".
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

BIN
ports/swankyamp/resources/PTSans/PTSans-Bold.ttf View File


BIN
ports/swankyamp/resources/PTSans/PTSans-Regular.ttf View File


+ 94
- 0
ports/swankyamp/resources/PTSansNarrow/OFL.txt View File

@@ -0,0 +1,94 @@
Copyright (c) 2010, ParaType Ltd. (http://www.paratype.com/public),
with Reserved Font Names "PT Sans" and "ParaType".
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

BIN
ports/swankyamp/resources/PTSansNarrow/PTSansNarrow-Regular.ttf View File


+ 679
- 0
ports/swankyamp/resources/license.rtf View File

@@ -0,0 +1,679 @@
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang2057{\fonttbl{\f0\fnil\fcharset0 Consolas;}}
{\colortbl ;\red0\green0\blue255;}
{\*\generator Riched20 10.0.19041}\viewkind4\uc1
\pard\sa200\sl240\slmult1\f0\fs20\lang9 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
\par
Copyright (C) 2007 Free Software Foundation, Inc. <{{\field{\*\fldinst{HYPERLINK "https://fsf.org/"}}{\fldrslt{https://fsf.org/\ul0\cf0}}}}\f0\fs20 >
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
\par
Preamble
\par
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
\par
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
\par
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
\par
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
\par
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
\par
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
\par
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
\par
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
\par
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
\par
The precise terms and conditions for copying, distribution and
modification follow.
\par
TERMS AND CONDITIONS
\par
0. Definitions.
\par
"This License" refers to version 3 of the GNU General Public License.
\par
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
\par
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
\par
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
\par
A "covered work" means either the unmodified Program or a work based
on the Program.
\par
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
\par
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
\par
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
\par
1. Source Code.
\par
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
\par
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
\par
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
\par
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
\par
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
\par
The Corresponding Source for a work in source code form is that
same work.
\par
2. Basic Permissions.
\par
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
\par
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
\par
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
\par
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
\par
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
\par
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
\par
4. Conveying Verbatim Copies.
\par
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
\par
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
\par
5. Conveying Modified Source Versions.
\par
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
\par
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
\par
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
\par
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
\par
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
\par
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
\par
6. Conveying Non-Source Forms.
\par
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
\par
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
\par
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
\par
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
\par
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
\par
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
\par
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
\par
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
\par
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
\par
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
\par
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
\par
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
\par
7. Additional Terms.
\par
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
\par
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
\par
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
\par
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
\par
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
\par
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
\par
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
\par
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
\par
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
\par
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
\par
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
\par
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
\par
8. Termination.
\par
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
\par
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
\par
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
\par
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
\par
9. Acceptance Not Required for Having Copies.
\par
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
\par
10. Automatic Licensing of Downstream Recipients.
\par
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
\par
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
\par
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
\par
11. Patents.
\par
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
\par
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
\par
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
\par
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
\par
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
\par
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
\par
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
\par
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
\par
12. No Surrender of Others' Freedom.
\par
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
\par
13. Use with the GNU Affero General Public License.
\par
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
\par
14. Revised Versions of this License.
\par
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
\par
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
\par
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
\par
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
\par
15. Disclaimer of Warranty.
\par
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
\par
16. Limitation of Liability.
\par
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
\par
17. Interpretation of Sections 15 and 16.
\par
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
\par
END OF TERMS AND CONDITIONS
\par
How to Apply These Terms to Your New Programs
\par
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
\par
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
\par
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
\par
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
\par
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
\par
You should have received a copy of the GNU General Public License
along with this program. If not, see <{{\field{\*\fldinst{HYPERLINK "https://www.gnu.org/licenses/"}}{\fldrslt{https://www.gnu.org/licenses/\ul0\cf0}}}}\f0\fs20 >.
\par
Also add information on how to contact you by electronic and paper mail.
\par
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
\par
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
\par
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
\par
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<{{\field{\*\fldinst{HYPERLINK "https://www.gnu.org/licenses/"}}{\fldrslt{https://www.gnu.org/licenses/\ul0\cf0}}}}\f0\fs20 >.
\par
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<{{\field{\*\fldinst{HYPERLINK "https://www.gnu.org/licenses/why-not-lgpl.html"}}{\fldrslt{https://www.gnu.org/licenses/why-not-lgpl.html\ul0\cf0}}}}\f0\fs20 >.
}

+ 99
- 0
ports/swankyamp/resources/logo.svg View File

@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
sodipodi:docname="logo.svg"
width="38.289413mm"
height="5.1724963mm"
viewBox="0 0 38.289413 5.1724963"
version="1.1"
id="svg2748">
<sodipodi:namedview
inkscape:current-layer="layer1"
inkscape:window-maximized="1"
inkscape:window-y="-8"
inkscape:window-x="-8"
inkscape:cy="2.1784828"
inkscape:cx="78.395298"
inkscape:zoom="5.9120733"
fit-margin-bottom="0"
fit-margin-right="0"
fit-margin-left="0"
fit-margin-top="0"
showgrid="false"
id="namedview18"
inkscape:window-height="1017"
inkscape:window-width="1920"
inkscape:pageshadow="2"
inkscape:pageopacity="0"
guidetolerance="10"
gridtolerance="10"
objecttolerance="10"
borderopacity="1"
bordercolor="#666666"
pagecolor="#ffffff" />
<defs
id="defs2742" />
<metadata
id="metadata2745">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
transform="translate(-29.9505,-132.64113)">
<path
style="fill:none;stroke:#bf4d50;stroke-width:0.661458;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 55.734927,135.33894 h 0.79398 0.661649 l 0.661641,2.36696 1.323289,-4.73394 1.32329,4.73394 1.323279,-4.73394 1.323293,4.73394 0.661638,-2.36696 h 0.661659 0.79398"
id="path835-3" />
<path
style="fill:none;stroke:#bf4d50;stroke-width:0.661458;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 53.088366,137.70589 v -2.36695 c 0,-1.18349 0,-2.36699 1.323281,-2.36699 1.32328,0 1.32328,1.1835 1.32328,2.36699 l -1.1e-5,2.36695"
id="path829-1" />
<path
style="fill:none;stroke:#bf4d50;stroke-width:0.661458;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 65.262625,137.70589 v -4.73394 c 1.323282,0 2.646561,0 2.646561,1.1835 0,1.18349 -1.323279,1.18349 -2.646561,1.18349"
id="path831-2" />
<path
style="fill:none;stroke:#bf4d50;stroke-width:0.661458;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 53.088366,135.33894 h 2.646561"
id="path837-7" />
<path
d="m 30.133945,137.07281 q 0.134055,0.0917 0.373944,0.17639 0.246945,0.0776 0.55739,0.0776 0.395111,0 0.642056,-0.1905 0.246944,-0.19756 0.246944,-0.61384 0,-0.27516 -0.141111,-0.47978 -0.141111,-0.20461 -0.352778,-0.37394 -0.211667,-0.17639 -0.458611,-0.33867 -0.239889,-0.16933 -0.451556,-0.36689 -0.211667,-0.20461 -0.352778,-0.46566 -0.141111,-0.26106 -0.141111,-0.62795 0,-0.59267 0.352778,-0.87489 0.359833,-0.28928 0.931333,-0.28928 0.352778,0 0.627945,0.0635 0.275167,0.0635 0.444501,0.16228 l -0.169334,0.46567 q -0.127,-0.0776 -0.366889,-0.14111 -0.232833,-0.0635 -0.543278,-0.0635 -0.381,0 -0.564445,0.1905 -0.183444,0.18344 -0.183444,0.46567 0,0.24694 0.141111,0.43744 0.141111,0.1905 0.352778,0.35983 0.211667,0.16934 0.451556,0.34573 0.246944,0.16933 0.458611,0.381 0.211667,0.21166 0.352778,0.47977 0.141111,0.26812 0.141111,0.635 0,0.62089 -0.366889,0.97367 -0.366889,0.35278 -1.037167,0.35278 -0.423334,0 -0.698501,-0.0776 -0.268111,-0.0776 -0.430389,-0.17639 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7.05556px;line-height:1.25;font-family:'PT Sans Narrow';-inkscape-font-specification:'PT Sans Narrow';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
id="path847" />
<path
d="m 34.019684,136.05681 0.08467,0.8255 h 0.01411 l 0.08467,-0.83962 0.790223,-3.25261 h 0.303389 l 0.790222,3.25967 0.08467,0.83256 h 0.0071 l 0.09878,-0.83962 0.627944,-3.25261 h 0.529167 l -1.100667,5.0165 h -0.324556 l -0.783167,-3.25261 -0.09878,-0.75494 h -0.02117 l -0.09878,0.762 -0.783167,3.24555 H 33.89273 l -1.121834,-5.0165 h 0.571501 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7.05556px;line-height:1.25;font-family:'PT Sans Narrow';-inkscape-font-specification:'PT Sans Narrow';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
id="path849" />
<path
d="m 39.646383,136.34608 h -1.397001 l -0.395111,1.38289 h -0.522112 l 1.488724,-5.0165 h 0.289278 l 1.488723,5.0165 H 40.04855 Z m -1.25589,-0.47272 h 1.12889 l -0.430389,-1.524 -0.134056,-0.74083 h -0.01411 l -0.134055,0.75494 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7.05556px;line-height:1.25;font-family:'PT Sans Narrow';-inkscape-font-specification:'PT Sans Narrow';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
id="path851" />
<path
d="m 41.838238,134.5963 -0.30339,-0.77611 h -0.02117 l 0.07761,0.77611 v 3.13267 h -0.508 v -5.0165 h 0.3175 l 1.82739,3.20322 0.289278,0.74084 h 0.02822 l -0.07761,-0.74084 v -3.12561 h 0.508 v 5.0165 H 43.65151 Z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7.05556px;line-height:1.25;font-family:'PT Sans Narrow';-inkscape-font-specification:'PT Sans Narrow';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
id="path853" />
<path
d="m 45.656067,135.44297 h -0.254 v 2.286 H 44.8729 v -4.93889 h 0.529167 v 2.30011 l 0.246944,-0.0988 1.284112,-2.20134 h 0.606778 l -1.291167,2.13078 -0.246945,0.22578 0.289278,0.28222 1.432279,2.30011 h -0.670278 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7.05556px;line-height:1.25;font-family:'PT Sans Narrow';-inkscape-font-specification:'PT Sans Narrow';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
id="path855" />
<path
d="m 49.07625,135.76753 -1.312335,-2.97745 h 0.62089 l 0.889,2.15195 0.09172,0.43039 h 0.01411 l 0.09172,-0.4445 0.860778,-2.13784 h 0.571501 l -1.298223,2.97039 v 1.9685 H 49.07625 Z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:7.05556px;line-height:1.25;font-family:'PT Sans Narrow';-inkscape-font-specification:'PT Sans Narrow';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
id="path857" />
</g>
</svg>

+ 243
- 0
ports/swankyamp/resources/presets.xml View File

@@ -0,0 +1,243 @@
<?xml version="1.0" encoding="UTF-8"?>
<presets>
<APVTSSwankyAmp presetName="clean">
<PARAM id="idCabBrightness" value="0.0"/>
<PARAM id="idCabDistance" value="0.4970000088214874"/>
<PARAM id="idCabDynamic" value="0.0"/>
<PARAM id="idCabOnOff" value="1.0"/>
<PARAM id="idGainOverhead" value="0.0"/>
<PARAM id="idGainStages" value="1.0"/>
<PARAM id="idLowCut" value="-1.0"/>
<PARAM id="idOutputLevel" value="-0.2"/>
<PARAM id="idPowerAmpDrive" value="-1.0"/>
<PARAM id="idPowerAmpGrit" value="0.0"/>
<PARAM id="idPowerAmpSag" value="-0.6000000238418579"/>
<PARAM id="idPowerAmpSagRatio" value="0.0"/>
<PARAM id="idPowerAmpTight" value="0.0"/>
<PARAM id="idPreAmpDrive" value="-1.0"/>
<PARAM id="idPreAmpGrit" value="-1.0"/>
<PARAM id="idPreAmpTight" value="0.0"/>
<PARAM id="idTsHigh" value="0.4000000953674316"/>
<PARAM id="idTsLow" value="0.0"/>
<PARAM id="idTsMid" value="-0.2999999523162842"/>
<PARAM id="idTsPresence" value="0.3900001049041748"/>
<PARAM id="idTsSelection" value="0.0"/>
</APVTSSwankyAmp>
<APVTSSwankyAmp presetName="bright">
<PARAM id="idCabBrightness" value="0.3960000276565552"/>
<PARAM id="idCabDistance" value="0.5"/>
<PARAM id="idCabDynamic" value="-0.1899999380111694"/>
<PARAM id="idCabOnOff" value="1.0"/>
<PARAM id="idGainOverhead" value="0.3000000715255737"/>
<PARAM id="idGainStages" value="1.972000122070312"/>
<PARAM id="idLowCut" value="0.4020000696182251"/>
<PARAM id="idOutputLevel" value="-0.1"/>
<PARAM id="idPowerAmpDrive" value="-0.4939999580383301"/>
<PARAM id="idPowerAmpGrit" value="0.0"/>
<PARAM id="idPowerAmpSag" value="-0.4959999918937683"/>
<PARAM id="idPowerAmpSagRatio" value="0.0"/>
<PARAM id="idPowerAmpTight" value="0.0"/>
<PARAM id="idPreAmpDrive" value="-0.6059999465942383"/>
<PARAM id="idPreAmpGrit" value="0.190000057220459"/>
<PARAM id="idPreAmpTight" value="0.0"/>
<PARAM id="idTsHigh" value="0.002000093460083008"/>
<PARAM id="idTsLow" value="-0.1979999542236328"/>
<PARAM id="idTsMid" value="0.2000000476837158"/>
<PARAM id="idTsPresence" value="0.2920000553131104"/>
<PARAM id="idTsSelection" value="2.0"/>
</APVTSSwankyAmp>
<APVTSSwankyAmp presetName="edge">
<PARAM id="idCabBrightness" value="0.3000000715255737"/>
<PARAM id="idCabDistance" value="0.5"/>
<PARAM id="idCabDynamic" value="0.0"/>
<PARAM id="idCabOnOff" value="1.0"/>
<PARAM id="idGainOverhead" value="0.0"/>
<PARAM id="idGainStages" value="2.0"/>
<PARAM id="idLowCut" value="-0.6"/>
<PARAM id="idOutputLevel" value="-0.1"/>
<PARAM id="idPowerAmpDrive" value="-0.3939999938011169"/>
<PARAM id="idPowerAmpGrit" value="0.0"/>
<PARAM id="idPowerAmpSag" value="-0.6000000238418579"/>
<PARAM id="idPowerAmpSagRatio" value="0.0"/>
<PARAM id="idPowerAmpTight" value="0.0"/>
<PARAM id="idPreAmpDrive" value="-0.6059999465942383"/>
<PARAM id="idPreAmpGrit" value="-0.5"/>
<PARAM id="idPreAmpTight" value="0.0"/>
<PARAM id="idTsHigh" value="0.2960000038146973"/>
<PARAM id="idTsLow" value="-0.1979999542236328"/>
<PARAM id="idTsMid" value="0.0"/>
<PARAM id="idTsPresence" value="0.3160001039505005"/>
<PARAM id="idTsSelection" value="0.2980000078678131"/>
</APVTSSwankyAmp>
<APVTSSwankyAmp presetName="distort">
<PARAM id="idCabBrightness" value="0.0"/>
<PARAM id="idCabDistance" value="0.7000000476837158"/>
<PARAM id="idCabDynamic" value="-0.2099999785423279"/>
<PARAM id="idCabOnOff" value="1.0"/>
<PARAM id="idGainOverhead" value="0.0"/>
<PARAM id="idGainStages" value="3.0"/>
<PARAM id="idLowCut" value="-0.2"/>
<PARAM id="idOutputLevel" value="0.05400002002716064"/>
<PARAM id="idPowerAmpDrive" value="0.190000057220459"/>
<PARAM id="idPowerAmpGrit" value="0.0"/>
<PARAM id="idPowerAmpSag" value="0.3960000276565552"/>
<PARAM id="idPowerAmpSagRatio" value="0.0"/>
<PARAM id="idPowerAmpTight" value="0.2000000476837158"/>
<PARAM id="idPreAmpDrive" value="0.1960000991821289"/>
<PARAM id="idPreAmpGrit" value="0.0"/>
<PARAM id="idPreAmpTight" value="0.1960000991821289"/>
<PARAM id="idTsHigh" value="0.190000057220459"/>
<PARAM id="idTsLow" value="0.1960000991821289"/>
<PARAM id="idTsMid" value="0.5900000333786011"/>
<PARAM id="idTsPresence" value="0.3940000534057617"/>
<PARAM id="idTsSelection" value="0.3960000276565552"/>
</APVTSSwankyAmp>
<APVTSSwankyAmp presetName="dirty distort">
<PARAM id="idCabBrightness" value="-0.4039999842643738"/>
<PARAM id="idCabDistance" value="0.495000034570694"/>
<PARAM id="idCabDynamic" value="-0.4039999842643738"/>
<PARAM id="idCabOnOff" value="1.0"/>
<PARAM id="idGainOverhead" value="-0.5"/>
<PARAM id="idGainStages" value="4.0"/>
<PARAM id="idLowCut" value="-1.0"/>
<PARAM id="idOutputLevel" value="0.0"/>
<PARAM id="idPowerAmpDrive" value="0.6540000438690186"/>
<PARAM id="idPowerAmpGrit" value="0.0"/>
<PARAM id="idPowerAmpSag" value="0.406000018119812"/>
<PARAM id="idPowerAmpSagRatio" value="0.0"/>
<PARAM id="idPowerAmpTight" value="-0.3999999761581421"/>
<PARAM id="idPreAmpDrive" value="0.2440000772476196"/>
<PARAM id="idPreAmpGrit" value="0.6000000238418579"/>
<PARAM id="idPreAmpTight" value="-0.3999999761581421"/>
<PARAM id="idTsHigh" value="0.5060000419616699"/>
<PARAM id="idTsLow" value="-0.1939999461174011"/>
<PARAM id="idTsMid" value="0.3060001134872437"/>
<PARAM id="idTsPresence" value="0.2020000219345093"/>
<PARAM id="idTsSelection" value="0.1900000125169754"/>
</APVTSSwankyAmp>
<APVTSSwankyAmp presetName="pre drive">
<PARAM id="idCabBrightness" value="-0.1939999461174011"/>
<PARAM id="idCabDistance" value="0.6000000238418579"/>
<PARAM id="idCabDynamic" value="-0.2099999785423279"/>
<PARAM id="idCabOnOff" value="1.0"/>
<PARAM id="idGainOverhead" value="0.2000000476837158"/>
<PARAM id="idGainStages" value="5.0"/>
<PARAM id="idLowCut" value="-0.2"/>
<PARAM id="idOutputLevel" value="0.0"/>
<PARAM id="idPowerAmpDrive" value="0.004000067710876465"/>
<PARAM id="idPowerAmpGrit" value="0.0"/>
<PARAM id="idPowerAmpSag" value="0.4020000696182251"/>
<PARAM id="idPowerAmpSagRatio" value="0.0"/>
<PARAM id="idPowerAmpTight" value="0.0140000581741333"/>
<PARAM id="idPreAmpDrive" value="0.474000096321106"/>
<PARAM id="idPreAmpGrit" value="-0.3979999423027039"/>
<PARAM id="idPreAmpTight" value="0.3920000791549683"/>
<PARAM id="idTsHigh" value="0.190000057220459"/>
<PARAM id="idTsLow" value="-0.199999988079071"/>
<PARAM id="idTsMid" value="0.6000000238418579"/>
<PARAM id="idTsPresence" value="0.1840000152587891"/>
<PARAM id="idTsSelection" value="0.300000011920929"/>
</APVTSSwankyAmp>
<APVTSSwankyAmp presetName="power drive">
<PARAM id="idCabBrightness" value="-0.1819999814033508"/>
<PARAM id="idCabDistance" value="0.5980000495910645"/>
<PARAM id="idCabDynamic" value="-0.2099999785423279"/>
<PARAM id="idCabOnOff" value="1.0"/>
<PARAM id="idGainOverhead" value="0.1960000991821289"/>
<PARAM id="idGainStages" value="2.0"/>
<PARAM id="idLowCut" value="0.4"/>
<PARAM id="idOutputLevel" value="0.0"/>
<PARAM id="idPowerAmpDrive" value="0.3880000114440918"/>
<PARAM id="idPowerAmpGrit" value="0.0"/>
<PARAM id="idPowerAmpSag" value="-0.6059999465942383"/>
<PARAM id="idPowerAmpSagRatio" value="0.0"/>
<PARAM id="idPowerAmpTight" value="0.4020000696182251"/>
<PARAM id="idPreAmpDrive" value="-0.203999936580658"/>
<PARAM id="idPreAmpGrit" value="0.0"/>
<PARAM id="idPreAmpTight" value="0.0"/>
<PARAM id="idTsHigh" value="0.474000096321106"/>
<PARAM id="idTsLow" value="-0.199999988079071"/>
<PARAM id="idTsMid" value="0.6000000238418579"/>
<PARAM id="idTsPresence" value="-0.2099999785423279"/>
<PARAM id="idTsSelection" value="0.5020000338554382"/>
</APVTSSwankyAmp>
<APVTSSwankyAmp presetName="full drive">
<PARAM id="idCabBrightness" value="-0.199999988079071"/>
<PARAM id="idCabDistance" value="0.800000011920929"/>
<PARAM id="idCabDynamic" value="-0.3739999532699585"/>
<PARAM id="idCabOnOff" value="1.0"/>
<PARAM id="idGainOverhead" value="0.0"/>
<PARAM id="idGainStages" value="1.0"/>
<PARAM id="idLowCut" value="0.0"/>
<PARAM id="idOutputLevel" value="0.0"/>
<PARAM id="idPowerAmpDrive" value="0.4040000438690186"/>
<PARAM id="idPowerAmpGrit" value="0.0"/>
<PARAM id="idPowerAmpSag" value="-0.6039999723434448"/>
<PARAM id="idPowerAmpSagRatio" value="0.0"/>
<PARAM id="idPowerAmpTight" value="0.6060000658035278"/>
<PARAM id="idPreAmpDrive" value="0.5900000333786011"/>
<PARAM id="idPreAmpGrit" value="-0.4039999842643738"/>
<PARAM id="idPreAmpTight" value="0.6600000858306885"/>
<PARAM id="idTsHigh" value="0.6060000658035278"/>
<PARAM id="idTsLow" value="-0.3139999508857727"/>
<PARAM id="idTsMid" value="0.3920000791549683"/>
<PARAM id="idTsPresence" value="0.1920000314712524"/>
<PARAM id="idTsSelection" value="0.4020000100135803"/>
</APVTSSwankyAmp>
<APVTSSwankyAmp presetName="high gain">
<PARAM id="idCabBrightness" value="0.0"/>
<PARAM id="idCabDistance" value="0.3510000109672546"/>
<PARAM id="idCabDynamic" value="0.0"/>
<PARAM id="idCabOnOff" value="1.0"/>
<PARAM id="idGainOverhead" value="-0.6000000238418579"/>
<PARAM id="idGainStages" value="5.0"/>
<PARAM id="idLowCut" value="-1.0"/>
<PARAM id="idOutputLevel" value="-0.05599993467330933"/>
<PARAM id="idPowerAmpDrive" value="0.6100001335144043"/>
<PARAM id="idPowerAmpGrit" value="0.0"/>
<PARAM id="idPowerAmpSag" value="-0.3999999761581421"/>
<PARAM id="idPowerAmpSagRatio" value="0.0"/>
<PARAM id="idPowerAmpTight" value="0.5000001192092896"/>
<PARAM id="idPreAmpDrive" value="0.596000075340271"/>
<PARAM id="idPreAmpGrit" value="-1.0"/>
<PARAM id="idPreAmpTight" value="1.0"/>
<PARAM id="idTsHigh" value="0.6000000238418579"/>
<PARAM id="idTsLow" value="0.2000000476837158"/>
<PARAM id="idTsMid" value="0.1860001087188721"/>
<PARAM id="idTsPresence" value="-0.3999999761581421"/>
<PARAM id="idTsSelection" value="0.3040000200271606"/>
</APVTSSwankyAmp>
<APVTSSwankyAmp presetName="level 11">
<PARAM id="idCabBrightness" value="-0.5979999899864197"/>
<PARAM id="idCabDistance" value="0.7980000376701355"/>
<PARAM id="idCabDynamic" value="-0.3699999451637268"/>
<PARAM id="idCabOnOff" value="1.0"/>
<PARAM id="idGainOverhead" value="-0.5959999561309814"/>
<PARAM id="idGainStages" value="5.0"/>
<PARAM id="idLowCut" value="-0.4"/>
<PARAM id="idOutputLevel" value="0.0"/>
<PARAM id="idPowerAmpDrive" value="1.0"/>
<PARAM id="idPowerAmpGrit" value="0.0"/>
<PARAM id="idPowerAmpSag" value="-0.6000000238418579"/>
<PARAM id="idPowerAmpSagRatio" value="0.0"/>
<PARAM id="idPowerAmpTight" value="-0.3999999761581421"/>
<PARAM id="idPreAmpDrive" value="1.0"/>
<PARAM id="idPreAmpGrit" value="0.7960001230239868"/>
<PARAM id="idPreAmpTight" value="-0.6000000238418579"/>
<PARAM id="idTsHigh" value="0.440000057220459"/>
<PARAM id="idTsLow" value="0.4020000696182251"/>
<PARAM id="idTsMid" value="1.0"/>
<PARAM id="idTsPresence" value="0.3840000629425049"/>
<PARAM id="idTsSelection" value="0.5180000066757202"/>
</APVTSSwankyAmp>
</presets>

+ 64
- 0
ports/swankyamp/resources/tooltips.xml View File

@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<tooltips>
<param id="idInputLevel">
Use to gain stage the guitar singal. A lightly strummed open chord should peak just above the "S" level for a single coil pickup, or "H" for humbucker pickup.
</param>
<param id="idOutputLevel">
Use to gain stage the overall plugin master volume. This affects only how loud the plugin will sound.
</param>
<param id="idCabBrightness">
Affects the microphone position in a way which relates to the overall brightness of the sound.
</param>
<param id="idCabDistance">
Affects the microphone distance which will remove some lows and upper mids. This can have the effect of creating a clearer sound.
</param>
<param id="idCabDynamic">
Affects how much the cabinet frequencies respond to the loudness of the signal. Increase to darken the distortion while leaving quiet parts unaffected.
</param>
<param id="idCabOnOff">
Disables the cabinet emulation. Turn off if you want to run a separate cabinet emulation after the plugin.
</param>
<param id="idGainOverhead">
Affects the amount of distortion in the later gain stages. Decrease for a high-gain sound.
</param>
<param id="idGainStages">
The number of gain stages (tubes) the signal goes through. Each stage is voiced differently and can bring out more low end or tighter distortion.
</param>
<param id="idLowCut">
How much of the lows are cut out from the pre amp stage. Increase to remove bass. Decrease to get fuller distortion.
</param>
<param id="idPreAmpDrive">
The amount of distortion in the pre amp stage (a.k.a. amp gain). The plugin will adjust the output level to compensate.
</param>
<param id="idPreAmpGrit">
Affects the amount of overhead available in the tubes. Decrease remove harsh artifacts from the tube distortion.
</param>
<param id="idPreAmpTight">
Affects the time scale and depth of the tube amp dynamics. Increase to get a cleaner distoriton. Decrease for more touch sensitivity.
</param>
<param id="idPowerAmpDrive">
The amount of distortion in the power amp stage (a.k.a. amp volume). The plugin will adjust the output level to compensate.
</param>
<param id="idPowerAmpTight">
Affects the time scale and depth of the power amp dynamics. Has large effect on the sag compression attack and release.
</param>
<param id="idPowerAmpSag">
Affects how much the amplified level drop in response to a large signal. Increase for a more compressed sound. Not as effectie with low power amp drive or large pre amp drive.
</param>
<param id="idTsHigh">
The amount of high end going into the power amp. Increase for a brighter tone. Decrase to reduce harsh distortion noise.
</param>
<param id="idTsMid">
The amount of mids going into the power amp. Increase for a more aggressive, punchier tone. Can increase sustain when the power amp drive is high.
</param>
<param id="idTsLow">
The amount of bass going into the power amp. Increase for a fuller sound. Decrease for more definition and more brightness.
</param>
<param id="idTsPresence">
The amoumt of signal in the higher mids, lower highs. Increase for more definition, more detail. Decrease to reduce brittle harshness.
</param>
<param id="idTsSelection">
Tone stack: 0 for a Fender-like mids scoop, 5 for a Marshall-like tone with mids, 10 for an AC30-like tone with added mids control.
</param>
</tooltips>

+ 9871
- 0
ports/swankyamp/source/BinaryData.cpp
File diff suppressed because it is too large
View File


+ 45
- 0
ports/swankyamp/source/BinaryData.h View File

@@ -0,0 +1,45 @@
/* =========================================================================================

This is an auto-generated file: Any edits you make may be overwritten!

*/

#pragma once

namespace BinaryData
{
extern const char* logo_svg;
const int logo_svgSize = 7224;

extern const char* presets_xml;
const int presets_xmlSize = 11837;

extern const char* PTSansBold_ttf;
const int PTSansBold_ttfSize = 287936;

extern const char* PTSansRegular_ttf;
const int PTSansRegular_ttfSize = 278168;

extern const char* PTSansNarrowRegular_ttf;
const int PTSansNarrowRegular_ttfSize = 234208;

extern const char* tooltips_xml;
const int tooltips_xmlSize = 3455;

// Number of elements in the namedResourceList and originalFileNames arrays.
const int namedResourceListSize = 6;

// Points to the start of a list of resource names.
extern const char* namedResourceList[];

// Points to the start of a list of resource filenames.
extern const char* originalFilenames[];

// If you provide the name of one of the binary resource variables above, this function will
// return the corresponding data and its size (or a null pointer if the name isn't found).
const char* getNamedResource (const char* resourceNameUTF8, int& dataSizeInBytes);

// If you provide the name of one of the binary resource variables above, this function will
// return the corresponding original, non-mangled filename (or a null pointer if the name isn't found).
const char* getNamedResourceOriginalFilename (const char* resourceNameUTF8);
}

+ 109
- 0
ports/swankyamp/source/Components/AmpGroup.cpp View File

@@ -0,0 +1,109 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <JuceHeader.h>

#include "../SwankyAmpLAF.h"

#include "AmpGroup.h"

#define GROUP_DROP_SHADOW(n) \
auto n##ShadowPath = Path(); \
n##ShadowPath.addRoundedRectangle( \
n##Group.getBorderBounds(), 2.0f * n##Group.getLineThickness()); \
n##ShadowPath.applyTransform(AffineTransform::translation( \
(float)n##Group.getBounds().getTopLeft().getX(), \
(float)n##Group.getBounds().getTopLeft().getY())); \
auto n##Shadow = SwankyAmpLAF::getDropShadow(); \
n##Shadow.drawForPath(g, n##ShadowPath);

AmpGroup::AmpGroup()
{
spacing = 32;
lineThickness = 0;
label.setFont(0.0f);

addAndMakeVisible(levelsGroup);
addAndMakeVisible(levelsGroup);
addAndMakeVisible(preAmpGroup);
addAndMakeVisible(powerAmpGroup);
addAndMakeVisible(stagingGroup);
addAndMakeVisible(toneStackGroup);
addAndMakeVisible(cabGroup);
}

void AmpGroup::setGroupsHeight(int height)
{
levelsGroup.setHeight(height);
preAmpGroup.setHeight(height);
powerAmpGroup.setHeight(height);
stagingGroup.setHeight(height);
toneStackGroup.setHeight(height);
cabGroup.setHeight(height);
resized();
}

void AmpGroup::attachVTS(AudioProcessorValueTreeState& vts)
{
levelsGroup.attachVTS(vts);
preAmpGroup.attachVTS(vts);
powerAmpGroup.attachVTS(vts);
stagingGroup.attachVTS(vts);
toneStackGroup.attachVTS(vts);
cabGroup.attachVTS(vts);
}

void AmpGroup::attachTooltips(const TooltipsData& tooltips)
{
levelsGroup.attachTooltips(tooltips);
preAmpGroup.attachTooltips(tooltips);
powerAmpGroup.attachTooltips(tooltips);
stagingGroup.attachTooltips(tooltips);
toneStackGroup.attachTooltips(tooltips);
cabGroup.attachTooltips(tooltips);
}

void AmpGroup::paint(Graphics& g)
{
// skip painting the group background and borders
Component::paint(g);
GROUP_DROP_SHADOW(levels)
GROUP_DROP_SHADOW(preAmp)
GROUP_DROP_SHADOW(powerAmp)
GROUP_DROP_SHADOW(staging)
GROUP_DROP_SHADOW(toneStack)
GROUP_DROP_SHADOW(cab)
}

void AmpGroup::resized()
{
ParameterGroup::resized();

levelsGroup.setTopLeftPosition(spacing, spacing);
preAmpGroup.setTopLeftPosition(spacing, spacing + levelsGroup.getBottom());
powerAmpGroup.setTopLeftPosition(spacing, spacing + preAmpGroup.getBottom());
stagingGroup.setTopLeftPosition(
spacing + preAmpGroup.getRight(), spacing + levelsGroup.getBottom());
toneStackGroup.setTopLeftPosition(
spacing + powerAmpGroup.getRight(), spacing + preAmpGroup.getBottom());
cabGroup.setTopLeftPosition(spacing + levelsGroup.getRight(), spacing);

setSize(
toneStackGroup.getRight() + spacing,
toneStackGroup.getBottom() + spacing);
}

+ 58
- 0
ports/swankyamp/source/Components/AmpGroup.h View File

@@ -0,0 +1,58 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>

#include "../Utils.h"
#include "CabGroup.h"
#include "LevelsGroup.h"
#include "ParameterGroup.h"
#include "PowerAmpGroup.h"
#include "PreAmpGroup.h"
#include "StagingGroup.h"
#include "ToneStackGroup.h"

class AmpGroup : public ParameterGroup
{
public:
AmpGroup();
~AmpGroup() {}

void resized() override;
void paint(Graphics& g) override;

void attachVTS(AudioProcessorValueTreeState& vts) override;
void attachTooltips(const TooltipsData& tooltips) override;

void setGroupsHeight(int height);

// TODO: for the time being keep public as need to access members, but this
// should be cleaned up at some point
LevelsGroup levelsGroup;
PreAmpGroup preAmpGroup;
PowerAmpGroup powerAmpGroup;
StagingGroup stagingGroup;
ToneStackGroup toneStackGroup;
CabGroup cabGroup;

private:
DISABLE_COMPONENT_RESIZE()
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AmpGroup)
};

+ 104
- 0
ports/swankyamp/source/Components/CabGroup.cpp View File

@@ -0,0 +1,104 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <JuceHeader.h>

#include "CabGroup.h"
#include "LevelMeter.h"
#include "ParameterGroup.h"

CabGroup::CabGroup() : ParameterGroup("CABINET")
{
addAndMakeVisible(buttonCabOnOff);

addAndMakeVisible(sliderBright);
sliderBright.setLabel("BRIGHT");
sliderBright.slider.setPosMapDownFmt("%4.1f");

addAndMakeVisible(sliderDistance);
sliderDistance.setLabel("DISTANCE");
sliderDistance.slider.setPosMapDownFmt("%4.1f");

addAndMakeVisible(sliderDynamic);
sliderDynamic.setLabel("DYNAMIC");
sliderDynamic.slider.setPosMapDownFmt("%4.1f");
}

void CabGroup::attachVTS(AudioProcessorValueTreeState& vts)
{
attCabOnOff.reset(new ButtonAttachment(vts, "idCabOnOff", buttonCabOnOff));
attCabBrightness.reset(
new SliderAttachment(vts, "idCabBrightness", sliderBright.slider));
attCabDistance.reset(
new SliderAttachment(vts, "idCabDistance", sliderDistance.slider));
attCabDynamic.reset(
new SliderAttachment(vts, "idCabDynamic", sliderDynamic.slider));
}

void CabGroup::attachTooltips(const TooltipsData& tooltips)
{
buttonCabOnOff.setTooltip(tooltips.getForParam("idCabOnOff"));
sliderBright.slider.setTooltip(tooltips.getForParam("idCabBrightness"));
sliderDistance.slider.setTooltip(tooltips.getForParam("idCabDistance"));
sliderDynamic.slider.setTooltip(tooltips.getForParam("idCabDynamic"));
}

void CabGroup::resized()
{
const int prevInnerHeight = getBorderBounds().getHeight() - 2 * spacing;
const Point<int> prevCorner =
getBorderBounds().getTopLeft() + Point<int>(spacing, spacing);

ParameterGroup::resized();

const int innerHeight = getBorderBounds().getHeight() - 2 * spacing;
Point<int> corner =
getBorderBounds().getTopLeft() + Point<int>(spacing, spacing);

// only re-set the positions when the height or position changes
if (prevInnerHeight == innerHeight && prevCorner == corner) return;

buttonCabOnOff.setTopLeftPosition(corner + Point<int>(spacing, spacing) / 2);
buttonCabOnOff.setSize(
(int)(buttonCabOnOff.calcWidthForHeight((float)innerHeight - spacing)),
(int)((float)innerHeight - spacing));

corner = buttonCabOnOff.getBounds().getTopRight() + Point<int>(spacing, 0);

sliderBright.setTopLeftPosition(corner + Point<int>(spacing, -spacing) / 2);
sliderBright.slider.setMargin(0.15f * (float)innerHeight);
sliderBright.setHeight(innerHeight);

corner = sliderBright.getBounds().getTopRight() + Point<int>(spacing, 0);

sliderDistance.setTopLeftPosition(corner);
sliderDistance.slider.setMargin(0.15f * (float)innerHeight);
sliderDistance.setHeight(innerHeight);

corner = sliderDistance.getBounds().getTopRight() + Point<int>(spacing, 0);

sliderDynamic.setTopLeftPosition(corner);
sliderDynamic.slider.setMargin(0.15f * (float)innerHeight);
sliderDynamic.setHeight(innerHeight);

corner = sliderDynamic.getBounds().getTopRight() + Point<int>(spacing, 0);

// can now determine the width and set it, this will re-call `resized` but
// since the height is the same it won't re-do the calculation
setSize(corner.getX() - getBounds().getX(), getHeight());
}

+ 53
- 0
ports/swankyamp/source/Components/CabGroup.h View File

@@ -0,0 +1,53 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>

#include "../Utils.h"
#include "ParameterGroup.h"
#include "RButton.h"
#include "RSliderLabel.h"

class CabGroup : public ParameterGroup
{
public:
CabGroup();
~CabGroup() {}

void attachVTS(AudioProcessorValueTreeState& vts) override;
void attachTooltips(const TooltipsData& tooltips) override;

void setHeight(int height) { setSize(0, height); }
void resized() override;

private:
RButton buttonCabOnOff;
RSliderLabel sliderBright;
RSliderLabel sliderDistance;
RSliderLabel sliderDynamic;

std::unique_ptr<ButtonAttachment> attCabOnOff;
std::unique_ptr<SliderAttachment> attCabBrightness;
std::unique_ptr<SliderAttachment> attCabDistance;
std::unique_ptr<SliderAttachment> attCabDynamic;

DISABLE_COMPONENT_RESIZE()
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CabGroup)
};

+ 149
- 0
ports/swankyamp/source/Components/LevelMeter.cpp View File

@@ -0,0 +1,149 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <JuceHeader.h>

#include "../SwankyAmpLAF.h"

#include "LevelMeter.h"

void LevelMeter::setBarWidth(int width)
{
barWidth = width;
setSize(labelWidth + labelGap + barWidth, getHeight());
}

void LevelMeter::setBarHeight(int height)
{
setSize(labelWidth + labelGap + barWidth, height);
}

void LevelMeter::setLabelWidth(int width)
{
labelWidth = width;
setSize(labelWidth + labelGap + barWidth, getHeight());
}

void LevelMeter::setLabelGap(int width)
{
labelGap = width;
setSize(labelWidth + labelGap + barWidth, getHeight());
}

float LevelMeter::dbToLevel(float db) const
{
return (db - dbLow) / (dbHigh - dbLow);
}

void LevelMeter::paint(Graphics& g)
{
g.fillAll(Colours::transparentBlack);

const auto bounds = g.getClipBounds();

auto fullBar = Rectangle<float>(bounds.toFloat());
if (!labelsOnRight)
fullBar.setLeft(fullBar.getX() + labelWidth + labelGap);
else
fullBar.setRight(fullBar.getRight() - labelWidth - labelGap);

const float lw = 2.0f;
const float corner = 2.0f;
const Font& font =
SwankyAmpLAF::getDefaultFontNarrow().withHeight(labelHeight);

const auto clippedLevel = jmax(0.0f, jmin(1.0f, level));

auto filledBarPath = Path();
filledBarPath.addRoundedRectangle(
fullBar.getX(),
fullBar.getY() + fullBar.getHeight() * (1.0f - clippedLevel),
fullBar.getWidth(),
fullBar.getHeight() * clippedLevel,
corner,
corner,
false,
false,
true,
true);

g.setColour(findColour(backgroundColourId));
g.fillRoundedRectangle(fullBar, corner);

g.setColour(findColour(meterColourId));
g.fillPath(filledBarPath);

g.setFont(font);
for (const auto& tick : ticks)
{
const float y =
(1.0f - (tick.first - dbLow) / (dbHigh - dbLow)) * fullBar.getHeight();

if (labelWidth > 0)
{
auto labelBox = Rectangle<float>();
if (!labelsOnRight)
labelBox.setX((float)bounds.getX());
else
labelBox.setX((float)fullBar.getRight() + labelGap);
labelBox.setY(y - labelHeight / 2.0f);
labelBox.setSize((float)labelWidth, labelHeight);

g.setColour(findColour(textColourId));
g.drawText(tick.second, labelBox, Justification::centredRight, false);
}

auto tickLineBox = Rectangle<float>(fullBar);
tickLineBox.setY(y);
tickLineBox.setHeight(lw);

g.setColour(findColour(backgroundColourId));
g.fillRect(tickLineBox);
}

g.setColour(findColour(outlineColourId));
g.drawRoundedRectangle(
BorderSize<float>(lw / 2.0f).subtractedFrom(fullBar), corner, lw);
}

void LevelMeter::update(float db)
{
// The processor will call this from the audio thread, which simply stores
// the maximum until the timer paints it to the UI
maxLevel = jmax(maxLevel.load(), dbToLevel(db));
}

void LevelMeter::timerCallback()
{
// The editor owns this component, and some time thread (?) will make calls to
// this method to repaint the meter.

auto callbackLevel = maxLevel.exchange(0.0);

const float refreshRateHz = 1.0f / getTimerInterval() * 1e3f;
const float decayFactor = powf(0.5f, 1.0f / (decayTau * refreshRateHz));

if (callbackLevel > level)
level = callbackLevel;
else if (level > 1e-3)
level *= decayFactor;
else
level = 0;

repaint();
}

+ 87
- 0
ports/swankyamp/source/Components/LevelMeter.h View File

@@ -0,0 +1,87 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>

#include "../Utils.h"

typedef std::pair<float, String> MeterTick;
typedef std::vector<MeterTick> MeterTicks;

struct LevelMeterListener
{
virtual ~LevelMeterListener() {}
virtual void update(float) = 0;
};

class LevelMeter : public Component, public LevelMeterListener, private Timer
{
public:
LevelMeter() { setRefreshRate(30); }

void paint(Graphics& g) override;
void update(float db) override;

// NOTE: startTime just adds this to a list of timers a singleton time thread
// so it shoudld be inexpensive to create a timer per meter
void setRefreshRate(int refreshRateHz) { startTimer(refreshRateHz); }
void setDbLow(float db) { dbLow = db; }
void setDbHigh(float db) { dbHigh = db; }
void setDecayTau(float tau) { decayTau = tau; }
void setTicks(const MeterTicks& pTicks) { ticks = pTicks; }

void setBarWidth(int width);
void setBarHeight(int height);
void setLabelWidth(int width);
void setLabelHeight(float height) { labelHeight = height; }
void setLabelGap(int width);
void setLabelsOnRight(bool choice) { labelsOnRight = choice; }

float getLabelHeight() const { return labelHeight; }
int getLabelWidth() const { return labelWidth; }

enum ColourIds
{
outlineColourId = 0x2000301,
backgroundColourId = 0x2000302,
meterColourId = 0x2000303,
textColourId = 0x2000304,
};

private:
void timerCallback() override;
float dbToLevel(float db) const;

std::atomic<float> maxLevel = {0.0f};
float level = 0.0f;
float dbLow = -30.0f;
float dbHigh = 0.0f;
float decayTau = 0.5f;
MeterTicks ticks;

int barWidth = 16;
int labelWidth = 16;
float labelHeight = 16.0f;
int labelGap = 2;
bool labelsOnRight = false;

DISABLE_COMPONENT_RESIZE()
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LevelMeter)
};

+ 139
- 0
ports/swankyamp/source/Components/LevelsGroup.cpp View File

@@ -0,0 +1,139 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <JuceHeader.h>

#include "LevelsGroup.h"

LevelsGroup::LevelsGroup() : ParameterGroup("LEVELS")
{
const auto inputTicks = MeterTicks{{-16.5f, "S"}, {-2.5f, "H"}};

meterInL.setDbLow(-26.0f);
meterInL.setDbHigh(+8.0f);
meterInL.setTicks(inputTicks);

meterInR.setDbLow(-26.0f);
meterInR.setDbHigh(+8.0f);
meterInR.setTicks(inputTicks);
meterInR.setLabelWidth(0);

const auto outputTicks = MeterTicks{
{-5.0f, "-5"},
{-10.0f, ""},
{-15.0f, "-15"},
{-20.0f, ""},
{-25.0f, "-25"},
};

meterOutL.setDbLow(-30.0f);
meterOutL.setDbHigh(0.0f);
meterOutL.setTicks(outputTicks);
meterOutL.setLabelWidth(0);

meterOutR.setDbLow(-30.0f);
meterOutR.setDbHigh(0.0f);
meterOutR.setTicks(outputTicks);
meterOutR.setLabelsOnRight(true);

addAndMakeVisible(meterInL);
addAndMakeVisible(meterInR);

addAndMakeVisible(meterOutL);
addAndMakeVisible(meterOutR);

addAndMakeVisible(sliderInputLevel);
sliderInputLevel.setLabel("INPUT");
sliderInputLevel.slider.setPosMapHigh(35.0f);
sliderInputLevel.slider.setPosMapLow(-35.0f);
sliderInputLevel.slider.setPosMapFmt("%+.0f dB");
sliderInputLevel.slider.setPosMapDownFmt("%+.1f");

addAndMakeVisible(sliderOutputLevel);
sliderOutputLevel.setLabel("OUTPUT");
sliderOutputLevel.slider.setPosMapHigh(35.0f);
sliderOutputLevel.slider.setPosMapLow(-35.0f);
sliderOutputLevel.slider.setPosMapFmt("%+.0f dB");
sliderOutputLevel.slider.setPosMapDownFmt("%+.1f");
}

void LevelsGroup::attachVTS(AudioProcessorValueTreeState& vts)
{
attInputLevel.reset(
new SliderAttachment(vts, "idInputLevel", sliderInputLevel.slider));
attOutputLevel.reset(
new SliderAttachment(vts, "idOutputLevel", sliderOutputLevel.slider));
}

void LevelsGroup::attachTooltips(const TooltipsData& tooltips)
{
sliderInputLevel.slider.setTooltip(tooltips.getForParam("idInputLevel"));
sliderOutputLevel.slider.setTooltip(tooltips.getForParam("idOutputLevel"));
}

void LevelsGroup::resized()
{
const int prevInnerHeight = getBorderBounds().getHeight() - 2 * spacing;
const Point<int> prevCorner =
getBorderBounds().getTopLeft() + Point<int>(spacing, spacing);

ParameterGroup::resized();

const int innerHeight = getBorderBounds().getHeight() - 2 * spacing;
Point<int> corner =
getBorderBounds().getTopLeft() + Point<int>(spacing, spacing);

// only re-set the positions when the height or position changes
if (prevInnerHeight == innerHeight && prevCorner == corner) return;

meterInL.setTopLeftPosition(corner);
meterInL.setBarHeight(innerHeight);

corner = meterInL.getBounds().getTopRight() + Point<int>(spacing, 0);

meterInR.setTopLeftPosition(corner);
meterInR.setBarHeight(innerHeight);

corner = meterInR.getBounds().getTopRight() + Point<int>(spacing, 0);

sliderInputLevel.setTopLeftPosition(corner);
sliderInputLevel.slider.setMargin(0.15f * (float)innerHeight);
sliderInputLevel.setHeight(innerHeight);

corner = sliderInputLevel.getBounds().getTopRight() + Point<int>(spacing, 0);

sliderOutputLevel.setTopLeftPosition(corner);
sliderOutputLevel.slider.setMargin(0.15f * (float)innerHeight);
sliderOutputLevel.setHeight(innerHeight);

corner = sliderOutputLevel.getBounds().getTopRight() + Point<int>(spacing, 0);

meterOutL.setTopLeftPosition(corner);
meterOutL.setBarHeight(innerHeight);

corner = meterOutL.getBounds().getTopRight() + Point<int>(spacing, 0);

meterOutR.setTopLeftPosition(corner);
meterOutR.setBarHeight(innerHeight);

corner = meterOutR.getBounds().getTopRight() + Point<int>(spacing, 0);

// can now determine the width and set it, this will re-call `resized` but
// since the height is the same it won't re-do the calculation
setSize(corner.getX() - getBounds().getX(), getHeight());
}

+ 59
- 0
ports/swankyamp/source/Components/LevelsGroup.h View File

@@ -0,0 +1,59 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>

#include "../Utils.h"
#include "LevelMeter.h"
#include "ParameterGroup.h"
#include "RSliderLabel.h"

class LevelsGroup : public ParameterGroup
{
public:
LevelsGroup();
~LevelsGroup() {}

void setHeight(int height) { setSize(0, height); }
void resized() override;

void attachVTS(AudioProcessorValueTreeState& vts) override;
void attachTooltips(const TooltipsData& tooltips) override;

LevelMeterListener* getLevelMeterListenerInL() { return &meterInL; }
LevelMeterListener* getLevelMeterListenerInR() { return &meterInR; }
LevelMeterListener* getLevelMeterListenerOutL() { return &meterOutL; }
LevelMeterListener* getLevelMeterListenerOutR() { return &meterOutR; }

private:
LevelMeter meterInL;
LevelMeter meterInR;
LevelMeter meterOutL;
LevelMeter meterOutR;

RSliderLabel sliderInputLevel;
RSliderLabel sliderOutputLevel;

std::unique_ptr<SliderAttachment> attInputLevel;
std::unique_ptr<SliderAttachment> attOutputLevel;

DISABLE_COMPONENT_RESIZE()
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LevelsGroup)
};

+ 109
- 0
ports/swankyamp/source/Components/ParameterGroup.cpp View File

@@ -0,0 +1,109 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <JuceHeader.h>

#include "../Utils.h"

#include "ParameterGroup.h"

ParameterGroup::ParameterGroup(const String& pLabel)
{
setLabel(pLabel);
label.setJustificationType(Justification::topLeft);
label.setFont(24.0f);

gradient.addColour(0.0f, Colours::white);
gradient.addColour(0.5f, Colours::white);
gradient.addColour(1.0f, Colours::white);

addAndMakeVisible(label);
}

void ParameterGroup::setFont(const Font& font)
{
label.setFont(font);
// note that if the font size changes, the box will need to change
resized();
}

void ParameterGroup::setFont(float height)
{
label.setFont(height);
resized();
}

void ParameterGroup::setLineThickness(float thickness)
{
lineThickness = thickness;
// note: border bounds depend on line thickness affects paint
resized();
}

void ParameterGroup::setSpacing(int pSpacing)
{
spacing = pSpacing;
resized();
}

void ParameterGroup::paint(Graphics& g)
{
gradient.setColour(0, findColour(steelColourId));
gradient.setColour(1, Colours::white);
gradient.setColour(2, findColour(steelColourId));

g.setGradientFill(gradient);
g.fillRoundedRectangle(getBorderBounds().toFloat(), 2.0f * lineThickness);

g.drawImage(
bgNoise, getBorderBounds().toFloat(), RectanglePlacement::stretchToFit);

g.setColour(findColour(borderColourId));
g.drawRoundedRectangle(
getBorderBounds().toFloat(), 2.0f * lineThickness, lineThickness);

g.setColour(Colour::fromHSV(0.0f, 0.0f, 1.0f, 0.5f));
g.drawRoundedRectangle(
getBorderBounds().toFloat().translated(
-lineThickness / 4.0f, -lineThickness / 4.0f),
2.0f * lineThickness,
lineThickness / 2.0f);
}

void ParameterGroup::resized()
{
label.setBounds(
getLocalBounds().withHeight((int)(label.getFont().getHeight() + 0.5f)));

Rectangle<float> bounds = getLocalBounds().toFloat();
bounds.setTop(label.getFont().getHeight());
BorderSize<float>(lineThickness / 2.0f).subtractFrom(bounds);
borderBounds = bounds.toNearestInt();

bgNoise = buildImageNoise(
// noise is not as wide, and gets stretched to create brushed metal
jmax(1, getBorderBounds().getWidth() / 20),
getBorderBounds().getHeight(),
rng,
bgNoiseAlpha);

gradient.point1 = getBorderBounds().getCentre().toFloat().translated(
-0.5f * (float)getHeight(), 0.0f);
gradient.point2 = getBorderBounds().getCentre().toFloat().translated(
+0.5f * (float)getHeight(), 0.0f);
}

+ 79
- 0
ports/swankyamp/source/Components/ParameterGroup.h View File

@@ -0,0 +1,79 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>

#include "../TooltipsData.h"
#include "../Utils.h"

typedef AudioProcessorValueTreeState::SliderAttachment SliderAttachment;
typedef AudioProcessorValueTreeState::ButtonAttachment ButtonAttachment;

/*
* A group of parameters drawn in a box, with a label sitting atop the box.
*/
class ParameterGroup : public Component
{
public:
ParameterGroup(const String& label);
ParameterGroup() : ParameterGroup("") {}
virtual ~ParameterGroup() {}

virtual void paint(Graphics&) override;
virtual void resized() override;

virtual void attachVTS(AudioProcessorValueTreeState& vts) = 0;
virtual void attachTooltips(const TooltipsData&) {}

const juce::Rectangle<int>& getBorderBounds() const { return borderBounds; }

void setLabel(const String& pLabel)
{
label.setText(pLabel, dontSendNotification);
}
void setFont(const Font& font);
void setFont(float height);
void setLineThickness(float thickness);
void setSpacing(int spacing);
void setBgNoiseAlpha(float alpha) { bgNoiseAlpha = alpha; }

float getLineThickness() const { return lineThickness; }
int getSpacing() const { return spacing; }

enum ColourIds
{
borderColourId = 0x2000101, // the colour of the border
steelColourId = 0x2000102, // the component background brushed steel colour
};

protected:
Label label;
float lineThickness = 2.0f;
int spacing = 12;
juce::Rectangle<int> borderBounds;
float bgNoiseAlpha = 0.04f;

ColourGradient gradient;
Image bgNoise;
Random rng;

private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ParameterGroup)
};

+ 91
- 0
ports/swankyamp/source/Components/PowerAmpGroup.cpp View File

@@ -0,0 +1,91 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <JuceHeader.h>

#include "PowerAmpGroup.h"

PowerAmpGroup::PowerAmpGroup() : ParameterGroup("POWER AMP")
{
addAndMakeVisible(sliderDrive);
sliderDrive.setLabel("DRIVE");
sliderDrive.slider.setPosMapDownFmt("%4.1f");
sliderDrive.slider.setOverValue(0.7f);

addAndMakeVisible(sliderTight);
sliderTight.setLabel("TIGHT");
sliderTight.slider.setPosMapDownFmt("%4.1f");

addAndMakeVisible(sliderSag);
sliderSag.setLabel("SAG");
sliderSag.slider.setPosMapDownFmt("%4.1f");
}

void PowerAmpGroup::attachVTS(AudioProcessorValueTreeState& vts)
{
attDrive.reset(
new SliderAttachment(vts, "idPowerAmpDrive", sliderDrive.slider));
attTight.reset(
new SliderAttachment(vts, "idPowerAmpTight", sliderTight.slider));
attSag.reset(new SliderAttachment(vts, "idPowerAmpSag", sliderSag.slider));
}

void PowerAmpGroup::attachTooltips(const TooltipsData& tooltips)
{
sliderDrive.slider.setTooltip(tooltips.getForParam("idPowerAmpDrive"));
sliderTight.slider.setTooltip(tooltips.getForParam("idPowerAmpTight"));
sliderSag.slider.setTooltip(tooltips.getForParam("idPowerAmpSag"));
}

void PowerAmpGroup::resized()
{
const int prevInnerHeight = getBorderBounds().getHeight() - 2 * spacing;
const Point<int> prevCorner =
getBorderBounds().getTopLeft() + Point<int>(spacing, spacing);

ParameterGroup::resized();

const int innerHeight = getBorderBounds().getHeight() - 2 * spacing;
Point<int> corner =
getBorderBounds().getTopLeft() + Point<int>(spacing, spacing);

// only re-set the positions when the height or position changes
if (prevInnerHeight == innerHeight && prevCorner == corner) return;

sliderDrive.setTopLeftPosition(corner);
sliderDrive.slider.setMargin(0.15f * (float)innerHeight);
sliderDrive.setHeight(innerHeight);

corner = sliderDrive.getBounds().getTopRight() + Point<int>(spacing, 0);

sliderTight.setTopLeftPosition(corner);
sliderTight.slider.setMargin(0.15f * (float)innerHeight);
sliderTight.setHeight(innerHeight);

corner = sliderTight.getBounds().getTopRight() + Point<int>(spacing, 0);

sliderSag.setTopLeftPosition(corner);
sliderSag.slider.setMargin(0.15f * (float)innerHeight);
sliderSag.setHeight(innerHeight);

corner = sliderSag.getBounds().getTopRight() + Point<int>(spacing, 0);

// can now determine the width and set it, this will re-call `resized` but
// since the height is the same it won't re-do the calculation
setSize(corner.getX() - getBounds().getX(), getHeight());
}

+ 50
- 0
ports/swankyamp/source/Components/PowerAmpGroup.h View File

@@ -0,0 +1,50 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>

#include "../Utils.h"
#include "ParameterGroup.h"
#include "RSliderLabel.h"

class PowerAmpGroup : public ParameterGroup
{
public:
PowerAmpGroup();
~PowerAmpGroup() {}

void setHeight(int height) { setSize(0, height); }
void resized() override;

void attachVTS(AudioProcessorValueTreeState& vts) override;
void attachTooltips(const TooltipsData& tooltips) override;

private:
RSliderLabel sliderDrive;
RSliderLabel sliderTight;
RSliderLabel sliderSag;

std::unique_ptr<SliderAttachment> attDrive;
std::unique_ptr<SliderAttachment> attTight;
std::unique_ptr<SliderAttachment> attSag;

DISABLE_COMPONENT_RESIZE()
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PowerAmpGroup)
};

+ 92
- 0
ports/swankyamp/source/Components/PreAmpGroup.cpp View File

@@ -0,0 +1,92 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <JuceHeader.h>

#include "PreAmpGroup.h"

PreAmpGroup::PreAmpGroup() : ParameterGroup("PRE AMP")
{
addAndMakeVisible(sliderDrive);
sliderDrive.setLabel("DRIVE");
sliderDrive.slider.setPosMapDownFmt("%4.1f");
sliderDrive.slider.setOverValue(0.7f);

addAndMakeVisible(sliderTight);
sliderTight.setLabel("TIGHT");
sliderTight.slider.setPosMapDownFmt("%4.1f");

addAndMakeVisible(sliderGrit);
sliderGrit.setLabel("GRIT");
sliderGrit.slider.setPosMapDownFmt("%4.1f");
sliderGrit.slider.setOverValue(0.7f);
}

void PreAmpGroup::attachVTS(AudioProcessorValueTreeState& vts)
{
attDrive.reset(
new SliderAttachment(vts, "idPreAmpDrive", sliderDrive.slider));
attTight.reset(
new SliderAttachment(vts, "idPreAmpTight", sliderTight.slider));
attGrit.reset(new SliderAttachment(vts, "idPreAmpGrit", sliderGrit.slider));
}

void PreAmpGroup::attachTooltips(const TooltipsData& tooltips)
{
sliderDrive.slider.setTooltip(tooltips.getForParam("idPreAmpDrive"));
sliderTight.slider.setTooltip(tooltips.getForParam("idPreAmpTight"));
sliderGrit.slider.setTooltip(tooltips.getForParam("idPreAmpGrit"));
}

void PreAmpGroup::resized()
{
const int prevInnerHeight = getBorderBounds().getHeight() - 2 * spacing;
const Point<int> prevCorner =
getBorderBounds().getTopLeft() + Point<int>(spacing, spacing);

ParameterGroup::resized();

const int innerHeight = getBorderBounds().getHeight() - 2 * spacing;
Point<int> corner =
getBorderBounds().getTopLeft() + Point<int>(spacing, spacing);

// only re-set the positions when the height or position changes
if (prevInnerHeight == innerHeight && prevCorner == corner) return;

sliderDrive.setTopLeftPosition(corner);
sliderDrive.slider.setMargin(0.15f * (float)innerHeight);
sliderDrive.setHeight(innerHeight);

corner = sliderDrive.getBounds().getTopRight() + Point<int>(spacing, 0);

sliderTight.setTopLeftPosition(corner);
sliderTight.slider.setMargin(0.15f * (float)innerHeight);
sliderTight.setHeight(innerHeight);

corner = sliderTight.getBounds().getTopRight() + Point<int>(spacing, 0);

sliderGrit.setTopLeftPosition(corner);
sliderGrit.slider.setMargin(0.15f * (float)innerHeight);
sliderGrit.setHeight(innerHeight);

corner = sliderGrit.getBounds().getTopRight() + Point<int>(spacing, 0);

// can now determine the width and set it, this will re-call `resized` but
// since the height is the same it won't re-do the calculation
setSize(corner.getX() - getBounds().getX(), getHeight());
}

+ 50
- 0
ports/swankyamp/source/Components/PreAmpGroup.h View File

@@ -0,0 +1,50 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>

#include "../Utils.h"
#include "ParameterGroup.h"
#include "RSliderLabel.h"

class PreAmpGroup : public ParameterGroup
{
public:
PreAmpGroup();
~PreAmpGroup() {}

void setHeight(int height) { setSize(0, height); }
void resized() override;

void attachVTS(AudioProcessorValueTreeState& vts) override;
void attachTooltips(const TooltipsData& tooltips) override;

private:
RSliderLabel sliderDrive;
RSliderLabel sliderTight;
RSliderLabel sliderGrit;

std::unique_ptr<SliderAttachment> attDrive;
std::unique_ptr<SliderAttachment> attTight;
std::unique_ptr<SliderAttachment> attGrit;

DISABLE_COMPONENT_RESIZE()
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PreAmpGroup)
};

+ 135
- 0
ports/swankyamp/source/Components/PresetGroup.cpp View File

@@ -0,0 +1,135 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <JuceHeader.h>

#include "../SwankyAmpLAF.h"
#include "LevelMeter.h"
#include "ParameterGroup.h"
#include "PresetGroup.h"

PresetGroup::PresetGroup() :
buttonSave("presetGroupButtonSave", DrawableButton::ButtonStyle::ImageRaw),
buttonRemove(
"presetGroupButtonRemove", DrawableButton::ButtonStyle::ImageRaw),
buttonNext("presetGroupButtonNext", DrawableButton::ButtonStyle::ImageRaw),
buttonPrev("presetGroupButtonPrev", DrawableButton::ButtonStyle::ImageRaw),
buttonOpen("presetGroupButtonOpen", DrawableButton::ButtonStyle::ImageRaw)
{
presetSelector.setEditableText(true);
addAndMakeVisible(presetSelector);

saveIcon.setFill(Colours::transparentBlack);
saveIcon.setStrokeFill(SwankyAmpLAF::colourDark);
saveIconHighlight.setFill(Colours::transparentBlack);
saveIconHighlight.setStrokeFill(SwankyAmpLAF::colourHighlight);
addAndMakeVisible(buttonSave);

removeIcon.setFill(Colours::transparentBlack);
removeIcon.setStrokeFill(SwankyAmpLAF::colourDark);
removeIconHighlight.setFill(Colours::transparentBlack);
removeIconHighlight.setStrokeFill(SwankyAmpLAF::colourHighlight);
addAndMakeVisible(buttonRemove);

nextIcon.setFill(Colours::transparentBlack);
nextIcon.setStrokeFill(SwankyAmpLAF::colourDark);
nextIconHighlight.setFill(Colours::transparentBlack);
nextIconHighlight.setStrokeFill(SwankyAmpLAF::colourHighlight);
addAndMakeVisible(buttonNext);

prevIcon.setFill(Colours::transparentBlack);
prevIcon.setStrokeFill(SwankyAmpLAF::colourDark);
prevIconHighlight.setFill(Colours::transparentBlack);
prevIconHighlight.setStrokeFill(SwankyAmpLAF::colourHighlight);
addAndMakeVisible(buttonPrev);

openIcon.setFill(Colours::transparentBlack);
openIcon.setStrokeFill(SwankyAmpLAF::colourDark);
openIconHighlight.setFill(Colours::transparentBlack);
openIconHighlight.setStrokeFill(SwankyAmpLAF::colourHighlight);
addAndMakeVisible(buttonOpen);
}

void PresetGroup::paint(Graphics& g)
{
// skip the group paint to avoid drawing border
Component::paint(g);
}

void PresetGroup::resized()
{
ParameterGroup::resized();
presetSelector.setTopLeftPosition(0, 0);
presetSelector.setSize(getHeight() * 8, getHeight());

const float stroke = 2.0f;
const float pad = 8.0f;

prevIcon.setPath(SwankyAmpLAF::getPrevIconPath((float)getHeight(), pad));
prevIcon.setStrokeType(PathStrokeType(stroke));
prevIconHighlight.setStrokeType(PathStrokeType(stroke));
prevIconHighlight.setPath(
SwankyAmpLAF::getPrevIconPath((float)getHeight(), pad));
buttonPrev.setImages(&prevIcon, &prevIconHighlight);

buttonPrev.setSize(getHeight(), getHeight());
buttonPrev.setTopLeftPosition(
presetSelector.getBounds().getTopRight() + Point<int>(spacing, 0));

nextIcon.setPath(SwankyAmpLAF::getNextIconPath((float)getHeight(), pad));
nextIcon.setStrokeType(PathStrokeType(stroke));
nextIconHighlight.setStrokeType(PathStrokeType(stroke));
nextIconHighlight.setPath(
SwankyAmpLAF::getNextIconPath((float)getHeight(), pad));
buttonNext.setImages(&nextIcon, &nextIconHighlight);

buttonNext.setSize(getHeight(), getHeight());
buttonNext.setTopLeftPosition(buttonPrev.getBounds().getTopRight());

saveIcon.setPath(SwankyAmpLAF::getSaveIconPath((float)getHeight(), pad));
saveIcon.setStrokeType(PathStrokeType(stroke));
saveIconHighlight.setStrokeType(PathStrokeType(stroke));
saveIconHighlight.setPath(
SwankyAmpLAF::getSaveIconPath((float)getHeight(), pad));
buttonSave.setImages(&saveIcon, &saveIconHighlight);

buttonSave.setSize(getHeight(), getHeight());
buttonSave.setTopLeftPosition(buttonNext.getBounds().getTopRight());

removeIcon.setPath(SwankyAmpLAF::getRemoveIconPath((float)getHeight(), pad));
removeIcon.setStrokeType(PathStrokeType(stroke));
removeIconHighlight.setStrokeType(PathStrokeType(stroke));
removeIconHighlight.setPath(
SwankyAmpLAF::getRemoveIconPath((float)getHeight(), pad));
buttonRemove.setImages(&removeIcon, &removeIconHighlight);

buttonRemove.setSize(getHeight(), getHeight());
buttonRemove.setTopLeftPosition(buttonSave.getBounds().getTopRight());

openIcon.setPath(SwankyAmpLAF::getOpenIconPath((float)getHeight(), pad));
openIcon.setStrokeType(PathStrokeType(stroke));
openIconHighlight.setStrokeType(PathStrokeType(stroke));
openIconHighlight.setPath(
SwankyAmpLAF::getOpenIconPath((float)getHeight(), pad));
buttonOpen.setImages(&openIcon, &openIconHighlight);

buttonOpen.setSize(getHeight(), getHeight());
buttonOpen.setTopLeftPosition(buttonRemove.getBounds().getTopRight());

setSize(buttonOpen.getRight(), getHeight());
}

+ 70
- 0
ports/swankyamp/source/Components/PresetGroup.h View File

@@ -0,0 +1,70 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>

#include "../Utils.h"
#include "ParameterGroup.h"

class PresetGroup : public ParameterGroup
{
public:
PresetGroup();
~PresetGroup() {}

void attachVTS(AudioProcessorValueTreeState&) override {}
void addPresetListener(ComboBox::Listener* listener)
{
presetSelector.addListener(listener);
}

void setHeight(int height) { setSize(0, height); }
void paint(Graphics& g) override;
void resized() override;

enum ComboIds
{
PresetInit = 1,
PresetOther = 2,
};

// public so the preset manager can modify it
ComboBox presetSelector;
DrawableButton buttonSave;
DrawableButton buttonRemove;
DrawableButton buttonNext;
DrawableButton buttonPrev;
DrawableButton buttonOpen;

private:
DrawablePath saveIcon;
DrawablePath saveIconHighlight;
DrawablePath removeIcon;
DrawablePath removeIconHighlight;
DrawablePath nextIcon;
DrawablePath nextIconHighlight;
DrawablePath prevIcon;
DrawablePath prevIconHighlight;
DrawablePath openIcon;
DrawablePath openIconHighlight;

DISABLE_COMPONENT_RESIZE()
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PresetGroup)
};

+ 29
- 0
ports/swankyamp/source/Components/RButton.cpp View File

@@ -0,0 +1,29 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <JuceHeader.h>

#include "../Utils.h"

#include "RButton.h"

void RButton::resized()
{
ToggleButton::resized();
bgNoise = buildImageNoise(getWidth(), getHeight(), rng, 0.1f);
}

+ 50
- 0
ports/swankyamp/source/Components/RButton.h View File

@@ -0,0 +1,50 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>

class RButton : public ToggleButton
{
public:
RButton() {}
~RButton() {}

void resized() override;

float calcWidthForHeight(float height) const { return height / 2.0f; }
float calcHeightForWidth(float width) const { return width * 2.0f; }

const Image& getBgNoise() const { return bgNoise; }

enum ColourIds
{
buttonColourId = 0x2000401,
textColourId = 0x2000402,
};

String textOn = "ON";
String textOff = "OFF";

private:
Random rng;
Image bgNoise;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(RButton)
};

+ 118
- 0
ports/swankyamp/source/Components/RSlider.cpp View File

@@ -0,0 +1,118 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <JuceHeader.h>

#include "../Utils.h"

#include "RSlider.h"

RSlider::RSlider()
{
setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
setTextBoxStyle(Slider::TextEntryBoxPosition::NoTextBox, true, 0, 0);
}

// from:
// https://stackoverflow.com/questions/2342162/stdstring-formatting-like-sprintf
// I don't even recognize C++ anymore, this looks like rust to me
template<typename... Args>
std::string stringFormat(const std::string& format, Args... args)
{
size_t size = snprintf(nullptr, 0, format.c_str(), args...)
+ (size_t)1; // Extra space for '\0'
if (size <= 0) throw std::runtime_error("Error during formatting.");
std::unique_ptr<char[]> buf(new char[size]);
snprintf(buf.get(), size, format.c_str(), args...);
return std::string(
buf.get(),
buf.get() + size - 1); // We don't want the '\0' inside
}

String RSlider::fmtSliderPos(float sliderPos) const
{
const float pos = sliderPos * (posMapHigh - posMapLow) + posMapLow;
if (isMouseButtonDown() && posMapDownFmt.length() > 0)
return String(stringFormat(posMapDownFmt.toStdString(), pos));
else
return String(stringFormat(posMapFmt.toStdString(), pos));
}

RSliderDims RSlider::calcDims() const
{
RSliderDims dims;

dims.gap = gap;
dims.margin = margin;

const RotaryParameters rotPars = getRotaryParameters();
dims.theta = jmax(
fabsf(angleModulo(rotPars.startAngleRadians)),
fabsf(angleModulo(rotPars.endAngleRadians)));

const float radiusForWidth =
(float)getBounds().getWidth() / 2.0f - dims.margin;
const float radiusForHeight = ((float)getBounds().getHeight() - dims.margin)
/ (1.0f - cosf(dims.theta));
dims.radius = jmin(radiusForWidth, radiusForHeight);

// the amount clipped from the bottom due to limited angle
const float clipped = jmin(
// remove the bottom margin, and some amount of the knob
(1.0f + cosf(dims.theta)) * dims.radius + dims.margin,
// always leave at least the top margin
2.0f * dims.radius + dims.margin);

dims.innerBounds = getBounds().toFloat();
dims.innerBounds.setSize(
(dims.radius + dims.margin) * 2.0f,
(dims.radius + dims.margin) * 2.0f - clipped);
dims.innerBounds.translate(
(getBounds().getWidth() - dims.innerBounds.getWidth()) / 2.0f,
(getBounds().getHeight() - dims.innerBounds.getHeight()) / 2.0f);

dims.centre.setXY(
dims.innerBounds.getX() + dims.margin + dims.radius,
dims.innerBounds.getY() + dims.margin + dims.radius);

return dims;
}

float RSlider::calcWidthForHeight(float height) const
{
const RotaryParameters rotPars = getRotaryParameters();
const float theta = jmax(
fabsf(angleModulo(rotPars.startAngleRadians)),
fabsf(angleModulo(rotPars.endAngleRadians)));

const float radiusForHeight = (height - margin) / (1.0f - cosf(theta));

return (radiusForHeight + margin) * 2.0f;
}

float RSlider::calcHeightForWidth(float width) const
{
const float radiusForWidth = width / 2.0f - margin;
return (radiusForWidth + margin) * 2.0f;
}

void RSlider::resized()
{
Slider::resized();
bgNoise = buildImageNoise(getWidth(), getHeight(), rng, 0.1f);
}

+ 93
- 0
ports/swankyamp/source/Components/RSlider.h View File

@@ -0,0 +1,93 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>

struct RSliderDims
{
// the radius of the knob
float radius = 0.0f;
// the amount of space between the knob edge and the graphic edge
float margin = 0.0f;
// the gap between the knob and the dots in the margin
float gap = 0.0f;
// the largest angle of the knob, where it cuts away
float theta = 0.0f;
// the bounds of the graphic
juce::Rectangle<float> innerBounds;
// the center of the knob
Point<float> centre;
};

class RSlider : public Slider
{
public:
RSlider();
// NOTE: base class destructor is not virtual, so can't be using pointers to
// an `RSlider` of type `Slider*` when deleting.
~RSlider() {}

void resized() override;

String fmtSliderPos(float sliderPos) const;

// NOTE: this could be called on `resized` and cached, but it also depends on
// the rotary parameters, so best to call on every paint
RSliderDims calcDims() const;
float calcWidthForHeight(float height) const;
float calcHeightForWidth(float width) const;

void setGap(float pGap) { gap = pGap; }
void setMargin(float pMargin) { margin = pMargin; }
void setOverValue(float value) { overValue = value; }
void setPosMapLow(float value) { posMapLow = value; }
void setPosMapHigh(float value) { posMapHigh = value; }
void setPosMapFmt(const String& fmt) { posMapFmt = fmt; }
void setPosMapDownFmt(const String& fmt) { posMapDownFmt = fmt; }

const Image& getBgNoise() const { return bgNoise; }
const float getOverValue() const { return overValue; }

enum ColourIds
{
dialColourId = 0x2000201,
dialOutlineColourId = 0x2000202,
dialTextColourId = 0x2000203,
dialDotColourId = 0x2000204,
};

private:
using Slider::setSliderStyle;
using Slider::setTextBoxStyle;

float posMapLow = 0.0f;
float posMapHigh = 10.0f;
String posMapFmt = "%02.0f";
String posMapDownFmt = "";

float gap = 2.0f;
float margin = 0.0f;
float overValue = -1.0f;

Random rng;
Image bgNoise;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(RSlider)
};

+ 81
- 0
ports/swankyamp/source/Components/RSliderLabel.cpp View File

@@ -0,0 +1,81 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <JuceHeader.h>

#include "RSliderLabel.h"

RSliderLabel::RSliderLabel()
{
addAndMakeVisible(slider);
addAndMakeVisible(label);
label.setJustificationType(Justification::centredTop);
label.setFont(16.0f);
slider.setMouseDragSensitivity(400);
}

void RSliderLabel::setWidth(int width)
{
setDimension = SetDimension::SetFromWidth;
setSize(width, 0);
}

void RSliderLabel::setHeight(int height)
{
setDimension = SetDimension::SetFromHeight;
setSize(0, height);
}

void RSliderLabel::setSliderMargin(float margin)
{
slider.setMargin(margin);
// since the slider aspect ratio changes, must re-calculate the sizes
resized();
}

void RSliderLabel::resized()
{
if (setDimension == SetDimension::NoDimension)
{
slider.setSize(0, 0);
label.setSize(0, 0);
return;
}

const int labelHeight = (int)(label.getFont().getHeight() + 0.5f);

if (setDimension == SetDimension::SetFromHeight)
{
const int sliderHeight = jmax(0, getHeight() - labelHeight);
const int width =
(int)(slider.calcWidthForHeight((float)sliderHeight) + 0.5f);
// note: this does re-trigger `resized`, but it won't recurse because it
// proceeds only if bounds changed
setSize(width, getHeight());
}
else if (setDimension == SetDimension::SetFromWidth)
{
const int sliderHeight =
(int)(slider.calcHeightForWidth((float)getWidth()) + 0.5f);
setSize(getWidth(), sliderHeight + labelHeight);
}

slider.setSize(getWidth(), getHeight() - labelHeight);
label.setSize(getWidth(), labelHeight);
label.setTopLeftPosition(slider.getLocalBounds().getBottomLeft());
}

+ 60
- 0
ports/swankyamp/source/Components/RSliderLabel.h View File

@@ -0,0 +1,60 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>

#include "../Utils.h"
#include "RSlider.h"

class RSliderLabel : public Component
{
public:
RSliderLabel();
~RSliderLabel() {}

void resized() override;

void setLabel(const String& text)
{
label.setText(text, NotificationType::dontSendNotification);
}

void setHeight(int size);
void setWidth(int size);
void setSliderMargin(float size);

// TODO: publich for parameter attachment, but maybe RSliderLabel should
// just inherent from RSlider and not compose the elements?
RSlider slider;

private:
Label label;

enum class SetDimension
{
SetFromHeight,
SetFromWidth,
NoDimension
};
SetDimension setDimension = SetDimension::NoDimension;

DISABLE_COMPONENT_RESIZE()
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(RSliderLabel)
};

+ 105
- 0
ports/swankyamp/source/Components/StagingGroup.cpp View File

@@ -0,0 +1,105 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <JuceHeader.h>

#include "StagingGroup.h"

StagingGroup::StagingGroup() : ParameterGroup("STAGING")
{
addAndMakeVisible(sliderStages);
sliderStages.setLabel("STAGES");
sliderStages.slider.setPosMapLow(1.0f);
sliderStages.slider.setPosMapHigh(5.0f);
sliderStages.slider.setPosMapDownFmt("%4.1f");

addAndMakeVisible(sliderOverhead);
sliderOverhead.setLabel("OVERHEAD");
sliderOverhead.slider.setPosMapDownFmt("%4.1f");

addAndMakeVisible(sliderFilter);
sliderFilter.setLabel("LOW CUT");
sliderFilter.slider.setPosMapDownFmt("%4.1f");

addAndMakeVisible(sliderSelection);
sliderSelection.setLabel("TONE STACK");
sliderSelection.slider.setPosMapDownFmt("%4.1f");
}

void StagingGroup::attachVTS(AudioProcessorValueTreeState& vts)
{
attStages.reset(
new SliderAttachment(vts, "idGainStages", sliderStages.slider));
attOverhead.reset(
new SliderAttachment(vts, "idGainOverhead", sliderOverhead.slider));
attFilter.reset(new SliderAttachment(vts, "idLowCut", sliderFilter.slider));
attSelection.reset(
new SliderAttachment(vts, "idTsSelection", sliderSelection.slider));
}

void StagingGroup::attachTooltips(const TooltipsData& tooltips)
{
sliderStages.slider.setTooltip(tooltips.getForParam("idGainStages"));
sliderOverhead.slider.setTooltip(tooltips.getForParam("idGainOverhead"));
sliderFilter.slider.setTooltip(tooltips.getForParam("idLowCut"));
sliderSelection.slider.setTooltip(tooltips.getForParam("idTsSelection"));
}

void StagingGroup::resized()
{
const int prevInnerHeight = getBorderBounds().getHeight() - 2 * spacing;
const Point<int> prevCorner =
getBorderBounds().getTopLeft() + Point<int>(spacing, spacing);

ParameterGroup::resized();

const int innerHeight = getBorderBounds().getHeight() - 2 * spacing;
Point<int> corner =
getBorderBounds().getTopLeft() + Point<int>(spacing, spacing);

// only re-set the positions when the height or position changes
if (prevInnerHeight == innerHeight && prevCorner == corner) return;

sliderStages.setTopLeftPosition(corner);
sliderStages.slider.setMargin(0.15f * (float)innerHeight);
sliderStages.setHeight(innerHeight);

corner = sliderStages.getBounds().getTopRight() + Point<int>(spacing, 0);

sliderOverhead.setTopLeftPosition(corner);
sliderOverhead.slider.setMargin(0.15f * (float)innerHeight);
sliderOverhead.setHeight(innerHeight);

corner = sliderOverhead.getBounds().getTopRight() + Point<int>(spacing, 0);

sliderFilter.setTopLeftPosition(corner);
sliderFilter.slider.setMargin(0.15f * (float)innerHeight);
sliderFilter.setHeight(innerHeight);

corner = sliderFilter.getBounds().getTopRight() + Point<int>(spacing, 0);

sliderSelection.setTopLeftPosition(corner);
sliderSelection.slider.setMargin(0.15f * (float)innerHeight);
sliderSelection.setHeight(innerHeight);

corner = sliderSelection.getBounds().getTopRight() + Point<int>(spacing, 0);

// can now determine the width and set it, this will re-call `resized` but
// since the height is the same it won't re-do the calculation
setSize(corner.getX() - getBounds().getX(), getHeight());
}

+ 52
- 0
ports/swankyamp/source/Components/StagingGroup.h View File

@@ -0,0 +1,52 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>

#include "../Utils.h"
#include "ParameterGroup.h"
#include "RSliderLabel.h"

class StagingGroup : public ParameterGroup
{
public:
StagingGroup();
~StagingGroup() {}

void setHeight(int height) { setSize(0, height); }
void resized() override;

void attachVTS(AudioProcessorValueTreeState& vts) override;
void attachTooltips(const TooltipsData& tooltips) override;

private:
RSliderLabel sliderStages;
RSliderLabel sliderOverhead;
RSliderLabel sliderFilter;
RSliderLabel sliderSelection;

std::unique_ptr<SliderAttachment> attStages;
std::unique_ptr<SliderAttachment> attOverhead;
std::unique_ptr<SliderAttachment> attFilter;
std::unique_ptr<SliderAttachment> attSelection;

DISABLE_COMPONENT_RESIZE()
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(StagingGroup)
};

+ 101
- 0
ports/swankyamp/source/Components/ToneStackGroup.cpp View File

@@ -0,0 +1,101 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <JuceHeader.h>

#include "ToneStackGroup.h"

ToneStackGroup::ToneStackGroup() : ParameterGroup("TONE")
{
addAndMakeVisible(sliderLow);
sliderLow.setLabel("LOW");
sliderLow.slider.setPosMapDownFmt("%4.1f");

addAndMakeVisible(sliderMid);
sliderMid.setLabel("MID");
sliderMid.slider.setPosMapDownFmt("%4.1f");

addAndMakeVisible(sliderHigh);
sliderHigh.setLabel("HIGH");
sliderHigh.slider.setPosMapDownFmt("%4.1f");

addAndMakeVisible(sliderPresence);
sliderPresence.setLabel("PRESENCE");
sliderPresence.slider.setPosMapDownFmt("%4.1f");
}

void ToneStackGroup::attachVTS(AudioProcessorValueTreeState& vts)
{
attLow.reset(new SliderAttachment(vts, "idTsLow", sliderLow.slider));
attMid.reset(new SliderAttachment(vts, "idTsMid", sliderMid.slider));
attHigh.reset(new SliderAttachment(vts, "idTsHigh", sliderHigh.slider));
attPresence.reset(
new SliderAttachment(vts, "idTsPresence", sliderPresence.slider));
}

void ToneStackGroup::attachTooltips(const TooltipsData& tooltips)
{
sliderLow.slider.setTooltip(tooltips.getForParam("idTsLow"));
sliderMid.slider.setTooltip(tooltips.getForParam("idTsMid"));
sliderHigh.slider.setTooltip(tooltips.getForParam("idTsHigh"));
sliderPresence.slider.setTooltip(tooltips.getForParam("idTsPresence"));
}

void ToneStackGroup::resized()
{
const int prevInnerHeight = getBorderBounds().getHeight() - 2 * spacing;
const Point<int> prevCorner =
getBorderBounds().getTopLeft() + Point<int>(spacing, spacing);

ParameterGroup::resized();

const int innerHeight = getBorderBounds().getHeight() - 2 * spacing;
Point<int> corner =
getBorderBounds().getTopLeft() + Point<int>(spacing, spacing);

// only re-set the positions when the height or position changes
if (prevInnerHeight == innerHeight && prevCorner == corner) return;

sliderLow.setTopLeftPosition(corner);
sliderLow.slider.setMargin(0.15f * (float)innerHeight);
sliderLow.setHeight(innerHeight);

corner = sliderLow.getBounds().getTopRight() + Point<int>(spacing, 0);

sliderMid.setTopLeftPosition(corner);
sliderMid.slider.setMargin(0.15f * (float)innerHeight);
sliderMid.setHeight(innerHeight);

corner = sliderMid.getBounds().getTopRight() + Point<int>(spacing, 0);

sliderHigh.setTopLeftPosition(corner);
sliderHigh.slider.setMargin(0.15f * (float)innerHeight);
sliderHigh.setHeight(innerHeight);

corner = sliderHigh.getBounds().getTopRight() + Point<int>(spacing, 0);

sliderPresence.setTopLeftPosition(corner);
sliderPresence.slider.setMargin(0.15f * (float)innerHeight);
sliderPresence.setHeight(innerHeight);

corner = sliderPresence.getBounds().getTopRight() + Point<int>(spacing, 0);

// can now determine the width and set it, this will re-call `resized` but
// since the height is the same it won't re-do the calculation
setSize(corner.getX() - getBounds().getX(), getHeight());
}

+ 52
- 0
ports/swankyamp/source/Components/ToneStackGroup.h View File

@@ -0,0 +1,52 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>

#include "../Utils.h"
#include "ParameterGroup.h"
#include "RSliderLabel.h"

class ToneStackGroup : public ParameterGroup
{
public:
ToneStackGroup();
~ToneStackGroup() {}

void attachVTS(AudioProcessorValueTreeState& vts) override;
void attachTooltips(const TooltipsData& tooltips) override;

void setHeight(int height) { setSize(0, height); }
void resized() override;

private:
RSliderLabel sliderLow;
RSliderLabel sliderMid;
RSliderLabel sliderHigh;
RSliderLabel sliderPresence;

std::unique_ptr<SliderAttachment> attLow;
std::unique_ptr<SliderAttachment> attMid;
std::unique_ptr<SliderAttachment> attHigh;
std::unique_ptr<SliderAttachment> attPresence;

DISABLE_COMPONENT_RESIZE()
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ToneStackGroup)
};

+ 33
- 0
ports/swankyamp/source/JuceHeader.h View File

@@ -0,0 +1,33 @@
/*

IMPORTANT! This file is auto-generated each time you save your
project - if you alter its contents, your changes may be overwritten!

This is the header file that your files should include in order to get all the
JUCE library headers. You should avoid including the JUCE headers directly in
your own source files, because that wouldn't pick up the correct configuration
options for your app.

*/

#pragma once

#include "JucePluginMain.h"

#include "BinaryData.h"

#if ! DONT_SET_USING_JUCE_NAMESPACE
// If your code uses a lot of JUCE classes, then this will obviously save you
// a lot of typing, but can be disabled by setting DONT_SET_USING_JUCE_NAMESPACE.
using namespace juce;
#endif

#if ! JUCE_DONT_DECLARE_PROJECTINFO
namespace ProjectInfo
{
const char* const projectName = "SwankyAmp";
const char* const companyName = "Resonant DSP";
const char* const versionString = "1.4.0";
const int versionNumber = 0x10400;
}
#endif

+ 52
- 0
ports/swankyamp/source/JucePluginCharacteristics.h View File

@@ -0,0 +1,52 @@
#ifndef __JUCE_PLUGIN_CHARACTERISTICS_H__
#define __JUCE_PLUGIN_CHARACTERISTICS_H__

#define JucePlugin_Name "Swanky Amp"
#define JucePlugin_Desc "Tube amplifiers simulation"
#define JucePlugin_Manufacturer "Resonant DSP"
#define JucePlugin_ManufacturerWebsite "https://www.resonantdsp.com/"
#define JucePlugin_ManufacturerEmail "info@resonantdsp.com"
#define JucePlugin_ManufacturerCode 0x4d616e75
#define JucePlugin_PluginCode 0x63637766
#define JucePlugin_IsSynth 0
#define JucePlugin_WantsMidiInput 0
#define JucePlugin_ProducesMidiOutput 0
#define JucePlugin_IsMidiEffect 0
#define JucePlugin_EditorRequiresKeyboardFocus 0
#define JucePlugin_Version 1.4.0
#define JucePlugin_VersionCode 0x10400
#define JucePlugin_VersionString "1.4.0"
#define JucePlugin_VSTUniqueID JucePlugin_PluginCode
#define JucePlugin_VSTCategory kPlugCategEffect
#define JucePlugin_Vst3Category "Fx"
#define JucePlugin_AUMainType 'aufx'
#define JucePlugin_AUSubType JucePlugin_PluginCode
#define JucePlugin_AUExportPrefix SwankyAmpAU
#define JucePlugin_AUExportPrefixQuoted "SwankyAmpAU"
#define JucePlugin_AUManufacturerCode JucePlugin_ManufacturerCode
#define JucePlugin_CFBundleIdentifier com.ResonantDSP.SwankyAmp
#define JucePlugin_RTASCategory 8192
#define JucePlugin_RTASManufacturerCode JucePlugin_ManufacturerCode
#define JucePlugin_RTASProductId JucePlugin_PluginCode
#define JucePlugin_RTASDisableBypass 0
#define JucePlugin_RTASDisableMultiMono 0
#define JucePlugin_AAXIdentifier com.ResonantDSP.SwankyAmp
#define JucePlugin_AAXManufacturerCode JucePlugin_ManufacturerCode
#define JucePlugin_AAXProductId JucePlugin_PluginCode
#define JucePlugin_AAXCategory 8192
#define JucePlugin_AAXDisableBypass 0
#define JucePlugin_AAXDisableMultiMono 0
#define JucePlugin_IAAType 0x61757278
#define JucePlugin_IAASubType JucePlugin_PluginCode
#define JucePlugin_IAAName "Resonant DSP: Swanky Amp"
#define JucePlugin_VSTNumMidiInputs 16
#define JucePlugin_VSTNumMidiOutputs 16

#define JucePlugin_LV2URI "urn:distrho:SwankyAmp"
#define JucePlugin_LV2Category "SimulatorPlugin"
#define JucePlugin_WantsLV2Latency 0
#define JucePlugin_WantsLV2State 1
#define JucePlugin_WantsLV2TimePos 0
#define JucePlugin_WantsLV2Presets 1

#endif

+ 0
- 0
ports/swankyamp/source/NewComponent.cpp View File


+ 0
- 0
ports/swankyamp/source/NewComponent.h View File


+ 209
- 0
ports/swankyamp/source/PluginEditor.cpp View File

@@ -0,0 +1,209 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include "PluginProcessor.h"
#include "Utils.h"

#include "PluginEditor.h"

SwankyAmpAudioProcessorEditor::SwankyAmpAudioProcessorEditor(
SwankyAmpAudioProcessor& p, AudioProcessorValueTreeState& vts) :
AudioProcessorEditor(&p),
StateChangeMonitor(30),
processor(p),
valueTreeState(vts),
presetManager(
processor,
valueTreeState,
presetGroup.presetSelector,
presetGroup.buttonSave,
presetGroup.buttonRemove,
presetGroup.buttonNext,
presetGroup.buttonPrev,
presetGroup.buttonOpen),
// TODO: how to handle localization?
tooltipsData(XmlDocument::parse(BinaryData::tooltips_xml)),
tooltipWindow(this)
{
LookAndFeel::getDefaultLookAndFeel().setDefaultSansSerifTypeface(
laf.getDefaultFont().getTypeface());
setLookAndFeel(&laf);
tooltipWindow.setLookAndFeel(&laf);
tooltipWindow.setOpaque(false);

processor.meterListenersIn[0] =
ampGroup.levelsGroup.getLevelMeterListenerInL();
processor.meterListenersIn[1] =
ampGroup.levelsGroup.getLevelMeterListenerInR();
processor.meterListenersOut[0] =
ampGroup.levelsGroup.getLevelMeterListenerOutL();
processor.meterListenersOut[1] =
ampGroup.levelsGroup.getLevelMeterListenerOutR();

ampGroup.attachVTS(vts);
ampGroup.attachTooltips(tooltipsData);

for (const auto& parameterId : presetManager.getParameterIds())
{
valueTreeState.addParameterListener(parameterId, &presetManager);
managerListenIds.push_back(parameterId);
}

logoSvg = Drawable::createFromSVG(*XmlDocument::parse(BinaryData::logo_svg));

versionLabel.setText("v" JucePlugin_VersionString, dontSendNotification);
versionLabel.setColour(Label::textColourId, SwankyAmpLAF::colourDark);
versionLabel.setFont(16.0f);
versionLabel.setJustificationType(Justification::centredRight);

addAndMakeVisible(ampGroup);
addAndMakeVisible(presetGroup);
addAndMakeVisible(versionLabel);

setSize((int)(1.5f * 600 + 0.5f), 600);
}

#undef ATTACH_SLIDER

SwankyAmpAudioProcessorEditor::~SwankyAmpAudioProcessorEditor()
{
// the LAF can be called from ... who knows where, after the Editor goes out
// of scope
setLookAndFeel(nullptr);
// not sure destruction order could be an issue
tooltipWindow.setLookAndFeel(nullptr);

// ensure the processor doesn't used cache pointers that were freed
processor.meterListenersIn[0] = nullptr;
processor.meterListenersIn[1] = nullptr;
processor.meterListenersOut[0] = nullptr;
processor.meterListenersOut[1] = nullptr;

for (const auto& parameterId : managerListenIds)
valueTreeState.removeParameterListener(parameterId, &presetManager);
}

void SwankyAmpAudioProcessorEditor::paint(Graphics& g)
{
g.fillAll(getLookAndFeel().findColour(ResizableWindow::backgroundColourId));

g.drawImage(bgNoise, getLocalBounds().toFloat());

const float logoHeight = (float)headerHeight;
const float logoPadding = (float)headerPadding;

const float logoRatio =
(float)logoSvg->getWidth() / (float)logoSvg->getHeight();
const float logoWidth = logoRatio * (float)headerHeight;
const float logoX = getBounds().getRight() - logoPadding - logoWidth;
const float logoY = getBounds().getY() + logoPadding;
logoSvg->setTransformToFit(
Rectangle<float>(logoX, logoY, logoWidth, logoHeight),
RectanglePlacement::centred);
logoSvg->draw(g, 1.0f);

g.setColour(Colour::fromHSV(0.0f, 0.0f, 0.0f, 0.1f));
g.fillPath(bgPattern);
}

#undef GROUP_DROP_SHADOW

void SwankyAmpAudioProcessorEditor::buildBgPattern()
{
bgPattern.clear();

const float scale = (float)getLocalBounds().getHeight() * 0.667f;

const Point<float> corner(getLocalBounds().getBottomRight().toFloat());

bgPattern.startNewSubPath(corner - Point<float>(scale, 0.0f));
bgPattern.addCentredArc(
corner.getX(),
corner.getY(),
scale,
scale,
0.0f,
-MathConstants<float>::halfPi,
0.0f,
false);
bgPattern.lineTo(corner - Point<float>(0.0f, scale * 7.0f / 8.0f));
bgPattern.addCentredArc(
corner.getX(),
corner.getY(),
scale * 7.0f / 8.0f,
scale * 7.0f / 8.0f,
0.0f,
0.0f,
-MathConstants<float>::halfPi,
false);
bgPattern.closeSubPath();

bgPattern.startNewSubPath(corner - Point<float>(scale * 6.0f / 8.0f, 0.0f));
bgPattern.addCentredArc(
corner.getX(),
corner.getY(),
scale * 6.0f / 8.0f,
scale * 6.0f / 8.0f,
0.0f,
-MathConstants<float>::halfPi,
0.0f,
false);
bgPattern.lineTo(corner - Point<float>(0.0f, scale * 2.0f / 8.0f));
bgPattern.addCentredArc(
corner.getX(),
corner.getY(),
scale * 2.0f / 8.0f,
scale * 2.0f / 8.0f,
0.0f,
0.0f,
-MathConstants<float>::halfPi,
false);
bgPattern.closeSubPath();
}

void SwankyAmpAudioProcessorEditor::resized()
{
// build noise to texture background
rng.setSeed(1234);
bgNoise = buildImageNoise(getWidth(), getHeight(), rng, 0.04f);

ampGroup.setGroupsHeight(128);
const int marginX = jmax(0, getWidth() - ampGroup.getWidth());
const int marginY = jmax(0, getHeight() - ampGroup.getHeight());

ampGroup.setTopLeftPosition(marginX / 2, marginY / 2);

presetGroup.setHeight(headerHeight + 4);
presetGroup.setTopLeftPosition(headerPadding - 2, headerPadding - 2);

const int fontSize = (int)(versionLabel.getFont().getHeight() + 0.5f);
versionLabel.setSize(fontSize * 6, fontSize);
versionLabel.setTopLeftPosition(
getLocalBounds().getRight() - fontSize * 6 - 4,
getLocalBounds().getBottom() - fontSize - 4);

// rebuild on re-size to track bottom right corner, could be built once then
// translated, but in future might want to re-scale as well
buildBgPattern();
}

void SwankyAmpAudioProcessorEditor::stateChangeCallback()
{
const String& text = processor.getPresetText();
if (text.isNotEmpty()) presetManager.setStateText(text);
}

+ 98
- 0
ports/swankyamp/source/PluginEditor.h View File

@@ -0,0 +1,98 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include "PluginProcessor.h"
#include <JuceHeader.h>

#include "Components/AmpGroup.h"
#include "Components/PresetGroup.h"
#include "PresetManager.h"
#include "SwankyAmpLAF.h"
#include "TooltipsData.h"

typedef AudioProcessorValueTreeState::SliderAttachment SliderAttachment;
typedef AudioProcessorValueTreeState::ButtonAttachment ButtonAttachment;

class StateChangeMonitor : public Timer
{
public:
StateChangeMonitor(int refreshRateHz) { startTimerHz(refreshRateHz); }
virtual ~StateChangeMonitor() = default;
virtual void stateChangeCallback() = 0;

private:
void timerCallback() override { stateChangeCallback(); }
};

class SwankyAmpAudioProcessorEditor :
public AudioProcessorEditor,
public StateChangeMonitor
{
public:
SwankyAmpAudioProcessorEditor(
SwankyAmpAudioProcessor&, AudioProcessorValueTreeState&);
~SwankyAmpAudioProcessorEditor();

void paint(Graphics&) override;
void resized() override;

String getPresetName() const { return presetGroup.presetSelector.getText(); }
void setPresetTextDontNotify(const String& text);

private:
// TODO: consdier setting and calling resized, bur for now these are const
const int padding = 64;
const int spacing = 32;
const int groupHeight = 128;
const int headerHeight = 24;
const int headerPadding = 16;

SwankyAmpLAF laf;

// This reference is provided as a quick way for your editor to
// access the processor object that created it.
SwankyAmpAudioProcessor& processor;
AudioProcessorValueTreeState& valueTreeState;

std::vector<String> managerListenIds;

Label versionLabel;
AmpGroup ampGroup;
PresetGroup presetGroup;

// NOTE: must be declared *AFTER* valueTreeState AND presetGroup
PresetManager presetManager;

TooltipsData tooltipsData;
TooltipWindow tooltipWindow;

std::unique_ptr<Drawable> logoSvg;

Image bgNoise;
Path bgPattern;
Random rng;

void buildBgPattern();
void stateChangeCallback() override;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SwankyAmpAudioProcessorEditor)
};

#undef INSERT_PARAMETER

+ 484
- 0
ports/swankyamp/source/PluginProcessor.cpp View File

@@ -0,0 +1,484 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <algorithm>
#include <cmath>
#include <unordered_map>

#include <JuceHeader.h>

#include "PluginEditor.h"
#include "Utils.h"

#include "PluginProcessor.h"

// add parameter to the VTS with default range -1 to +1
#define MAKE_PARAMETER_UNIT(n) \
std::make_unique<AudioParameterFloat>( \
"id" #n, #n, NormalisableRange<float>(-1.0f, 1.0f, 2.0f / 1e3f), 0.0f)
// add parameter to the VTS with custom range
#define MAKE_PARAMETER(n, l, h, d) \
std::make_unique<AudioParameterFloat>( \
"id" #n, #n, NormalisableRange<float>(l, h, fabs(h - l) / 1e3f), d)
// assign a VTS parameter to an object member of the same name
#define ASSIGN_PARAMETER(n) par##n = parameters.getRawParameterValue("id" #n);

SwankyAmpAudioProcessor::SwankyAmpAudioProcessor() :
#ifndef JucePlugin_PreferredChannelConfigurations
AudioProcessor(BusesProperties()
#if !JucePlugin_IsMidiEffect
#if !JucePlugin_IsSynth
.withInput("Input", AudioChannelSet::stereo(), true)
#endif
.withOutput("Output", AudioChannelSet::stereo(), true)
#endif
),
#endif
parameters(
*this,
nullptr,
Identifier("APVTSSwankyAmp"),
{
MAKE_PARAMETER_UNIT(InputLevel),
MAKE_PARAMETER_UNIT(OutputLevel),

MAKE_PARAMETER_UNIT(TsLow),
MAKE_PARAMETER_UNIT(TsMid),
MAKE_PARAMETER_UNIT(TsHigh),
MAKE_PARAMETER_UNIT(TsPresence),
MAKE_PARAMETER(TsSelection, 0.0f, 2.0f, 0.0f),

MAKE_PARAMETER(GainStages, 1.0f, 5.0f, 3.0f),
MAKE_PARAMETER_UNIT(GainOverhead),
MAKE_PARAMETER_UNIT(LowCut),

std::make_unique<AudioParameterBool>(
"idCabOnOff", "CabOnOff", true),
MAKE_PARAMETER_UNIT(CabBrightness),
MAKE_PARAMETER(CabDistance, 0.0f, 1.0f, 0.5f),
MAKE_PARAMETER(CabDynamic, -1.0f, 1.0f, -0.3f),

MAKE_PARAMETER(PreAmpDrive, -1.0f, 1.0f, -0.4f),
MAKE_PARAMETER_UNIT(PreAmpTight),
MAKE_PARAMETER_UNIT(PreAmpGrit),

MAKE_PARAMETER(PowerAmpDrive, -1.0f, 1.0f, -0.2f),
MAKE_PARAMETER_UNIT(PowerAmpTight),
MAKE_PARAMETER_UNIT(PowerAmpGrit),

MAKE_PARAMETER(PowerAmpSag, -1.0f, 1.0f, -0.6f),
MAKE_PARAMETER_UNIT(PowerAmpSagRatio),
})
{
ASSIGN_PARAMETER(InputLevel)
ASSIGN_PARAMETER(OutputLevel)

ASSIGN_PARAMETER(TsLow)
ASSIGN_PARAMETER(TsMid)
ASSIGN_PARAMETER(TsHigh)
ASSIGN_PARAMETER(TsPresence)
ASSIGN_PARAMETER(TsSelection)

ASSIGN_PARAMETER(GainStages)
ASSIGN_PARAMETER(GainOverhead)
ASSIGN_PARAMETER(LowCut)

ASSIGN_PARAMETER(CabOnOff)
ASSIGN_PARAMETER(CabBrightness)
ASSIGN_PARAMETER(CabDistance)
ASSIGN_PARAMETER(CabDynamic)

ASSIGN_PARAMETER(PreAmpDrive)
ASSIGN_PARAMETER(PreAmpTight)
ASSIGN_PARAMETER(PreAmpGrit)

ASSIGN_PARAMETER(PowerAmpDrive)
ASSIGN_PARAMETER(PowerAmpTight)
ASSIGN_PARAMETER(PowerAmpGrit)
ASSIGN_PARAMETER(PowerAmpSag)

ASSIGN_PARAMETER(PowerAmpSag)
ASSIGN_PARAMETER(PowerAmpSagRatio)
}

#undef MAKE_PARAMETER_UNIT
#undef MAKE_PARAMETER
#undef ASSIGN_PARAMETER

SwankyAmpAudioProcessor::~SwankyAmpAudioProcessor() {}

// set the amp object user parameters from the VTS values
void SwankyAmpAudioProcessor::setAmpParameters()
{
for (int i = 0; i < 2; i++)
{
const float preAmpDriveMap = remapSinh(*parPreAmpDrive, 0.5f, 1.0f);
const float powerAmpDriveMap = remapSinh(*parPowerAmpDrive, -0.2f, 1.0f);
const float powerAmpSagMap = remapSinh(*parPowerAmpSag, 0.0f, 1.0f);
const float lowCutMap =
remapSinh(remapXY(*parLowCut, -1.0f, 1.0f, 0.0f, 1.23f), 0.5f, 1.0f);

amp_channel[i].set_input_level(*parInputLevel);
amp_channel[i].set_output_level(
*parOutputLevel
+ (10.0f + remapXY(preAmpDriveMap, 0.0f, 1.0f, 0.0f, -3.0f)) / 35.0f);
amp_channel[i].set_triode_drive(preAmpDriveMap);
amp_channel[i].set_tetrode_drive(powerAmpDriveMap);

amp_channel[i].set_tonestack_bass(*parTsLow);
amp_channel[i].set_tonestack_mids(*parTsMid);
amp_channel[i].set_tonestack_treble(*parTsHigh);
amp_channel[i].set_tonestack_presence(*parTsPresence);
amp_channel[i].set_tonestack_selection(*parTsSelection);

amp_channel[i].set_triode_num_stages(*parGainStages);
amp_channel[i].set_triode_overhead(*parGainOverhead);

amp_channel[i].set_cabinet_on((*parCabOnOff > 0.5f) ? true : false);
amp_channel[i].set_cabinet_brightness(
remapSided(*parCabBrightness, -0.6f, +0.6f));
amp_channel[i].set_cabinet_distance(*parCabDistance);
// full dynamic when knob is at 0.0
amp_channel[i].set_cabinet_dynamic(
remapXY(*parCabDynamic, -1.0f, 0.0f, -1.0f, +1.0f));
// move the dynamic level down over the dynamic knob range
amp_channel[i].set_cabinet_dynamic_level(-1.0f * *parCabDynamic);

amp_channel[i].set_triode_hp_freq(remapSided(lowCutMap, -1.0f, +0.75f));
// amp_channel[i].set_tetrode_hp_freq(remapSided(lowCutMap, -1.0f, +0.75f));

const float minPreAmpTight =
remapXY(preAmpDriveMap, -0.5f, +1.0f, -1.0f, 0.0f);
const float adjPreAmpTight =
remapRange(*parPreAmpTight, minPreAmpTight, +1.0f);

amp_channel[i].set_triode_grid_tau(
remapSided(adjPreAmpTight * -1.0f, -0.5f, +0.1f));
amp_channel[i].set_triode_grid_ratio(
remapSided(adjPreAmpTight * -1.0f, -1.0f, +0.1f));
amp_channel[i].set_triode_plate_bias(
remapSided(adjPreAmpTight, -1.0f, +0.5f));
amp_channel[i].set_triode_plate_comp_ratio(
remapSided(adjPreAmpTight, -1.0f, +0.0f));

amp_channel[i].set_triode_grid_level(
remapSided(*parPreAmpGrit * -1.0f, -0.2f, +3.0f));
amp_channel[i].set_triode_grid_clip(
remapSided(*parPreAmpGrit * -1.0f, -1.0f, +4.0f));
amp_channel[i].set_triode_plate_comp_level(
remapSided(*parPreAmpGrit * +1.0f, -0.0f, +1.0f));
amp_channel[i].set_triode_plate_comp_offset(
remapSided(*parPreAmpGrit * -1.0f, -0.0f, +5.0f));

amp_channel[i].set_tetrode_grid_tau(
remapSided(*parPowerAmpTight * -1.0f, -1.0f, +1.0f));
amp_channel[i].set_tetrode_grid_ratio(
remapSided(*parPowerAmpTight * -1.0f, -1.0f, +0.1f));
amp_channel[i].set_tetrode_plate_comp_depth(
remapSided(*parPowerAmpTight * -1.0f, -0.5f, +0.0f));
amp_channel[i].set_tetrode_plate_sag_tau(
remapSided(*parPowerAmpTight * -1.0f, -1.0f, +1.0f));

amp_channel[i].set_tetrode_plate_sag_depth(
powerAmpSagMap +
// shift the depth higher at low drive to get some audible effect when
// not much of signal is over clip, and lower at high drive to avoid
// just hacking away the signal with a constant db offset
remapXY(powerAmpDriveMap, -1.0f, 1.0f, 1.0f, -1.0f));
amp_channel[i].set_tetrode_plate_sag_ratio(*parPowerAmpSagRatio);
amp_channel[i].set_tetrode_plate_sag_onset(powerAmpSagMap);
amp_channel[i].set_tetrode_plate_sag_factor(
amp_channel[i].get_tetrode_drive());
amp_channel[i].set_tetrode_plate_sag_toggle(
powerAmpSagMap < -0.99f ? -1.0f : 1.0f);
}
}

const String SwankyAmpAudioProcessor::getName() const
{
return JucePlugin_Name;
}

bool SwankyAmpAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}

bool SwankyAmpAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}

bool SwankyAmpAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}

double SwankyAmpAudioProcessor::getTailLengthSeconds() const { return 0.0; }

int SwankyAmpAudioProcessor::getNumPrograms() { return 1; }

int SwankyAmpAudioProcessor::getCurrentProgram() { return 0; }

void SwankyAmpAudioProcessor::setCurrentProgram(int index)
{
ignoreUnused(index);
}

const String SwankyAmpAudioProcessor::getProgramName(int index)
{
ignoreUnused(index);
return {};
}

void SwankyAmpAudioProcessor::changeProgramName(
int index, const String& newName)
{
ignoreUnused(index, newName);
}

void SwankyAmpAudioProcessor::prepareToPlay(
double sampleRate, int samplesPerBlock)
{
ignoreUnused(samplesPerBlock);

// Use this method as the place to do any pre-playback
// initialisation that you need..
for (int i = 0; i < 2; i++) amp_channel[i].prepare(jmax(1, (int)sampleRate));
}

void SwankyAmpAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
for (int i = 0; i < 2; i++) amp_channel[i].reset();
}

#ifndef JucePlugin_PreferredChannelConfigurations
bool SwankyAmpAudioProcessor::isBusesLayoutSupported(
const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
ignoreUnused(layouts);
return true;

#else
// outputs must be mono or stereo
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;
// inputs must be mono or stereo
if (layouts.getMainInputChannelSet() != AudioChannelSet::mono()
&& layouts.getMainInputChannelSet() != AudioChannelSet::stereo())
return false;
// if input is stereo, output must be stereo
if (layouts.getMainInputChannelSet() == AudioChannelSet::stereo()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
return false;

// This checks if the input layout matches the output layout
#if !JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif

return true;
#endif
}
#endif

void SwankyAmpAudioProcessor::processBlock(
AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ignoreUnused(midiMessages);

if (buffer.getNumSamples() <= 0) return;

ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();

// copy plugin parameter values into the amp object
setAmpParameters();

// In case we have more outputs than inputs, this code clears any output
// channels that didn't contain input data, (because these aren't
// guaranteed to be empty - they may contain garbage).
// This is here to avoid people getting screaming feedback
// when they first compile a plugin, but obviously you don't need to keep
// this code if your algorithm always overwrites all the output channels.
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear(i, 0, buffer.getNumSamples());

const auto numSamples = buffer.getNumSamples();

for (int ichannel = 0; ichannel < jmin(totalNumInputChannels, 2); ichannel++)
{
auto inLevel = buffer.getMagnitude(ichannel, 0, numSamples);
// convert to decibels and add the input level which ranges from -35 to +35
inLevel = 20 * log10f(inLevel) + (*parInputLevel * 35);
if (meterListenersIn[ichannel] != nullptr)
meterListenersIn[ichannel]->update(inLevel);
if (ichannel == 0 && totalNumInputChannels < 2
&& meterListenersIn[1] != nullptr)
meterListenersIn[1]->update(inLevel);
}

// mono to mono: run the amp once
if (totalNumInputChannels == 1 && totalNumOutputChannels == 1)
{
float* amp_buffer = buffer.getWritePointer(0);
amp_channel[0].process(buffer.getNumSamples(), &amp_buffer);
}
// mono to stereo: run the amp once, copy the result
else if (totalNumInputChannels == 1 && totalNumOutputChannels == 2)
{
float* amp_buffer = buffer.getWritePointer(0);
amp_channel[0].process(buffer.getNumSamples(), &amp_buffer);
float* amp_buffer_other = buffer.getWritePointer(1);
std::memcpy(
(void*)amp_buffer_other, (void*)amp_buffer, numSamples * sizeof(float));
}
// stereo to stereo: run the amp twice
else if (totalNumInputChannels == 2 && totalNumOutputChannels == 2)
{
for (int i = 0; i < 2; i++)
{
float* amp_buffer = buffer.getWritePointer(i);
amp_channel[i].process(buffer.getNumSamples(), &amp_buffer);
}
}

for (int ichannel = 0; ichannel < jmin(totalNumOutputChannels, 2); ichannel++)
{
auto outLevel = buffer.getMagnitude(ichannel, 0, numSamples);
// note: the output level parameter is already factored into the buffer
outLevel = 20 * log10f(outLevel);
if (meterListenersOut[ichannel] != nullptr)
meterListenersOut[ichannel]->update(outLevel);
if (ichannel == 0 && totalNumOutputChannels < 2
&& meterListenersOut[1] != nullptr)
meterListenersOut[1]->update(outLevel);
}

if (numBurnIn > 0)
{
const int numBurnInUsed = jmin(numBurnIn.load(), buffer.getNumSamples());
buffer.applyGain(0, numBurnInUsed, 0.0f);
numBurnIn -= numBurnInUsed;
}
}

bool SwankyAmpAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}

AudioProcessorEditor* SwankyAmpAudioProcessor::createEditor()
{
return new SwankyAmpAudioProcessorEditor(*this, parameters);
}

void SwankyAmpAudioProcessor::setPresetText(const String& text)
{
storedPresetText = text;
}

const String& SwankyAmpAudioProcessor::getPresetText() const
{
return storedPresetText;
}

void SwankyAmpAudioProcessor::getStateInformation(MemoryBlock& destData)
{
auto state = parameters.copyState();
std::unique_ptr<XmlElement> xml(state.createXml());
const String presetText = getPresetText();
if (presetText.isNotEmpty()) { xml->setAttribute("presetName", presetText); }
copyXmlToBinary(*xml, destData);
}

void SwankyAmpAudioProcessor::setStateInformation(
const void* data, int sizeInBytes)
{
std::unique_ptr<XmlElement> xmlState(getXmlFromBinary(data, sizeInBytes));
if (xmlState.get() != nullptr)
{
if (xmlState->hasTagName(parameters.state.getType()))
{
if (xmlState->hasAttribute("presetName"))
{
setStateInformation(
xmlState, xmlState->getStringAttribute("presetName"), true);
}
else
{
setStateInformation(xmlState, "", true);
}
}
}
}

void SwankyAmpAudioProcessor::setStateInformation(
const std::unique_ptr<XmlElement>& state,
const String& presetText,
bool useAll)
{
setPresetText(presetText);

std::unordered_map<String, double> values;
if (state != nullptr) values = mapParameterValues(state);

for (const auto& id : parameterIds)
{
if (!useAll && (id == "idInputLevel" || id == "idCabOnOff")) continue;

auto parameter = parameters.getParameter(id);
if (parameter == nullptr) continue;

if (values.find(id) == values.end())
parameter->setValueNotifyingHost(parameter->getDefaultValue());
else
parameter->setValueNotifyingHost(
parameter->convertTo0to1((float)values[id]));
}

// clear the amp state so that buffered values don't decay too slowly with new
// parameters
for (int i = 0; i < 2; i++) amp_channel[i].reset();

notifyStateChanged = true;
numBurnIn = burnInLength;
}

AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new SwankyAmpAudioProcessor();
}

+ 131
- 0
ports/swankyamp/source/PluginProcessor.h View File

@@ -0,0 +1,131 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>

#include "Components/LevelMeter.h"
#include "dsp/PushPullAmp.h"

class SwankyAmpAudioProcessor : public AudioProcessor
{
public:
SwankyAmpAudioProcessor();
~SwankyAmpAudioProcessor();

// The amplifier DSP objects (contains DSP state and the process function)
// one for each possible channel (even if unused)
PushPullAmp amp_channel[2];

// Objects with an `update` method for updating the value of input meters.
LevelMeterListener* meterListenersIn[2] = {nullptr, nullptr};
LevelMeterListener* meterListenersOut[2] = {nullptr, nullptr};

AudioProcessorValueTreeState parameters;

std::atomic<float>* parInputLevel = nullptr;
std::atomic<float>* parOutputLevel = nullptr;

std::atomic<float>* parTsLow = nullptr;
std::atomic<float>* parTsMid = nullptr;
std::atomic<float>* parTsHigh = nullptr;
std::atomic<float>* parTsPresence = nullptr;
std::atomic<float>* parTsSelection = nullptr;

std::atomic<float>* parGainStages = nullptr;
std::atomic<float>* parGainOverhead = nullptr;

std::atomic<float>* parCabOnOff = nullptr;
std::atomic<float>* parCabBrightness = nullptr;
std::atomic<float>* parCabDistance = nullptr;
std::atomic<float>* parCabDynamic = nullptr;

std::atomic<float>* parPreAmpDrive = nullptr;
std::atomic<float>* parPreAmpTight = nullptr;
std::atomic<float>* parPreAmpGrit = nullptr;
std::atomic<float>* parLowCut = nullptr;

std::atomic<float>* parPowerAmpDrive = nullptr;
std::atomic<float>* parPowerAmpTight = nullptr;
std::atomic<float>* parPowerAmpGrit = nullptr;

std::atomic<float>* parPowerAmpSag = nullptr;
std::atomic<float>* parPowerAmpSagRatio = nullptr;

const std::vector<String> parameterIds = {
"idInputLevel", "idOutputLevel",
"idTsLow", "idTsMid",
"idTsHigh", "idTsPresence",
"idTsSelection", "idGainStages",
"idGainOverhead", "idCabOnOff",
"idCabBrightness", "idCabDistance",
"idCabDynamic", "idPreAmpDrive",
"idPreAmpTight", "idPreAmpGrit",
"idLowCut", "idPowerAmpDrive",
"idPowerAmpTight", "idPowerAmpGrit",
"idPowerAmpSag", "idPowerAmpSagRatio",
};

std::atomic<bool> notifyStateChanged { false };
const int burnInLength = 1024;
std::atomic<int> numBurnIn { burnInLength };

void setAmpParameters();

void prepareToPlay(double sampleRate, int samplesPerBlock) override;
void releaseResources() override;

#ifndef JucePlugin_PreferredChannelConfigurations
bool isBusesLayoutSupported(const BusesLayout& layouts) const override;
#endif

void processBlock(AudioBuffer<float>&, MidiBuffer&) override;

AudioProcessorEditor* createEditor() override;
bool hasEditor() const override;

const String getName() const override;

bool acceptsMidi() const override;
bool producesMidi() const override;
bool isMidiEffect() const override;
double getTailLengthSeconds() const override;

int getNumPrograms() override;
int getCurrentProgram() override;
void setCurrentProgram(int index) override;
const String getProgramName(int index) override;
void changeProgramName(int index, const String& newName) override;

void getStateInformation(MemoryBlock& destData) override;
void setStateInformation(const void* data, int sizeInBytes) override;
void setStateInformation(
const std::unique_ptr<XmlElement>& state,
const String& presetName,
bool useAll = true);

void setPresetText(const String& text);
const String& getPresetText() const;

private:
CriticalSection setStateMutex;
String storedPresetText;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SwankyAmpAudioProcessor)
};

+ 629
- 0
ports/swankyamp/source/PresetManager.cpp View File

@@ -0,0 +1,629 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <cmath>
#include <iomanip>
#include <sstream>

#include "unordered_map"

#include "Components/PresetGroup.h"
#include "PresetManager.h"

std::pair<int, String> extractNumAndName(const String& name)
{
static const String digits = "09";
static const String div = " ";

int startIdx = -1;

for (int i = 0; i < name.length(); i++)
{
const juce_wchar c = name[i];

if (c >= digits[0] && c <= digits[1]) continue;

const bool hasNumber = i > 0;
const bool hasDivider = i + div.length() <= name.length()
&& name.substring(i, i + div.length()) == div;

if (hasNumber && hasDivider) startIdx = i + div.length();

break;
}

if (startIdx > 1)
{
int num = std::atoi(name.substring(0, startIdx - div.length()).toRawUTF8());
String nameStripped = name.substring(startIdx);
return std::pair<int, String>(num, nameStripped);
}
else
{
return std::pair<int, String>(-1, name);
}
}

StateEntry::StateEntry(
const String& name, File file, nonstd::optional<size_t> stateIdx) :
name(name), file(file), stateIdx(stateIdx)
{
}

PresetManager::PresetManager(
SwankyAmpAudioProcessor& processor,
AudioProcessorValueTreeState& vts,
ComboBox& comboBox,
Button& buttonSave,
Button& buttonRemove,
Button& buttonNext,
Button& buttonPrev,
Button& buttonOpen) :
processor(processor),
vts(vts),
comboBox(comboBox),
buttonSave(buttonSave),
buttonRemove(buttonRemove),
buttonNext(buttonNext),
buttonPrev(buttonPrev),
buttonOpen(buttonOpen)
{
presetDir = File::getSpecialLocation(
File::SpecialLocationType::userApplicationDataDirectory);
#ifdef JUCE_MAC
presetDir = presetDir.getChildFile("Audio").getChildFile("Presets");
#endif
presetDir = presetDir.getChildFile(JucePlugin_Manufacturer)
.getChildFile(JucePlugin_Name);
// silent if invalid, will only notify user when they try to save
presetDir.createDirectory();

parameterIds = buildParameterIds(SerializedState(vts.state.createXml()));

addStateEntry("init", File(), nullptr);

// cleanup:
// go through xml files
// any without correct tag are removed
// any with resonantamp tag are converted to swankyamp

if (!loadPresetsFromDir()) loadFactoryPresets();

updatePresetDir();
updateComboBox();

comboBox.onChange = [&]() { comboBoxChanged(); };
buttonSave.onClick = [&]() { buttonSaveClicked(); };
buttonRemove.onClick = [&]() { buttonRemoveClicked(); };
buttonNext.onClick = [&]() { buttonNextClicked(); };
buttonPrev.onClick = [&]() { buttonPrevClicked(); };
buttonOpen.onClick = [&]() { buttonOpenClicked(); };

const String storedText = processor.getPresetText();
setStateText(storedText);
}

PresetManager::~PresetManager()
{
// UI elements can outlive the manager, ensure they don't try to use callbacks
comboBox.onChange = []() {};
buttonSave.onClick = []() {};
buttonRemove.onClick = []() {};
buttonNext.onClick = []() {};
buttonPrev.onClick = []() {};
buttonOpen.onClick = []() {};
}

void PresetManager::addStateEntry(
const String& name, const File& file, SerializedState state)
{
removeStateEntry(name);

if (state != nullptr)
{
stateEntryIdx[name] = stateEntries.size();
stateEntries.push_back(StateEntry(name, file, states.size()));
states.push_back(std::move(state));
}
else
{
stateEntryIdx[name] = stateEntries.size();
stateEntries.push_back(StateEntry(name, file, nonstd::nullopt));
}
}

void PresetManager::removeStateEntry(const String& name)
{
if (!containsName(name)) return;

const size_t idx = stateEntryIdx[name];
stateEntries.erase(stateEntries.begin() + idx);

stateEntryIdx.clear();
for (size_t i = 0; i < stateEntries.size(); i++)
stateEntryIdx[stateEntries[i].name] = i;
}

void PresetManager::moveStateEntry(size_t idx, size_t newIdx)
{
std::vector<StateEntry> moved;
moved.reserve(stateEntries.size());

if (newIdx < 1) newIdx = 1;

if (newIdx == idx) return;

if (newIdx > idx) newIdx += 1;

for (size_t i = 0; i < stateEntries.size(); i++)
{
if (i == idx) continue;
if (i == newIdx) moved.push_back(stateEntries[idx]);
moved.push_back(stateEntries[i]);
}

if (newIdx >= stateEntries.size()) moved.push_back(stateEntries[idx]);

stateEntries = moved;

stateEntryIdx.clear();
for (size_t i = 0; i < stateEntries.size(); i++)
stateEntryIdx[stateEntries[i].name] = i;
}

void PresetManager::loadPreset(
SerializedState state, File file, const String& name)
{
if (state == nullptr) return;

auto values = mapParameterValues(state);

// range changes from 0.6 to 0.7
if (state != nullptr && state->hasAttribute("pluginVersion")
&& parseVersionString(state->getStringAttribute("pluginVersion"))
< VersionNumber(0, 7, 0))
{
if (values.find("idPowerAmpDrive") != values.end())
{
const double value = values["idPowerAmpDrive"];
const double post =
transformUnitScale(value, log(1.0), log(1e3), log(0.5), log(5e2));
values["idPowerAmpDrive"] = post;
}
if (values.find("idPowerAmpSag") != values.end())
{
const double value = values["idPowerAmpSag"];
const double post = transformUnitScale(value, 0.0, 1.0, 0.0, 0.5);
values["idPowerAmpSag"] = post;
}
}

// from 1.1 to 1.2
if (state != nullptr && state->hasAttribute("pluginVersion")
&& parseVersionString(state->getStringAttribute("pluginVersion"))
< VersionNumber(1, 2, 0))
{
if (values.find("idPreAmpDrive") != values.end())
{
const double value = values["idPreAmpDrive"];
const float post = remapXY((float)value, -1.0f, 1.0f, -0.67f, 0.86f);
values["idPreAmpDrive"] = (double)post;
}
if (values.find("idPowerAmpDrive") != values.end())
{
const double value = values["idPowerAmpDrive"];
const float post = invertRemapSinh(
remapXY((float)value, -1.0f, 1.0f, -0.85f, 1.14f), -0.2f, 1.0f);
values["idPowerAmpDrive"] = (double)post;
}
if (values.find("idPowerAmpSag") != values.end())
{
const double value = values["idPowerAmpSag"];
const float post = remapSinh((float)value, 0.0f, 1.0f);
values["idPowerAmpSag"] = (double)post;
}
}

// from 1.3.0 to 1.3.1
if (state != nullptr && state->hasAttribute("pluginVersion")
&& parseVersionString(state->getStringAttribute("pluginVersion"))
< VersionNumber(1, 3, 1))
{
if (values.find("idPreAmpDrive") != values.end())
{
const double value = values["idPreAmpDrive"];
const float post = invertRemapSinh((float)value, 0.5f, 1.0f);
values["idPreAmpDrive"] = (double)post;
}
}

// from 1.3.1 to 1.4
if (state != nullptr && state->hasAttribute("pluginVersion")
&& parseVersionString(state->getStringAttribute("pluginVersion"))
< VersionNumber(1, 4, 0))
{
if (values.find("idLowCut") != values.end())
{
const double value = values["idLowCut"];
const float post = remapXY(
invertRemapSinh((float)value, 0.5f, 1.0f), 0.0f, 1.23f, -1.0f, +1.0f);
values["idLowCut"] = (double)post;
}
}

updateStateFromMap(state, values);

addStateEntry(name, file, std::move(state));
}

void PresetManager::loadFactoryPresets()
{
const std::unique_ptr<XmlElement> xml =
XmlDocument::parse(BinaryData::presets_xml);
if (xml == nullptr) return;

bool writingSuccess = true;
const Identifier& stateType = vts.state.getType();

XmlElement* stateXml = xml->getFirstChildElement();
while (stateXml != nullptr)
{
if (stateXml->hasTagName(stateType) && stateXml->hasAttribute("presetName"))
{
const String presetName = stateXml->getStringAttribute("presetName");
stateXml->removeAttribute("presetName");
stateXml->setAttribute("pluginVersion", JucePlugin_VersionString);

File presetFile = presetDir.getChildFile(presetName + ".xml");
loadPreset(
std::make_unique<XmlElement>(*stateXml), presetFile, presetName);
writingSuccess &= stateXml->writeTo(presetFile);
}
stateXml = stateXml->getNextElement();
}

if (!writingSuccess)
{
AlertWindow::showMessageBox(
AlertWindow::AlertIconType::WarningIcon,
"Factory preset failure",
"Unalble to write factory presets to disk");
}
}

bool PresetManager::loadPresetsFromDir()
{
std::vector<String> filePaths;
auto files =
presetDir.findChildFiles(File::TypesOfFileToFind::findFiles, false);

if (files.isEmpty()) return false;

std::sort(files.begin(), files.end());

const Identifier& stateType = vts.state.getType();

for (int i = 0; i < files.size(); i++)
{
const File& presetFile = files[i];
if (presetFile.getFileExtension() != ".xml"
&& presetFile.getFileExtension() != ".XML")
continue;

const auto numAndName =
extractNumAndName(presetFile.getFileNameWithoutExtension());

SerializedState stateXml = XmlDocument::parse(presetFile);

// allow using preseets from version before name change
if (stateXml->hasTagName("APVTSResonantAmp"))
stateXml->setTagName("APVTSSwankyAmp");

if (stateXml->hasTagName(stateType))
{
const String& presetName = numAndName.second;
loadPreset(
std::make_unique<XmlElement>(*stateXml), presetFile, presetName);
}
}

return true;
}

void PresetManager::updateComboBox()
{
// don't re-trigger comboBoxChanged
comboBox.clear(NotificationType::dontSendNotification);
const int width = (int)(log10f((float)stateEntries.size())) + 1;

for (size_t idx = 0; idx < stateEntries.size(); idx++)
{
const auto& entry = stateEntries[idx];
const int id = (int)(idx + 1);

std::ostringstream ss;
ss << std::setfill('0') << std::setw(width);
ss << idx << " " << entry.name;

const String text = idx > 0 ? ss.str() : entry.name;
comboBox.addItem(text, id);

if (entry.name == currentName)
// don't re-trigger comboBoxChanged
comboBox.setText(text, NotificationType::dontSendNotification);
}
}

void PresetManager::updatePresetDir()
{
const int width = (int)(log10f((float)stateEntries.size())) + 1;

size_t idx = 0;
for (auto& entry : stateEntries)
{
if (!entry.file.existsAsFile()) continue;

idx++;

std::ostringstream ss;
ss << std::setfill('0') << std::setw(width);
ss << idx << " " << entry.name << ".xml";

const String targetPath =
presetDir.getChildFile(ss.str()).getFullPathName();
if (entry.file == targetPath) continue;

if (entry.file.getParentDirectory() == presetDir)
{
if (entry.file.moveFileTo(targetPath)) entry.file = File(targetPath);
}
else
{
if (entry.file.copyFileTo(targetPath)) entry.file = File(targetPath);
}
}
}

void PresetManager::updateButtonState()
{
if (currentName == "init")
{
buttonSave.setEnabled(false);
buttonRemove.setEnabled(false);
return;
}

buttonSave.setEnabled(true);
if (containsName(currentName)) buttonRemove.setEnabled(true);
}

void PresetManager::comboBoxChanged()
{
const auto numAndName = extractNumAndName(comboBox.getText());
const String& name = numAndName.second;
const int ord = numAndName.first;

if (name == "") return;

if (!containsName(name))
{
const bool makeNew = currentName == "init" || !containsName(currentName)
|| AlertWindow::showOkCancelBox(
AlertWindow::AlertIconType::QuestionIcon,
"New preset name",
"Create new preset \"" + name + "\" or rename \""
+ currentName + "\"?",
"new",
"rename");

if (makeNew)
{
// new entry
addStateEntry(name, File(), SerializedState(vts.state.createXml()));
currentName = name;
buttonSaveClicked();
}
// can only happen if not init and currentName exists
else
{
const size_t idx = stateEntryIdx[currentName];
StateEntry& currentEntry = stateEntries[idx];
currentEntry.name = name;
stateEntryIdx[name] = idx;
stateEntryIdx.erase(currentName);
currentName = name;
}

// possible a new order was defined, update if so
if (ord > 0 && stateEntryIdx.find(name) != stateEntryIdx.end()
&& ord != stateEntryIdx[name])
moveStateEntry(stateEntryIdx[name], (size_t)ord);

updatePresetDir();
updateComboBox();
updateButtonState();

// after making a new preset, leave enabled to help user with feedback
if (makeNew) buttonSave.setEnabled(true);
}
else
{
currentName = name;
// cn only happen if name exists
const StateEntry& currentEntry = stateEntries[stateEntryIdx[name]];

if (currentEntry.stateIdx != nonstd::nullopt)
{
// load the state for this entry
setState(states[*currentEntry.stateIdx]);

if (ord > 0 && ord != (int)(stateEntryIdx[name]))
{
moveStateEntry(stateEntryIdx[name], (size_t)ord);
updatePresetDir();
updateComboBox();
}

updateButtonState();
// just loaded a preset
buttonSave.setEnabled(false);
}
else
{
// the init preset
setState(nullptr);
buttonRemove.setEnabled(false);
buttonSave.setEnabled(false);
}
}
}

void PresetManager::buttonSaveClicked()
{
if (currentName == "init") return;
if (!containsName(currentName))
{
// not currently a valid selection, create one
comboBoxChanged();
return;
}

// can only happen if currentName exists
StateEntry& currentEntry = stateEntries[stateEntryIdx[currentName]];
if (currentEntry.name == "") return;

SerializedState state = vts.state.createXml();
if (state == nullptr) return;

if (currentEntry.file.getFullPathName() != ""
&& !AlertWindow::showOkCancelBox(
AlertWindow::AlertIconType::QuestionIcon,
"Confirm save",
"Save preset: " + currentName + "?"))
return;

state->setAttribute("pluginVersion", JucePlugin_VersionString);

// TODO: sanitize preset names for valid file paths... could be tricky with
// multiple os support
if (currentEntry.file.getFullPathName() == "")
currentEntry.file = presetDir.getChildFile(currentEntry.name + ".xml");

if (!state->writeTo(currentEntry.file))
{
AlertWindow::showMessageBox(
AlertWindow::AlertIconType::WarningIcon,
"Failed to save",
"Failed to save preset file.");
return;
}

states.push_back(std::move(state));
currentEntry.stateIdx = {states.size() - 1};

// TODO: properly extract save functionaliy from button callback, this is
// button specific, not save-specific
updatePresetDir();
}

void PresetManager::buttonRemoveClicked()
{
if (currentName == "init") return;
if (!containsName(currentName)) return;

// can only happen if currentName exists
StateEntry& currentEntry = stateEntries[stateEntryIdx[currentName]];

if (currentEntry.file.getFullPathName() != "")
{
currentEntry.file.deleteFile();
currentEntry.file = File();
}

removeStateEntry(currentEntry.name);
updatePresetDir();
updateComboBox();
setStateText("init");
}

void PresetManager::buttonNextClicked()
{
if (!containsName(currentName))
{
comboBox.setSelectedId(1, NotificationType::sendNotificationSync);
return;
}

size_t currentIdx = stateEntryIdx[currentName];

if (currentIdx < stateEntries.size() - 1)
{
currentIdx += 1;
currentName = stateEntries[currentIdx].name;
const int id = (int)(currentIdx + 1);
comboBox.setSelectedId(id, NotificationType::sendNotificationSync);
}
}

void PresetManager::buttonPrevClicked()
{
if (!containsName(currentName))
{
comboBox.setSelectedId(1, NotificationType::sendNotificationSync);
return;
}

size_t currentIdx = stateEntryIdx[currentName];

if (currentIdx > 1)
{
currentIdx -= 1;
currentName = stateEntries[currentIdx].name;
const int id = (int)(currentIdx + 1);
comboBox.setSelectedId(id, NotificationType::sendNotificationSync);
}
}

void PresetManager::buttonOpenClicked() { presetDir.startAsProcess(); }

void PresetManager::parameterChanged(const String& id, float)
{
if (currentName != "init" && id != "idInputLevel" && id != "idCabOnOff")
buttonSave.setEnabled(true);
}

void PresetManager::setState(const SerializedState& state)
{
processor.setStateInformation(state, comboBox.getText(), false);
}

void PresetManager::setStateText(const String& text)
{
const auto name = extractNumAndName(text).second;
if (name.isEmpty())
{
currentName = "init";
comboBox.setText("init", NotificationType::dontSendNotification);
}
else
{
currentName = name;
comboBox.setText(text, NotificationType::dontSendNotification);
}
updateButtonState();
}

+ 100
- 0
ports/swankyamp/source/PresetManager.h View File

@@ -0,0 +1,100 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>
#include <nonstd/optional.hpp>
#include <unordered_map>

#include "PluginProcessor.h"

struct StateEntry
{
StateEntry(const String& name, File file, nonstd::optional<size_t> stateIdx);
StateEntry() {}

String name;
File file;
nonstd::optional<size_t> stateIdx = nonstd::nullopt;
};

/** Connects a value tree state to a combo box and preset directory. */
class PresetManager : public AudioProcessorValueTreeState::Listener
{
public:
PresetManager(
SwankyAmpAudioProcessor& processor,
AudioProcessorValueTreeState& vts,
ComboBox& comboBox,
Button& bntSave,
Button& bntRemove,
Button& bntNext,
Button& bntPrev,
Button& btnOpen);
~PresetManager();

void comboBoxChanged();
void buttonSaveClicked();
void buttonRemoveClicked();
void buttonNextClicked();
void buttonPrevClicked();
void buttonOpenClicked();
void parameterChanged(const String& id, float newValue);

const std::vector<String>& getParameterIds() const { return parameterIds; }

void setState(const SerializedState& state);
void setStateText(const String& text);

private:
void loadPreset(SerializedState state, File file, const String& name);
void loadFactoryPresets();
bool loadPresetsFromDir();

void updateComboBox();
void updatePresetDir();
void updateButtonState();

bool containsName(const String& name) const
{
return stateEntryIdx.find(name) != stateEntryIdx.end();
}

void
addStateEntry(const String& name, const File& file, SerializedState state);
void removeStateEntry(const String& name);
void moveStateEntry(size_t idx, size_t newIdx);

SwankyAmpAudioProcessor& processor;
AudioProcessorValueTreeState& vts;
ComboBox& comboBox;
Button& buttonSave;
Button& buttonRemove;
Button& buttonNext;
Button& buttonPrev;
Button& buttonOpen;
File presetDir;

std::vector<String> parameterIds;

String currentName = "init";
std::vector<StateEntry> stateEntries;
std::unordered_map<String, size_t> stateEntryIdx;
std::vector<SerializedState> states;
};

+ 684
- 0
ports/swankyamp/source/SwankyAmpLAF.cpp View File

@@ -0,0 +1,684 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include "Components/LevelMeter.h"
#include "Components/ParameterGroup.h"
#include "Components/RButton.h"
#include "Components/RSlider.h"
#include "Utils.h"

#include "SwankyAmpLAF.h"

const Colour SwankyAmpLAF::colourDark =
Colour::fromHSV(0.0f, 0.0f, 0.25f, 1.0f);
const Colour SwankyAmpLAF::colourGrey =
Colour::fromHSV(0.0f, 0.0f, 0.75f, 1.0f);
const Colour SwankyAmpLAF::colourBackground =
Colour::fromHSV(0.0f, 0.0f, 1.0f, 1.0f);
const Colour SwankyAmpLAF::colourHighlight =
Colour::fromHSV(0.98f, 0.6f, 0.75f, 1.0f);
const Colour SwankyAmpLAF::colourSteel =
Colour::fromHSV(0.0f, 0.0f, 0.96f, 1.0f);

SwankyAmpLAF::SwankyAmpLAF()
{
setColour(
ResizableWindow::backgroundColourId, SwankyAmpLAF::colourBackground);
setColour(Slider::textBoxTextColourId, SwankyAmpLAF::colourDark);

setColour(ParameterGroup::borderColourId, SwankyAmpLAF::colourDark);
setColour(ParameterGroup::steelColourId, SwankyAmpLAF::colourSteel);

setColour(RSlider::dialColourId, SwankyAmpLAF::colourDark);
setColour(RSlider::dialOutlineColourId, SwankyAmpLAF::colourGrey);
setColour(RSlider::dialTextColourId, SwankyAmpLAF::colourGrey);
setColour(RSlider::dialDotColourId, SwankyAmpLAF::colourHighlight);

setColour(LevelMeter::outlineColourId, SwankyAmpLAF::colourDark);
setColour(LevelMeter::backgroundColourId, SwankyAmpLAF::colourBackground);
setColour(LevelMeter::meterColourId, SwankyAmpLAF::colourGrey);
setColour(LevelMeter::textColourId, SwankyAmpLAF::colourDark);

setColour(RButton::buttonColourId, SwankyAmpLAF::colourDark);
setColour(RButton::textColourId, SwankyAmpLAF::colourGrey);

setColour(ComboBox::backgroundColourId, SwankyAmpLAF::colourBackground);
setColour(ComboBox::textColourId, SwankyAmpLAF::colourDark);
setColour(ComboBox::outlineColourId, SwankyAmpLAF::colourDark);
setColour(ComboBox::buttonColourId, SwankyAmpLAF::colourDark);
setColour(ComboBox::arrowColourId, SwankyAmpLAF::colourDark);
setColour(ComboBox::focusedOutlineColourId, SwankyAmpLAF::colourHighlight);

setColour(PopupMenu::backgroundColourId, SwankyAmpLAF::colourBackground);
setColour(PopupMenu::textColourId, SwankyAmpLAF::colourDark);
setColour(PopupMenu::headerTextColourId, SwankyAmpLAF::colourDark);
setColour(PopupMenu::highlightedBackgroundColourId, SwankyAmpLAF::colourDark);
setColour(PopupMenu::highlightedTextColourId, SwankyAmpLAF::colourBackground);

setColour(TextEditor::backgroundColourId, SwankyAmpLAF::colourBackground);
setColour(TextEditor::textColourId, SwankyAmpLAF::colourDark);
setColour(TextEditor::highlightColourId, SwankyAmpLAF::colourGrey);
setColour(TextEditor::highlightedTextColourId, SwankyAmpLAF::colourDark);
setColour(TextEditor::outlineColourId, Colours::transparentBlack);
setColour(TextEditor::focusedOutlineColourId, Colours::transparentBlack);
setColour(TextEditor::shadowColourId, Colours::transparentBlack);

setColour(Label::textColourId, SwankyAmpLAF::colourDark);
setColour(Label::backgroundColourId, Colours::transparentBlack);
setColour(Label::outlineColourId, Colours::transparentBlack);
setColour(Label::backgroundWhenEditingColourId, Colours::transparentBlack);
setColour(Label::textWhenEditingColourId, SwankyAmpLAF::colourDark);
setColour(Label::outlineWhenEditingColourId, Colours::transparentBlack);

setColour(TooltipWindow::backgroundColourId, SwankyAmpLAF::colourBackground);
setColour(TooltipWindow::textColourId, SwankyAmpLAF::colourDark);
setColour(TooltipWindow::outlineColourId, SwankyAmpLAF::colourDark);
}

const Font& SwankyAmpLAF::getDefaultFont()
{
const static Font font = Font(Typeface::createSystemTypefaceFor(
BinaryData::PTSansRegular_ttf, BinaryData::PTSansRegular_ttfSize));

return font;
}

const Font& SwankyAmpLAF::getDefaultFontNarrow()
{
const static Font font = Font(Typeface::createSystemTypefaceFor(
BinaryData::PTSansNarrowRegular_ttf,
BinaryData::PTSansNarrowRegular_ttfSize));

return font;
}

const Font& SwankyAmpLAF::getDefaultFontBold()
{
const static Font font = Font(Typeface::createSystemTypefaceFor(
BinaryData::PTSansBold_ttf, BinaryData::PTSansBold_ttfSize));

return font;
}

const DropShadow& SwankyAmpLAF::getDropShadow()
{
const static DropShadow dropShadow(
Colour::fromHSV(0.0f, 0.0f, 0.0f, 0.5), 6, Point<int>(1, 1));
return dropShadow;
}

Path SwankyAmpLAF::getSaveIconPath(float d, float stroke)
{
Path path;

path.startNewSubPath(0.5f, 0.0f);
path.lineTo(0.875f, 0.0f);
path.lineTo(1.0f, 0.125f);
path.lineTo(1.0f, 0.875f);
path.addCentredArc(
0.875f,
0.875f,
0.125f,
0.125f,
0.0f,
MathConstants<float>::halfPi,
MathConstants<float>::pi);
path.lineTo(0.125f, 1.0f);
path.addCentredArc(
0.125f,
0.875f,
0.125f,
0.125f,
0.0f,
MathConstants<float>::pi,
3.0f * MathConstants<float>::halfPi);
path.lineTo(0.0f, 0.125f);
path.addCentredArc(
0.125f,
0.125f,
0.125f,
0.125f,
0.0f,
3.0f * MathConstants<float>::halfPi,
2.0f * MathConstants<float>::pi);
path.closeSubPath();

path.startNewSubPath(0.25f, 0.0f);
path.lineTo(0.25f, 2.0f / 5.0f);
path.lineTo(0.75f, 2.0f / 5.0f);
path.lineTo(0.75f, 0.0f);

path.startNewSubPath(0.75f - 1.0f / 6.0f, 2.0f / 5.0f);
path.lineTo(0.75f - 1.0f / 6.0f, 0.0f);

const float pad = stroke / 2.0f;
path.scaleToFit(0.0f + pad, 0.0f + pad, d - stroke, d - stroke, true);
return path;
}

Path SwankyAmpLAF::getRemoveIconPath(float d, float stroke)
{
Path path;

path.addRoundedRectangle(0.0f, 0.0f, 1.0f, 1.0f, 0.125f, 0.125f);

path.startNewSubPath(0.25f, 0.25f);
path.lineTo(0.75f, 0.75f);
path.startNewSubPath(0.25f, 0.75f);
path.lineTo(0.75f, 0.25f);

const float pad = stroke / 2.0f;
path.scaleToFit(0.0f + pad, 0.0f + pad, d - stroke, d - stroke, true);
return path;
}

Path SwankyAmpLAF::getNextIconPath(float d, float stroke)
{
Path path;

path.addRoundedRectangle(0.0f, 0.0f, 1.0f, 1.0f, 0.125f, 0.125f);

path.startNewSubPath(0.333f, 0.25f);
path.lineTo(0.667f, 0.5f);
path.lineTo(0.333f, 0.75f);

const float pad = stroke / 2.0f;
path.scaleToFit(0.0f + pad, 0.0f + pad, d - stroke, d - stroke, true);
return path;
}

Path SwankyAmpLAF::getPrevIconPath(float d, float stroke)
{
Path path;

path.addRoundedRectangle(0.0f, 0.0f, 1.0f, 1.0f, 0.125f, 0.125f);

path.startNewSubPath(0.667f, 0.25f);
path.lineTo(0.333f, 0.5f);
path.lineTo(0.667f, 0.75f);

const float pad = stroke / 2.0f;
path.scaleToFit(0.0f + pad, 0.0f + pad, d - stroke, d - stroke, true);
return path;
}

Path SwankyAmpLAF::getOpenIconPath(float d, float stroke)
{
Path path;

path.startNewSubPath(1.0f, 0.5f);
path.lineTo(1.0f, 0.875f);
path.addCentredArc(
0.875f,
0.875f,
0.125f,
0.125f,
0.0f,
MathConstants<float>::halfPi,
2.0f * MathConstants<float>::halfPi);
path.lineTo(0.125f, 1.0f);
path.addCentredArc(
0.125f,
0.875f,
0.125f,
0.125f,
0.0f,
2.0f * MathConstants<float>::halfPi,
3.0f * MathConstants<float>::halfPi);
path.lineTo(0.0f, 0.125f);
path.addCentredArc(
0.125f,
0.125f,
0.125f,
0.125f,
0.0f,
3.0f * MathConstants<float>::halfPi,
4.0f * MathConstants<float>::halfPi);
path.lineTo(0.5f, 0.0f);

path.startNewSubPath(0.5f, 0.5f);
path.lineTo(1.0f, 0.0f);

path.startNewSubPath(0.75f, 0.0f);
path.lineTo(1.0f, 0.0f);
path.lineTo(1.0f, 0.25f);

const float pad = stroke / 2.0f;
path.scaleToFit(0.0f + pad, 0.0f + pad, d - stroke, d - stroke, true);
return path;
}

Path SwankyAmpLAF::getTickShape(float height)
{
const float padding = height / 5.0f;

Path path;

// explicitely add padding to the path otherwise it will get resized, this
// is kind of nasty (e.g. if someones tries to draw instead of fill), but it
// seems the alternative is to re-implemment the entire popup draw
path.startNewSubPath(0, height / 2.0f);
path.lineTo(padding, height / 2.0f);
path.startNewSubPath(height, height / 2.0f);
path.lineTo(height - padding, height / 2.0f);

path.addEllipse(
padding, padding, height - 2.0f * padding, height - 2.0f * padding);

return path;
}

Slider::SliderLayout SwankyAmpLAF::getSliderLayout(Slider& slider)
{
if (!slider.isRotary() && slider.getTextBoxPosition() != Slider::TextBoxBelow)
return LookAndFeel_V4::getSliderLayout(slider);

auto localBounds = slider.getLocalBounds();

Slider::SliderLayout layout;
layout.textBoxBounds = localBounds;
layout.sliderBounds = localBounds;

return layout;
}

void SwankyAmpLAF::drawRotarySlider(
Graphics& g,
int x,
int y,
int width,
int height,
float sliderPos,
const float rotaryStartAngle,
const float rotaryEndAngle,
Slider& slider)
{
// should make this rslider specific, then move the cast to the paint call
// of the rslider (cast the LAF)
RSlider* rslider = dynamic_cast<RSlider*>(&slider);

if (!rslider)
return LookAndFeel_V4::drawRotarySlider(
g,
x,
y,
width,
height,
sliderPos,
rotaryStartAngle,
rotaryEndAngle,
slider);

const RSliderDims dims = rslider->calcDims();

const auto sliderAngle = angleModulo(
rotaryStartAngle + sliderPos * (rotaryEndAngle - rotaryStartAngle));

// dial

auto dialBounds = Rectangle<float>();
dialBounds.setSize(dims.radius * 2.0f, dims.radius * 2.0f);
dialBounds.setX(dims.centre.getX() - dims.radius);
dialBounds.setY(dims.centre.getY() - dims.radius);

Path dialPath;
dialPath.addCentredArc(
dims.centre.getX(),
dims.centre.getY(),
dims.radius,
dims.radius,
0.0f,
-dims.theta,
dims.theta,
true);
dialPath.closeSubPath();

// dots outline

const float dotSize = dims.margin - 2.0f * dims.gap;

g.setColour(findColour(RSlider::dialOutlineColourId));

for (int iangle = 1; iangle < 10; iangle++)
{
const float angle = dims.theta - iangle * dims.theta / 5.0f;
const auto dotCenter = dialBounds.getCentre()
- (dims.radius + dims.margin / 2.0f)
* Point<float>(sinf(angle), cosf(angle));
auto dotBounds = Rectangle<float>();
dotBounds.setCentre(dotCenter);
dotBounds.translate(-dotSize / 2.0f, -dotSize / 2.0f);
dotBounds.setSize(dotSize, dotSize);
g.fillEllipse(dotBounds);
}

const auto overAngle = rslider->getOverValue() >= 0.0f
? angleModulo(
rotaryStartAngle
+ rslider->getOverValue() * (rotaryEndAngle - rotaryStartAngle))
: MathConstants<float>::pi;

// show range
if (rslider->getOverValue() >= 0)
{
auto rangePath = Path();
rangePath.startNewSubPath(dialBounds.getCentre());
rangePath.addCentredArc(
dialBounds.getCentreX(),
dialBounds.getCentreY(),
dims.radius + dims.margin,
dims.radius + dims.margin,
0.0f,
overAngle,
dims.theta);
rangePath.addCentredArc(
dialBounds.getCentreX(),
dialBounds.getCentreY(),
dims.radius,
dims.radius,
0.0f,
dims.theta,
overAngle);
rangePath.closeSubPath();

g.setColour(
findColour(RSlider::dialDotColourId).withMultipliedSaturation(0.45f));
g.fillPath(rangePath);
}

// dots filled

auto dotClipPath = Path();
dotClipPath.startNewSubPath(dialBounds.getCentre());
dotClipPath.addCentredArc(
dialBounds.getCentreX(),
dialBounds.getCentreY(),
dims.radius + dims.margin,
dims.radius + dims.margin,
0.0f,
-dims.theta,
jmin(overAngle, sliderAngle));
dotClipPath.closeSubPath();

g.setColour(findColour(RSlider::dialDotColourId));
g.saveState();
g.reduceClipRegion(dotClipPath);

for (int iangle = 1; iangle < 10; iangle++)
{
const float angle = dims.theta - iangle * dims.theta / 5.0f;
const auto dotCenter = dialBounds.getCentre()
- (dims.radius + dims.margin / 2.0f)
* Point<float>(sinf(angle), cosf(angle));
auto dotBounds = Rectangle<float>();
dotBounds.setCentre(dotCenter);
dotBounds.translate(-dotSize / 2.0f, -dotSize / 2.0f);
dotBounds.setSize(dotSize, dotSize);
g.fillEllipse(dotBounds);
}

g.restoreState();

// dots filled range

if (sliderAngle > overAngle)
{
auto overClipPath = Path();
overClipPath.startNewSubPath(dialBounds.getCentre());
overClipPath.addCentredArc(
dialBounds.getCentreX(),
dialBounds.getCentreY(),
dims.radius + dims.margin,
dims.radius + dims.margin,
0.0f,
overAngle,
sliderAngle);
overClipPath.closeSubPath();

g.setColour(findColour(RSlider::dialColourId));
g.saveState();
g.reduceClipRegion(overClipPath);

for (int iangle = 1; iangle < 10; iangle++)
{
const float angle = dims.theta - iangle * dims.theta / 5.0f;
const auto dotCenter = dialBounds.getCentre()
- (dims.radius + dims.margin / 2.0f)
* Point<float>(sinf(angle), cosf(angle));
auto dotBounds = Rectangle<float>();
dotBounds.setCentre(dotCenter);
dotBounds.translate(-dotSize / 2.0f, -dotSize / 2.0f);
dotBounds.setSize(dotSize, dotSize);
g.fillEllipse(dotBounds);
}

g.restoreState();
}

// Shadow
SwankyAmpLAF::getDropShadow().drawForPath(g, dialPath);

g.setColour(findColour(RSlider::dialColourId));
g.fillPath(dialPath);

// texture the dial

ColourGradient gradient;
gradient.addColour(0.0f, Colour::fromHSV(0.0f, 0.0f, 1.0f, 0.1f));
gradient.addColour(0.75f, Colour::fromHSV(0.0f, 0.0f, 1.0f, 0.0f));
gradient.point1 = dialBounds.getTopLeft();
gradient.point2 = dialBounds.getBottomLeft();
g.setGradientFill(gradient);
g.fillPath(dialPath);

g.saveState();
g.reduceClipRegion(dialPath);
g.drawImage(rslider->getBgNoise(), slider.getLocalBounds().toFloat());
g.restoreState();

// dial outline

g.setColour(findColour(RSlider::dialOutlineColourId));

Path dialOutlinePath;
dialOutlinePath.addCentredArc(
dims.centre.getX(),
dims.centre.getY(),
dims.radius - 1.5f,
dims.radius - 1.5f,
0.0f,
-dims.theta,
dims.theta,
true);
dialOutlinePath.closeSubPath();
g.strokePath(dialOutlinePath, PathStrokeType(1.0f));

// label text

const String labelText = rslider->fmtSliderPos(sliderPos);
g.setFont(
SwankyAmpLAF::getDefaultFontNarrow().withHeight(dims.radius / 1.5f));
g.setColour(findColour(RSlider::dialTextColourId));
g.drawText(labelText, dialBounds, Justification::centred, true);

// tick

Path pointerPath;
auto pointerLength = dims.radius * 0.33f;
auto lineThickness = 2.0f;
pointerPath.addRoundedRectangle(
-lineThickness * 2.0f * 0.5f,
-dims.radius,
lineThickness * 2.0f,
pointerLength,
lineThickness);
pointerPath.applyTransform(AffineTransform::rotation(sliderAngle)
.translated(dialBounds.getCentre()));
g.setColour(findColour(RSlider::dialOutlineColourId));
g.fillPath(pointerPath);
}

void SwankyAmpLAF::drawToggleButton(
Graphics& g,
ToggleButton& button,
bool shouldDrawButtonAsHighlighted,
bool shouldDrawButtonAsDown)
{
RButton* rbutton = dynamic_cast<RButton*>(&button);

if (!rbutton)
return LookAndFeel_V4::drawToggleButton(
g, button, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);

ignoreUnused(shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);

const float lineWidth = 2.0f;

const float radiusForHeight =
(float)g.getClipBounds().getHeight() / 4.0f - lineWidth;
const float radiusForWidth =
(float)g.getClipBounds().getWidth() / 2.0f - lineWidth;

const float radius = jmin(radiusForHeight, radiusForWidth);

Rectangle<float> outer;
outer.setSize(2.0f * radius, 4.0f * radius);
outer.setPosition(
g.getClipBounds().getCentreX() - radius,
g.getClipBounds().getCentreY() - 2.0f * radius);

// draw the circle

Rectangle<float> circleBounds;
circleBounds.setSize(2.0f * radius, 2.0f * radius);
if (button.getToggleState())
circleBounds.setPosition(outer.getTopLeft());
else
circleBounds.setPosition(
outer.getTopLeft().translated(0.0f, 2.0f * radius));

Path circlePath;
circlePath.addEllipse(circleBounds);

g.setColour(findColour(RButton::buttonColourId));
g.fillPath(circlePath);

// texture the circle

ColourGradient gradient;
gradient.addColour(0.0f, Colour::fromHSV(0.0f, 0.0f, 1.0f, 0.1f));
gradient.addColour(0.75f, Colour::fromHSV(0.0f, 0.0f, 1.0f, 0.0f));
gradient.point1 = circleBounds.getTopLeft();
gradient.point2 = circleBounds.getBottomLeft();
g.setGradientFill(gradient);
g.fillPath(circlePath);

g.saveState();
g.reduceClipRegion(circlePath);
g.drawImage(rbutton->getBgNoise(), button.getLocalBounds().toFloat());
g.restoreState();

// draw the text

g.setColour(findColour(RButton::textColourId));
g.setFont(SwankyAmpLAF::getDefaultFontNarrow().withHeight(radius));
g.drawText(
button.getToggleState() ? rbutton->textOn : rbutton->textOff,
circleBounds,
Justification::centred,
true);

g.setColour(findColour(RButton::buttonColourId));
g.drawRoundedRectangle(outer, radius, lineWidth);
}

void SwankyAmpLAF::drawComboBox(
Graphics& g, int width, int height, bool, int, int, int, int, ComboBox& box)
{
const float lineThickness = 2.0f;
const float cornerSize = 2.0f;
Rectangle<int> boxBounds(0, 0, width, height);

g.setColour(box.findColour(ComboBox::backgroundColourId));
g.fillRoundedRectangle(boxBounds.toFloat(), cornerSize);

g.setColour(box.findColour(ComboBox::outlineColourId));
g.drawRoundedRectangle(
boxBounds.toFloat().reduced(lineThickness / 2.0f, lineThickness / 2.0f),
cornerSize,
lineThickness);

Rectangle<float> arrowZone(
(float)(width - height), 0.0f, (float)height, (float)height);
arrowZone.reduce(height / 3.0f, height / 2.5f);

Path path;
path.startNewSubPath(arrowZone.getTopLeft());
path.lineTo(arrowZone.getCentre().withY(arrowZone.getBottom()));
path.lineTo(arrowZone.getTopRight());

g.setColour(box.findColour(ComboBox::arrowColourId)
.withAlpha((box.isEnabled() ? 0.9f : 0.2f)));
g.strokePath(path, PathStrokeType(2.0f));
}

Rectangle<int> SwankyAmpLAF::getTooltipBounds(
const String&, Point<int>, Rectangle<int> parentArea)
{
const int lineHeight = 16;
const int margin = lineHeight;
const int padding = 4;
const int shadowMargin = getDropShadow().radius;

Rectangle<int> area(parentArea.withPosition(0, 0));
area.setBottom(area.getBottom() - margin);
area.setTop(
area.getBottom() - 2 * lineHeight - 2 * padding - 2 * shadowMargin);
area.setLeft((int)(area.getWidth() * 0.4f + 0.5f));
area.setRight(area.getRight() - margin);

return area;
}

void SwankyAmpLAF::drawTooltip(
Graphics& g, const String& text, int width, int height)
{
const float lineHeight = 16.0f;
const float lineThickness = 1.0f;
const float padding = 4.0f;

const DropShadow& shadow = getDropShadow();
Rectangle<int> areaShadow(width, height);
Rectangle<float> area = areaShadow.reduced(shadow.radius).toFloat();

shadow.drawForRectangle(g, areaShadow.reduced(shadow.radius));

g.setColour(findColour(TooltipWindow::backgroundColourId));
g.fillRect(area);

g.setColour(findColour(TooltipWindow::outlineColourId));
g.drawRect(area, lineThickness);

AttributedString text2;
text2.setJustification(Justification::centredLeft);
text2.append(text, Font(lineHeight), findColour(TooltipWindow::textColourId));

TextLayout text3;
text3.createLayout(text2, (float)(area.reduced(padding).getWidth()));
text3.draw(g, area.reduced(padding));
}

+ 89
- 0
ports/swankyamp/source/SwankyAmpLAF.h View File

@@ -0,0 +1,89 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>

class SwankyAmpLAF : public LookAndFeel_V4
{
public:
SwankyAmpLAF();

// Font size conversions (for 96 dpi):
// 12pt/16px
// 14/18.667px
// 16/21.333px
// 18/24px
// 22/29.333px
// 24/32px

static const Font& getDefaultFont();
static const Font& getDefaultFontNarrow();
static const Font& getDefaultFontBold();

static const Colour colourDark;
static const Colour colourGrey;
static const Colour colourBackground;
static const Colour colourHighlight;
static const Colour colourSteel;

static const DropShadow& getDropShadow();

static Path getSaveIconPath(float d, float stroke = 0.0f);
static Path getRemoveIconPath(float d, float stroke = 0.0f);
static Path getNextIconPath(float d, float stroke = 0.0f);
static Path getPrevIconPath(float d, float stroke = 0.0f);
static Path getOpenIconPath(float d, float stroke = 0.0f);

Path getTickShape(float height) override;
Slider::SliderLayout getSliderLayout(Slider& slider) override;

void drawRotarySlider(
Graphics& g,
int x,
int y,
int width,
int height,
float sliderPos,
const float rotaryStartAngle,
const float rotaryEndAngle,
Slider& slider) override;

void drawToggleButton(
Graphics& g,
ToggleButton& button,
bool shouldDrawButtonAsHighlighted,
bool shouldDrawButtonAsDown) override;

void drawComboBox(
Graphics& g,
int width,
int height,
bool,
int,
int,
int,
int,
ComboBox& box) override;

virtual juce::Rectangle<int> getTooltipBounds(
const String&, Point<int>, juce::Rectangle<int> parentArea) override;
virtual void
drawTooltip(Graphics& g, const String& text, int width, int height) override;
};

+ 46
- 0
ports/swankyamp/source/TooltipsData.cpp View File

@@ -0,0 +1,46 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include "TooltipsData.h"

TooltipsData::TooltipsData(const std::unique_ptr<XmlElement>& xml)
{
if (xml == nullptr) return;

XmlElement* element = xml->getFirstChildElement();
while (element != nullptr)
{
if (element->hasTagName("param") && element->hasAttribute("id"))
{
const String& id = element->getStringAttribute("id");
const String& text = element->getAllSubText().trimStart().trimEnd();
paramStrings.insert(std::pair<const String&, const String&>(id, text));
}

element = element->getNextElement();
}
}

const String& TooltipsData::getForParam(const String& name) const
{
const static String empty = "";
if (paramStrings.find(name) == paramStrings.end())
return empty;
else
return paramStrings.at(name);
}

+ 34
- 0
ports/swankyamp/source/TooltipsData.h View File

@@ -0,0 +1,34 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <JuceHeader.h>
#include <unordered_map>

class TooltipsData
{
public:
TooltipsData(const std::unique_ptr<XmlElement>& xml);
~TooltipsData() {}

const String& getForParam(const String& name) const;

private:
std::unordered_map<String, String> paramStrings;
};

+ 161
- 0
ports/swankyamp/source/Utils.cpp View File

@@ -0,0 +1,161 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <JuceHeader.h>

#include "Utils.h"

float angleModulo(float angle)
{
const float modulo = fmodf(angle, MathConstants<float>::twoPi);
if (modulo > MathConstants<float>::pi)
return modulo - MathConstants<float>::twoPi;
else
return modulo;
}

void fillImageNoise(Image& image, Random& rng, float alpha)
{
if (image.getFormat() != Image::PixelFormat::ARGB)
image.convertedToFormat(Image::PixelFormat::ARGB);
for (int i = 0; i < image.getWidth(); i++)
for (int j = 0; j < image.getHeight(); j++)
image.setPixelAt(
i, j, Colour::fromHSV(0.0f, 0.0f, 0.0f, rng.nextFloat() * alpha));
}

Image buildImageNoise(int width, int height, Random& rng, float alpha)
{
Image noise(Image::PixelFormat::ARGB, jmax(1, width), jmax(1, height), false);
fillImageNoise(noise, rng, alpha);
return noise;
}

VersionNumber parseVersionString(const String& versionString)
{
int section = 0;
VersionNumber versionNumber;
String buff;
for (const auto c : versionString)
{
if (c == '.')
{
if (buff.isNotEmpty())
{
if (section == 0)
versionNumber.major = buff.getIntValue();
else if (section == 1)
versionNumber.minor = buff.getIntValue();
else if (section == 2)
versionNumber.patch = buff.getIntValue();
}
section += 1;
buff.clear();
continue;
}
buff += c;
}

if (buff.isNotEmpty())
{
if (section == 0)
versionNumber.major = buff.getIntValue();
else if (section == 1)
versionNumber.minor = buff.getIntValue();
else if (section == 2)
versionNumber.patch = buff.getIntValue();
}

return versionNumber;
}

/**
* @brief Build map of serialized state parameter names to values.
* @param state serialized state
* @return map of parameter names to values
*/
std::unordered_map<String, double>
mapParameterValues(const SerializedState& state)
{
std::unordered_map<String, double> values;

XmlElement* element = state->getFirstChildElement();

while (element != nullptr)
{
if (element->getTagName() == "PARAM" && element->hasAttribute("id")
&& element->hasAttribute("value"))
{
const String& id = element->getStringAttribute("id");
const double value = element->getDoubleAttribute("value");
values[id] = value;
}

element = element->getNextElement();
}

return values;
}

/**
* @brief Set serialized state from map of parameter to value
* @param state serialized state
* @param map map of parameter names to values
*/
void updateStateFromMap(
SerializedState& state, const std::unordered_map<String, double>& map)
{
std::unordered_map<String, double> values;

XmlElement* element = state->getFirstChildElement();

while (element != nullptr)
{
if (element->getTagName() == "PARAM" && element->hasAttribute("id")
&& element->hasAttribute("value"))
{
const String& id = element->getStringAttribute("id");
if (map.find(id) == map.end()) continue;
element->setAttribute("value", map.at(id));
}
element = element->getNextElement();
}
}

// TODO: could be useful for building parameter list in processor?
std::vector<String> buildParameterIds(const SerializedState& state)
{
if (state == nullptr) return {};

std::vector<String> parameterIds;

XmlElement* element = state->getFirstChildElement();

while (element != nullptr)
{
if (element->getTagName() == "PARAM" && element->hasAttribute("id"))
{
const String& id = element->getStringAttribute("id");
parameterIds.push_back(id);
}

element = element->getNextElement();
}

return parameterIds;
}

+ 195
- 0
ports/swankyamp/source/Utils.h View File

@@ -0,0 +1,195 @@
/*
* Swanky Amp tube amplifier simulation
* Copyright (C) 2020 Garrin McGoldrick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <unordered_map>

#include <JuceHeader.h>

using SerializedState = std::unique_ptr<XmlElement>;

struct VersionNumber
{
int major = -1;
int minor = -1;
int patch = -1;

VersionNumber() {}

VersionNumber(int major, int minor, int patch) :
major(major), minor(minor), patch(patch)
{
}

bool operator==(const VersionNumber& other) const
{
return this->major == other.major && this->minor == other.minor
&& this->patch == other.patch;
}

bool operator<(const VersionNumber& other) const
{
if (this->major < other.major) return true;
if (this->major == other.major && this->minor < other.minor) return true;
if (this->major == other.major && this->minor == other.minor
&& this->patch < other.patch)
return true;
return false;
}

bool operator>(const VersionNumber& other) const
{
return !(*this == other) && !(*this < other);
}

bool operator!=(const VersionNumber& other) const
{
return !(*this == other);
}
};

VersionNumber parseVersionString(const String& versionString);

std::unordered_map<String, double>
mapParameterValues(const SerializedState& state);

void updateStateFromMap(
SerializedState& state, const std::unordered_map<String, double>& map);

std::vector<String> buildParameterIds(const SerializedState& state);

float angleModulo(float angle);

Image buildImageNoise(int width, int height, Random& rng, float alpha);

/**
* @brief Remap a float value to a positive and negative range.
*
* Remap the range [-1, 0) to [`to_low`, 0) and the range (0, 1] to
* (0, `to_high`]. Note that the values below zero can be scaled differently
* from those above zero.
*
* @param unit value to remap, usually in the unit scale [-1, +1]
* @param to_low scale values above zero by this amount
* @param to_high scale values below zero by this amount
* @return remapped value
*/
inline float remapSided(float unit, float to_low, float to_high)
{
if (unit >= 0) { return unit * to_high; }
else
{
return -unit * to_low;
}
}

/**
* @brief Remap a float value to a new range.
*
* Remap the range [-1, +1] to [`to_low`, `to_high`]. Unlike `remap_sided`, the
* same scaling is applied to all input values. An input value of `0` will map
* to the mean of `to_low` and `to_high`.
*
* @param unit value to remap, usually in the unit scale [-1, +1]
* @param to_low value to reach when `unit` is at `-1`
* @param to_high value to reach when `unit` is at `+1`
* @return remapped value
*/
inline float remapRange(float unit, float to_low, float to_high)
{
return (unit + 1.0f) / 2.0f * (to_high - to_low) + to_low;
}

/**
* @brief Remap a given range of floats to a new range.
*
* Remap the range [`x1`, `x2`] to the range [`y1`, `y2`]. Clips the input `x`
* to the range [`x1`, `x2`].
*
* @param x value to remap
* @param x1 lower value in the range to map from
* @param x2 upper value in the range to map from
* @param y1 lower value in the range to map to
* @param y2 upper value in the range to map to
* @return remapped value
*/
inline float remapXY(float x, float x1, float x2, float y1, float y2)
{
x = jmax(x1, jmin(x2, x));
x = (x - x1) / (x2 - x1);
float y = x * (y2 - y1) + y1;
return y;
}

/**
* @brief Remap a value from the range (-1, +1) to the same range, but with a
* new metric such that dy/dx(x) follows a sinh curve.
*
* In other words, for an input x near the eges -1 or 1, a small change in x
* will result in a bigger change in y. For input values near 0, a small
* change in x will result in a smaller change in y.
*
* The calulating uses exponential values in the intermediate steps. This can
* probably be fixed later, but for now scales should stay below 100.
*
* @param x the value to remap
* @param x0 the point in the range (-1, 1) where y changes most slowly
* @param scale larger values will create a bigger difference
* @return remaped value
*/
inline float remapSinh(float x, float x0, float scale)
{
// the value mapped by sinh
const float mapped = sinh((x - x0) * scale);
// y(x) at the bounds -1 and 1
const float lower = sinh((-1.0f - x0) * scale);
const float upper = sinh((+1.0f - x0) * scale);
return (mapped - lower) / (upper - lower) * 2.0f - 1.0f;
}

inline float invertRemapSinh(float x, float x0, float scale)
{
const float lower = sinh((-1.0f - x0) * scale);
const float upper = sinh((+1.0f - x0) * scale);
const float unscaled = (x + 1.0f) / 2.0f * (upper - lower) + lower;
return asinh(unscaled) / scale + x0;
}

inline double transformUnitScale(
double value,
double lower,
double upper,
double lowerPost,
double upperPost)
{
const double post = 2.0 / (upperPost - lowerPost)
* ((value + 1.0) / 2.0 * (upper - lower) + lower - lowerPost)
- 1.0;
return jmin(1.0, jmax(-1.0, post));
}

// commonly used in parameter groups that need to handle the size (e.g. to
// maintain an aspect ratio)
#define DISABLE_COMPONENT_RESIZE() \
using Component::setSize; \
using Component::setBounds; \
using Component::setBoundsRelative; \
using Component::setBoundsInset; \
using Component::setBoundsToFit; \
using Component::centreWithSize;

+ 388
- 0
ports/swankyamp/source/dsp/Cabinet.h View File

@@ -0,0 +1,388 @@
#ifndef __faust2hpp_Cabinet_H__
#define __faust2hpp_Cabinet_H__

#include <cmath>

#define uscale(x, l, u) (x + 1.0f) / 2.0f * (u - l) + l;
#define ulscale(x, l, u) \
std::exp((x + 1.0f) / 2.0f * (std::log(u) - std::log(l)) + std::log(l));

#include "CabinetFaust.h"

class Cabinet
{
public:
Cabinet()
{
faustDsp.buildUserInterface(&faustDsp);
par_brightness = faustDsp.getParameter("brightness");
par_distance = faustDsp.getParameter("distance");
par_dynamic = faustDsp.getParameter("dynamic");
par_dynamic_level = faustDsp.getParameter("dynamic_level");
par_hp_f = faustDsp.getParameter("hp_f");
par_lp_f = faustDsp.getParameter("lp_f");
par_offset = faustDsp.getParameter("offset");
par_peak_10_b = faustDsp.getParameter("peak_10_b");
par_peak_10_f = faustDsp.getParameter("peak_10_f");
par_peak_10_l = faustDsp.getParameter("peak_10_l");
par_peak_1_b = faustDsp.getParameter("peak_1_b");
par_peak_1_f = faustDsp.getParameter("peak_1_f");
par_peak_1_l = faustDsp.getParameter("peak_1_l");
par_peak_2_b = faustDsp.getParameter("peak_2_b");
par_peak_2_f = faustDsp.getParameter("peak_2_f");
par_peak_2_l = faustDsp.getParameter("peak_2_l");
par_peak_3_b = faustDsp.getParameter("peak_3_b");
par_peak_3_f = faustDsp.getParameter("peak_3_f");
par_peak_3_l = faustDsp.getParameter("peak_3_l");
par_peak_4_b = faustDsp.getParameter("peak_4_b");
par_peak_4_f = faustDsp.getParameter("peak_4_f");
par_peak_4_l = faustDsp.getParameter("peak_4_l");
par_peak_5_b = faustDsp.getParameter("peak_5_b");
par_peak_5_f = faustDsp.getParameter("peak_5_f");
par_peak_5_l = faustDsp.getParameter("peak_5_l");
par_peak_6_b = faustDsp.getParameter("peak_6_b");
par_peak_6_f = faustDsp.getParameter("peak_6_f");
par_peak_6_l = faustDsp.getParameter("peak_6_l");
par_peak_7_b = faustDsp.getParameter("peak_7_b");
par_peak_7_f = faustDsp.getParameter("peak_7_f");
par_peak_7_l = faustDsp.getParameter("peak_7_l");
par_peak_8_b = faustDsp.getParameter("peak_8_b");
par_peak_8_f = faustDsp.getParameter("peak_8_f");
par_peak_8_l = faustDsp.getParameter("peak_8_l");
par_peak_9_b = faustDsp.getParameter("peak_9_b");
par_peak_9_f = faustDsp.getParameter("peak_9_f");
par_peak_9_l = faustDsp.getParameter("peak_9_l");
par_scoop_b = faustDsp.getParameter("scoop_b");
par_scoop_f = faustDsp.getParameter("scoop_f");
par_scoop_l = faustDsp.getParameter("scoop_l");
par_shelf_f = faustDsp.getParameter("shelf_f");
par_shelf_l = faustDsp.getParameter("shelf_l");
}

~Cabinet() = default;

void reset()
{
faustDsp.instanceClear();
zeroParameters();
}

void prepare(int sampleRate)
{
faustDsp.init(sampleRate);
zeroParameters();
}

void process(int count, FAUSTFLOAT** buffer)
{
faustDsp.compute(count, buffer, buffer);
}

inline void set_brightness(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_brightness = x;
}
inline void set_distance(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_distance = x;
}
inline void set_dynamic(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_dynamic = uscale(x, 0.0f, 1.0f);
}
inline void set_dynamic_level(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_dynamic_level = ulscale(x, 0.5f, 2.0f);
}
inline void set_hp_f(FAUSTFLOAT x)
{
x += 1.110027e+02f;
*par_hp_f = x;
}
inline void set_lp_f(FAUSTFLOAT x)
{
x += 1.099876e+04f;
*par_lp_f = x;
}
inline void set_offset(FAUSTFLOAT x)
{
x += 1.937125e+01f;
*par_offset = x;
}
inline void set_peak_10_b(FAUSTFLOAT x)
{
x += 1.000935e+03f;
*par_peak_10_b = x;
}
inline void set_peak_10_f(FAUSTFLOAT x)
{
x += 4.900000e+03f;
*par_peak_10_f = x;
}
inline void set_peak_10_l(FAUSTFLOAT x)
{
x += -4.999868e+00f;
*par_peak_10_l = x;
}
inline void set_peak_1_b(FAUSTFLOAT x)
{
x += 2.993194e+01f;
*par_peak_1_b = x;
}
inline void set_peak_1_f(FAUSTFLOAT x)
{
x += 6.000000e+02f;
*par_peak_1_f = x;
}
inline void set_peak_1_l(FAUSTFLOAT x)
{
x += -2.500029e+01f;
*par_peak_1_l = x;
}
inline void set_peak_2_b(FAUSTFLOAT x)
{
x += 1.000074e+02f;
*par_peak_2_b = x;
}
inline void set_peak_2_f(FAUSTFLOAT x)
{
x += 6.400000e+02f;
*par_peak_2_f = x;
}
inline void set_peak_2_l(FAUSTFLOAT x)
{
x += 1.597118e+01f;
*par_peak_2_l = x;
}
inline void set_peak_3_b(FAUSTFLOAT x)
{
x += 4.999785e+01f;
*par_peak_3_b = x;
}
inline void set_peak_3_f(FAUSTFLOAT x)
{
x += 1.120000e+03f;
*par_peak_3_f = x;
}
inline void set_peak_3_l(FAUSTFLOAT x)
{
x += -1.507867e+01f;
*par_peak_3_l = x;
}
inline void set_peak_4_b(FAUSTFLOAT x)
{
x += 1.599996e+02f;
*par_peak_4_b = x;
}
inline void set_peak_4_f(FAUSTFLOAT x)
{
x += 1.180000e+03f;
*par_peak_4_f = x;
}
inline void set_peak_4_l(FAUSTFLOAT x)
{
x += 8.909575e+00f;
*par_peak_4_l = x;
}
inline void set_peak_5_b(FAUSTFLOAT x)
{
x += 7.901408e+02f;
*par_peak_5_b = x;
}
inline void set_peak_5_f(FAUSTFLOAT x)
{
x += 1.660000e+03f;
*par_peak_5_f = x;
}
inline void set_peak_5_l(FAUSTFLOAT x)
{
x += -3.531785e+00f;
*par_peak_5_l = x;
}
inline void set_peak_6_b(FAUSTFLOAT x)
{
x += 3.309512e+02f;
*par_peak_6_b = x;
}
inline void set_peak_6_f(FAUSTFLOAT x)
{
x += 3.050000e+03f;
*par_peak_6_f = x;
}
inline void set_peak_6_l(FAUSTFLOAT x)
{
x += -9.011323e+00f;
*par_peak_6_l = x;
}
inline void set_peak_7_b(FAUSTFLOAT x)
{
x += 7.499988e+02f;
*par_peak_7_b = x;
}
inline void set_peak_7_f(FAUSTFLOAT x)
{
x += 3.800000e+03f;
*par_peak_7_f = x;
}
inline void set_peak_7_l(FAUSTFLOAT x)
{
x += -5.999392e+00f;
*par_peak_7_l = x;
}
inline void set_peak_8_b(FAUSTFLOAT x)
{
x += 1.999953e+02f;
*par_peak_8_b = x;
}
inline void set_peak_8_f(FAUSTFLOAT x)
{
x += 7.200000e+03f;
*par_peak_8_f = x;
}
inline void set_peak_8_l(FAUSTFLOAT x)
{
x += -2.999869e+01f;
*par_peak_8_l = x;
}
inline void set_peak_9_b(FAUSTFLOAT x)
{
x += 7.500001e+02f;
*par_peak_9_b = x;
}
inline void set_peak_9_f(FAUSTFLOAT x)
{
x += 2.300000e+03f;
*par_peak_9_f = x;
}
inline void set_peak_9_l(FAUSTFLOAT x)
{
x += 3.000100e+00f;
*par_peak_9_l = x;
}
inline void set_scoop_b(FAUSTFLOAT x)
{
x += 2.799926e+03f;
*par_scoop_b = x;
}
inline void set_scoop_f(FAUSTFLOAT x)
{
x += 9.509019e+02f;
*par_scoop_f = x;
}
inline void set_scoop_l(FAUSTFLOAT x)
{
x += -1.529571e+01f;
*par_scoop_l = x;
}
inline void set_shelf_f(FAUSTFLOAT x)
{
x += 5.600000e+03f;
*par_shelf_f = x;
}
inline void set_shelf_l(FAUSTFLOAT x)
{
x += -3.002781e+01f;
*par_shelf_l = x;
}

private:
CabinetFaust faustDsp;

FAUSTFLOAT* par_brightness = nullptr;
FAUSTFLOAT* par_distance = nullptr;
FAUSTFLOAT* par_dynamic = nullptr;
FAUSTFLOAT* par_dynamic_level = nullptr;
FAUSTFLOAT* par_hp_f = nullptr;
FAUSTFLOAT* par_lp_f = nullptr;
FAUSTFLOAT* par_offset = nullptr;
FAUSTFLOAT* par_peak_10_b = nullptr;
FAUSTFLOAT* par_peak_10_f = nullptr;
FAUSTFLOAT* par_peak_10_l = nullptr;
FAUSTFLOAT* par_peak_1_b = nullptr;
FAUSTFLOAT* par_peak_1_f = nullptr;
FAUSTFLOAT* par_peak_1_l = nullptr;
FAUSTFLOAT* par_peak_2_b = nullptr;
FAUSTFLOAT* par_peak_2_f = nullptr;
FAUSTFLOAT* par_peak_2_l = nullptr;
FAUSTFLOAT* par_peak_3_b = nullptr;
FAUSTFLOAT* par_peak_3_f = nullptr;
FAUSTFLOAT* par_peak_3_l = nullptr;
FAUSTFLOAT* par_peak_4_b = nullptr;
FAUSTFLOAT* par_peak_4_f = nullptr;
FAUSTFLOAT* par_peak_4_l = nullptr;
FAUSTFLOAT* par_peak_5_b = nullptr;
FAUSTFLOAT* par_peak_5_f = nullptr;
FAUSTFLOAT* par_peak_5_l = nullptr;
FAUSTFLOAT* par_peak_6_b = nullptr;
FAUSTFLOAT* par_peak_6_f = nullptr;
FAUSTFLOAT* par_peak_6_l = nullptr;
FAUSTFLOAT* par_peak_7_b = nullptr;
FAUSTFLOAT* par_peak_7_f = nullptr;
FAUSTFLOAT* par_peak_7_l = nullptr;
FAUSTFLOAT* par_peak_8_b = nullptr;
FAUSTFLOAT* par_peak_8_f = nullptr;
FAUSTFLOAT* par_peak_8_l = nullptr;
FAUSTFLOAT* par_peak_9_b = nullptr;
FAUSTFLOAT* par_peak_9_f = nullptr;
FAUSTFLOAT* par_peak_9_l = nullptr;
FAUSTFLOAT* par_scoop_b = nullptr;
FAUSTFLOAT* par_scoop_f = nullptr;
FAUSTFLOAT* par_scoop_l = nullptr;
FAUSTFLOAT* par_shelf_f = nullptr;
FAUSTFLOAT* par_shelf_l = nullptr;

void zeroParameters()
{
set_brightness(0.0f);
set_distance(0.0f);
set_dynamic(0.0f);
set_dynamic_level(0.0f);
set_hp_f(0.0f);
set_lp_f(0.0f);
set_offset(0.0f);
set_peak_10_b(0.0f);
set_peak_10_f(0.0f);
set_peak_10_l(0.0f);
set_peak_1_b(0.0f);
set_peak_1_f(0.0f);
set_peak_1_l(0.0f);
set_peak_2_b(0.0f);
set_peak_2_f(0.0f);
set_peak_2_l(0.0f);
set_peak_3_b(0.0f);
set_peak_3_f(0.0f);
set_peak_3_l(0.0f);
set_peak_4_b(0.0f);
set_peak_4_f(0.0f);
set_peak_4_l(0.0f);
set_peak_5_b(0.0f);
set_peak_5_f(0.0f);
set_peak_5_l(0.0f);
set_peak_6_b(0.0f);
set_peak_6_f(0.0f);
set_peak_6_l(0.0f);
set_peak_7_b(0.0f);
set_peak_7_f(0.0f);
set_peak_7_l(0.0f);
set_peak_8_b(0.0f);
set_peak_8_f(0.0f);
set_peak_8_l(0.0f);
set_peak_9_b(0.0f);
set_peak_9_f(0.0f);
set_peak_9_l(0.0f);
set_scoop_b(0.0f);
set_scoop_f(0.0f);
set_scoop_l(0.0f);
set_shelf_f(0.0f);
set_shelf_l(0.0f);
}
};

#undef uscale
#undef ulscale

#endif

+ 1198
- 0
ports/swankyamp/source/dsp/CabinetFaust.h
File diff suppressed because it is too large
View File


+ 79
- 0
ports/swankyamp/source/dsp/FaustImpl.h View File

@@ -0,0 +1,79 @@
#ifndef __faust2hpp_FaustImpl_H__
#define __faust2hpp_FaustImpl_H__

#include <stdexcept>
#include <unordered_map>

#include "Meta.h"
#include "UI.h"

class FaustImpl : public UI, public Meta
{
public:
FaustImpl() = default;
~FaustImpl() = default;

FAUSTFLOAT* getParameter(const char* name)
{
const auto entry = parameterMap.find(name);
if (entry == parameterMap.end())
throw std::invalid_argument(
std::string("FaustImpl::getParameter: invalid parameter name: ")
+ name);
return entry->second;
}

void setParameter(const char* name, FAUSTFLOAT* value)
{
const auto entry = parameterMap.find(name);
if (entry != parameterMap.end()) entry->second = value;
}

// blank implementations for UI
virtual void openTabBox(const char*){};
virtual void openHorizontalBox(const char*){};
virtual void openVerticalBox(const char*){};
virtual void closeBox(){};
virtual void addButton(const char*, FAUSTFLOAT*){};
virtual void addCheckButton(const char*, FAUSTFLOAT*){};
virtual void addVerticalSlider(
const char*,
FAUSTFLOAT*,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT){};
virtual void addHorizontalSlider(
const char*,
FAUSTFLOAT*,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT){};
virtual void
// use UI entry to expose user parameters
addNumEntry(
const char* label,
FAUSTFLOAT* zone,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT)
{
if (zone == nullptr) return;
parameterMap[label] = zone;
}
virtual void
addHorizontalBargraph(const char*, FAUSTFLOAT*, FAUSTFLOAT, FAUSTFLOAT){};
virtual void
addVerticalBargraph(const char*, FAUSTFLOAT*, FAUSTFLOAT, FAUSTFLOAT){};
virtual void addSoundfile(const char*, const char*, Soundfile**){};

// blank implememtation for Meta
virtual void declare(const char*, const char*){};

private:
std::unordered_map<const char*, FAUSTFLOAT*> parameterMap;
};

#endif

+ 34
- 0
ports/swankyamp/source/dsp/Meta.h View File

@@ -0,0 +1,34 @@
/************************************************************************
FAUST Architecture File
Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale
---------------------------------------------------------------------
This Architecture section is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3 of
the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; If not, see <http://www.gnu.org/licenses/>.

EXCEPTION : As a special exception, you may create a larger work
that contains this FAUST architecture section and distribute
that work under terms of your choice, so long as this FAUST
architecture section is not modified.
************************************************************************/

#pragma once
#ifndef __faust2hpp_Meta_H__
#define __faust2hpp_Meta_H__

struct Meta
{
virtual ~Meta(){};
virtual void declare(const char* key, const char* value) = 0;
};

#endif

+ 504
- 0
ports/swankyamp/source/dsp/PushPullAmp.h View File

@@ -0,0 +1,504 @@
#ifndef __PushPullAmP_H__
#define __PushPullAmP_H__

#include <algorithm>
#include <cmath>
#include <random>

#define USCALE(x, l, u) (x + 1.0f) / 2.0f * (u - l) + l
#define ULSCALE(x, l, u) std::exp(USCALE(x, std::log(l), std::log(u)));
#define IUSCALE(x, l, u) (x - l) / (u - l) * 2.0f - 1.0f
#define IULSCALE(x, l, u) IUSCALE(std::log(x), std::log(l), std::log(u))

#define LINEAR2DB(x) 20.0f * std::log10(x)
#define DB2LINEAR(x) std::pow(10.0f, (x) / 20.0f)

#define NUM_SWEEP_BINS 10

#include "Cabinet.h"
#include "TetrodeGrid.h"
#include "TetrodePlate.h"
#include "ToneStack.h"
#include "Triode.h"

inline void scaleBuffer(int count, FAUSTFLOAT** buffer, FAUSTFLOAT scale)
{
for (int i = 0; i < count; i++) buffer[0][i] *= scale;
}

inline FAUSTFLOAT scaleBuffer(
int count,
FAUSTFLOAT** buffer,
FAUSTFLOAT fromScale,
FAUSTFLOAT toScale,
FAUSTFLOAT dbPerSecond,
int sampleRate)
{
FAUSTFLOAT scale = fromScale;
const FAUSTFLOAT dbPerSample = (toScale > fromScale ? 1.0f : -1.0f)
* dbPerSecond / (FAUSTFLOAT)sampleRate;
const FAUSTFLOAT factor = std::pow(10.0f, dbPerSample / 20.0f);
const FAUSTFLOAT upper = toScale > fromScale ? toScale : fromScale;
const FAUSTFLOAT lower = toScale <= fromScale ? toScale : fromScale;
for (int i = 0; i < count; i++)
{
buffer[0][i] *= scale;
scale = std::min(upper, std::max(lower, scale * factor));
}
return scale;
}

inline float interp1d(float x, float xl, float xh, const float* edges, size_t n)
{
const float xu = (x - xl) / (xh - xl);
const float xbin = xu * (float)n;
size_t i = 0;
if (xbin >= n)
i = n - 1;
else if (xbin >= 0)
i = (int)(xbin);
const float m = edges[i + 1] - edges[i];
const float b = edges[i];
return m * (xbin - i) + b;
}

class PreAmp
{
public:
PreAmp() : rngDist(-0.2f, 0.2f) {}
~PreAmp() = default;

void reset()
{
for (size_t i = 0; i < MAX_STAGES; i++) triode[i].reset();
resetParameters();
}

void prepare(int sampleRate)
{
for (size_t i = 0; i < MAX_STAGES; i++) triode[i].prepare(sampleRate);
resetParameters();
}

void process(int count, FAUSTFLOAT** buffer)
{
// drive below 0.5 can cause high-pitch artifacts due to float precision
// loss, so bound it here to be sure and to allow UI to maintain old range
scaleBuffer(count, buffer, drive < 0.5f ? 0.5f : drive);
const int numStagesLow = (int)std::floor(numStagesActive());
const int numStagesHigh = (int)std::ceil(numStagesActive());
const float stageMix = numStagesActive() - numStagesLow;

for (size_t i = 0; i < numStagesHigh; i++)
{
triode[i].set_overhead(i > 0 ? overhead : 1.0f);
triode[i].set_mix(i < numStagesLow ? 1.0f : stageMix);
triode[i].process(count, buffer);
}

// scale up to nominal output rms
scaleBuffer(count, buffer, triodeScale);
}

inline void set_hp_freq(FAUSTFLOAT x)
{
auto rng = std::minstd_rand(rngSeed + 1);
for (size_t i = 0; i < MAX_STAGES; i++)
triode[i].set_hp_freq(x + rngDist(rng));
}
inline void set_grid_tau(FAUSTFLOAT x)
{
auto rng = std::minstd_rand(rngSeed + 2);
for (size_t i = 0; i < MAX_STAGES; i++) triode[i].set_tau(x + rngDist(rng));
}
inline void set_grid_ratio(FAUSTFLOAT x)
{
for (size_t i = 0; i < MAX_STAGES; i++) triode[i].set_ratio(x);
}
inline void set_grid_level(FAUSTFLOAT x)
{
for (size_t i = 0; i < MAX_STAGES; i++) triode[i].set_level(x);
}
inline void set_grid_clip(FAUSTFLOAT x)
{
auto rng = std::minstd_rand(rngSeed + 4);
for (size_t i = 0; i < MAX_STAGES; i++)
triode[i].set_grid_clip(x + rngDist(rng));
}
inline void set_plate_bias(FAUSTFLOAT x)
{
auto rng = std::minstd_rand(rngSeed + 5);
for (size_t i = 0; i < MAX_STAGES; i++)
triode[i].set_bias(x + rngDist(rng));
}
inline void set_plate_scale(FAUSTFLOAT x)
{
for (size_t i = 0; i < MAX_STAGES; i++) triode[i].set_scale(x);
}
inline void set_plate_clip(FAUSTFLOAT x)
{
auto rng = std::minstd_rand(rngSeed + 7);
for (size_t i = 0; i < MAX_STAGES; i++)
triode[i].set_plate_clip(x + rngDist(rng));
}
inline void set_plate_drift_level(FAUSTFLOAT x)
{
auto rng = std::minstd_rand(rngSeed + 8);
for (size_t i = 0; i < MAX_STAGES; i++)
triode[i].set_drift_level(x + rngDist(rng));
}
inline void set_plate_drift_tau(FAUSTFLOAT x)
{
auto rng = std::minstd_rand(rngSeed + 9);
for (size_t i = 0; i < MAX_STAGES; i++)
triode[i].set_drift_tau(x + rngDist(rng));
}
inline void set_plate_comp_ratio(FAUSTFLOAT x)
{
for (size_t i = 0; i < MAX_STAGES; i++) triode[i].set_comp_ratio(x);
}
inline void set_plate_comp_level(FAUSTFLOAT x)
{
auto rng = std::minstd_rand(rngSeed + 10);
for (size_t i = 0; i < MAX_STAGES; i++)
triode[i].set_comp_level(x + rngDist(rng));
}
inline void set_plate_comp_offset(FAUSTFLOAT x)
{
for (size_t i = 0; i < MAX_STAGES; i++) triode[i].set_comp_offset(x);
}

inline void set_num_stages(FAUSTFLOAT x) { numStages = x; }
inline void set_drive(FAUSTFLOAT x) { drive = ULSCALE(x, 1e-1f, 2e3f); }
inline float get_drive() const { return IULSCALE(drive, 1e-1f, 2e3f); }
inline void set_overhead(FAUSTFLOAT x) { overhead = ULSCALE(x, 1e-1f, 1e1f); }
inline float get_overhead() const { return IULSCALE(overhead, 1e-1f, 1e1f); }

private:
static const size_t MAX_STAGES = 5;

FAUSTFLOAT drive = 0.0f;
FAUSTFLOAT overhead = 0.0f;
float numStages = 0.0f;

Triode triode[MAX_STAGES];

std::uniform_real_distribution<float> rngDist;
unsigned int rngSeed = 123;

const float triodeScale = 3.501334e+01f;

inline float numStagesActive() const
{
float num = numStages > MAX_STAGES ? (float)MAX_STAGES : numStages;
// keep always some amount of stage 2 mixed in to smooth out artifcats
// that can arise from a single stage
num = num < 1.1f ? 1.1f : num;
return num;
}

void resetParameters()
{
set_num_stages(3.0f);
set_drive(0.0f);
set_overhead(0.0f);

// must manually set to get the randomization
set_hp_freq(0.0f);
set_grid_tau(0.0f);
set_grid_ratio(0.0f);
set_grid_clip(0.0f);
set_plate_bias(0.0f);
set_plate_clip(0.0f);
set_plate_drift_level(0.0f);
set_plate_drift_tau(0.0f);
set_plate_comp_ratio(0.0f);
set_plate_comp_level(0.0f);
set_plate_comp_offset(0.0f);

for (size_t i = 0; i < MAX_STAGES; i++)
{
triode[i].set_mix(1.0f);
triode[i].set_overhead(1.0f);
triode[i].set_unscale(triodeScale);
}
}
};

class PowerAmp
{
public:
PowerAmp() = default;
~PowerAmp() = default;

void reset()
{
tetrodeGrid.reset();
tetrodePlate.reset();
resetParameters();
}

void prepare(int sampleRate)
{
tetrodeGrid.prepare(sampleRate);
tetrodePlate.prepare(sampleRate);
resetParameters();
}

void process(int count, FAUSTFLOAT** buffer)
{
scaleBuffer(count, buffer, drive);
tetrodeGrid.process(count, buffer);
tetrodePlate.process(count, buffer);
}

inline void set_hp_freq(FAUSTFLOAT x) { tetrodeGrid.set_hp_freq(x); }
inline void set_grid_tau(FAUSTFLOAT x) { tetrodeGrid.set_tau(x); }
inline void set_grid_ratio(FAUSTFLOAT x) { tetrodeGrid.set_ratio(x); }
inline void set_plate_comp_depth(FAUSTFLOAT x)
{
tetrodePlate.set_comp_depth(x);
}
inline void set_plate_sag_tau(FAUSTFLOAT x) { tetrodePlate.set_sag_tau(x); }
inline void set_plate_sag_toggle(FAUSTFLOAT x)
{
tetrodePlate.set_sag_toggle(x);
}
inline void set_plate_sag_depth(FAUSTFLOAT x)
{
tetrodePlate.set_sag_depth(x);
}
inline void set_plate_sag_ratio(FAUSTFLOAT x)
{
tetrodePlate.set_sag_ratio(x);
}
inline void set_plate_sag_factor(FAUSTFLOAT x)
{
tetrodePlate.set_sag_factor(x);
}
inline void set_plate_sag_onset(FAUSTFLOAT x)
{
tetrodePlate.set_sag_onset(x);
}

inline void set_drive(FAUSTFLOAT x) { drive = ULSCALE(x, 3e1f, 3e4f); }
inline float get_drive() const { return IULSCALE(drive, 3e1f, 3e4f); }

private:
TetrodeGrid tetrodeGrid;
TetrodePlate tetrodePlate;

FAUSTFLOAT drive;

void resetParameters() { set_drive(0.0f); }
};

class PushPullAmp
{
public:
PushPullAmp() = default;
~PushPullAmp() = default;

void reset()
{
preAmp.reset();
toneStack.reset();
powerAmp.reset();
cabinet.reset();
resetParameters();
}

void prepare(int sampleRate)
{
preAmp.prepare(sampleRate);
toneStack.prepare(sampleRate);
powerAmp.prepare(sampleRate);
cabinet.prepare(sampleRate);
resetParameters();
}

void process(int count, FAUSTFLOAT** buffer)
{
scaleBuffer(count, buffer, DB2LINEAR(inputLevel));

preAmp.process(count, buffer);

const float preAmpScale = interp1d(
preAmp.get_drive(),
-1.0f,
1.0f,
preAmpSweepScales,
(size_t)NUM_SWEEP_BINS);
const float preAmpTarget = 3.228806e+01f;

const float toneStackScale = 1.0f / 5.302220e-01f;

toneStack.process(count, buffer);

scaleBuffer(count, buffer, toneStackScale * preAmpScale * preAmpTarget);

powerAmp.process(count, buffer);

scaleBuffer(count, buffer, 1.0f / preAmpTarget);

const float cabinetScale = cabinetOn ? 1.0f / 2.821151e+00f : 1.0f;
if (cabinetOn) cabinet.process(count, buffer);

const float powerAmpScale = interp1d(
powerAmp.get_drive(),
-1.0f,
1.0f,
powerAmpSweepScales,
(size_t)NUM_SWEEP_BINS);

const float outputScale = DB2LINEAR(outputLevel);
scaleBuffer(count, buffer, powerAmpScale * cabinetScale * outputScale);
}

inline void set_triode_num_stages(FAUSTFLOAT x) { preAmp.set_num_stages(x); }
inline void set_triode_overhead(FAUSTFLOAT x) { preAmp.set_overhead(x); }
inline void set_triode_hp_freq(FAUSTFLOAT x) { preAmp.set_hp_freq(x); }
inline void set_triode_grid_tau(FAUSTFLOAT x) { preAmp.set_grid_tau(x); }
inline void set_triode_grid_ratio(FAUSTFLOAT x) { preAmp.set_grid_ratio(x); }
inline void set_triode_grid_level(FAUSTFLOAT x) { preAmp.set_grid_level(x); }
inline void set_triode_grid_clip(FAUSTFLOAT x) { preAmp.set_grid_clip(x); }
inline void set_triode_plate_bias(FAUSTFLOAT x) { preAmp.set_plate_bias(x); }
inline void set_triode_plate_comp_ratio(FAUSTFLOAT x)
{
preAmp.set_plate_comp_ratio(x);
}
inline void set_triode_plate_comp_level(FAUSTFLOAT x)
{
preAmp.set_plate_comp_level(x);
}
inline void set_triode_plate_comp_offset(FAUSTFLOAT x)
{
preAmp.set_plate_comp_offset(x);
}
inline void set_triode_drive(FAUSTFLOAT x) { preAmp.set_drive(x); }

inline void set_tetrode_hp_freq(FAUSTFLOAT x) { powerAmp.set_hp_freq(x); }
inline void set_tetrode_grid_tau(FAUSTFLOAT x) { powerAmp.set_grid_tau(x); }
inline void set_tetrode_grid_ratio(FAUSTFLOAT x)
{
powerAmp.set_grid_ratio(x);
}

inline void set_tetrode_plate_comp_depth(FAUSTFLOAT x)
{
powerAmp.set_plate_comp_depth(x);
}
inline void set_tetrode_plate_sag_tau(FAUSTFLOAT x)
{
powerAmp.set_plate_sag_tau(x);
}
inline void set_tetrode_plate_sag_toggle(FAUSTFLOAT x)
{
powerAmp.set_plate_sag_toggle(x);
}
inline void set_tetrode_plate_sag_depth(FAUSTFLOAT x)
{
powerAmp.set_plate_sag_depth(x);
}
inline void set_tetrode_plate_sag_ratio(FAUSTFLOAT x)
{
powerAmp.set_plate_sag_ratio(x);
}
inline void set_tetrode_plate_sag_factor(FAUSTFLOAT x)
{
powerAmp.set_plate_sag_factor(x);
}
inline void set_tetrode_plate_sag_onset(FAUSTFLOAT x)
{
powerAmp.set_plate_sag_onset(x);
}
inline void set_tetrode_drive(FAUSTFLOAT x) { powerAmp.set_drive(x); }

inline void set_tonestack_bass(FAUSTFLOAT x) { toneStack.set_bass(x); }
inline void set_tonestack_mids(FAUSTFLOAT x) { toneStack.set_mids(x); }
inline void set_tonestack_treble(FAUSTFLOAT x) { toneStack.set_treble(x); }
inline void set_tonestack_presence(FAUSTFLOAT x)
{
toneStack.set_presence(x);
}
inline void set_tonestack_selection(FAUSTFLOAT x)
{
toneStack.set_selection(x);
}

inline void set_cabinet_brightness(FAUSTFLOAT x)
{
cabinet.set_brightness(x);
}
inline void set_cabinet_distance(FAUSTFLOAT x) { cabinet.set_distance(x); }
inline void set_cabinet_dynamic(FAUSTFLOAT x) { cabinet.set_dynamic(x); }
inline void set_cabinet_dynamic_level(FAUSTFLOAT x)
{
cabinet.set_dynamic_level(x);
}

inline void set_input_level(FAUSTFLOAT x)
{
inputLevel = USCALE(x, -35.0f, 35.0f);
}
inline void set_output_level(FAUSTFLOAT x)
{
outputLevel = USCALE(x, -35.0f, 35.0f);
}
inline void set_cabinet_on(bool x) { cabinetOn = x; }

float get_tetrode_drive() const { return powerAmp.get_drive(); }
float get_triode_drive() const { return preAmp.get_drive(); }

private:
PreAmp preAmp;
ToneStack toneStack;
PowerAmp powerAmp;
Cabinet cabinet;

FAUSTFLOAT inputLevel = 0.0f;
FAUSTFLOAT outputLevel = 0.0f;
bool cabinetOn = true;

const float preAmpSweepScales[NUM_SWEEP_BINS + 1] = {
4.487723e-03f,
3.323652e-03f,
1.606984e-03f,
6.262808e-04f,
2.279750e-04f,
7.981833e-05f,
2.851987e-05f,
1.361236e-05f,
1.102758e-05f,
1.065001e-05f,
9.354531e-06f};

const float powerAmpSweepScales[NUM_SWEEP_BINS + 1] = {
8.572513e-01f,
4.489064e-01f,
2.412848e-01f,
1.278829e-01f,
6.694987e-02f,
4.332370e-02f,
3.664175e-02f,
3.589781e-02f,
3.497760e-02f,
3.313881e-02f,
3.162063e-02f};

void resetParameters()
{
set_input_level(0.0f);
set_output_level(0.0f);
set_cabinet_on(true);
}
};

#undef USCALE
#undef ULSCALE
#undef IUSCALE
#undef IULSCALE
#undef LINEAR2DB
#undef DB2LINEAR

#endif

+ 116
- 0
ports/swankyamp/source/dsp/TetrodeGrid.h View File

@@ -0,0 +1,116 @@
#ifndef __faust2hpp_TetrodeGrid_H__
#define __faust2hpp_TetrodeGrid_H__

#include <cmath>

#define uscale(x, l, u) (x + 1.0f) / 2.0f * (u - l) + l;
#define ulscale(x, l, u) \
std::exp((x + 1.0f) / 2.0f * (std::log(u) - std::log(l)) + std::log(l));

#include "TetrodeGridFaust.h"

class TetrodeGrid
{
public:
TetrodeGrid()
{
faustDsp.buildUserInterface(&faustDsp);
par_cap = faustDsp.getParameter("cap");
par_hp_freq = faustDsp.getParameter("hp_freq");
par_level = faustDsp.getParameter("level");
par_offset1 = faustDsp.getParameter("offset1");
par_offset2 = faustDsp.getParameter("offset2");
par_ratio = faustDsp.getParameter("ratio");
par_tau = faustDsp.getParameter("tau");
par_taus = faustDsp.getParameter("taus");
}

~TetrodeGrid() = default;

void reset()
{
faustDsp.instanceClear();
zeroParameters();
}

void prepare(int sampleRate)
{
faustDsp.init(sampleRate);
zeroParameters();
}

void process(int count, FAUSTFLOAT** buffer)
{
faustDsp.compute(count, buffer, buffer);
}

inline void set_cap(FAUSTFLOAT x)
{
x += 2.465974e+00f;
*par_cap = ulscale(x, 1e-1f, 1e+1f);
}
inline void set_hp_freq(FAUSTFLOAT x)
{
x += -7.134431e+00f;
*par_hp_freq = ulscale(x, 1e-1f, 1e+2f);
}
inline void set_level(FAUSTFLOAT x)
{
x += 4.248251e-01f;
*par_level = uscale(x, -100.0f, +100.0f);
}
inline void set_offset1(FAUSTFLOAT x)
{
x += 4.783875e-02f;
*par_offset1 = uscale(x, 0.0f, 500.0f);
}
inline void set_offset2(FAUSTFLOAT x)
{
x += -2.047840e+00f;
*par_offset2 = uscale(x, 0.0f, 500.0f);
}
inline void set_ratio(FAUSTFLOAT x)
{
x += 6.316976e-01f;
*par_ratio = ulscale(x, 1e-2f, 1e+2f);
}
inline void set_tau(FAUSTFLOAT x)
{
x += -6.193241e-01f;
*par_tau = ulscale(x, 1e-4f, 1e0f);
}
inline void set_taus(FAUSTFLOAT x)
{
x += -4.923804e-05f;
*par_taus = ulscale(x, 1e-4f, 1e0f);
}

private:
TetrodeGridFaust faustDsp;

FAUSTFLOAT* par_cap = nullptr;
FAUSTFLOAT* par_hp_freq = nullptr;
FAUSTFLOAT* par_level = nullptr;
FAUSTFLOAT* par_offset1 = nullptr;
FAUSTFLOAT* par_offset2 = nullptr;
FAUSTFLOAT* par_ratio = nullptr;
FAUSTFLOAT* par_tau = nullptr;
FAUSTFLOAT* par_taus = nullptr;

void zeroParameters()
{
set_cap(0.0f);
set_hp_freq(0.0f);
set_level(0.0f);
set_offset1(0.0f);
set_offset2(0.0f);
set_ratio(0.0f);
set_tau(0.0f);
set_taus(0.0f);
}
};

#undef uscale
#undef ulscale

#endif

+ 246
- 0
ports/swankyamp/source/dsp/TetrodeGridFaust.h View File

@@ -0,0 +1,246 @@
/* ------------------------------------------------------------
name: "TetrodeGrid"
Code generated with Faust 2.28.3 (https://faust.grame.fr)
Compilation options: -lang cpp -inpl -scal -ftz 2
------------------------------------------------------------ */

#ifndef __TetrodeGridFaust_H__
#define __TetrodeGridFaust_H__

#include "FaustImpl.h"
#ifndef FAUSTFLOAT
#define FAUSTFLOAT float
#endif

#include <algorithm>
#include <cmath>
#include <math.h>

#ifndef FAUSTCLASS
#define FAUSTCLASS TetrodeGridFaust
#endif

#ifdef __APPLE__
#define exp10f __exp10f
#define exp10 __exp10
#endif

class TetrodeGridFaust : public FaustImpl
{
private:
int fSampleRate;
float fConst0;
float fConst1;
FAUSTFLOAT fEntry0;
FAUSTFLOAT fEntry1;
float fVec0[2];
float fRec0[2];
FAUSTFLOAT fEntry2;
float fConst2;
FAUSTFLOAT fEntry3;
float fRec1[2];
FAUSTFLOAT fEntry4;
FAUSTFLOAT fEntry5;
FAUSTFLOAT fEntry6;
FAUSTFLOAT fEntry7;
float fRec2[2];

public:
void metadata(Meta* m)
{
m->declare("basics.lib/name", "Faust Basic Element Library");
m->declare("basics.lib/version", "0.1");
m->declare("filename", "TetrodeGrid.dsp");
m->declare("filters.lib/highpass:author", "Julius O. Smith III");
m->declare(
"filters.lib/highpass:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/lowpass0_highpass1", "MIT-style STK-4.3 license");
m->declare("filters.lib/lowpass0_highpass1:author", "Julius O. Smith III");
m->declare("filters.lib/name", "Faust Filters Library");
m->declare("filters.lib/tf1:author", "Julius O. Smith III");
m->declare(
"filters.lib/tf1:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/tf1:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/tf1s:author", "Julius O. Smith III");
m->declare(
"filters.lib/tf1s:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/tf1s:license", "MIT-style STK-4.3 license");
m->declare("maths.lib/author", "GRAME");
m->declare("maths.lib/copyright", "GRAME");
m->declare("maths.lib/license", "LGPL with exception");
m->declare("maths.lib/name", "Faust Math Library");
m->declare("maths.lib/version", "2.3");
m->declare("name", "TetrodeGrid");
m->declare("platform.lib/name", "Generic Platform Library");
m->declare("platform.lib/version", "0.1");
m->declare("signals.lib/name", "Faust Signal Routing Library");
m->declare("signals.lib/version", "0.0");
}

virtual int getNumInputs() { return 1; }
virtual int getNumOutputs() { return 1; }
virtual int getInputRate(int channel)
{
int rate;
switch ((channel))
{
case 0:
{
rate = 1;
break;
}
default:
{
rate = -1;
break;
}
}
return rate;
}
virtual int getOutputRate(int channel)
{
int rate;
switch ((channel))
{
case 0:
{
rate = 1;
break;
}
default:
{
rate = -1;
break;
}
}
return rate;
}

static void classInit(int) {}

virtual void instanceConstants(int sample_rate)
{
fSampleRate = sample_rate;
fConst0 =
std::min<float>(192000.0f, std::max<float>(1.0f, float(fSampleRate)));
fConst1 = (3.14159274f / fConst0);
fConst2 = (1.0f / fConst0);
}

virtual void instanceResetUserInterface()
{
fEntry0 = FAUSTFLOAT(0.0f);
fEntry1 = FAUSTFLOAT(0.0f);
fEntry2 = FAUSTFLOAT(0.0f);
fEntry3 = FAUSTFLOAT(0.0f);
fEntry4 = FAUSTFLOAT(0.0f);
fEntry5 = FAUSTFLOAT(0.0f);
fEntry6 = FAUSTFLOAT(0.0f);
fEntry7 = FAUSTFLOAT(0.0f);
}

virtual void instanceClear()
{
for (int l0 = 0; (l0 < 2); l0 = (l0 + 1)) { fVec0[l0] = 0.0f; }
for (int l1 = 0; (l1 < 2); l1 = (l1 + 1)) { fRec0[l1] = 0.0f; }
for (int l2 = 0; (l2 < 2); l2 = (l2 + 1)) { fRec1[l2] = 0.0f; }
for (int l3 = 0; (l3 < 2); l3 = (l3 + 1)) { fRec2[l3] = 0.0f; }
}

virtual void init(int sample_rate)
{
classInit(sample_rate);
instanceInit(sample_rate);
}
virtual void instanceInit(int sample_rate)
{
instanceConstants(sample_rate);
instanceResetUserInterface();
instanceClear();
}

virtual TetrodeGridFaust* clone() { return new TetrodeGridFaust(); }

virtual int getSampleRate() { return fSampleRate; }

virtual void buildUserInterface(UI* ui_interface)
{
ui_interface->openVerticalBox("TetrodeGrid");
ui_interface->addNumEntry("cap", &fEntry4, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("hp_freq", &fEntry0, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("level", &fEntry6, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("offset1", &fEntry1, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("offset2", &fEntry3, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("ratio", &fEntry7, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("tau", &fEntry5, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("taus", &fEntry2, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->closeBox();
}

virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs)
{
FAUSTFLOAT* input0 = inputs[0];
FAUSTFLOAT* output0 = outputs[0];
float fSlow0 = std::tan((fConst1 * float(fEntry0)));
float fSlow1 = (1.0f / fSlow0);
float fSlow2 = (fSlow1 + 1.0f);
float fSlow3 = (0.0f - (1.0f / (fSlow0 * fSlow2)));
float fSlow4 = float(fEntry1);
float fSlow5 = (1.0f / fSlow2);
float fSlow6 = (1.0f - fSlow1);
float fSlow7 = float(fEntry2);
int iSlow8 = (std::fabs(fSlow7) < 1.1920929e-07f);
float fSlow9 =
(iSlow8 ? 0.0f
: std::exp((0.0f - (fConst2 / (iSlow8 ? 1.0f : fSlow7)))));
float fSlow10 = float(fEntry3);
float fSlow11 = (1.0f - fSlow9);
float fSlow12 = float(fEntry4);
float fSlow13 = float(fEntry5);
float fSlow14 = (1.0f / (fSlow12 * ((fConst0 * fSlow13) + 1.0f)));
float fSlow15 = (fSlow10 + float(fEntry6));
float fSlow16 =
(1.0f - (1.0f / ((fConst0 * (fSlow13 * float(fEntry7))) + 1.0f)));
for (int i = 0; (i < count); i = (i + 1))
{
float fTemp0 = float(input0[i]);
float fTemp1 = (fTemp0 - fSlow4);
fVec0[0] = fTemp1;
float fTempFTZ0 =
((fSlow3 * fVec0[1])
- (fSlow5 * ((fSlow6 * fRec0[1]) - (fSlow1 * fTemp1))));
fRec0[0] =
((*reinterpret_cast<int*>(&fTempFTZ0) & 2139095040) ? fTempFTZ0
: 0.0f);
float fTempFTZ1 =
((fRec1[1] * fSlow9) + ((fRec0[0] - fSlow10) * fSlow11));
fRec1[0] =
((*reinterpret_cast<int*>(&fTempFTZ1) & 2139095040) ? fTempFTZ1
: 0.0f);
float fTempFTZ2 =
((fSlow14
* (std::max<float>(0.0f, (fSlow12 - fRec2[1]))
* std::max<float>(
0.0f,
(std::max<float>(0.0f, ((fRec0[0] - fRec1[0]) - fSlow15))
- fRec2[1]))))
+ (fSlow16 * fRec2[1]));
fRec2[0] =
((*reinterpret_cast<int*>(&fTempFTZ2) & 2139095040) ? fTempFTZ2
: 0.0f);
output0[i] = FAUSTFLOAT(((fRec0[0] - (fRec1[0] + fRec2[0])) - fSlow10));
fVec0[1] = fVec0[0];
fRec0[1] = fRec0[0];
fRec1[1] = fRec1[0];
fRec2[1] = fRec2[0];
}
}
};

#endif

+ 204
- 0
ports/swankyamp/source/dsp/TetrodePlate.h View File

@@ -0,0 +1,204 @@
#ifndef __faust2hpp_TetrodePlate_H__
#define __faust2hpp_TetrodePlate_H__

#include <cmath>

#define uscale(x, l, u) (x + 1.0f) / 2.0f * (u - l) + l;
#define ulscale(x, l, u) \
std::exp((x + 1.0f) / 2.0f * (std::log(u) - std::log(l)) + std::log(l));

#include "TetrodePlateFaust.h"

class TetrodePlate
{
public:
TetrodePlate()
{
faustDsp.buildUserInterface(&faustDsp);
par_clip = faustDsp.getParameter("clip");
par_clip_corner = faustDsp.getParameter("clip_corner");
par_comp_depth = faustDsp.getParameter("comp_depth");
par_comp_tau = faustDsp.getParameter("comp_tau");
par_cross_corner = faustDsp.getParameter("cross_corner");
par_drift2_depth = faustDsp.getParameter("drift2_depth");
par_drift2_level = faustDsp.getParameter("drift2_level");
par_drift_depth = faustDsp.getParameter("drift_depth");
par_drift_level = faustDsp.getParameter("drift_level");
par_drift_tau = faustDsp.getParameter("drift_tau");
par_hp_freq = faustDsp.getParameter("hp_freq");
par_lp_freq = faustDsp.getParameter("lp_freq");
par_sag_depth = faustDsp.getParameter("sag_depth");
par_sag_factor = faustDsp.getParameter("sag_factor");
par_sag_onset = faustDsp.getParameter("sag_onset");
par_sag_ratio = faustDsp.getParameter("sag_ratio");
par_sag_tau = faustDsp.getParameter("sag_tau");
par_sag_toggle = faustDsp.getParameter("sag_toggle");
par_scale = faustDsp.getParameter("scale");
}

~TetrodePlate() = default;

void reset()
{
faustDsp.instanceClear();
zeroParameters();
}

void prepare(int sampleRate)
{
faustDsp.init(sampleRate);
zeroParameters();
}

void process(int count, FAUSTFLOAT** buffer)
{
faustDsp.compute(count, buffer, buffer);
}

inline void set_clip(FAUSTFLOAT x)
{
x += 5.126605e-01f;
*par_clip = uscale(x, 10.0f, 50.0f);
}
inline void set_clip_corner(FAUSTFLOAT x)
{
x += 1.071061e+00f;
*par_clip_corner = ulscale(x, 1e-1f, 1e+2f);
}
inline void set_comp_depth(FAUSTFLOAT x)
{
x += -5.413471e-01f;
*par_comp_depth = ulscale(x, 1e-1f, 1e+1f);
}
inline void set_comp_tau(FAUSTFLOAT x)
{
x += -1.314454e+00f;
*par_comp_tau = ulscale(x, 1e-3f, 1e0f);
}
inline void set_cross_corner(FAUSTFLOAT x)
{
x += 5.975769e-01f;
*par_cross_corner = ulscale(x, 1e-1f, 1e+2f);
}
inline void set_drift2_depth(FAUSTFLOAT x)
{
x += 3.820307e-02f;
*par_drift2_depth = ulscale(x, 1e-1f, 1e+1f);
}
inline void set_drift2_level(FAUSTFLOAT x)
{
x += 5.687942e-01f;
*par_drift2_level = uscale(x, -50.0f, +50.0f);
}
inline void set_drift_depth(FAUSTFLOAT x)
{
x += 1.725652e-01f;
*par_drift_depth = ulscale(x, 1e-1f, 1e+1f);
}
inline void set_drift_level(FAUSTFLOAT x)
{
x += 1.145707e+00f;
*par_drift_level = uscale(x, -100.0f, +100.0f);
}
inline void set_drift_tau(FAUSTFLOAT x)
{
x += -2.449016e-01f;
*par_drift_tau = ulscale(x, 1e-3f, 1e0f);
}
inline void set_hp_freq(FAUSTFLOAT x)
{
x += -2.867792e+00f;
*par_hp_freq = ulscale(x, 1e1f, 1e2f);
}
inline void set_lp_freq(FAUSTFLOAT x)
{
x += 4.804991e-01f;
*par_lp_freq = ulscale(x, 5e3f, 15e3f);
}
inline void set_sag_depth(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_sag_depth = ulscale(x, 1e-2f, 1e-1f);
}
inline void set_sag_factor(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_sag_factor = x;
}
inline void set_sag_onset(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_sag_onset = ulscale(x, 1e-2f, 1e0f);
}
inline void set_sag_ratio(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_sag_ratio = ulscale(x, 1e0f, 1e+1f);
}
inline void set_sag_tau(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_sag_tau = ulscale(x, 1e-2f, 5e-1f);
}
inline void set_sag_toggle(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_sag_toggle = uscale(x, 0.0f, 1.0f);
}
inline void set_scale(FAUSTFLOAT x)
{
x += 3.354130e-01f;
*par_scale = ulscale(x, 1e-2f, 1e+2f);
}

private:
TetrodePlateFaust faustDsp;

FAUSTFLOAT* par_clip = nullptr;
FAUSTFLOAT* par_clip_corner = nullptr;
FAUSTFLOAT* par_comp_depth = nullptr;
FAUSTFLOAT* par_comp_tau = nullptr;
FAUSTFLOAT* par_cross_corner = nullptr;
FAUSTFLOAT* par_drift2_depth = nullptr;
FAUSTFLOAT* par_drift2_level = nullptr;
FAUSTFLOAT* par_drift_depth = nullptr;
FAUSTFLOAT* par_drift_level = nullptr;
FAUSTFLOAT* par_drift_tau = nullptr;
FAUSTFLOAT* par_hp_freq = nullptr;
FAUSTFLOAT* par_lp_freq = nullptr;
FAUSTFLOAT* par_sag_depth = nullptr;
FAUSTFLOAT* par_sag_factor = nullptr;
FAUSTFLOAT* par_sag_onset = nullptr;
FAUSTFLOAT* par_sag_ratio = nullptr;
FAUSTFLOAT* par_sag_tau = nullptr;
FAUSTFLOAT* par_sag_toggle = nullptr;
FAUSTFLOAT* par_scale = nullptr;

void zeroParameters()
{
set_clip(0.0f);
set_clip_corner(0.0f);
set_comp_depth(0.0f);
set_comp_tau(0.0f);
set_cross_corner(0.0f);
set_drift2_depth(0.0f);
set_drift2_level(0.0f);
set_drift_depth(0.0f);
set_drift_level(0.0f);
set_drift_tau(0.0f);
set_hp_freq(0.0f);
set_lp_freq(0.0f);
set_sag_depth(0.0f);
set_sag_factor(0.0f);
set_sag_onset(0.0f);
set_sag_ratio(0.0f);
set_sag_tau(0.0f);
set_sag_toggle(0.0f);
set_scale(0.0f);
}
};

#undef uscale
#undef ulscale

#endif

+ 425
- 0
ports/swankyamp/source/dsp/TetrodePlateFaust.h View File

@@ -0,0 +1,425 @@
/* ------------------------------------------------------------
name: "TetrodePlate"
Code generated with Faust 2.28.3 (https://faust.grame.fr)
Compilation options: -lang cpp -inpl -scal -ftz 2
------------------------------------------------------------ */

#ifndef __TetrodePlateFaust_H__
#define __TetrodePlateFaust_H__

#include "FaustImpl.h"
#ifndef FAUSTFLOAT
#define FAUSTFLOAT float
#endif

#include <algorithm>
#include <cmath>
#include <math.h>

static float TetrodePlateFaust_faustpower2_f(float value)
{
return (value * value);
}

#ifndef FAUSTCLASS
#define FAUSTCLASS TetrodePlateFaust
#endif

#ifdef __APPLE__
#define exp10f __exp10f
#define exp10 __exp10
#endif

class TetrodePlateFaust : public FaustImpl
{
private:
int fSampleRate;
float fConst0;
float fConst1;
float fConst2;
float fConst3;
float fConst4;
FAUSTFLOAT fEntry0;
float fConst5;
float fConst6;
FAUSTFLOAT fEntry1;
float fConst7;
float fConst8;
FAUSTFLOAT fEntry2;
FAUSTFLOAT fEntry3;
FAUSTFLOAT fEntry4;
FAUSTFLOAT fEntry5;
FAUSTFLOAT fEntry6;
FAUSTFLOAT fEntry7;
FAUSTFLOAT fEntry8;
FAUSTFLOAT fEntry9;
FAUSTFLOAT fEntry10;
float fRec2[2];
float fRec1[2];
FAUSTFLOAT fEntry11;
FAUSTFLOAT fEntry12;
float fRec4[2];
float fRec3[2];
FAUSTFLOAT fEntry13;
FAUSTFLOAT fEntry14;
FAUSTFLOAT fEntry15;
FAUSTFLOAT fEntry16;
float fRec5[2];
float fConst9;
float fRec0[3];
FAUSTFLOAT fEntry17;
FAUSTFLOAT fEntry18;
float fRec6[2];

public:
void metadata(Meta* m)
{
m->declare("basics.lib/name", "Faust Basic Element Library");
m->declare("basics.lib/version", "0.1");
m->declare("filename", "TetrodePlate.dsp");
m->declare("filters.lib/bandpass0_bandstop1:author", "Julius O. Smith III");
m->declare(
"filters.lib/bandpass0_bandstop1:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare(
"filters.lib/bandpass0_bandstop1:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/bandpass:author", "Julius O. Smith III");
m->declare(
"filters.lib/bandpass:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/bandpass:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/fir:author", "Julius O. Smith III");
m->declare(
"filters.lib/fir:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/fir:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/iir:author", "Julius O. Smith III");
m->declare(
"filters.lib/iir:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/iir:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/lowpass0_highpass1", "MIT-style STK-4.3 license");
m->declare("filters.lib/name", "Faust Filters Library");
m->declare("filters.lib/tf1sb:author", "Julius O. Smith III");
m->declare(
"filters.lib/tf1sb:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/tf1sb:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/tf2:author", "Julius O. Smith III");
m->declare(
"filters.lib/tf2:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/tf2:license", "MIT-style STK-4.3 license");
m->declare("maths.lib/author", "GRAME");
m->declare("maths.lib/copyright", "GRAME");
m->declare("maths.lib/license", "LGPL with exception");
m->declare("maths.lib/name", "Faust Math Library");
m->declare("maths.lib/version", "2.3");
m->declare("name", "TetrodePlate");
m->declare("platform.lib/name", "Generic Platform Library");
m->declare("platform.lib/version", "0.1");
m->declare("signals.lib/name", "Faust Signal Routing Library");
m->declare("signals.lib/version", "0.0");
}

virtual int getNumInputs() { return 1; }
virtual int getNumOutputs() { return 1; }
virtual int getInputRate(int channel)
{
int rate;
switch ((channel))
{
case 0:
{
rate = 1;
break;
}
default:
{
rate = -1;
break;
}
}
return rate;
}
virtual int getOutputRate(int channel)
{
int rate;
switch ((channel))
{
case 0:
{
rate = 1;
break;
}
default:
{
rate = -1;
break;
}
}
return rate;
}

static void classInit(int) {}

virtual void instanceConstants(int sample_rate)
{
fSampleRate = sample_rate;
fConst0 =
std::min<float>(192000.0f, std::max<float>(1.0f, float(fSampleRate)));
fConst1 = (2.0f / fConst0);
fConst2 = (2.0f * fConst0);
fConst3 = (3.14159274f / fConst0);
fConst4 = (0.449999988f * fConst0);
fConst5 = (0.5f / fConst0);
fConst6 = (4.0f * TetrodePlateFaust_faustpower2_f(fConst0));
fConst7 = (1.0f / fConst0);
fConst8 = TetrodePlateFaust_faustpower2_f(fConst7);
fConst9 = (2.0f * fConst8);
}

virtual void instanceResetUserInterface()
{
fEntry0 = FAUSTFLOAT(0.0f);
fEntry1 = FAUSTFLOAT(0.0f);
fEntry2 = FAUSTFLOAT(0.0f);
fEntry3 = FAUSTFLOAT(0.0f);
fEntry4 = FAUSTFLOAT(0.0f);
fEntry5 = FAUSTFLOAT(0.0f);
fEntry6 = FAUSTFLOAT(0.0f);
fEntry7 = FAUSTFLOAT(0.0f);
fEntry8 = FAUSTFLOAT(0.0f);
fEntry9 = FAUSTFLOAT(0.0f);
fEntry10 = FAUSTFLOAT(0.0f);
fEntry11 = FAUSTFLOAT(0.0f);
fEntry12 = FAUSTFLOAT(0.0f);
fEntry13 = FAUSTFLOAT(0.0f);
fEntry14 = FAUSTFLOAT(0.0f);
fEntry15 = FAUSTFLOAT(0.0f);
fEntry16 = FAUSTFLOAT(0.0f);
fEntry17 = FAUSTFLOAT(0.0f);
fEntry18 = FAUSTFLOAT(0.0f);
}

virtual void instanceClear()
{
for (int l0 = 0; (l0 < 2); l0 = (l0 + 1)) { fRec2[l0] = 0.0f; }
for (int l1 = 0; (l1 < 2); l1 = (l1 + 1)) { fRec1[l1] = 0.0f; }
for (int l2 = 0; (l2 < 2); l2 = (l2 + 1)) { fRec4[l2] = 0.0f; }
for (int l3 = 0; (l3 < 2); l3 = (l3 + 1)) { fRec3[l3] = 0.0f; }
for (int l4 = 0; (l4 < 2); l4 = (l4 + 1)) { fRec5[l4] = 0.0f; }
for (int l5 = 0; (l5 < 3); l5 = (l5 + 1)) { fRec0[l5] = 0.0f; }
for (int l6 = 0; (l6 < 2); l6 = (l6 + 1)) { fRec6[l6] = 0.0f; }
}

virtual void init(int sample_rate)
{
classInit(sample_rate);
instanceInit(sample_rate);
}
virtual void instanceInit(int sample_rate)
{
instanceConstants(sample_rate);
instanceResetUserInterface();
instanceClear();
}

virtual TetrodePlateFaust* clone() { return new TetrodePlateFaust(); }

virtual int getSampleRate() { return fSampleRate; }

virtual void buildUserInterface(UI* ui_interface)
{
ui_interface->openVerticalBox("TetrodePlate");
ui_interface->addNumEntry("clip", &fEntry4, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("clip_corner", &fEntry11, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("comp_depth", &fEntry5, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("comp_tau", &fEntry6, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry(
"cross_corner", &fEntry12, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry(
"drift2_depth", &fEntry17, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry(
"drift2_level", &fEntry18, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("drift_depth", &fEntry8, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("drift_level", &fEntry10, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("drift_tau", &fEntry9, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("hp_freq", &fEntry1, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("lp_freq", &fEntry0, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("sag_depth", &fEntry3, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("sag_factor", &fEntry14, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("sag_onset", &fEntry15, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("sag_ratio", &fEntry16, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("sag_tau", &fEntry13, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("sag_toggle", &fEntry2, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("scale", &fEntry7, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->closeBox();
}

virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs)
{
FAUSTFLOAT* input0 = inputs[0];
FAUSTFLOAT* output0 = outputs[0];
float fSlow0 =
std::tan((fConst3 * std::min<float>(fConst4, float(fEntry0))));
float fSlow1 = TetrodePlateFaust_faustpower2_f(std::sqrt((
fConst6
* (fSlow0
* std::tan((fConst3 * std::min<float>(fConst4, float(fEntry1))))))));
float fSlow2 = ((fConst2 * fSlow0) - (fConst5 * (fSlow1 / fSlow0)));
float fSlow3 = (fConst8 * fSlow1);
float fSlow4 = (fConst1 * fSlow2);
float fSlow5 = ((fSlow3 + fSlow4) + 4.0f);
float fSlow6 = (fConst1 * (fSlow2 / fSlow5));
float fSlow7 = (float(fEntry2) * float(fEntry3));
float fSlow8 = (fSlow7 + 1.0f);
float fSlow9 = float(fEntry4);
float fSlow10 = float(fEntry5);
float fSlow11 = float(fEntry6);
int iSlow12 = (std::fabs(fSlow11) < 1.1920929e-07f);
float fSlow13 =
(iSlow12 ? 0.0f
: std::exp((0.0f - (fConst7 / (iSlow12 ? 1.0f : fSlow11)))));
float fSlow14 = (1.0f - fSlow13);
float fSlow15 = (1.0f / fSlow9);
float fSlow16 = float(fEntry7);
float fSlow17 = float(fEntry8);
float fSlow18 = float(fEntry9);
int iSlow19 = (std::fabs(fSlow18) < 1.1920929e-07f);
float fSlow20 =
(iSlow19 ? 0.0f
: std::exp((0.0f - (fConst7 / (iSlow19 ? 1.0f : fSlow18)))));
float fSlow21 = (1.0f - fSlow20);
float fSlow22 = float(fEntry10);
float fSlow23 = float(fEntry11);
float fSlow24 = (0.294117659f / fSlow23);
float fSlow25 = float(fEntry12);
float fSlow26 = (0.294117659f / fSlow25);
float fSlow27 = float(fEntry13);
float fSlow28 = (1.0f / ((fConst0 * fSlow27) + 1.0f));
float fSlow29 = (1.0f / (std::max<float>(0.0f, float(fEntry14)) + 1.0f));
float fSlow30 = float(fEntry15);
float fSlow31 = (fSlow16 / fSlow9);
float fSlow32 =
(1.0f - (1.0f / ((fConst0 * (fSlow27 * float(fEntry16))) + 1.0f)));
float fSlow33 = (1.0f / fSlow5);
float fSlow34 = ((fConst9 * fSlow1) + -8.0f);
float fSlow35 = (fSlow3 + (4.0f - fSlow4));
float fSlow36 = (0.0f - fSlow6);
float fSlow37 = float(fEntry17);
float fSlow38 = float(fEntry18);
for (int i = 0; (i < count); i = (i + 1))
{
float fTemp0 = float(input0[i]);
float fTemp1 = (fSlow16 * fTemp0);
float fTempFTZ0 =
((fSlow20 * fRec2[1])
+ (fSlow21 * (std::max<float>(fSlow22, fTemp1) - fSlow22)));
fRec2[0] =
((*reinterpret_cast<int*>(&fTempFTZ0) & 2139095040) ? fTempFTZ0
: 0.0f);
float fTemp2 = (fSlow17 * fRec2[0]);
float fTempFTZ1 =
((fSlow13 * fRec1[1])
+ (fSlow14
* std::min<float>(
1.0f, std::fabs((fSlow15 * (fTemp1 - fTemp2))))));
fRec1[0] =
((*reinterpret_cast<int*>(&fTempFTZ1) & 2139095040) ? fTempFTZ1
: 0.0f);
float fTemp3 = (fSlow9 / ((fSlow10 * fRec1[0]) + 1.0f));
float fTemp4 = (fSlow23 + (fTemp1 - (fTemp2 + fTemp3)));
float fTemp5 = std::max<float>(
-1.0f,
std::min<float>(1.0f, (fSlow24 * std::max<float>(0.0f, fTemp4))));
float fTemp6 = (fTemp5 * (std::fabs(fTemp5) + -2.0f));
float fTemp7 =
(((fTemp3 + std::min<float>(0.0f, fTemp4))
- (fSlow23 * (1.0f - (fTemp6 * (std::fabs(fTemp6) + -2.0f)))))
- fSlow25);
float fTempFTZ2 =
((fRec4[1] * fSlow20)
+ ((std::max<float>(fSlow22, (0.0f - fTemp1)) - fSlow22) * fSlow21));
fRec4[0] =
((*reinterpret_cast<int*>(&fTempFTZ2) & 2139095040) ? fTempFTZ2
: 0.0f);
float fTemp8 = (fTemp1 + (fSlow17 * fRec4[0]));
float fTempFTZ3 =
((fRec3[1] * fSlow13)
+ (std::min<float>(1.0f, std::fabs((fSlow15 * (0.0f - fTemp8))))
* fSlow14));
fRec3[0] =
((*reinterpret_cast<int*>(&fTempFTZ3) & 2139095040) ? fTempFTZ3
: 0.0f);
float fTemp9 = (fSlow9 / ((fSlow10 * fRec3[0]) + 1.0f));
float fTemp10 = (fSlow23 - (fTemp8 + fTemp9));
float fTemp11 = std::max<float>(
-1.0f,
std::min<float>(1.0f, (fSlow24 * std::max<float>(0.0f, fTemp10))));
float fTemp12 = (fTemp11 * (std::fabs(fTemp11) + -2.0f));
float fTemp13 =
(((fTemp9 + std::min<float>(0.0f, fTemp10))
- (fSlow23 * (1.0f - (fTemp12 * (std::fabs(fTemp12) + -2.0f)))))
- fSlow25);
float fTemp14 = std::max<float>(
-1.0f,
std::min<float>(1.0f, (fSlow26 * std::min<float>(0.0f, fTemp13))));
float fTemp15 = (fTemp14 * (std::fabs(fTemp14) + -2.0f));
float fTemp16 = std::max<float>(
-1.0f,
std::min<float>(1.0f, (fSlow26 * std::min<float>(0.0f, fTemp7))));
float fTemp17 = (fTemp16 * (std::fabs(fTemp16) + -2.0f));
float fTemp18 = std::fabs((fSlow31 * fTemp0));
float fTempFTZ4 =
((fSlow28
* std::max<float>(
0.0f,
((fSlow29
* ((fSlow30 * std::min<float>(1.0f, fTemp18))
+ std::max<float>(1.0f, fTemp18)))
- fRec5[1])))
+ (fSlow32 * fRec5[1]));
fRec5[0] =
((*reinterpret_cast<int*>(&fTempFTZ4) & 2139095040) ? fTempFTZ4
: 0.0f);
float fTempFTZ5 =
((fSlow8
* ((std::max<float>(0.0f, fTemp7)
- (std::max<float>(0.0f, fTemp13)
+ (fSlow25
* (((fTemp15 * (std::fabs(fTemp15) + -2.0f)) + 1.0f)
- ((fTemp17 * (std::fabs(fTemp17) + -2.0f)) + 1.0f)))))
/ ((fSlow7 * fRec5[0]) + 1.0f)))
- (fSlow33 * ((fSlow34 * fRec0[1]) + (fSlow35 * fRec0[2]))));
fRec0[0] =
((*reinterpret_cast<int*>(&fTempFTZ5) & 2139095040) ? fTempFTZ5
: 0.0f);
float fTemp19 = ((fSlow6 * fRec0[0]) + (fSlow36 * fRec0[2]));
float fTempFTZ6 =
((fSlow20 * fRec6[1])
+ (fSlow21
* (std::max<float>(fSlow38, std::fabs(fTemp19)) - fSlow38)));
fRec6[0] =
((*reinterpret_cast<int*>(&fTempFTZ6) & 2139095040) ? fTempFTZ6
: 0.0f);
output0[i] = FAUSTFLOAT((fTemp19 + (fSlow37 * fRec6[0])));
fRec2[1] = fRec2[0];
fRec1[1] = fRec1[0];
fRec4[1] = fRec4[0];
fRec3[1] = fRec3[0];
fRec5[1] = fRec5[0];
fRec0[2] = fRec0[1];
fRec0[1] = fRec0[0];
fRec6[1] = fRec6[0];
}
}
};

#endif

+ 92
- 0
ports/swankyamp/source/dsp/ToneStack.h View File

@@ -0,0 +1,92 @@
#ifndef __faust2hpp_ToneStack_H__
#define __faust2hpp_ToneStack_H__

#include <cmath>

#define uscale(x, l, u) (x + 1.0f) / 2.0f * (u - l) + l;
#define ulscale(x, l, u) \
std::exp((x + 1.0f) / 2.0f * (std::log(u) - std::log(l)) + std::log(l));

#include "ToneStackFaust.h"

class ToneStack
{
public:
ToneStack()
{
faustDsp.buildUserInterface(&faustDsp);
par_bass = faustDsp.getParameter("bass");
par_mids = faustDsp.getParameter("mids");
par_presence = faustDsp.getParameter("presence");
par_selection = faustDsp.getParameter("selection");
par_treble = faustDsp.getParameter("treble");
}

~ToneStack() = default;

void reset()
{
faustDsp.instanceClear();
zeroParameters();
}

void prepare(int sampleRate)
{
faustDsp.init(sampleRate);
zeroParameters();
}

void process(int count, FAUSTFLOAT** buffer)
{
faustDsp.compute(count, buffer, buffer);
}

inline void set_bass(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_bass = uscale(x, -1.0f, 1.0f);
}
inline void set_mids(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_mids = uscale(x, -1.0f, 1.0f);
}
inline void set_presence(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_presence = uscale(x, -1.0f, 1.0f);
}
inline void set_selection(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_selection = x;
}
inline void set_treble(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_treble = uscale(x, -1.0f, 1.0f);
}

private:
ToneStackFaust faustDsp;

FAUSTFLOAT* par_bass = nullptr;
FAUSTFLOAT* par_mids = nullptr;
FAUSTFLOAT* par_presence = nullptr;
FAUSTFLOAT* par_selection = nullptr;
FAUSTFLOAT* par_treble = nullptr;

void zeroParameters()
{
set_bass(0.0f);
set_mids(0.0f);
set_presence(0.0f);
set_selection(0.0f);
set_treble(0.0f);
}
};

#undef uscale
#undef ulscale

#endif

+ 84
- 0
ports/swankyamp/source/dsp/ToneStackF.h View File

@@ -0,0 +1,84 @@
#ifndef __faust2hpp_ToneStackF_H__
#define __faust2hpp_ToneStackF_H__

#include <cmath>

#define uscale(x, l, u) (x + 1.0f) / 2.0f * (u - l) + l;
#define ulscale(x, l, u) \
std::exp((x + 1.0f) / 2.0f * (std::log(u) - std::log(l)) + std::log(l));

#include "ToneStackFFaust.h"

class ToneStackF
{
public:
ToneStackF()
{
faustDsp.buildUserInterface(&faustDsp);
par_bass = faustDsp.getParameter("bass");
par_mids = faustDsp.getParameter("mids");
par_presence = faustDsp.getParameter("presence");
par_treble = faustDsp.getParameter("treble");
}

~ToneStackF() = default;

void reset()
{
faustDsp.instanceClear();
zeroParameters();
}

void prepare(int sampleRate)
{
faustDsp.init(sampleRate);
zeroParameters();
}

void process(int count, FAUSTFLOAT** buffer)
{
faustDsp.compute(count, buffer, buffer);
}

inline void set_bass(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_bass = uscale(x, -1.0f, 1.0f);
}
inline void set_mids(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_mids = uscale(x, -1.0f, 1.0f);
}
inline void set_presence(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_presence = uscale(x, -1.0f, 1.0f);
}
inline void set_treble(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_treble = uscale(x, -1.0f, 1.0f);
}

private:
ToneStackFFaust faustDsp;

FAUSTFLOAT* par_bass = nullptr;
FAUSTFLOAT* par_mids = nullptr;
FAUSTFLOAT* par_presence = nullptr;
FAUSTFLOAT* par_treble = nullptr;

void zeroParameters()
{
set_bass(0.0f);
set_mids(0.0f);
set_presence(0.0f);
set_treble(0.0f);
}
};

#undef uscale
#undef ulscale

#endif

+ 355
- 0
ports/swankyamp/source/dsp/ToneStackFFaust.h View File

@@ -0,0 +1,355 @@
/* ------------------------------------------------------------
name: "ToneStackF"
Code generated with Faust 2.28.3 (https://faust.grame.fr)
Compilation options: -lang cpp -inpl -scal -ftz 2
------------------------------------------------------------ */

#ifndef __ToneStackFFaust_H__
#define __ToneStackFFaust_H__

#ifndef __faust2hpp_FaustImpl_H__
#define __faust2hpp_FaustImpl_H__

#include <stdexcept>
#include <unordered_map>

#include "Meta.h"
#include "UI.h"

class FaustImpl : public UI, public Meta
{
public:
FaustImpl() = default;
~FaustImpl() = default;

FAUSTFLOAT* getParameter(const char* name)
{
const auto entry = parameterMap.find(name);
if (entry == parameterMap.end())
throw std::invalid_argument(
std::string("FaustImpl::getParameter: invalid parameter name: ")
+ name);
return entry->second;
}

void setParameter(const char* name, FAUSTFLOAT* value)
{
const auto entry = parameterMap.find(name);
if (entry != parameterMap.end()) entry->second = value;
}

// blank implementations for UI
virtual void openTabBox(const char*){};
virtual void openHorizontalBox(const char*){};
virtual void openVerticalBox(const char*){};
virtual void closeBox(){};
virtual void addButton(const char*, FAUSTFLOAT*){};
virtual void addCheckButton(const char*, FAUSTFLOAT*){};
virtual void addVerticalSlider(
const char*,
FAUSTFLOAT*,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT){};
virtual void addHorizontalSlider(
const char*,
FAUSTFLOAT*,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT){};
virtual void
// use UI entry to expose user parameters
addNumEntry(
const char* label,
FAUSTFLOAT* zone,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT)
{
if (zone == nullptr) return;
parameterMap.insert_or_assign(label, zone);
}
virtual void
addHorizontalBargraph(const char*, FAUSTFLOAT*, FAUSTFLOAT, FAUSTFLOAT){};
virtual void
addVerticalBargraph(const char*, FAUSTFLOAT*, FAUSTFLOAT, FAUSTFLOAT){};
virtual void addSoundfile(const char*, const char*, Soundfile**){};

// blank implememtation for Meta
virtual void declare(const char*, const char*){};

private:
std::unordered_map<const char*, FAUSTFLOAT*> parameterMap;
};

#endif
#ifndef FAUSTFLOAT
#define FAUSTFLOAT float
#endif

#include <algorithm>
#include <cmath>
#include <math.h>

static float ToneStackFFaust_faustpower2_f(float value)
{
return (value * value);
}

#ifndef FAUSTCLASS
#define FAUSTCLASS ToneStackFFaust
#endif

#ifdef __APPLE__
#define exp10f __exp10f
#define exp10 __exp10
#endif

class ToneStackFFaust : public FaustImpl
{
private:
int fSampleRate;
float fConst0;
float fConst1;
float fConst2;
float fConst3;
float fConst4;
FAUSTFLOAT fEntry0;
FAUSTFLOAT fEntry1;
float fRec1[3];
float fConst5;
float fConst6;
float fConst7;
float fConst8;
FAUSTFLOAT fEntry2;
float fConst9;
float fConst10;
float fRec2[3];
float fConst11;
FAUSTFLOAT fEntry3;
float fConst12;
float fRec0[3];

public:
void metadata(Meta* m)
{
m->declare("basics.lib/name", "Faust Basic Element Library");
m->declare("basics.lib/version", "0.1");
m->declare("filename", "ToneStackF.dsp");
m->declare("filters.lib/fir:author", "Julius O. Smith III");
m->declare(
"filters.lib/fir:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/fir:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/iir:author", "Julius O. Smith III");
m->declare(
"filters.lib/iir:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/iir:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/lowpass0_highpass1", "MIT-style STK-4.3 license");
m->declare("filters.lib/name", "Faust Filters Library");
m->declare("filters.lib/peak_eq:author", "Julius O. Smith III");
m->declare(
"filters.lib/peak_eq:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/peak_eq:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/tf2:author", "Julius O. Smith III");
m->declare(
"filters.lib/tf2:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/tf2:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/tf2s:author", "Julius O. Smith III");
m->declare(
"filters.lib/tf2s:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/tf2s:license", "MIT-style STK-4.3 license");
m->declare("maths.lib/author", "GRAME");
m->declare("maths.lib/copyright", "GRAME");
m->declare("maths.lib/license", "LGPL with exception");
m->declare("maths.lib/name", "Faust Math Library");
m->declare("maths.lib/version", "2.3");
m->declare("name", "ToneStackF");
m->declare("platform.lib/name", "Generic Platform Library");
m->declare("platform.lib/version", "0.1");
}

virtual int getNumInputs() { return 1; }
virtual int getNumOutputs() { return 1; }
virtual int getInputRate(int channel)
{
int rate;
switch ((channel))
{
case 0:
{
rate = 1;
break;
}
default:
{
rate = -1;
break;
}
}
return rate;
}
virtual int getOutputRate(int channel)
{
int rate;
switch ((channel))
{
case 0:
{
rate = 1;
break;
}
default:
{
rate = -1;
break;
}
}
return rate;
}

static void classInit(int) {}

virtual void instanceConstants(int sample_rate)
{
fSampleRate = sample_rate;
fConst0 =
std::min<float>(192000.0f, std::max<float>(1.0f, float(fSampleRate)));
fConst1 = std::tan((12566.3711f / fConst0));
fConst2 = (2.0f * (1.0f - (1.0f / ToneStackFFaust_faustpower2_f(fConst1))));
fConst3 = ToneStackFFaust_faustpower2_f(fConst0);
fConst4 = (2.35000007e-05f * fConst3);
fConst5 = (1.17500003e-05f * fConst0);
fConst6 = (9.57499981f * fConst0);
fConst7 = (fConst6 + 138000.0f);
fConst8 = (2.5f * (fConst0 / fConst7));
fConst9 = (1.0f / fConst7);
fConst10 = (138000.0f - fConst6);
fConst11 = (1.0f / fConst1);
fConst12 = (6283.18555f / (fConst0 * std::sin((25132.7422f / fConst0))));
}

virtual void instanceResetUserInterface()
{
fEntry0 = FAUSTFLOAT(0.0f);
fEntry1 = FAUSTFLOAT(0.0f);
fEntry2 = FAUSTFLOAT(0.0f);
fEntry3 = FAUSTFLOAT(0.0f);
}

virtual void instanceClear()
{
for (int l0 = 0; (l0 < 3); l0 = (l0 + 1)) { fRec1[l0] = 0.0f; }
for (int l1 = 0; (l1 < 3); l1 = (l1 + 1)) { fRec2[l1] = 0.0f; }
for (int l2 = 0; (l2 < 3); l2 = (l2 + 1)) { fRec0[l2] = 0.0f; }
}

virtual void init(int sample_rate)
{
classInit(sample_rate);
instanceInit(sample_rate);
}
virtual void instanceInit(int sample_rate)
{
instanceConstants(sample_rate);
instanceResetUserInterface();
instanceClear();
}

virtual ToneStackFFaust* clone() { return new ToneStackFFaust(); }

virtual int getSampleRate() { return fSampleRate; }

virtual void buildUserInterface(UI* ui_interface)
{
ui_interface->openVerticalBox("ToneStackF");
ui_interface->addNumEntry("bass", &fEntry0, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("mids", &fEntry1, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("presence", &fEntry3, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("treble", &fEntry2, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->closeBox();
}

virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs)
{
FAUSTFLOAT* input0 = inputs[0];
FAUSTFLOAT* output0 = outputs[0];
float fSlow0 = ToneStackFFaust_faustpower2_f(
((0.495000005f * float(fEntry0)) + 0.504999995f));
float fSlow1 = ((0.495000005f * float(fEntry1)) + 0.504999995f);
float fSlow2 = (fSlow0 * fSlow1);
float fSlow3 = ((0.00147000002f * fSlow1) + (0.0250000004f * fSlow0));
float fSlow4 = (fSlow3 + 0.0202859994f);
float fSlow5 = (fSlow0 * ((1.17500003e-05f * fSlow1) + 0.000162149998f));
float fSlow6 = (fConst0 * fSlow5);
float fSlow7 = ((fConst0 * (fSlow4 + fSlow6)) + 1.0f);
float fSlow8 = (0.0f - (fConst4 * (fSlow2 / fSlow7)));
float fSlow9 = (1.0f / fSlow7);
float fSlow10 = (1.0f - (fConst0 * (fSlow4 - fSlow6)));
float fSlow11 = (2.0f * (1.0f - (fConst3 * fSlow5)));
float fSlow12 = (fConst0 / fSlow7);
float fSlow13 = (fConst5 * fSlow2);
float fSlow14 = (fSlow3 + fSlow13);
float fSlow15 = (fSlow13 - fSlow3);
float fSlow16 =
(fConst8 * ((0.495000005f * float(fEntry2)) + 0.504999995f));
float fSlow17 = (0.0f - fSlow16);
float fSlow18 = (10.0f * float(fEntry3));
int iSlow19 = (fSlow18 > 0.0f);
float fSlow20 =
(fConst12 * std::pow(10.0f, (0.0500000007f * std::fabs(fSlow18))));
float fSlow21 = (iSlow19 ? fConst12 : fSlow20);
float fSlow22 = ((fConst11 * (fConst11 - fSlow21)) + 1.0f);
float fSlow23 = ((fConst11 * (fConst11 + fSlow21)) + 1.0f);
float fSlow24 = (iSlow19 ? fSlow20 : fConst12);
float fSlow25 = ((fConst11 * (fConst11 + fSlow24)) + 1.0f);
float fSlow26 = ((fConst11 * (fConst11 - fSlow24)) + 1.0f);
for (int i = 0; (i < count); i = (i + 1))
{
float fTemp0 = float(input0[i]);
float fTempFTZ0 =
(fTemp0 - (fSlow9 * ((fSlow10 * fRec1[2]) + (fSlow11 * fRec1[1]))));
fRec1[0] =
((*reinterpret_cast<int*>(&fTempFTZ0) & 2139095040) ? fTempFTZ0
: 0.0f);
float fTempFTZ1 =
(fTemp0
- (fConst9 * ((fConst10 * fRec2[2]) + (276000.0f * fRec2[1]))));
fRec2[0] =
((*reinterpret_cast<int*>(&fTempFTZ1) & 2139095040) ? fTempFTZ1
: 0.0f);
float fTemp1 = (fConst2 * fRec0[1]);
float fTempFTZ2 =
(((4.0f
* ((fSlow8 * fRec1[1])
+ (fSlow12 * ((fSlow14 * fRec1[0]) + (fSlow15 * fRec1[2])))))
+ (12.0f * ((fSlow16 * fRec2[0]) + (fSlow17 * fRec2[2]))))
- (((fRec0[2] * fSlow22) + fTemp1) / fSlow23));
fRec0[0] =
((*reinterpret_cast<int*>(&fTempFTZ2) & 2139095040) ? fTempFTZ2
: 0.0f);
output0[i] = FAUSTFLOAT(
(((fTemp1 + (fRec0[0] * fSlow25)) + (fRec0[2] * fSlow26)) / fSlow23));
fRec1[2] = fRec1[1];
fRec1[1] = fRec1[0];
fRec2[2] = fRec2[1];
fRec2[1] = fRec2[0];
fRec0[2] = fRec0[1];
fRec0[1] = fRec0[0];
}
}
};

#endif

+ 479
- 0
ports/swankyamp/source/dsp/ToneStackFaust.h View File

@@ -0,0 +1,479 @@
/* ------------------------------------------------------------
name: "ToneStack"
Code generated with Faust 2.28.3 (https://faust.grame.fr)
Compilation options: -lang cpp -inpl -scal -ftz 2
------------------------------------------------------------ */

#ifndef __ToneStackFaust_H__
#define __ToneStackFaust_H__

#include "FaustImpl.h"
#ifndef FAUSTFLOAT
#define FAUSTFLOAT float
#endif

#include <algorithm>
#include <cmath>
#include <math.h>

static float ToneStackFaust_faustpower2_f(float value)
{
return (value * value);
}

#ifndef FAUSTCLASS
#define FAUSTCLASS ToneStackFaust
#endif

#ifdef __APPLE__
#define exp10f __exp10f
#define exp10 __exp10
#endif

class ToneStackFaust : public FaustImpl
{
private:
int fSampleRate;
float fConst0;
float fConst1;
float fConst2;
FAUSTFLOAT fEntry0;
float fConst3;
float fConst4;
float fConst5;
FAUSTFLOAT fEntry1;
float fConst6;
float fConst7;
float fRec1[3];
float fConst8;
float fConst9;
FAUSTFLOAT fEntry2;
FAUSTFLOAT fEntry3;
float fRec2[3];
float fConst10;
float fConst11;
float fConst12;
float fConst13;
float fConst14;
float fConst15;
float fRec3[3];
float fConst16;
float fConst17;
float fRec4[3];
float fConst18;
float fConst19;
float fConst20;
float fConst21;
float fConst22;
float fConst23;
float fConst24;
float fConst25;
float fRec6[3];
float fConst26;
float fRec7[3];
float fConst27;
float fConst28;
float fConst29;
float fRec5[3];
float fConst30;
FAUSTFLOAT fEntry4;
float fConst31;
float fRec0[3];

public:
void metadata(Meta* m)
{
m->declare("basics.lib/name", "Faust Basic Element Library");
m->declare("basics.lib/version", "0.1");
m->declare("filename", "ToneStack.dsp");
m->declare("filters.lib/fir:author", "Julius O. Smith III");
m->declare(
"filters.lib/fir:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/fir:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/iir:author", "Julius O. Smith III");
m->declare(
"filters.lib/iir:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/iir:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/lowpass0_highpass1", "MIT-style STK-4.3 license");
m->declare("filters.lib/name", "Faust Filters Library");
m->declare("filters.lib/peak_eq:author", "Julius O. Smith III");
m->declare(
"filters.lib/peak_eq:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/peak_eq:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/tf2:author", "Julius O. Smith III");
m->declare(
"filters.lib/tf2:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/tf2:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/tf2s:author", "Julius O. Smith III");
m->declare(
"filters.lib/tf2s:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/tf2s:license", "MIT-style STK-4.3 license");
m->declare("maths.lib/author", "GRAME");
m->declare("maths.lib/copyright", "GRAME");
m->declare("maths.lib/license", "LGPL with exception");
m->declare("maths.lib/name", "Faust Math Library");
m->declare("maths.lib/version", "2.3");
m->declare("name", "ToneStack");
m->declare("platform.lib/name", "Generic Platform Library");
m->declare("platform.lib/version", "0.1");
}

virtual int getNumInputs() { return 1; }
virtual int getNumOutputs() { return 1; }
virtual int getInputRate(int channel)
{
int rate;
switch ((channel))
{
case 0:
{
rate = 1;
break;
}
default:
{
rate = -1;
break;
}
}
return rate;
}
virtual int getOutputRate(int channel)
{
int rate;
switch ((channel))
{
case 0:
{
rate = 1;
break;
}
default:
{
rate = -1;
break;
}
}
return rate;
}

static void classInit(int) {}

virtual void instanceConstants(int sample_rate)
{
fSampleRate = sample_rate;
fConst0 =
std::min<float>(192000.0f, std::max<float>(1.0f, float(fSampleRate)));
fConst1 = std::tan((12566.3711f / fConst0));
fConst2 = (2.0f * (1.0f - (1.0f / ToneStackFaust_faustpower2_f(fConst1))));
fConst3 = (9.57499981f * fConst0);
fConst4 = (fConst3 + 138000.0f);
fConst5 = (2.5f * (fConst0 / fConst4));
fConst6 = (1.0f / fConst4);
fConst7 = (138000.0f - fConst3);
fConst8 = ToneStackFaust_faustpower2_f(fConst0);
fConst9 = (2.35000007e-05f * fConst8);
fConst10 = (1.17500003e-05f * fConst0);
fConst11 = (3.41219997f * fConst0);
fConst12 = (fConst11 + 33000.0f);
fConst13 = (0.511829972f * (fConst0 / fConst12));
fConst14 = (1.0f / fConst12);
fConst15 = (33000.0f - fConst11);
fConst16 = (9.68000052e-16f * fConst8);
fConst17 = (4.84000026e-16f * fConst0);
fConst18 = std::tan((3141.59277f / fConst0));
fConst19 =
(2.0f * (1.0f - (1.0f / ToneStackFaust_faustpower2_f(fConst18))));
fConst20 = (25.368f * fConst0);
fConst21 = (fConst20 + 158000.0f);
fConst22 = (1.5f / fConst21);
fConst23 = (5.59999991e-10f * fConst0);
fConst24 = (1.0f / fConst21);
fConst25 = (158000.0f - fConst20);
fConst26 = (412500.0f * fConst8);
fConst27 = (206250.0f * fConst0);
fConst28 = (1.0f / fConst18);
fConst29 = (6283.18555f / (fConst0 * std::sin((6283.18555f / fConst0))));
fConst30 = (1.0f / fConst1);
fConst31 = (6283.18555f / (fConst0 * std::sin((25132.7422f / fConst0))));
}

virtual void instanceResetUserInterface()
{
fEntry0 = FAUSTFLOAT(0.0f);
fEntry1 = FAUSTFLOAT(0.0f);
fEntry2 = FAUSTFLOAT(0.0f);
fEntry3 = FAUSTFLOAT(0.0f);
fEntry4 = FAUSTFLOAT(0.0f);
}

virtual void instanceClear()
{
for (int l0 = 0; (l0 < 3); l0 = (l0 + 1)) { fRec1[l0] = 0.0f; }
for (int l1 = 0; (l1 < 3); l1 = (l1 + 1)) { fRec2[l1] = 0.0f; }
for (int l2 = 0; (l2 < 3); l2 = (l2 + 1)) { fRec3[l2] = 0.0f; }
for (int l3 = 0; (l3 < 3); l3 = (l3 + 1)) { fRec4[l3] = 0.0f; }
for (int l4 = 0; (l4 < 3); l4 = (l4 + 1)) { fRec6[l4] = 0.0f; }
for (int l5 = 0; (l5 < 3); l5 = (l5 + 1)) { fRec7[l5] = 0.0f; }
for (int l6 = 0; (l6 < 3); l6 = (l6 + 1)) { fRec5[l6] = 0.0f; }
for (int l7 = 0; (l7 < 3); l7 = (l7 + 1)) { fRec0[l7] = 0.0f; }
}

virtual void init(int sample_rate)
{
classInit(sample_rate);
instanceInit(sample_rate);
}
virtual void instanceInit(int sample_rate)
{
instanceConstants(sample_rate);
instanceResetUserInterface();
instanceClear();
}

virtual ToneStackFaust* clone() { return new ToneStackFaust(); }

virtual int getSampleRate() { return fSampleRate; }

virtual void buildUserInterface(UI* ui_interface)
{
ui_interface->openVerticalBox("ToneStack");
ui_interface->addNumEntry("bass", &fEntry2, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("mids", &fEntry3, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("presence", &fEntry4, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("selection", &fEntry0, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("treble", &fEntry1, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->closeBox();
}

virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs)
{
FAUSTFLOAT* input0 = inputs[0];
FAUSTFLOAT* output0 = outputs[0];
float fSlow0 = float(fEntry0);
float fSlow1 =
(1.0f - std::min<float>(std::max<float>(fSlow0, 0.0f), 1.0f));
float fSlow2 = ((0.495000005f * float(fEntry1)) + 0.504999995f);
float fSlow3 = (fConst5 * fSlow2);
float fSlow4 = (0.0f - fSlow3);
float fSlow5 = ((0.495000005f * float(fEntry2)) + 0.504999995f);
float fSlow6 = ToneStackFaust_faustpower2_f(fSlow5);
float fSlow7 = float(fEntry3);
float fSlow8 = (0.495000005f * fSlow7);
float fSlow9 = (fSlow8 + 0.504999995f);
float fSlow10 = (fSlow6 * fSlow9);
float fSlow11 = ((0.00147000002f * fSlow9) + (0.0250000004f * fSlow6));
float fSlow12 = (fSlow11 + 0.0202859994f);
float fSlow13 = (fSlow6 * ((1.17500003e-05f * fSlow9) + 0.000162149998f));
float fSlow14 = (fConst0 * fSlow13);
float fSlow15 = ((fConst0 * (fSlow12 + fSlow14)) + 1.0f);
float fSlow16 = (0.0f - (fConst9 * (fSlow10 / fSlow15)));
float fSlow17 = (1.0f / fSlow15);
float fSlow18 = (1.0f - (fConst0 * (fSlow12 - fSlow14)));
float fSlow19 = (2.0f * (1.0f - (fConst8 * fSlow13)));
float fSlow20 = (fConst0 / fSlow15);
float fSlow21 = (fConst10 * fSlow10);
float fSlow22 = (fSlow11 + fSlow21);
float fSlow23 = (fSlow21 - fSlow11);
float fSlow24 =
(1.0f
- std::min<float>(
std::max<float>(std::fabs((fSlow0 + -1.0f)), 0.0f), 1.0f));
float fSlow25 = (fConst13 * fSlow2);
float fSlow26 = (0.0f - fSlow25);
float fSlow27 =
(484000000.0f
* (ToneStackFaust_faustpower2_f(fSlow9) + (-0.504999995f - fSlow8)));
float fSlow28 =
((0.200000003f * (fSlow5 * float((fSlow5 <= 0.5f))))
+ (float((fSlow5 > 0.5f)) * ((1.60000002f * fSlow5) + -0.699999988f)));
float fSlow29 = (fSlow9 * fSlow28);
float fSlow30 = (fSlow27 - (2.2000001e+10f * fSlow29));
float fSlow31 = (22000.0f * (0.0f - (2.2e-08f * (fSlow9 + 1.0f))));
float fSlow32 = (0.0219999999f * fSlow28);
float fSlow33 = (fSlow31 + (-0.001452f - fSlow32));
float fSlow34 =
((fSlow27
+ (22000.0f
* ((1000000.0f * (0.0f - fSlow29))
+ (16335.0f * (fSlow7 + -1.0f)))))
+ (1000000.0f * (0.0f - (33000.0f * fSlow28))));
float fSlow35 = (fConst17 * fSlow34);
float fSlow36 = ((fConst0 * (fSlow33 + fSlow35)) + -1.0f);
float fSlow37 = (0.0f - (fConst16 * (fSlow30 / fSlow36)));
float fSlow38 = (1.0f / fSlow36);
float fSlow39 = (-2.0f - (fConst16 * fSlow34));
float fSlow40 = ((fConst0 * (fSlow35 - fSlow33)) + -1.0f);
float fSlow41 = (fConst0 / fSlow36);
float fSlow42 = (fSlow31 - fSlow32);
float fSlow43 = (fConst17 * fSlow30);
float fSlow44 = (fSlow42 + fSlow43);
float fSlow45 = (fSlow43 - fSlow42);
float fSlow46 =
(std::min<float>(std::max<float>(fSlow0, 1.0f), 2.0f) + -1.0f);
float fSlow47 =
(fConst23 * ((250000.0f * ((100000.0f * fSlow2) + 10000.0f)) + 1e+09f));
float fSlow48 = (fSlow47 + 10000.0f);
float fSlow49 = (10000.0f - fSlow47);
float fSlow50 = (ToneStackFaust_faustpower2_f(fSlow28) - fSlow28);
float fSlow51 = (fSlow28 + -1.0f);
float fSlow52 =
(((150000.0f * ((250000.0f * fSlow51) + -10000.0f))
+ (6.24999997e+10f * fSlow50))
+ (250000.0f * ((250000.0f * (fSlow2 * fSlow51)) + -10000.0f)));
float fSlow53 = (6250.0f * fSlow50);
float fSlow54 = ((2.2e-08f * fSlow51) + -1.00000001e-07f);
float fSlow55 =
((((150000.0f * ((fSlow53 + (4813.0f * fSlow51)) + -440.320007f))
+ (6.24999997e+10f
* (fSlow50 * ((0.0250000004f * fSlow2) + 0.0192520004f))))
+ (250000.0f
* ((250000.0f
* (fSlow2
* ((((0.0121999998f * fSlow51) + (10000.0f * fSlow54))
+ (0.0055999998f * fSlow51))
+ (0.00123199995f * fSlow51))))
+ -190.320007f)))
+ (2.5e+09f
* ((100000.0f * (0.0f - (1.22000003e-07f * fSlow2)))
- (0.00683199987f * fSlow2))));
float fSlow56 =
(((150000.0f * ((22.8250008f * fSlow50) - (0.85799998f * fSlow28)))
+ (6.24999997e+10f
* (fSlow50 * ((9.12999967e-05f * fSlow2) + 3.43200009e-06f))))
- (214500.0f * (fSlow2 * fSlow28)));
float fSlow57 = (fConst0 * fSlow56);
float fSlow58 = (2.5e+09f * fSlow2);
float fSlow59 = ((fSlow52 + (fConst0 * (fSlow55 + fSlow57))) - fSlow58);
float fSlow60 = (0.0f - (fConst26 * (fSlow50 / fSlow59)));
float fSlow61 = (1.0f / fSlow59);
float fSlow62 = (fSlow52 - (fSlow58 + (fConst0 * (fSlow55 - fSlow57))));
float fSlow63 = (2.0f * ((fSlow52 - fSlow58) - (fConst8 * fSlow56)));
float fSlow64 = (fConst0 / fSlow59);
float fSlow65 = (150000.0f * (fSlow53 + (2.5e+09f * fSlow54)));
float fSlow66 = (fConst27 * fSlow50);
float fSlow67 = (fSlow65 + fSlow66);
float fSlow68 = (fSlow66 - fSlow65);
float fSlow69 = (10.0f * fSlow7);
int iSlow70 = (fSlow69 > 0.0f);
float fSlow71 =
(fConst29 * std::pow(10.0f, (0.0500000007f * std::fabs(fSlow69))));
float fSlow72 = (iSlow70 ? fConst29 : fSlow71);
float fSlow73 = ((fConst28 * (fConst28 - fSlow72)) + 1.0f);
float fSlow74 = ((fConst28 * (fConst28 + fSlow72)) + 1.0f);
float fSlow75 = (iSlow70 ? fSlow71 : fConst29);
float fSlow76 = ((fConst28 * (fConst28 + fSlow75)) + 1.0f);
float fSlow77 = ((fConst28 * (fConst28 - fSlow75)) + 1.0f);
float fSlow78 = (10.0f * float(fEntry4));
int iSlow79 = (fSlow78 > 0.0f);
float fSlow80 =
(fConst31 * std::pow(10.0f, (0.0500000007f * std::fabs(fSlow78))));
float fSlow81 = (iSlow79 ? fConst31 : fSlow80);
float fSlow82 = ((fConst30 * (fConst30 - fSlow81)) + 1.0f);
float fSlow83 = ((fConst30 * (fConst30 + fSlow81)) + 1.0f);
float fSlow84 = (iSlow79 ? fSlow80 : fConst31);
float fSlow85 = ((fConst30 * (fConst30 + fSlow84)) + 1.0f);
float fSlow86 = ((fConst30 * (fConst30 - fSlow84)) + 1.0f);
for (int i = 0; (i < count); i = (i + 1))
{
float fTemp0 = float(input0[i]);
float fTempFTZ0 =
(fTemp0
- (fConst6 * ((fConst7 * fRec1[2]) + (276000.0f * fRec1[1]))));
fRec1[0] =
((*reinterpret_cast<int*>(&fTempFTZ0) & 2139095040) ? fTempFTZ0
: 0.0f);
float fTempFTZ1 =
(fTemp0 - (fSlow17 * ((fSlow18 * fRec2[2]) + (fSlow19 * fRec2[1]))));
fRec2[0] =
((*reinterpret_cast<int*>(&fTempFTZ1) & 2139095040) ? fTempFTZ1
: 0.0f);
float fTempFTZ2 =
(fTemp0
- (fConst14 * ((fConst15 * fRec3[2]) + (66000.0f * fRec3[1]))));
fRec3[0] =
((*reinterpret_cast<int*>(&fTempFTZ2) & 2139095040) ? fTempFTZ2
: 0.0f);
float fTempFTZ3 =
(fTemp0 - (fSlow38 * ((fSlow39 * fRec4[1]) + (fSlow40 * fRec4[2]))));
fRec4[0] =
((*reinterpret_cast<int*>(&fTempFTZ3) & 2139095040) ? fTempFTZ3
: 0.0f);
float fTempFTZ4 =
(fTemp0
- (fConst24 * ((fConst25 * fRec6[2]) + (316000.0f * fRec6[1]))));
fRec6[0] =
((*reinterpret_cast<int*>(&fTempFTZ4) & 2139095040) ? fTempFTZ4
: 0.0f);
float fTempFTZ5 =
(fTemp0 - (fSlow61 * ((fSlow62 * fRec7[2]) + (fSlow63 * fRec7[1]))));
fRec7[0] =
((*reinterpret_cast<int*>(&fTempFTZ5) & 2139095040) ? fTempFTZ5
: 0.0f);
float fTemp1 = (fConst19 * fRec5[1]);
float fTempFTZ6 =
(((fConst22
* (((fSlow48 * fRec6[0]) + (20000.0f * fRec6[1]))
+ (fSlow49 * fRec6[2])))
+ (8.0f
* ((fSlow60 * fRec7[1])
+ (fSlow64 * ((fSlow67 * fRec7[0]) + (fSlow68 * fRec7[2]))))))
- (((fRec5[2] * fSlow73) + fTemp1) / fSlow74));
fRec5[0] =
((*reinterpret_cast<int*>(&fTempFTZ6) & 2139095040) ? fTempFTZ6
: 0.0f);
float fTemp2 = (fConst2 * fRec0[1]);
float fTempFTZ7 =
((((fSlow1
* ((12.0f * ((fSlow3 * fRec1[0]) + (fSlow4 * fRec1[2])))
+ (4.0f
* ((fSlow16 * fRec2[1])
+ (fSlow20
* ((fSlow22 * fRec2[0]) + (fSlow23 * fRec2[2])))))))
+ (fSlow24
* ((6.0f * ((fSlow25 * fRec3[0]) + (fSlow26 * fRec3[2])))
+ (1.39999998f
* ((fSlow37 * fRec4[1])
+ (fSlow41
* ((fSlow44 * fRec4[0])
+ (fSlow45 * fRec4[2]))))))))
+ (fSlow46
* (((fTemp1 + (fRec5[0] * fSlow76)) + (fRec5[2] * fSlow77))
/ fSlow74)))
- (((fRec0[2] * fSlow82) + fTemp2) / fSlow83));
fRec0[0] =
((*reinterpret_cast<int*>(&fTempFTZ7) & 2139095040) ? fTempFTZ7
: 0.0f);
output0[i] = FAUSTFLOAT(
(((fTemp2 + (fRec0[0] * fSlow85)) + (fRec0[2] * fSlow86)) / fSlow83));
fRec1[2] = fRec1[1];
fRec1[1] = fRec1[0];
fRec2[2] = fRec2[1];
fRec2[1] = fRec2[0];
fRec3[2] = fRec3[1];
fRec3[1] = fRec3[0];
fRec4[2] = fRec4[1];
fRec4[1] = fRec4[0];
fRec6[2] = fRec6[1];
fRec6[1] = fRec6[0];
fRec7[2] = fRec7[1];
fRec7[1] = fRec7[0];
fRec5[2] = fRec5[1];
fRec5[1] = fRec5[0];
fRec0[2] = fRec0[1];
fRec0[1] = fRec0[0];
}
}
};

#endif

+ 84
- 0
ports/swankyamp/source/dsp/ToneStackM.h View File

@@ -0,0 +1,84 @@
#ifndef __faust2hpp_ToneStackM_H__
#define __faust2hpp_ToneStackM_H__

#include <cmath>

#define uscale(x, l, u) (x + 1.0f) / 2.0f * (u - l) + l;
#define ulscale(x, l, u) \
std::exp((x + 1.0f) / 2.0f * (std::log(u) - std::log(l)) + std::log(l));

#include "ToneStackMFaust.h"

class ToneStackM
{
public:
ToneStackM()
{
faustDsp.buildUserInterface(&faustDsp);
par_bass = faustDsp.getParameter("bass");
par_mids = faustDsp.getParameter("mids");
par_presence = faustDsp.getParameter("presence");
par_treble = faustDsp.getParameter("treble");
}

~ToneStackM() = default;

void reset()
{
faustDsp.instanceClear();
zeroParameters();
}

void prepare(int sampleRate)
{
faustDsp.init(sampleRate);
zeroParameters();
}

void process(int count, FAUSTFLOAT** buffer)
{
faustDsp.compute(count, buffer, buffer);
}

inline void set_bass(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_bass = uscale(x, -1.0f, 1.0f);
}
inline void set_mids(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_mids = uscale(x, -1.0f, 1.0f);
}
inline void set_presence(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_presence = uscale(x, -1.0f, 1.0f);
}
inline void set_treble(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_treble = uscale(x, -1.0f, 1.0f);
}

private:
ToneStackMFaust faustDsp;

FAUSTFLOAT* par_bass = nullptr;
FAUSTFLOAT* par_mids = nullptr;
FAUSTFLOAT* par_presence = nullptr;
FAUSTFLOAT* par_treble = nullptr;

void zeroParameters()
{
set_bass(0.0f);
set_mids(0.0f);
set_presence(0.0f);
set_treble(0.0f);
}
};

#undef uscale
#undef ulscale

#endif

+ 367
- 0
ports/swankyamp/source/dsp/ToneStackMFaust.h View File

@@ -0,0 +1,367 @@
/* ------------------------------------------------------------
name: "ToneStackM"
Code generated with Faust 2.28.3 (https://faust.grame.fr)
Compilation options: -lang cpp -inpl -scal -ftz 2
------------------------------------------------------------ */

#ifndef __ToneStackMFaust_H__
#define __ToneStackMFaust_H__

#ifndef __faust2hpp_FaustImpl_H__
#define __faust2hpp_FaustImpl_H__

#include <stdexcept>
#include <unordered_map>

#include "Meta.h"
#include "UI.h"

class FaustImpl : public UI, public Meta
{
public:
FaustImpl() = default;
~FaustImpl() = default;

FAUSTFLOAT* getParameter(const char* name)
{
const auto entry = parameterMap.find(name);
if (entry == parameterMap.end())
throw std::invalid_argument(
std::string("FaustImpl::getParameter: invalid parameter name: ")
+ name);
return entry->second;
}

void setParameter(const char* name, FAUSTFLOAT* value)
{
const auto entry = parameterMap.find(name);
if (entry != parameterMap.end()) entry->second = value;
}

// blank implementations for UI
virtual void openTabBox(const char*){};
virtual void openHorizontalBox(const char*){};
virtual void openVerticalBox(const char*){};
virtual void closeBox(){};
virtual void addButton(const char*, FAUSTFLOAT*){};
virtual void addCheckButton(const char*, FAUSTFLOAT*){};
virtual void addVerticalSlider(
const char*,
FAUSTFLOAT*,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT){};
virtual void addHorizontalSlider(
const char*,
FAUSTFLOAT*,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT){};
virtual void
// use UI entry to expose user parameters
addNumEntry(
const char* label,
FAUSTFLOAT* zone,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT,
FAUSTFLOAT)
{
if (zone == nullptr) return;
parameterMap.insert_or_assign(label, zone);
}
virtual void
addHorizontalBargraph(const char*, FAUSTFLOAT*, FAUSTFLOAT, FAUSTFLOAT){};
virtual void
addVerticalBargraph(const char*, FAUSTFLOAT*, FAUSTFLOAT, FAUSTFLOAT){};
virtual void addSoundfile(const char*, const char*, Soundfile**){};

// blank implememtation for Meta
virtual void declare(const char*, const char*){};

private:
std::unordered_map<const char*, FAUSTFLOAT*> parameterMap;
};

#endif
#ifndef FAUSTFLOAT
#define FAUSTFLOAT float
#endif

#include <algorithm>
#include <cmath>
#include <math.h>

static float ToneStackMFaust_faustpower2_f(float value)
{
return (value * value);
}

#ifndef FAUSTCLASS
#define FAUSTCLASS ToneStackMFaust
#endif

#ifdef __APPLE__
#define exp10f __exp10f
#define exp10 __exp10
#endif

class ToneStackMFaust : public FaustImpl
{
private:
int fSampleRate;
float fConst0;
float fConst1;
float fConst2;
float fConst3;
FAUSTFLOAT fEntry0;
FAUSTFLOAT fEntry1;
float fConst4;
float fRec1[3];
float fConst5;
float fConst6;
float fConst7;
FAUSTFLOAT fEntry2;
float fConst8;
float fConst9;
float fRec2[3];
float fConst10;
FAUSTFLOAT fEntry3;
float fConst11;
float fRec0[3];

public:
void metadata(Meta* m)
{
m->declare("basics.lib/name", "Faust Basic Element Library");
m->declare("basics.lib/version", "0.1");
m->declare("filename", "ToneStackM.dsp");
m->declare("filters.lib/fir:author", "Julius O. Smith III");
m->declare(
"filters.lib/fir:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/fir:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/iir:author", "Julius O. Smith III");
m->declare(
"filters.lib/iir:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/iir:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/lowpass0_highpass1", "MIT-style STK-4.3 license");
m->declare("filters.lib/name", "Faust Filters Library");
m->declare("filters.lib/peak_eq:author", "Julius O. Smith III");
m->declare(
"filters.lib/peak_eq:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/peak_eq:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/tf2:author", "Julius O. Smith III");
m->declare(
"filters.lib/tf2:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/tf2:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/tf2s:author", "Julius O. Smith III");
m->declare(
"filters.lib/tf2s:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/tf2s:license", "MIT-style STK-4.3 license");
m->declare("maths.lib/author", "GRAME");
m->declare("maths.lib/copyright", "GRAME");
m->declare("maths.lib/license", "LGPL with exception");
m->declare("maths.lib/name", "Faust Math Library");
m->declare("maths.lib/version", "2.3");
m->declare("name", "ToneStackM");
m->declare("platform.lib/name", "Generic Platform Library");
m->declare("platform.lib/version", "0.1");
}

virtual int getNumInputs() { return 1; }
virtual int getNumOutputs() { return 1; }
virtual int getInputRate(int channel)
{
int rate;
switch ((channel))
{
case 0:
{
rate = 1;
break;
}
default:
{
rate = -1;
break;
}
}
return rate;
}
virtual int getOutputRate(int channel)
{
int rate;
switch ((channel))
{
case 0:
{
rate = 1;
break;
}
default:
{
rate = -1;
break;
}
}
return rate;
}

static void classInit(int) {}

virtual void instanceConstants(int sample_rate)
{
fSampleRate = sample_rate;
fConst0 =
std::min<float>(192000.0f, std::max<float>(1.0f, float(fSampleRate)));
fConst1 = std::tan((12566.3711f / fConst0));
fConst2 = (2.0f * (1.0f - (1.0f / ToneStackMFaust_faustpower2_f(fConst1))));
fConst3 = (9.68000052e-16f * ToneStackMFaust_faustpower2_f(fConst0));
fConst4 = (4.84000026e-16f * fConst0);
fConst5 = (3.41219997f * fConst0);
fConst6 = (fConst5 + 33000.0f);
fConst7 = (0.511829972f * (fConst0 / fConst6));
fConst8 = (1.0f / fConst6);
fConst9 = (33000.0f - fConst5);
fConst10 = (1.0f / fConst1);
fConst11 = (6283.18555f / (fConst0 * std::sin((25132.7422f / fConst0))));
}

virtual void instanceResetUserInterface()
{
fEntry0 = FAUSTFLOAT(0.0f);
fEntry1 = FAUSTFLOAT(0.0f);
fEntry2 = FAUSTFLOAT(0.0f);
fEntry3 = FAUSTFLOAT(0.0f);
}

virtual void instanceClear()
{
for (int l0 = 0; (l0 < 3); l0 = (l0 + 1)) { fRec1[l0] = 0.0f; }
for (int l1 = 0; (l1 < 3); l1 = (l1 + 1)) { fRec2[l1] = 0.0f; }
for (int l2 = 0; (l2 < 3); l2 = (l2 + 1)) { fRec0[l2] = 0.0f; }
}

virtual void init(int sample_rate)
{
classInit(sample_rate);
instanceInit(sample_rate);
}
virtual void instanceInit(int sample_rate)
{
instanceConstants(sample_rate);
instanceResetUserInterface();
instanceClear();
}

virtual ToneStackMFaust* clone() { return new ToneStackMFaust(); }

virtual int getSampleRate() { return fSampleRate; }

virtual void buildUserInterface(UI* ui_interface)
{
ui_interface->openVerticalBox("ToneStackM");
ui_interface->addNumEntry("bass", &fEntry1, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("mids", &fEntry0, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("presence", &fEntry3, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("treble", &fEntry2, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->closeBox();
}

virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs)
{
FAUSTFLOAT* input0 = inputs[0];
FAUSTFLOAT* output0 = outputs[0];
float fSlow0 = float(fEntry0);
float fSlow1 = (0.495000005f * fSlow0);
float fSlow2 = (fSlow1 + 0.504999995f);
float fSlow3 =
(484000000.0f
* (ToneStackMFaust_faustpower2_f(fSlow2) + (-0.504999995f - fSlow1)));
float fSlow4 = ((0.495000005f * float(fEntry1)) + 0.504999995f);
float fSlow5 =
((0.200000003f * (fSlow4 * float((fSlow4 <= 0.5f))))
+ (float((fSlow4 > 0.5f)) * ((1.60000002f * fSlow4) + -0.699999988f)));
float fSlow6 = (fSlow2 * fSlow5);
float fSlow7 = (fSlow3 - (2.2000001e+10f * fSlow6));
float fSlow8 = (22000.0f * (0.0f - (2.2e-08f * (fSlow2 + 1.0f))));
float fSlow9 = (0.0219999999f * fSlow5);
float fSlow10 = (fSlow8 + (-0.001452f - fSlow9));
float fSlow11 =
((fSlow3
+ (22000.0f
* ((1000000.0f * (0.0f - fSlow6))
+ (16335.0f * (fSlow0 + -1.0f)))))
+ (1000000.0f * (0.0f - (33000.0f * fSlow5))));
float fSlow12 = (fConst4 * fSlow11);
float fSlow13 = ((fConst0 * (fSlow10 + fSlow12)) + -1.0f);
float fSlow14 = (0.0f - (fConst3 * (fSlow7 / fSlow13)));
float fSlow15 = (1.0f / fSlow13);
float fSlow16 = (-2.0f - (fConst3 * fSlow11));
float fSlow17 = ((fConst0 * (fSlow12 - fSlow10)) + -1.0f);
float fSlow18 = (fConst0 / fSlow13);
float fSlow19 = (fSlow8 - fSlow9);
float fSlow20 = (fConst4 * fSlow7);
float fSlow21 = (fSlow19 + fSlow20);
float fSlow22 = (fSlow20 - fSlow19);
float fSlow23 =
(fConst7 * ((0.495000005f * float(fEntry2)) + 0.504999995f));
float fSlow24 = (0.0f - fSlow23);
float fSlow25 = (10.0f * float(fEntry3));
int iSlow26 = (fSlow25 > 0.0f);
float fSlow27 =
(fConst11 * std::pow(10.0f, (0.0500000007f * std::fabs(fSlow25))));
float fSlow28 = (iSlow26 ? fConst11 : fSlow27);
float fSlow29 = ((fConst10 * (fConst10 - fSlow28)) + 1.0f);
float fSlow30 = ((fConst10 * (fConst10 + fSlow28)) + 1.0f);
float fSlow31 = (iSlow26 ? fSlow27 : fConst11);
float fSlow32 = ((fConst10 * (fConst10 + fSlow31)) + 1.0f);
float fSlow33 = ((fConst10 * (fConst10 - fSlow31)) + 1.0f);
for (int i = 0; (i < count); i = (i + 1))
{
float fTemp0 = float(input0[i]);
float fTempFTZ0 =
(fTemp0 - (fSlow15 * ((fSlow16 * fRec1[1]) + (fSlow17 * fRec1[2]))));
fRec1[0] =
((*reinterpret_cast<int*>(&fTempFTZ0) & 2139095040) ? fTempFTZ0
: 0.0f);
float fTempFTZ1 =
(fTemp0 - (fConst8 * ((fConst9 * fRec2[2]) + (66000.0f * fRec2[1]))));
fRec2[0] =
((*reinterpret_cast<int*>(&fTempFTZ1) & 2139095040) ? fTempFTZ1
: 0.0f);
float fTemp1 = (fConst2 * fRec0[1]);
float fTempFTZ2 =
(((1.39999998f
* ((fSlow14 * fRec1[1])
+ (fSlow18 * ((fSlow21 * fRec1[0]) + (fSlow22 * fRec1[2])))))
+ (6.0f * ((fSlow23 * fRec2[0]) + (fSlow24 * fRec2[2]))))
- (((fRec0[2] * fSlow29) + fTemp1) / fSlow30));
fRec0[0] =
((*reinterpret_cast<int*>(&fTempFTZ2) & 2139095040) ? fTempFTZ2
: 0.0f);
output0[i] = FAUSTFLOAT(
(((fTemp1 + (fRec0[0] * fSlow32)) + (fRec0[2] * fSlow33)) / fSlow30));
fRec1[2] = fRec1[1];
fRec1[1] = fRec1[0];
fRec2[2] = fRec2[1];
fRec2[1] = fRec2[0];
fRec0[2] = fRec0[1];
fRec0[1] = fRec0[0];
}
}
};

#endif

+ 260
- 0
ports/swankyamp/source/dsp/Triode.h View File

@@ -0,0 +1,260 @@
#ifndef __faust2hpp_Triode_H__
#define __faust2hpp_Triode_H__

#include <cmath>

#define uscale(x, l, u) (x + 1.0f) / 2.0f * (u - l) + l;
#define ulscale(x, l, u) \
std::exp((x + 1.0f) / 2.0f * (std::log(u) - std::log(l)) + std::log(l));

#include "TriodeFaust.h"

class Triode
{
public:
Triode()
{
faustDsp.buildUserInterface(&faustDsp);
par_bias = faustDsp.getParameter("bias");
par_bias_corner = faustDsp.getParameter("bias_corner");
par_cap = faustDsp.getParameter("cap");
par_comp_cap = faustDsp.getParameter("comp_cap");
par_comp_corner = faustDsp.getParameter("comp_corner");
par_comp_depth = faustDsp.getParameter("comp_depth");
par_comp_level = faustDsp.getParameter("comp_level");
par_comp_offset = faustDsp.getParameter("comp_offset");
par_comp_ratio = faustDsp.getParameter("comp_ratio");
par_comp_tau = faustDsp.getParameter("comp_tau");
par_drift_depth = faustDsp.getParameter("drift_depth");
par_drift_level = faustDsp.getParameter("drift_level");
par_drift_tau = faustDsp.getParameter("drift_tau");
par_grid_clip = faustDsp.getParameter("grid_clip");
par_grid_corner = faustDsp.getParameter("grid_corner");
par_hp_freq = faustDsp.getParameter("hp_freq");
par_level = faustDsp.getParameter("level");
par_mix = faustDsp.getParameter("mix");
par_overhead = faustDsp.getParameter("overhead");
par_plate_clip = faustDsp.getParameter("plate_clip");
par_plate_corner = faustDsp.getParameter("plate_corner");
par_ratio = faustDsp.getParameter("ratio");
par_scale = faustDsp.getParameter("scale");
par_smooth = faustDsp.getParameter("smooth");
par_tau = faustDsp.getParameter("tau");
par_unscale = faustDsp.getParameter("unscale");
}

~Triode() = default;

void reset()
{
faustDsp.instanceClear();
zeroParameters();
}

void prepare(int sampleRate)
{
faustDsp.init(sampleRate);
zeroParameters();
}

void process(int count, FAUSTFLOAT** buffer)
{
faustDsp.compute(count, buffer, buffer);
}

inline void set_bias(FAUSTFLOAT x)
{
x += 2.368186e+00f;
*par_bias = uscale(x, -100.0f, +100.0f);
}
inline void set_bias_corner(FAUSTFLOAT x)
{
x += 4.893700e-01f;
*par_bias_corner = ulscale(x, 1e-1f, 1e+3f);
}
inline void set_cap(FAUSTFLOAT x)
{
x += 1.739277e+00f;
*par_cap = ulscale(x, 1e-1f, 1e+1f);
}
inline void set_comp_cap(FAUSTFLOAT x)
{
x += 2.536884e+00f;
*par_comp_cap = ulscale(x, 1e-1f, 1e+1f);
}
inline void set_comp_corner(FAUSTFLOAT x)
{
x += 1.507149e-02f;
*par_comp_corner = ulscale(x, 1e-1f, 1e+2f);
}
inline void set_comp_depth(FAUSTFLOAT x)
{
x += -1.602357e-01f;
*par_comp_depth = ulscale(x, 1e-1f, 1e+1f);
}
inline void set_comp_level(FAUSTFLOAT x)
{
x += -1.019789e+00f;
*par_comp_level = uscale(x, -100.0f, +100.0f);
}
inline void set_comp_offset(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_comp_offset = uscale(x, -100.0f, +100.0f);
}
inline void set_comp_ratio(FAUSTFLOAT x)
{
x += 3.138570e+00f;
*par_comp_ratio = ulscale(x, 1e0f, 1e+1f);
}
inline void set_comp_tau(FAUSTFLOAT x)
{
x += -1.100164e+00f;
*par_comp_tau = ulscale(x, 1e-3f, 1e0f);
}
inline void set_drift_depth(FAUSTFLOAT x)
{
x += -8.249800e-01f;
*par_drift_depth = ulscale(x, 1e-1f, 1e+1f);
}
inline void set_drift_level(FAUSTFLOAT x)
{
x += 1.018694e-01f;
*par_drift_level = uscale(x, -100.0f, +100.0f);
}
inline void set_drift_tau(FAUSTFLOAT x)
{
x += -1.088060e+00f;
*par_drift_tau = ulscale(x, 1e-3f, 1e0f);
}
inline void set_grid_clip(FAUSTFLOAT x)
{
x += 4.078275e-01f;
*par_grid_clip = uscale(x, 0.0f, 5.0f);
}
inline void set_grid_corner(FAUSTFLOAT x)
{
x += 1.150913e-02f;
*par_grid_corner = uscale(x, 0.0f, 5.0f);
}
inline void set_hp_freq(FAUSTFLOAT x)
{
x += 4.522232e-01f;
*par_hp_freq = ulscale(x, 1e-1f, 1e+2f);
}
inline void set_level(FAUSTFLOAT x)
{
x += 3.357531e-01f;
*par_level = uscale(x, -5.0f, +5.0f);
}
inline void set_mix(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_mix = x;
}
inline void set_overhead(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_overhead = x;
}
inline void set_plate_clip(FAUSTFLOAT x)
{
x += -1.075611e+00f;
*par_plate_clip = uscale(x, -100.0f, +100.0f);
}
inline void set_plate_corner(FAUSTFLOAT x)
{
x += -2.447939e-02f;
*par_plate_corner = ulscale(x, 1e-2f, 1e+2f);
}
inline void set_ratio(FAUSTFLOAT x)
{
x += 1.208988e+00f;
*par_ratio = ulscale(x, 1e-1f, 1e+4f);
}
inline void set_scale(FAUSTFLOAT x)
{
x += 1.524156e+00f;
*par_scale = ulscale(x, 1e-1f, 1e+1f);
}
inline void set_smooth(FAUSTFLOAT x)
{
x += 1.529416e+00f;
*par_smooth = ulscale(x, 1e-5f, 1e+1f);
}
inline void set_tau(FAUSTFLOAT x)
{
x += -1.357776e+00f;
*par_tau = ulscale(x, 1e-6f, 1e-3f);
}
inline void set_unscale(FAUSTFLOAT x)
{
x += 0.000000e+00f;
*par_unscale = x;
}

private:
TriodeFaust faustDsp;

FAUSTFLOAT* par_bias = nullptr;
FAUSTFLOAT* par_bias_corner = nullptr;
FAUSTFLOAT* par_cap = nullptr;
FAUSTFLOAT* par_comp_cap = nullptr;
FAUSTFLOAT* par_comp_corner = nullptr;
FAUSTFLOAT* par_comp_depth = nullptr;
FAUSTFLOAT* par_comp_level = nullptr;
FAUSTFLOAT* par_comp_offset = nullptr;
FAUSTFLOAT* par_comp_ratio = nullptr;
FAUSTFLOAT* par_comp_tau = nullptr;
FAUSTFLOAT* par_drift_depth = nullptr;
FAUSTFLOAT* par_drift_level = nullptr;
FAUSTFLOAT* par_drift_tau = nullptr;
FAUSTFLOAT* par_grid_clip = nullptr;
FAUSTFLOAT* par_grid_corner = nullptr;
FAUSTFLOAT* par_hp_freq = nullptr;
FAUSTFLOAT* par_level = nullptr;
FAUSTFLOAT* par_mix = nullptr;
FAUSTFLOAT* par_overhead = nullptr;
FAUSTFLOAT* par_plate_clip = nullptr;
FAUSTFLOAT* par_plate_corner = nullptr;
FAUSTFLOAT* par_ratio = nullptr;
FAUSTFLOAT* par_scale = nullptr;
FAUSTFLOAT* par_smooth = nullptr;
FAUSTFLOAT* par_tau = nullptr;
FAUSTFLOAT* par_unscale = nullptr;

void zeroParameters()
{
set_bias(0.0f);
set_bias_corner(0.0f);
set_cap(0.0f);
set_comp_cap(0.0f);
set_comp_corner(0.0f);
set_comp_depth(0.0f);
set_comp_level(0.0f);
set_comp_offset(0.0f);
set_comp_ratio(0.0f);
set_comp_tau(0.0f);
set_drift_depth(0.0f);
set_drift_level(0.0f);
set_drift_tau(0.0f);
set_grid_clip(0.0f);
set_grid_corner(0.0f);
set_hp_freq(0.0f);
set_level(0.0f);
set_mix(0.0f);
set_overhead(0.0f);
set_plate_clip(0.0f);
set_plate_corner(0.0f);
set_ratio(0.0f);
set_scale(0.0f);
set_smooth(0.0f);
set_tau(0.0f);
set_unscale(0.0f);
}
};

#undef uscale
#undef ulscale

#endif

+ 413
- 0
ports/swankyamp/source/dsp/TriodeFaust.h View File

@@ -0,0 +1,413 @@
/* ------------------------------------------------------------
name: "Triode"
Code generated with Faust 2.28.3 (https://faust.grame.fr)
Compilation options: -lang cpp -inpl -scal -ftz 2
------------------------------------------------------------ */

#ifndef __TriodeFaust_H__
#define __TriodeFaust_H__

#include "FaustImpl.h"
#ifndef FAUSTFLOAT
#define FAUSTFLOAT float
#endif

#include <algorithm>
#include <cmath>
#include <math.h>

#ifndef FAUSTCLASS
#define FAUSTCLASS TriodeFaust
#endif

#ifdef __APPLE__
#define exp10f __exp10f
#define exp10 __exp10
#endif

class TriodeFaust : public FaustImpl
{
private:
FAUSTFLOAT fEntry0;
FAUSTFLOAT fEntry1;
FAUSTFLOAT fEntry2;
FAUSTFLOAT fEntry3;
FAUSTFLOAT fEntry4;
FAUSTFLOAT fEntry5;
int fSampleRate;
float fConst0;
FAUSTFLOAT fEntry6;
FAUSTFLOAT fEntry7;
FAUSTFLOAT fEntry8;
FAUSTFLOAT fEntry9;
FAUSTFLOAT fEntry10;
FAUSTFLOAT fEntry11;
FAUSTFLOAT fEntry12;
FAUSTFLOAT fEntry13;
float fConst1;
FAUSTFLOAT fEntry14;
float fVec0[2];
float fRec2[2];
FAUSTFLOAT fEntry15;
FAUSTFLOAT fEntry16;
FAUSTFLOAT fEntry17;
FAUSTFLOAT fEntry18;
FAUSTFLOAT fEntry19;
float fRec4[2];
float fRec3[2];
FAUSTFLOAT fEntry20;
FAUSTFLOAT fEntry21;
FAUSTFLOAT fEntry22;
float fConst2;
FAUSTFLOAT fEntry23;
float fRec5[2];
FAUSTFLOAT fEntry24;
float fRec1[2];
FAUSTFLOAT fEntry25;
float fVec1[2];
float fRec0[2];

public:
void metadata(Meta* m)
{
m->declare("basics.lib/name", "Faust Basic Element Library");
m->declare("basics.lib/version", "0.1");
m->declare("filename", "Triode.dsp");
m->declare("filters.lib/highpass:author", "Julius O. Smith III");
m->declare(
"filters.lib/highpass:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/lowpass0_highpass1", "MIT-style STK-4.3 license");
m->declare("filters.lib/lowpass0_highpass1:author", "Julius O. Smith III");
m->declare("filters.lib/lowpass:author", "Julius O. Smith III");
m->declare(
"filters.lib/lowpass:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/lowpass:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/name", "Faust Filters Library");
m->declare("filters.lib/tf1:author", "Julius O. Smith III");
m->declare(
"filters.lib/tf1:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/tf1:license", "MIT-style STK-4.3 license");
m->declare("filters.lib/tf1s:author", "Julius O. Smith III");
m->declare(
"filters.lib/tf1s:copyright",
"Copyright (C) 2003-2019 by Julius O. Smith III "
"<jos@ccrma.stanford.edu>");
m->declare("filters.lib/tf1s:license", "MIT-style STK-4.3 license");
m->declare("maths.lib/author", "GRAME");
m->declare("maths.lib/copyright", "GRAME");
m->declare("maths.lib/license", "LGPL with exception");
m->declare("maths.lib/name", "Faust Math Library");
m->declare("maths.lib/version", "2.3");
m->declare("name", "Triode");
m->declare("platform.lib/name", "Generic Platform Library");
m->declare("platform.lib/version", "0.1");
m->declare("signals.lib/name", "Faust Signal Routing Library");
m->declare("signals.lib/version", "0.0");
}

virtual int getNumInputs() { return 1; }
virtual int getNumOutputs() { return 1; }
virtual int getInputRate(int channel)
{
int rate;
switch ((channel))
{
case 0:
{
rate = 1;
break;
}
default:
{
rate = -1;
break;
}
}
return rate;
}
virtual int getOutputRate(int channel)
{
int rate;
switch ((channel))
{
case 0:
{
rate = 1;
break;
}
default:
{
rate = -1;
break;
}
}
return rate;
}

static void classInit(int) {}

virtual void instanceConstants(int sample_rate)
{
fSampleRate = sample_rate;
fConst0 =
std::min<float>(192000.0f, std::max<float>(1.0f, float(fSampleRate)));
fConst1 = (3.14159274f / fConst0);
fConst2 = (1.0f / fConst0);
}

virtual void instanceResetUserInterface()
{
fEntry0 = FAUSTFLOAT(0.0f);
fEntry1 = FAUSTFLOAT(0.0f);
fEntry2 = FAUSTFLOAT(0.0f);
fEntry3 = FAUSTFLOAT(0.0f);
fEntry4 = FAUSTFLOAT(0.0f);
fEntry5 = FAUSTFLOAT(0.0f);
fEntry6 = FAUSTFLOAT(0.0f);
fEntry7 = FAUSTFLOAT(0.0f);
fEntry8 = FAUSTFLOAT(0.0f);
fEntry9 = FAUSTFLOAT(0.0f);
fEntry10 = FAUSTFLOAT(0.0f);
fEntry11 = FAUSTFLOAT(0.0f);
fEntry12 = FAUSTFLOAT(0.0f);
fEntry13 = FAUSTFLOAT(0.0f);
fEntry14 = FAUSTFLOAT(0.0f);
fEntry15 = FAUSTFLOAT(0.0f);
fEntry16 = FAUSTFLOAT(0.0f);
fEntry17 = FAUSTFLOAT(0.0f);
fEntry18 = FAUSTFLOAT(0.0f);
fEntry19 = FAUSTFLOAT(0.0f);
fEntry20 = FAUSTFLOAT(0.0f);
fEntry21 = FAUSTFLOAT(0.0f);
fEntry22 = FAUSTFLOAT(0.0f);
fEntry23 = FAUSTFLOAT(0.0f);
fEntry24 = FAUSTFLOAT(0.0f);
fEntry25 = FAUSTFLOAT(0.0f);
}

virtual void instanceClear()
{
for (int l0 = 0; (l0 < 2); l0 = (l0 + 1)) { fVec0[l0] = 0.0f; }
for (int l1 = 0; (l1 < 2); l1 = (l1 + 1)) { fRec2[l1] = 0.0f; }
for (int l2 = 0; (l2 < 2); l2 = (l2 + 1)) { fRec4[l2] = 0.0f; }
for (int l3 = 0; (l3 < 2); l3 = (l3 + 1)) { fRec3[l3] = 0.0f; }
for (int l4 = 0; (l4 < 2); l4 = (l4 + 1)) { fRec5[l4] = 0.0f; }
for (int l5 = 0; (l5 < 2); l5 = (l5 + 1)) { fRec1[l5] = 0.0f; }
for (int l6 = 0; (l6 < 2); l6 = (l6 + 1)) { fVec1[l6] = 0.0f; }
for (int l7 = 0; (l7 < 2); l7 = (l7 + 1)) { fRec0[l7] = 0.0f; }
}

virtual void init(int sample_rate)
{
classInit(sample_rate);
instanceInit(sample_rate);
}
virtual void instanceInit(int sample_rate)
{
instanceConstants(sample_rate);
instanceResetUserInterface();
instanceClear();
}

virtual TriodeFaust* clone() { return new TriodeFaust(); }

virtual int getSampleRate() { return fSampleRate; }

virtual void buildUserInterface(UI* ui_interface)
{
ui_interface->openVerticalBox("Triode");
ui_interface->addNumEntry("bias", &fEntry9, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("bias_corner", &fEntry20, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("cap", &fEntry17, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("comp_cap", &fEntry5, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("comp_corner", &fEntry25, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("comp_depth", &fEntry4, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("comp_level", &fEntry7, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("comp_offset", &fEntry3, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("comp_ratio", &fEntry24, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("comp_tau", &fEntry6, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("drift_depth", &fEntry21, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("drift_level", &fEntry23, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("drift_tau", &fEntry22, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("grid_clip", &fEntry12, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("grid_corner", &fEntry13, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("hp_freq", &fEntry14, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("level", &fEntry18, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("mix", &fEntry0, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("overhead", &fEntry1, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("plate_clip", &fEntry8, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry(
"plate_corner", &fEntry10, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("ratio", &fEntry19, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("scale", &fEntry11, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("smooth", &fEntry16, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("tau", &fEntry15, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->addNumEntry("unscale", &fEntry2, 0.0f, 0.0f, 1.0f, 1.0f);
ui_interface->closeBox();
}

virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs)
{
FAUSTFLOAT* input0 = inputs[0];
FAUSTFLOAT* output0 = outputs[0];
float fSlow0 = float(fEntry0);
float fSlow1 = (1.0f - fSlow0);
float fSlow2 = float(fEntry1);
float fSlow3 = ((fSlow2 * fSlow0) / float(fEntry2));
float fSlow4 = float(fEntry3);
float fSlow5 = float(fEntry4);
float fSlow6 = float(fEntry5);
float fSlow7 = float(fEntry6);
float fSlow8 = (1.0f / (fSlow6 * ((fConst0 * fSlow7) + 1.0f)));
float fSlow9 = float(fEntry7);
float fSlow10 = float(fEntry8);
float fSlow11 = float(fEntry9);
float fSlow12 = float(fEntry10);
float fSlow13 = (fSlow12 + fSlow10);
float fSlow14 = float(fEntry11);
float fSlow15 = float(fEntry12);
float fSlow16 = float(fEntry13);
float fSlow17 = std::tan((fConst1 * float(fEntry14)));
float fSlow18 = (1.0f / fSlow17);
float fSlow19 = (fSlow18 + 1.0f);
float fSlow20 = (0.0f - (1.0f / (fSlow17 * fSlow19)));
float fSlow21 = (1.0f / fSlow2);
float fSlow22 = (1.0f / fSlow19);
float fSlow23 = (1.0f - fSlow18);
float fSlow24 = (1.0f / (fSlow17 * fSlow2));
float fSlow25 = float(fEntry15);
float fSlow26 = (1.0f / ((fConst0 * (fSlow25 * float(fEntry16))) + 1.0f));
float fSlow27 = (1.0f - fSlow26);
float fSlow28 = float(fEntry17);
float fSlow29 = (1.0f / (fSlow28 * ((fConst0 * fSlow25) + 1.0f)));
float fSlow30 = float(fEntry18);
float fSlow31 =
((1.0f / ((fConst0 * (fSlow25 * float(fEntry19))) + 1.0f)) + -1.0f);
float fSlow32 = (0.294117659f / fSlow16);
float fSlow33 = float(fEntry20);
float fSlow34 = (0.294117659f / fSlow33);
float fSlow35 = (0.294117659f / fSlow12);
float fSlow36 = float(fEntry21);
float fSlow37 = float(fEntry22);
int iSlow38 = (std::fabs(fSlow37) < 1.1920929e-07f);
float fSlow39 =
(iSlow38 ? 0.0f
: std::exp((0.0f - (fConst2 / (iSlow38 ? 1.0f : fSlow37)))));
float fSlow40 = float(fEntry23);
float fSlow41 = (1.0f - fSlow39);
float fSlow42 =
(1.0f - (1.0f / ((fConst0 * (fSlow7 * float(fEntry24))) + 1.0f)));
float fSlow43 = float(fEntry25);
float fSlow44 = (fSlow43 + fSlow10);
float fSlow45 = (0.294117659f / fSlow43);
for (int i = 0; (i < count); i = (i + 1))
{
float fTemp0 = float(input0[i]);
fVec0[0] = (fSlow21 * fTemp0);
float fTempFTZ0 =
((fSlow20 * fVec0[1])
- (fSlow22 * ((fSlow23 * fRec2[1]) - (fSlow24 * fTemp0))));
fRec2[0] =
((*reinterpret_cast<int*>(&fTempFTZ0) & 2139095040) ? fTempFTZ0
: 0.0f);
float fTempFTZ1 =
((fSlow29
* (std::max<float>(0.0f, (fSlow28 - fRec4[1]))
* std::max<float>(
0.0f,
(std::max<float>(0.0f, (fRec2[0] - fSlow30)) - fRec4[1]))))
- (fSlow31 * fRec4[1]));
fRec4[0] =
((*reinterpret_cast<int*>(&fTempFTZ1) & 2139095040) ? fTempFTZ1
: 0.0f);
float fTempFTZ2 = ((fSlow27 * fRec3[1]) + (fSlow26 * fRec4[0]));
fRec3[0] =
((*reinterpret_cast<int*>(&fTempFTZ2) & 2139095040) ? fTempFTZ2
: 0.0f);
float fTemp1 = (fSlow16 + ((fRec2[0] - fRec3[0]) - fSlow15));
float fTemp2 = std::max<float>(
-1.0f,
std::min<float>(1.0f, (fSlow32 * std::max<float>(0.0f, fTemp1))));
float fTemp3 = (fTemp2 * (std::fabs(fTemp2) + -2.0f));
float fTemp4 =
(fSlow11
+ ((fSlow14
* (fSlow15
+ (std::min<float>(0.0f, fTemp1)
- (fSlow16
* (1.0f - (fTemp3 * (std::fabs(fTemp3) + -2.0f)))))))
- fSlow33));
float fTemp5 = std::max<float>(
-1.0f,
std::min<float>(1.0f, (fSlow34 * std::min<float>(0.0f, fTemp4))));
float fTemp6 = (fTemp5 * (std::fabs(fTemp5) + -2.0f));
float fTemp7 =
(fSlow11
- (fSlow13
+ (std::max<float>(0.0f, fTemp4)
+ (fSlow33
* ((fTemp6 * (std::fabs(fTemp6) + -2.0f)) + 1.0f)))));
float fTemp8 = std::max<float>(
-1.0f,
std::min<float>(1.0f, (fSlow35 * std::min<float>(0.0f, fTemp7))));
float fTemp9 = (fTemp8 * (std::fabs(fTemp8) + -2.0f));
float fTemp10 =
(std::max<float>(0.0f, fTemp7)
+ (fSlow12 * ((fTemp9 * (std::fabs(fTemp9) + -2.0f)) + 1.0f)));
float fTempFTZ3 =
((fRec5[1] * fSlow39)
+ ((std::max<float>(fSlow40, (fSlow10 + fTemp10)) - fSlow40)
* fSlow41));
fRec5[0] =
((*reinterpret_cast<int*>(&fTempFTZ3) & 2139095040) ? fTempFTZ3
: 0.0f);
float fTemp11 = (fSlow36 * fRec5[0]);
float fTempFTZ4 =
((fSlow8
* (std::max<float>(0.0f, (fSlow6 - fRec1[1]))
* std::max<float>(
0.0f,
((std::max<float>(fSlow9, (fSlow10 + (fTemp10 - fTemp11)))
- fRec1[1])
- fSlow9))))
+ (fSlow42 * fRec1[1]));
fRec1[0] =
((*reinterpret_cast<int*>(&fTempFTZ4) & 2139095040) ? fTempFTZ4
: 0.0f);
float fTemp12 = (fSlow5 * fRec1[0]);
float fTemp13 = (fSlow44 + ((fTemp10 - (fTemp11 + fTemp12)) - fSlow4));
float fTemp14 = std::max<float>(
-1.0f,
std::min<float>(1.0f, (fSlow45 * std::max<float>(0.0f, fTemp13))));
float fTemp15 = (fTemp14 * (std::fabs(fTemp14) + -2.0f));
float fTemp16 =
(fSlow4
+ ((fTemp12 + std::min<float>(0.0f, fTemp13))
- (fSlow43 * (1.0f - (fTemp15 * (std::fabs(fTemp15) + -2.0f))))));
fVec1[0] = fTemp16;
float fTempFTZ5 =
((0.863271236f * (fTemp16 + fVec1[1])) - (0.726542532f * fRec0[1]));
fRec0[0] =
((*reinterpret_cast<int*>(&fTempFTZ5) & 2139095040) ? fTempFTZ5
: 0.0f);
output0[i] =
FAUSTFLOAT(((fSlow1 * fTemp0) + (fSlow3 * (0.0f - fRec0[0]))));
fVec0[1] = fVec0[0];
fRec2[1] = fRec2[0];
fRec4[1] = fRec4[0];
fRec3[1] = fRec3[0];
fRec5[1] = fRec5[0];
fRec1[1] = fRec1[0];
fVec1[1] = fVec1[0];
fRec0[1] = fRec0[0];
}
}
};

#endif

+ 105
- 0
ports/swankyamp/source/dsp/UI.h View File

@@ -0,0 +1,105 @@
/************************************************************************
FAUST Architecture File
Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale
---------------------------------------------------------------------
This Architecture section is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3 of
the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; If not, see <http://www.gnu.org/licenses/>.

EXCEPTION : As a special exception, you may create a larger work
that contains this FAUST architecture section and distribute
that work under terms of your choice, so long as this FAUST
architecture section is not modified.
************************************************************************/

#pragma once

#ifndef __faust2hpp_UI_H__
#define __faust2hpp_UI_H__

#ifndef FAUSTFLOAT
#define FAUSTFLOAT float
#endif

/*******************************************************************************
* UI : Faust DSP User Interface
* User Interface as expected by the buildUserInterface() method of a DSP.
* This abstract class contains only the method that the Faust compiler can
* generate to describe a DSP user interface.
******************************************************************************/

struct Soundfile;

template<typename REAL> class UIReal
{
public:
UIReal() {}
virtual ~UIReal() {}

// -- widget's layouts

virtual void openTabBox(const char* label) = 0;
virtual void openHorizontalBox(const char* label) = 0;
virtual void openVerticalBox(const char* label) = 0;
virtual void closeBox() = 0;

// -- active widgets

virtual void addButton(const char* label, REAL* zone) = 0;
virtual void addCheckButton(const char* label, REAL* zone) = 0;
virtual void addVerticalSlider(
const char* label,
REAL* zone,
REAL init,
REAL min,
REAL max,
REAL step) = 0;
virtual void addHorizontalSlider(
const char* label,
REAL* zone,
REAL init,
REAL min,
REAL max,
REAL step) = 0;
virtual void addNumEntry(
const char* label,
REAL* zone,
REAL init,
REAL min,
REAL max,
REAL step) = 0;

// -- passive widgets

virtual void
addHorizontalBargraph(const char* label, REAL* zone, REAL min, REAL max) = 0;
virtual void
addVerticalBargraph(const char* label, REAL* zone, REAL min, REAL max) = 0;

// -- soundfiles

virtual void addSoundfile(
const char* label, const char* filename, Soundfile** sf_zone) = 0;

// -- metadata declarations

virtual void declare(REAL*, const char*, const char*) {}
};

class UI : public UIReal<FAUSTFLOAT>
{
public:
UI() {}
virtual ~UI() {}
};

#endif

+ 23
- 0
ports/swankyamp/thirdparty/optional-lite/LICENSE.txt View File

@@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

+ 1791
- 0
ports/swankyamp/thirdparty/optional-lite/include/nonstd/optional.hpp
File diff suppressed because it is too large
View File


Loading…
Cancel
Save