├── screenshot.jpg
├── resources
├── bg.jpg
├── crypt-icon.png
├── Gothica-Book.ttf
├── keyboard-icon.png
├── crypt-icon-fullsize-round.png
├── crypt-icon-fullsize-square.png
├── LICENSE.md
├── keyboard-icon.svg
└── presets.xml
├── .gitmodules
├── .gitignore
├── src
├── CryptPlugin.cpp
├── CustomParameterModel.hpp
├── SharedBuffer.hpp
├── CryptParameters.hpp
├── ParameterControlledADSR.hpp
├── FxProcessors.hpp
├── CryptAudioProcessor.hpp
├── SuperSawVoice.hpp
└── CryptAudioProcessorEditor.hpp
├── README.md
├── CMakeLists.txt
└── COPYING
/screenshot.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vitling/crypt/HEAD/screenshot.jpg
--------------------------------------------------------------------------------
/resources/bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vitling/crypt/HEAD/resources/bg.jpg
--------------------------------------------------------------------------------
/resources/crypt-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vitling/crypt/HEAD/resources/crypt-icon.png
--------------------------------------------------------------------------------
/resources/Gothica-Book.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vitling/crypt/HEAD/resources/Gothica-Book.ttf
--------------------------------------------------------------------------------
/resources/keyboard-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vitling/crypt/HEAD/resources/keyboard-icon.png
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "JUCE"]
2 | path = JUCE
3 | url = https://github.com/juce-framework/JUCE.git
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .*
2 | build/
3 | cmake-build-debug
4 | cmake-build-release
5 | release-scripts
6 | build-release
7 |
--------------------------------------------------------------------------------
/resources/crypt-icon-fullsize-round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vitling/crypt/HEAD/resources/crypt-icon-fullsize-round.png
--------------------------------------------------------------------------------
/resources/crypt-icon-fullsize-square.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vitling/crypt/HEAD/resources/crypt-icon-fullsize-square.png
--------------------------------------------------------------------------------
/resources/LICENSE.md:
--------------------------------------------------------------------------------
1 | # Resource licenses
2 |
3 | ## Visual assets
4 |
5 | These assets are all Copyright 2025 David Whiting, and are licensed to this project under the Creative Commons Attribution 4.0 International license CC-BY-4.0 (https://creativecommons.org/licenses/by/4.0/)
6 |
7 | * bg.jpg
8 | * crypt-icon-fullsize-round.png
9 | * crypt-icon-fullsize-square.png
10 | * crypt-icon.png
11 | * keyboard-icon.png
12 | * keyboard-icon.svg
13 |
14 | ## Font
15 |
16 | The font Gothica-Book.ttf from the Gothica typeface by Wojciech Kalinowski is included in this package, licensed under the SIL Open Font License (OFL) version 1.1 (https://openfontlicense.org/), allowing its use in this application.
17 |
18 | ## Presets
19 |
20 | I consider presets.xml to be part of the source code, and therefore licensed under the GPL-3 as the rest of the source.
21 |
--------------------------------------------------------------------------------
/src/CryptPlugin.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2025 David Whiting
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 | */
17 |
18 | #include
19 | #include "CryptAudioProcessor.hpp"
20 | #include "CryptAudioProcessorEditor.hpp"
21 |
22 | AudioProcessor* JUCE_CALLTYPE createPluginFilter()
23 | {
24 | return new CryptAudioProcessor();
25 | }
26 |
27 | juce::AudioProcessorEditor *CryptAudioProcessor::createEditor() {
28 | return new CryptAudioProcessorEditor(*this);
29 | }
--------------------------------------------------------------------------------
/src/CustomParameterModel.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2025 David Whiting
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 | */
17 | #pragma once
18 | #include
19 |
20 | /* I found it helpful to separate the definition of a parameter from its
21 | identity within an AudioProcessor, so that different components can 'own'
22 | their own parameter space */
23 | struct ParameterSpec {
24 | String id;
25 | String name;
26 | String label;
27 | NormalisableRange range;
28 | float def;
29 | };
30 |
31 | std::unique_ptr createParameterGroup(String groupId, String groupName, std::vector params) {
32 | auto group = std::make_unique(groupId, groupName, "|");
33 | for (auto p : params) {
34 | group->addChild(std::make_unique(ParameterID {p.id,1 }, p.name, p.range, p.def));
35 | }
36 |
37 | return std::move(group);
38 | }
--------------------------------------------------------------------------------
/resources/keyboard-icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
47 |
--------------------------------------------------------------------------------
/src/SharedBuffer.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2025 David Whiting
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 | */
17 | #pragma once
18 | #include
19 |
20 | /** Simple encapsulation of the FIFO buffer to communicate data from the audio thread to the GUI thread.
21 | * I don't really actually understand it fully so I thought best to get it all inside here instead of
22 | * spread around the rest of the code
23 | */
24 | class SharedBuffer {
25 | private:
26 | AbstractFifo fifo;
27 | std::vector writeBuffer;
28 | std::vector readBuffer;
29 | int size;
30 | public:
31 | SharedBuffer(int size): fifo(size), writeBuffer(size, 0.0f), readBuffer(size, 0.0f) {
32 |
33 | }
34 |
35 | /** Call this from the audio thread only */
36 | void write(int count, const float * readPointer) {
37 | int start1, size1, start2, size2;
38 | fifo.prepareToWrite(count, start1, size1, start2, size2);
39 |
40 | if (size1 > 0)
41 | std::copy(readPointer, readPointer + size1, writeBuffer.begin() + start1);
42 | if (size2 > 0)
43 | std::copy(readPointer + size1, readPointer + size1 + size2, writeBuffer.begin() + start2);
44 |
45 | fifo.finishedWrite(size1 + size2);
46 | }
47 |
48 | /** Call this from the GUI thread only */
49 | const std::vector & read() {
50 | int start1, size1, start2, size2;
51 | fifo.prepareToRead(512, start1, size1, start2, size2);
52 |
53 | if (size1 > 0)
54 | std::copy(writeBuffer.begin() + start1,
55 | writeBuffer.begin() + start1 + size1,
56 | readBuffer.begin());
57 | if (size2 > 0)
58 | std::copy(writeBuffer.begin() + start2,
59 | writeBuffer.begin() + start2 + size2,
60 | readBuffer.begin() + size1);
61 |
62 | fifo.finishedRead(size1 + size2);
63 |
64 | return readBuffer;
65 | }
66 |
67 | /** Call this from the GUI thread only */
68 | const std::vector & get() const {
69 | return readBuffer;
70 | }
71 |
72 | };
73 |
74 |
--------------------------------------------------------------------------------
/src/CryptParameters.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2025 David Whiting
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 | */
17 | #pragma once
18 | #include
19 |
20 | namespace CryptParameters {
21 | const String Unison = "Unison";
22 | const String Spread = "Spread";
23 | const String Shape = "Shape";
24 | const String Dirt = "Dirt";
25 | /// + ADSR
26 |
27 | const String Cutoff = "Cutoff";
28 | const String Resonance = "Resonance";
29 | const String FilterEnv = "FilterEnv";
30 | /// + ADSR
31 |
32 | const String DelayTime = "DelayTime";
33 | const String DelayMix = "DelayMix";
34 | const String DelayFeedback = "DelayFeedback";
35 |
36 | const String PhaserDepth = "PhaserDepth";
37 | const String PhaserRate = "PhaserRate";
38 | const String PhaserMix = "PhaserMix";
39 |
40 | const String Space = "Space";
41 |
42 | const String Attack = "Attack";
43 | const String Decay = "Decay";
44 | const String Sustain = "Sustain";
45 | const String Release = "Release";
46 |
47 | const String PitchBendRange = "PitchBendRange";
48 | const String Master = "Master";
49 |
50 | // ID prefixes
51 | const String Amplitude = "Amplitude";
52 | const String Filter = "Filter";
53 |
54 |
55 | std::map unitMap {
56 | {Cutoff, "Hz"},
57 | {DelayTime, "ms"},
58 | {PhaserRate, "Hz"},
59 | {Attack, "s"},
60 | {Decay, "s"},
61 | {Release, "s"},
62 | {Master, "dB"},
63 | {PitchBendRange, " st"}
64 | };
65 |
66 | std::map labelMap {
67 | {DelayTime, "Time"},
68 | {DelayMix, "Mix"},
69 | {DelayFeedback, "Feedback"},
70 | {PhaserDepth, "Depth"},
71 | {PhaserRate, "Rate"},
72 | {PhaserMix, "Mix"},
73 | {FilterEnv, "Env Amount"},
74 | {PitchBendRange, "PB Range"}
75 | };
76 |
77 | StringRef getUnit(StringRef param) {
78 | auto out = unitMap.find(param);
79 | if (out != unitMap.end()) {
80 | return out->second;
81 | } else {
82 | return "";
83 | }
84 | }
85 |
86 | StringRef getLabel(StringRef paramId) {
87 | auto out = labelMap.find(paramId);
88 | if (out != labelMap.end()) {
89 | return out->second;
90 | } else {
91 | return paramId;
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/ParameterControlledADSR.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2025 David Whiting
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 | */
17 | #pragma once
18 | #include
19 | #include "CryptParameters.hpp"
20 | #include "CustomParameterModel.hpp"
21 |
22 | class ParameterControlledADSR: public ADSR, public AudioProcessorValueTreeState::Listener {
23 |
24 | private:
25 | String idPrefix;
26 | ADSR::Parameters envParams {0.02f,0.2f,0.6f,0.5f};
27 |
28 | public:
29 | ParameterControlledADSR(String idPrefix): idPrefix(idPrefix) {
30 | envParams = getParameters();
31 | }
32 |
33 | static std::vector params(String idPrefix) {
34 | return {
35 | {.id = idPrefix + "." + CryptParameters::Attack, .name = "Attack", .range = {0.0,8.0,0.001, 0.3}, .def = 0.02f},
36 | {.id = idPrefix + "." + CryptParameters::Decay, .name = "Decay", .range = {0.0,8.0,0.001, 0.3}, .def = 0.2f},
37 | {.id = idPrefix + "." + CryptParameters::Sustain, .name = "Sustain", .range = {0.0,1.0,0.01}, .def = 0.6f},
38 | {.id = idPrefix + "." + CryptParameters::Release, .name = "Release", .range = {0.0, 8.0, 0.001, 0.3}, .def = 0.5f},
39 | };
40 | }
41 |
42 | void noteOn() noexcept
43 | {
44 | setParameters(envParams);
45 | ADSR::noteOn();
46 | }
47 |
48 | void registerParams(AudioProcessorValueTreeState& state) {
49 | for (auto p: params(idPrefix)) {
50 | state.addParameterListener(p.id, this);
51 | }
52 | }
53 | void unRegisterParams(AudioProcessorValueTreeState& state) {
54 | for (auto p: params(idPrefix)) {
55 | state.removeParameterListener(p.id, this);
56 | }
57 | }
58 | void parameterChanged (const String& parameterID, float newValue) override {
59 | if (parameterID.endsWith(CryptParameters::Attack)) {
60 | envParams.attack = newValue;
61 | } else if (parameterID.endsWith(CryptParameters::Decay)) {
62 | envParams.decay = newValue;
63 | } else if (parameterID.endsWith(CryptParameters::Sustain)) {
64 | envParams.sustain = newValue;
65 | } else if (parameterID.endsWith(CryptParameters::Release)) {
66 | envParams.release = newValue;
67 | }
68 | // If we're currently playing then we defer applying new params until the next note
69 | if (!ADSR::isActive()) {
70 | setParameters(envParams);
71 | }
72 | }
73 | };
74 |
75 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # Crypt
3 |
4 | **Crypt** is a software synthesiser plugin designed for creating spacious cold hyper-unisoned
5 | synth sounds; developed by [Vitling](https://www.vitling.xyz) for the [Bow Church](http://bowchurch.bandcamp.com/) project.
6 |
7 | 
8 |
9 | It is written in C++20 and depends on the [JUCE](https://github.com/juce-framework/JUCE) framework, which is
10 | included as a submodule.
11 |
12 | ## Installation
13 |
14 | ### Mac & Windows
15 |
16 | Go to the [Crypt plugin download page](https://www.vitling.xyz/crypt) for conveniently packaged donwloads for **Mac** and **Windows**
17 |
18 | ### Linux
19 |
20 | Building on Linux should be fairly straightforward, but I haven't done much testing on that front myself.
21 |
22 | #### Dependencies
23 | ```cmake g++ libfreetype6-dev libx11-dev libxinerama-dev libxrandr-dev libxcursor-dev mesa-common-dev libasound2-dev freeglut3-dev libxcomposite-dev pkg-config```
24 |
25 | These are Debian/Ubuntu package names (install with `sudo apt-get install ` and paste the above), you may need to translate for your distro
26 |
27 | #### Build
28 |
29 | ```bash
30 | git clone --recursive --shallow-submodules https://github.com/vitling/crypt.git
31 | cd crypt
32 | cmake -Bbuild -DCMAKE_BUILD_TYPE=Release # For MacOS universal binary add "-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64"
33 | cmake --build build --parallel
34 | ```
35 |
36 | ## Contribute
37 |
38 | This plugin is published open source primarily so that (a) Linux users are able to build from source and (b) people can learn from what I have learned and created. This is not intended to be a project that gets features added over time ad infinitum.
39 |
40 | As such, in general, I will NOT accept Pull Requests which add new features to the plugin. Feel free to make suggestions, especially if you can back it up with a solid use case, but I make no promises.
41 |
42 | I will, in general, accept pull requests which fix bugs or allow a broader adoption of the plugin, for example adjustments to make it build for more platforms.
43 |
44 | If you want to take components of Crypt and do something new with them, then that is your right under the [GPL3 license](https://www.gnu.org/licenses/gpl-3.0.html), you may take code from this for your own plugin, but if you do then legally that plugin must also be published under the GPL3 license.
45 |
46 | I kindly request (but cannot legally enforce) that you do not use the name or branding if you create a new plugin based on parts of Crypt.
47 |
48 | ## Support
49 |
50 | If you find this useful, then please consider supporting me. This project took a lot of serious work that nobody was paying me to do.
51 | [I accept monetary tips](https://ko-fi.com/vitling) and [Github Sponsors](https://github.com/sponsors/vitling)
52 |
53 | You can also buy the music of [Bow Church](https://bowchurch.bandcamp.com)
54 | or [Vitling](https://vitling.bandcamp.com); or listen and add to playlists on Spotify and/or SoundCloud.
55 |
56 | You can also see my [website](https://www.vitling.xyz) for my latest work; and/or contact me to hire me for stuff.
57 |
58 | ## License
59 |
60 | This plugin is free software, licensed under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.html).
61 |
62 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # This program is free software: you can redistribute it and/or modify
2 | # it under the terms of the GNU General Public License as published by
3 | # the Free Software Foundation, either version 3 of the License, or
4 | # (at your option) any later version.
5 | #
6 | # This program is distributed in the hope that it will be useful,
7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 | # GNU General Public License for more details.
10 | #
11 | # You should have received a copy of the GNU General Public License
12 | # along with this program. If not, see .
13 |
14 | cmake_minimum_required(VERSION 3.15)
15 |
16 | set(CMAKE_CXX_STANDARD 20)
17 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
18 | set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "Minimum OS X deployment version" FORCE)
19 |
20 | project(CRYPT_SYNTH_PLUGIN VERSION 2.1.0)
21 |
22 | add_subdirectory(JUCE)
23 |
24 | juce_add_plugin(Crypt2SynthPlugin
25 | VERSION 2.1.0 # Set this if the plugin version is different to the project version
26 | ICON_BIG ${CMAKE_CURRENT_SOURCE_DIR}/resources/crypt-icon.png # ICON_* arguments specify a path to an image file to use as an icon for the Standalone
27 | ICON_SMALL ${CMAKE_CURRENT_SOURCE_DIR}/resources/crypt-icon.png
28 | COMPANY_NAME Vitling # Specify the name of the plugin's author
29 | IS_SYNTH TRUE # Is this a synth or an effect?
30 | NEEDS_MIDI_INPUT TRUE # Does the plugin need midi input?
31 | NEEDS_MIDI_OUTPUT FALSE # Does the plugin need midi output?
32 | IS_MIDI_EFFECT FALSE # Is this plugin a MIDI effect?
33 | EDITOR_WANTS_KEYBOARD_FOCUS FALSE # Does the editor need keyboard focus?
34 | COPY_PLUGIN_AFTER_BUILD TRUE # Should the plugin be installed to a default location after building?
35 | PLUGIN_MANUFACTURER_CODE Vitl # A four-character manufacturer id with at least one upper-case character
36 | PLUGIN_CODE Crp2 # A unique four-character plugin id with at least one upper-case character
37 | DESCRIPTION "Hyper-Unison Synthesiser from Bow Church/Vitling"
38 | VST3_CATEGORIES "Instrument Synth Stereo"
39 | AU_MAIN_TYPE "kAudioUnitType_MusicDevice"
40 | FORMATS VST3 AU Standalone # The formats to build. Other valid formats are: AAX Unity VST AU AUv3
41 | BUNDLE_ID "xyz.vitling.plugins.crypt2"
42 | HARDENED_RUNTIME_ENABLED TRUE
43 | PRODUCT_NAME "Crypt2") # The name of the final executable, which can differ from the target name
44 |
45 |
46 | juce_generate_juce_header(Crypt2SynthPlugin)
47 |
48 | target_sources(Crypt2SynthPlugin PRIVATE
49 | src/CryptPlugin.cpp)
50 |
51 | target_compile_definitions(Crypt2SynthPlugin
52 | PUBLIC
53 | JUCE_WEB_BROWSER=0
54 | JUCE_USE_CURL=0
55 | JUCE_VST3_CAN_REPLACE_VST2=0
56 |
57 | # We don't have to display the splash screen since we're using JUCE
58 | # under the GPL
59 | JUCE_DISPLAY_SPLASH_SCREEN=0)
60 |
61 | juce_add_binary_data(Crypt2SynthPluginData SOURCES resources/Gothica-Book.ttf resources/bg.jpg resources/presets.xml resources/keyboard-icon.png)
62 | set_target_properties(Crypt2SynthPluginData PROPERTIES POSITION_INDEPENDENT_CODE ON)
63 |
64 | target_link_libraries(Crypt2SynthPlugin PRIVATE
65 | Crypt2SynthPluginData
66 | juce::juce_audio_utils
67 | juce::juce_dsp)
68 |
--------------------------------------------------------------------------------
/src/FxProcessors.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2025 David Whiting
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 | */
17 | #pragma once
18 |
19 | #include
20 | #include "CryptParameters.hpp"
21 | #include "CustomParameterModel.hpp"
22 |
23 | class StereoDelay: public dsp::ProcessorBase, public AudioProcessorValueTreeState::Listener {
24 | private:
25 | dsp::DelayLine delayLine;
26 | float feedback = 0.5;
27 | float wet = 0.3;
28 | float delayTime = 375.0f;
29 | float smoothedDelayTime = 0.5f;
30 | double sampleRate = 44100.0;
31 |
32 | public:
33 |
34 | static std::vector params() {
35 | return {
36 | {.id = CryptParameters::DelayTime, .name = "Time", .range = {2.0,2000.0,0.1,0.5}, .def = 375.0f},
37 | {.id = CryptParameters::DelayMix, .name = "Mix", .range = {0.0,1.0,0.01}, .def = 0.3f},
38 | {.id = CryptParameters::DelayFeedback, .name = "Feedback", .range = {0.0,0.99,0.01}, .def = 0.5f}
39 | };
40 | }
41 |
42 | void registerParams(AudioProcessorValueTreeState& state) {
43 | for (auto p: params()) {
44 | state.addParameterListener(p.id, this);
45 | }
46 | }
47 |
48 | void unRegisterParams(AudioProcessorValueTreeState& state) {
49 | for (auto p: params()) {
50 | state.removeParameterListener(p.id, this);
51 | }
52 | }
53 |
54 | void parameterChanged (const String& parameterID, float newValue) override {
55 | if (parameterID == CryptParameters::DelayTime) {
56 | delayTime = newValue;
57 | } else if (parameterID == CryptParameters::DelayMix) {
58 | wet = newValue;
59 | } else if (parameterID == CryptParameters::DelayFeedback) {
60 | feedback = newValue;
61 | }
62 | }
63 |
64 | void prepare (const dsp::ProcessSpec &spec) override {
65 | delayLine.prepare(spec);
66 | delayLine.setMaximumDelayInSamples(spec.sampleRate * 2.1);
67 | sampleRate = spec.sampleRate;
68 | }
69 | void process (const dsp::ProcessContextReplacing< float > &context) override {
70 |
71 | auto input = context.getInputBlock();
72 | auto output = context.getOutputBlock();
73 | auto channels = input.getNumChannels();
74 | auto samples = input.getNumSamples();
75 | if (abs(smoothedDelayTime - delayTime) < 0.1) {
76 | smoothedDelayTime = delayTime;
77 | }
78 |
79 | for (auto i = 0; i < samples; i++) {
80 | smoothedDelayTime += (delayTime - smoothedDelayTime) * 0.0001;
81 | for (auto c = 0; c < channels; c++) {
82 | auto w = delayLine.popSample(c, (sampleRate / 1000) * smoothedDelayTime + smoothedDelayTime * (0.01) * c, true);
83 | auto d = input.getSample(c, i);
84 | float v = w * wet + d;
85 | delayLine.pushSample(c, d + feedback * w);
86 | output.setSample(c, i, v);
87 | }
88 | }
89 |
90 | }
91 | void reset () override {
92 | delayLine.reset();
93 | }
94 | };
95 |
96 | class Phaser : public dsp::ProcessorWrapper>, public AudioProcessorValueTreeState::Listener {
97 | public:
98 | Phaser() {
99 | processor.setCentreFrequency(1000.0f);
100 | processor.setDepth(0.5f);
101 | processor.setRate(0.2f);
102 | processor.setMix(0.15f);
103 | }
104 | static std::vector params() {
105 | return {
106 | {.id = CryptParameters::PhaserDepth, .name = "Depth", .range = {0.0,1.0,0.01}, .def = 0.5f},
107 | {.id = CryptParameters::PhaserRate, .name = "Rate", .range = {0.02,1.0,0.01,0.5}, .def = 0.2f},
108 | {.id = CryptParameters::PhaserMix, .name = "Mix", .range = {0.0,1.0,0.01}, .def = 0.3f}
109 | };
110 | }
111 |
112 | void registerParams(AudioProcessorValueTreeState& state) {
113 | for (auto p: params()) {
114 | state.addParameterListener(p.id, this);
115 | }
116 | }
117 |
118 | void unRegisterParams(AudioProcessorValueTreeState& state) {
119 | for (auto p: params()) {
120 | state.removeParameterListener(p.id, this);
121 | }
122 | }
123 |
124 | void parameterChanged (const String& parameterID, float newValue) override {
125 | if (parameterID == CryptParameters::PhaserDepth) {
126 | processor.setDepth(newValue);
127 | } else if (parameterID == CryptParameters::PhaserRate) {
128 | processor.setRate(newValue);
129 | } else if (parameterID == CryptParameters::PhaserMix) {
130 | processor.setMix(newValue * 0.5f); // 0.5 is actually full "mix" because it's half phased and half normal signal
131 | }
132 | }
133 |
134 | };
135 |
136 | class CryptReverb : public dsp::ProcessorWrapper, public AudioProcessorValueTreeState::Listener {
137 | private:
138 | void setSpace(float space) {
139 | Reverb::Parameters params {
140 | .roomSize = 0.2f + 0.8f * space,
141 | .damping = 0.8f - 0.7f * space,
142 | .wetLevel = space * 0.8f,
143 | .dryLevel = 1.0f - space * 0.8f,
144 | .width = 1.0f,
145 | .freezeMode = 0.0f};
146 |
147 | processor.setParameters(params);
148 | }
149 | void parameterChanged (const String& parameterID, float newValue) override {
150 | if (parameterID == CryptParameters::Space) {
151 | setSpace(newValue);
152 | }
153 | }
154 |
155 | public:
156 | static std::vector params() {
157 | return {
158 | {.id = CryptParameters::Space, .name = "Space", .range = {0.0,1.0,0.01}, .def = 0.2f},
159 | };
160 | }
161 |
162 | void registerParams(AudioProcessorValueTreeState& state) {
163 | for (auto p: params()) {
164 | state.addParameterListener(p.id, this);
165 | }
166 | }
167 |
168 | void unRegisterParams(AudioProcessorValueTreeState& state) {
169 | for (auto p: params()) {
170 | state.removeParameterListener(p.id, this);
171 | }
172 | }
173 |
174 | CryptReverb() {
175 | setSpace(0.2f);
176 | }
177 | };
178 |
--------------------------------------------------------------------------------
/src/CryptAudioProcessor.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2025 David Whiting
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 | */
17 | #pragma once
18 |
19 | #include
20 | #include "CryptParameters.hpp"
21 | #include "CustomParameterModel.hpp"
22 | #include "ParameterControlledADSR.hpp"
23 | #include "SuperSawVoice.hpp"
24 | #include "SharedBuffer.hpp"
25 | #include "FxProcessors.hpp"
26 |
27 | /** This needs to exist to satisfy the needs of the Synthesiser class, but is otherwise meaningless */
28 | class AlwaysOnSound : public SynthesiserSound {
29 | public:
30 | AlwaysOnSound() = default;
31 | ~AlwaysOnSound() override = default;
32 |
33 | bool appliesToNote(int midiNoteNumber) override { return true; }
34 |
35 | bool appliesToChannel(int midiChannel) override { return true; }
36 |
37 | };
38 |
39 | /* The simple presets in Crypt are managed by a baked-in XML file, containing a set of possible plugin
40 | states in the same form as they are saved by the createXml function of an AudioProcessorValueTreeState.
41 | This baked-in XML is a BinaryData resource in resources/presets.xml */
42 | struct Preset {
43 | int id;
44 | String name;
45 | std::unique_ptr stateData;
46 | };
47 |
48 | class PresetManager {
49 | typedef std::pair> NamedPreset;
50 |
51 | private:
52 | std::vector presetData;
53 |
54 | void loadPresets() {
55 | DBG("Loading Preset");
56 | String content (BinaryData::presets_xml);
57 | auto parsed = parseXML(content);
58 |
59 | if (parsed) {
60 | DBG("Document parsed successfully");
61 | if (parsed->hasTagName("presets")) {
62 | DBG("Presets as top level tag, good!");
63 | int n = 1;
64 | for (auto preset: parsed->getChildIterator()) {
65 | auto name = preset->getChildByName("name")->getAllSubText();
66 | DBG("Loading preset " << name);
67 | auto element = std::make_unique(*(preset->getChildByName("state")));
68 | presetData.push_back({n++, name, std::move(element)});
69 | DBG("successfully inserted into map");
70 | }
71 | }
72 | } else {
73 | DBG("Failed XML Parse");
74 | }
75 | }
76 | public:
77 |
78 | PresetManager() {
79 | loadPresets();
80 | }
81 |
82 | void applyPreset(int index, AudioProcessorValueTreeState &state) {
83 | state.replaceState(ValueTree::fromXml(*presetData[index-1].stateData.get()));
84 | }
85 |
86 | std::vector listPresets() {
87 | std::vector result(presetData.size());
88 | std::transform(presetData.begin(), presetData.end(), result.begin(), [](Preset& x) { return x.name; });
89 | return result;
90 | }
91 | };
92 |
93 |
94 | /** The plugin itself */
95 | class CryptAudioProcessor : public AudioProcessor {
96 | friend class CryptAudioProcessorEditor;
97 | private:
98 | //==============================================================================
99 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CryptAudioProcessor)
100 |
101 | Synthesiser synth;
102 |
103 | dsp::ProcessorChain fxRig;
104 |
105 | SharedBuffer oscBuffer;
106 |
107 | MidiKeyboardState keyboardState;
108 |
109 | // This was kind of an arbitrary choice
110 | const int MAX_POLYPHONY = 8;
111 |
112 | /* Shortcut for getting true (non-normalised) values out of a parameter tree
113 | * I honestly cannot remember why I'm not using getRawParameterValue, but I remember crashes
114 | * when I tried to rationalise all the parameter stuff and I'm scared to change it now
115 | */
116 | float getParameterValue(StringRef parameterName) const {
117 | auto param = state.getParameter(parameterName);
118 | return param->convertFrom0to1(param->getValue());
119 | }
120 |
121 | static AudioProcessorValueTreeState::ParameterLayout createCryptParameterLayout() {
122 | std::vector> params;
123 |
124 | auto phaser = createParameterGroup("Phaser", "Phaser", Phaser::params());
125 | auto delay = createParameterGroup("Delay", "Delay", StereoDelay::params());
126 | auto oscillator = createParameterGroup("Osc", "Oscillator", SuperSawVoice::params());
127 | auto reverb = createParameterGroup("Reverb", "Reverb", CryptReverb::params());
128 | auto ampEnv = createParameterGroup("Amplitude", "Amp Env",
129 | ParameterControlledADSR::params(CryptParameters::Amplitude));
130 | auto filterEnv = createParameterGroup("Filter", "Filter Env",
131 | ParameterControlledADSR::params(CryptParameters::Filter));
132 |
133 | return {
134 | std::move(oscillator),
135 | std::move(phaser),
136 | std::move(delay),
137 | std::move(reverb),
138 | std::move(ampEnv),
139 | std::move(filterEnv),
140 | std::make_unique(
141 | ParameterID {CryptParameters::Master, 1},
142 | "Master Gain",
143 | NormalisableRange(-12.0,3.0,0.01),
144 | 0.0f)
145 | };
146 | }
147 |
148 | public:
149 |
150 | AudioProcessorValueTreeState state;
151 |
152 | PresetManager presetManager;
153 |
154 | /** Create plugin with Stereo output and setup all the parameters */
155 | CryptAudioProcessor() :
156 | AudioProcessor(BusesProperties().withOutput ("Output", juce::AudioChannelSet::stereo(), true)),
157 | state(*this, nullptr, "state", createCryptParameterLayout()),
158 | oscBuffer(512) {
159 |
160 | // Add some voices to our empty synthesiser
161 | for (int i = 0; i < MAX_POLYPHONY; i++) {
162 | // The synth takes ownership of the voices, so this 'new' is safe
163 | auto voice = new SuperSawVoice(state);
164 | synth.addVoice(voice);
165 | }
166 | // The synth takes ownership of the Sound, so this 'new' is safe
167 | synth.addSound(new AlwaysOnSound());
168 | fxRig.get<0>().registerParams(state);
169 | fxRig.get<1>().registerParams(state);
170 | fxRig.get<2>().registerParams(state);
171 | }
172 | ~CryptAudioProcessor() override {
173 | fxRig.get<0>().unRegisterParams(state);
174 | fxRig.get<1>().unRegisterParams(state);
175 | fxRig.get<2>().unRegisterParams(state);
176 | }
177 |
178 | /** Before playing for the first time we need to inform components of the current sample rate, and do an inital setup
179 | * of the Reverb processor parameters
180 | */
181 | void prepareToPlay (double sampleRate, int samplesPerBlock) override {
182 | synth.setCurrentPlaybackSampleRate(sampleRate);
183 | fxRig.prepare({.sampleRate = sampleRate, .maximumBlockSize = (uint32)samplesPerBlock, .numChannels = 2});
184 | }
185 |
186 | /** Everything we've allocated will be self-destructed, so there's no resources to release */
187 | void releaseResources() override {}
188 |
189 | bool isBusesLayoutSupported (const BusesLayout& layouts) const override {
190 | return (layouts.getMainOutputChannels() == 2);
191 | }
192 |
193 | /** Main audio generating segment. There is nothing in the chain that requires creating extra buffers, so this same
194 | * AudioBuffer is passed around everywhere and only ever incremented
195 | */
196 | void processBlock (AudioBuffer& audio, MidiBuffer& midi) override {
197 | keyboardState.processNextMidiBuffer(midi, 0, audio.getNumSamples(), true);
198 |
199 | audio.clear();
200 | synth.renderNextBlock(audio, midi, 0, audio.getNumSamples());
201 |
202 | dsp::AudioBlock block(audio);
203 | dsp::ProcessContextReplacing context(block);
204 |
205 | fxRig.process(context);
206 |
207 | float masterDb = getParameterValue(CryptParameters::Master);
208 | audio.applyGain(pow(10, masterDb/10));
209 |
210 | // Buffer for waveform visualisation
211 | oscBuffer.write(audio.getNumSamples(), audio.getReadPointer(0));
212 | }
213 |
214 | // We need to defer this implementation until the end of the file, when we have defined our editor
215 | juce::AudioProcessorEditor* createEditor() override;
216 |
217 | // Various metadata about the plugin
218 | bool hasEditor() const override { return true; }
219 | const String getName() const override { return "Crypt";}
220 | bool acceptsMidi() const override {return true;}
221 | bool producesMidi() const override {return false;}
222 | bool isMidiEffect() const override {return false;}
223 | double getTailLengthSeconds() const override {
224 | // note this is a total guess, probably should have
225 | // done a real calculation
226 | return 5.0;
227 | }
228 |
229 |
230 | // Made an executive decision to just not support this type of program switching
231 | // behaviour and instead only expose a small selection of presets from the UI
232 | int getNumPrograms() override { return 1; }
233 | int getCurrentProgram() override { return 1; }
234 | void setCurrentProgram (int index) override { }
235 | const String getProgramName (int index) override { return "Default Program"; }
236 | void changeProgramName (int index, const String& newName) override { }
237 |
238 | // Save state to binary block (used eg. for saving state inside Ableton project)
239 | void getStateInformation (MemoryBlock& destData) override {
240 | auto stateToSave = state.copyState();
241 | std::unique_ptr xml (stateToSave.createXml());
242 | copyXmlToBinary(*xml, destData);
243 | }
244 |
245 | // Restore state from binary block
246 | void setStateInformation (const void* data, int sizeInBytes) override {
247 | std::unique_ptr xmlState (getXmlFromBinary(data, sizeInBytes));
248 |
249 | if (xmlState != nullptr) {
250 | if (xmlState->hasTagName(state.state.getType())) {
251 | state.replaceState(ValueTree::fromXml(*xmlState));
252 | }
253 | }
254 | }
255 | };
--------------------------------------------------------------------------------
/resources/presets.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | cold winter pad
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | soft melancholy pad
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | trance sequence ready
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 | thick percussive bass
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 | epic hypersaw
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 | wasps in space
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 | tunnel harmonies
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 | arpeggiate me
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
--------------------------------------------------------------------------------
/src/SuperSawVoice.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2025 David Whiting
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 | */
17 |
18 | #include
19 | #include "CryptParameters.hpp"
20 | #include "CustomParameterModel.hpp"
21 | #include "ParameterControlledADSR.hpp"
22 |
23 | #define TAU MathConstants::twoPi
24 |
25 | /**
26 | * A single voice of the polyphonic synthesiser
27 | */
28 | class SuperSawVoice : public SynthesiserVoice, public AudioProcessorValueTreeState::Listener {
29 | private:
30 | /** Stores the state of a single oscillator (of many) within the Voice */
31 | struct OscState {
32 | float angle = 0.0;
33 | float frequency = 440;
34 | float increment = 0.0;
35 | float pan = 0.0;
36 | float spreadRnd = 0.0;
37 | };
38 |
39 | /** The set of oscillators which make up this voice */
40 | std::vector oscillators;
41 |
42 | int maxUnisonOscs = 64;
43 | int activeUnisonOscs = 32;
44 |
45 | /** Multiplier for output signal (used to scale by velocity) */
46 | float level = 0.0;
47 |
48 | float mainFrequency = 440;
49 |
50 | float pitchBend = 0.0;
51 |
52 | int pitchBendRange = 2;
53 |
54 | int midiNote = 4;
55 |
56 | float shape = 0.0f;
57 | float dirt = 0.0f;
58 | float cutoff = 20000.0f;
59 | float resonance = 1.0f;
60 | float filterEnv = 0.0f;
61 | float spread = 0.03f;
62 |
63 | /** Reference to the parameter tree for the entire plugin so we can access parameters */
64 | AudioProcessorValueTreeState& state;
65 |
66 | /** Un-antialiased sawtooth function between 0 and TAU */
67 | static inline float saw(float angle) {
68 | return (2.0f * angle/TAU) - 1;
69 | }
70 |
71 | static inline float square(float angle) {
72 | return std::copysign(1.0f, angle - MathConstants::pi);
73 | }
74 |
75 | ParameterControlledADSR ampEnvelope { CryptParameters::Amplitude };
76 | ParameterControlledADSR filterEnvelope { CryptParameters::Filter };
77 |
78 | dsp::StateVariableTPTFilter filter;
79 |
80 | /** Waveshaping function which applies a cubic clipping curve, gained by the 'dirt' parameter */
81 | inline float shapeCompoundWave(float f, float dirt) {
82 | constexpr float factor = 2.0f;
83 | f = f * (1.0f/factor + dirt*10.0f);
84 | if (f < -1.0f) {
85 | return factor * -2/3.0f;
86 | } else if (f > 1.0f) {
87 | return factor * 2/3.0f;
88 | } else {
89 | return factor * (f - (f * f * f)/3.0f);
90 | }
91 | }
92 |
93 | static constexpr int SINE_WAVETABLE_SIZE = 512;
94 | float sinTable[SINE_WAVETABLE_SIZE];
95 |
96 | void fillWaveTable() {
97 | for (auto i = 0; i < SINE_WAVETABLE_SIZE; i++) {
98 | float angle = TAU * i / SINE_WAVETABLE_SIZE;
99 | sinTable[i] = sin(angle);
100 | }
101 | }
102 |
103 | float wtSin(float angle) {
104 | jassert(angle >= 0.0f);
105 |
106 | return sinTable[static_cast(SINE_WAVETABLE_SIZE * angle / TAU) % SINE_WAVETABLE_SIZE];
107 | }
108 |
109 | void parameterChanged(const String ¶meterID, float newValue) override {
110 | if (parameterID == CryptParameters::Spread) {
111 | spread = newValue;
112 | setFrequency(mainFrequency, spread, false);
113 | } else if (parameterID == CryptParameters::Unison) {
114 | activeUnisonOscs = static_cast(newValue);
115 | setFrequency(mainFrequency, spread, true);
116 | } else if (parameterID == CryptParameters::Shape) {
117 | shape = newValue;
118 | } else if (parameterID == CryptParameters::Dirt) {
119 | dirt = newValue;
120 | } else if (parameterID == CryptParameters::Cutoff) {
121 | cutoff = newValue;
122 | } else if (parameterID == CryptParameters::Resonance) {
123 | resonance = newValue;
124 | } else if (parameterID == CryptParameters::FilterEnv) {
125 | filterEnv = newValue;
126 | } else if (parameterID == CryptParameters::PitchBendRange) {
127 | pitchBendRange = newValue;
128 | }
129 | }
130 |
131 |
132 |
133 | public:
134 |
135 | static std::vector params() {
136 | std::vector params = {
137 | {.id = CryptParameters::Unison, .name = "Unison Voices", .range = {4.0,64.0,1.0,0.5}, .def = 32.0f},
138 | {.id = CryptParameters::Spread, .name = "Unison Spread", .range = {0.0, 0.1, 0.001}, .def = 0.03f},
139 | {.id = CryptParameters::Shape, .name = "Osc Shape", .range = {0.0, 1.0, 0.01}, .def = 0.0f},
140 | {.id = CryptParameters::Dirt, .name = "Dirt", .range = {0.0,1.0,0.01}, .def = 0.0f},
141 | {.id = CryptParameters::Cutoff, .name = "Filter Cutoff", .range = {50.0,20000.0,1.0,0.2}, .def = 20000.0f},
142 | {.id = CryptParameters::Resonance, .name = "Filter Resonance", .range = {0.1,6.0,0.01}, .def = 1.0f},
143 | {.id = CryptParameters::FilterEnv, .name = "Filter Env Amount", .range = {0.0,1.0,0.001}, .def = 0.0f},
144 | {.id = CryptParameters::PitchBendRange, .name = "Pitchbend Range", .range = {0,12,1}, .def = 2.0f},
145 | };
146 | return params;
147 | }
148 |
149 | void registerParams(AudioProcessorValueTreeState& state) {
150 | for (auto p: params()) {
151 | state.addParameterListener(p.id, this);
152 | }
153 | ampEnvelope.registerParams(state);
154 | filterEnvelope.registerParams(state);
155 | }
156 |
157 | void unRegisterParams(AudioProcessorValueTreeState& state) {
158 | for (auto p: params()) {
159 | state.removeParameterListener(p.id, this);
160 | }
161 | ampEnvelope.unRegisterParams(state);
162 | filterEnvelope.unRegisterParams(state);
163 | }
164 |
165 | explicit SuperSawVoice(AudioProcessorValueTreeState& state): state(state) {
166 | for (int i = 0; i < maxUnisonOscs; i++) {
167 | oscillators.emplace_back();
168 | }
169 | fillWaveTable();
170 | registerParams(state);
171 | // We need to prepare with something before we hit a note, because we may hit renderBlock before startNote
172 | filter.prepare({ .sampleRate = 44100, .maximumBlockSize = 8192, .numChannels = 2 });
173 | }
174 |
175 | /**
176 | * Whenever we change the frequency, we need to apply the variations across all oscillators
177 | * @param freq Base frequency (ie. note frequency)
178 | * @param spread How much random deviation from the freq to apply to each oscillator
179 | * @param resetAngles Whether osc angles should be reset to initial positions (yes when starting new note, no when
180 | * continuing existing note
181 | */
182 | void setFrequency(float freq, float spread, bool phaseReset) {
183 | mainFrequency = freq;
184 | Random rnd;
185 | for (int i = 0; i < activeUnisonOscs; i++) {
186 | if (phaseReset) {
187 | oscillators[i].angle = i / float(activeUnisonOscs) * TAU;
188 | oscillators[i].spreadRnd = rnd.nextFloat();
189 | }
190 | oscillators[i].frequency = freq * (1 + oscillators[i].spreadRnd * spread - spread / 2);
191 | oscillators[i].pan = i / float(activeUnisonOscs - 1) * 2 - 1;
192 | float cyclesPerSample = oscillators[i].frequency / getSampleRate();
193 | oscillators[i].increment = cyclesPerSample * TAU;
194 | }
195 | }
196 |
197 | float calcFrequency(int midiNoteNumber, int pitchWheelValue) {
198 | const float pitchBend = (float(pitchWheelValue) / 8192.0)-1.0;
199 | return MidiMessage::getMidiNoteInHertz(midiNoteNumber) * pow(2, pitchBend * pitchBendRange / 12.0);
200 | }
201 |
202 | /* We only have one sound, so this is always true */
203 | bool canPlaySound(juce::SynthesiserSound *) override {return true;}
204 |
205 | void startNote(int midiNoteNumber, float velocity, juce::SynthesiserSound *sound, int currentPitchWheelPosition) override {
206 | ampEnvelope.reset();
207 | ampEnvelope.setSampleRate(getSampleRate());
208 | filterEnvelope.reset();
209 | filterEnvelope.setSampleRate(getSampleRate());
210 |
211 | midiNote = midiNoteNumber;
212 | setFrequency(calcFrequency(midiNoteNumber, currentPitchWheelPosition), spread, true);
213 |
214 | filter.prepare({ .sampleRate = getSampleRate(), .maximumBlockSize = 8192, .numChannels = 2});
215 |
216 | level = velocity * 0.04f + 0.02f;
217 | ampEnvelope.noteOn();
218 | filterEnvelope.noteOn();
219 | }
220 |
221 | void pitchWheelMoved (int newPitchWheelValue) override {
222 |
223 | setFrequency(calcFrequency(midiNote, newPitchWheelValue), spread, false);
224 | }
225 |
226 | void stopNote(float velocity, bool allowTailOff) override {
227 | if (allowTailOff) {
228 | ampEnvelope.noteOff();
229 | filterEnvelope.noteOff();
230 |
231 | } else {
232 | level = 0;
233 | ampEnvelope.reset();
234 | filterEnvelope.reset();
235 | clearCurrentNote();
236 | }
237 | }
238 |
239 | void controllerMoved(int controllerNumber, int newControllerValue) override {}
240 |
241 | void renderNextBlock(AudioBuffer &buffer, int startSample, int numSamples) override {
242 | auto* left = buffer.getWritePointer(0);
243 | auto* right = buffer.getWritePointer(1);
244 |
245 | // Approximated function to reduce volume as number of oscs increases. I didn't do the actual
246 | // maths here to figure out what the function should be , just went for a function that gave a
247 | // pleasing response curve to it.
248 | float unisonScaleFactor = 3.0f / sqrt(4.0f + (float)activeUnisonOscs);
249 |
250 | filter.setCutoffFrequency(cutoff);
251 | filter.setResonance(resonance);
252 |
253 | // Save CPU if the voice is not currently playing
254 | if (!ampEnvelope.isActive()) {
255 | clearCurrentNote();
256 | return;
257 | }
258 |
259 | for (auto sample = startSample; sample < startSample + numSamples; ++sample) {
260 | auto outL = 0.0f;
261 | auto outR = 0.0f;
262 | auto envelopeValue = ampEnvelope.getNextSample();
263 | auto filterEnvValue = filterEnvelope.getNextSample();
264 |
265 | for (int i = 0; i < activeUnisonOscs; i++) {
266 | auto &o = oscillators[i];
267 | float rPan = (o.pan + 1) / 2;
268 | float lPan = 1.0f - rPan;
269 |
270 | float wave = saw(o.angle);
271 | float shaped = std::clamp(float(wave + copysign(shape, wave)), -1.0f, 1.0f);
272 |
273 | outL += unisonScaleFactor * shaped * lPan;
274 | outR += unisonScaleFactor * shaped * rPan;
275 | o.angle += o.increment;
276 | if (o.angle > TAU) o.angle -= TAU;
277 | }
278 |
279 | float cutoffWithEnv = cutoff * pow(2.0f, (filterEnv * 4.0f * filterEnvValue));
280 | filter.setCutoffFrequency(cutoffWithEnv > 20000.0f ? 20000.0f : cutoffWithEnv);
281 |
282 | left[sample] += shapeCompoundWave(filter.processSample(0, outL), dirt) * level * envelopeValue;
283 | right[sample] += shapeCompoundWave(filter.processSample(1, outR), dirt) * level * envelopeValue;
284 | }
285 |
286 | if (!ampEnvelope.isActive()) {
287 | clearCurrentNote();
288 | }
289 |
290 | }
291 | };
292 |
--------------------------------------------------------------------------------
/src/CryptAudioProcessorEditor.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2025 David Whiting
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 | */
17 | #pragma once
18 |
19 | #include
20 | #include "CryptAudioProcessor.hpp"
21 |
22 | const Colour CRYPT_BLUE = Colour::fromString("ff60a5ca");
23 |
24 | class EmbeddedFonts {
25 | private:
26 | Font gothicaBook;
27 |
28 | public:
29 | EmbeddedFonts() {
30 | gothicaBook = Font(Typeface::createSystemTypefaceFor(BinaryData::GothicaBook_ttf, BinaryData::GothicaBook_ttfSize));
31 | }
32 | const Font& getGothicaBook() const {
33 | return gothicaBook;
34 | }
35 | };
36 |
37 | EmbeddedFonts& getFonts()
38 | {
39 | static EmbeddedFonts fonts;
40 | return fonts;
41 | }
42 |
43 |
44 | class CryptLookAndFeel: public LookAndFeel_V4 {
45 | public:
46 | CryptLookAndFeel() {
47 | auto thumb = CRYPT_BLUE;
48 | auto& fonts = getFonts();
49 | this->setColour(Slider::ColourIds::thumbColourId, thumb);
50 | this->setColour(Slider::ColourIds::trackColourId, Colours::orange);
51 | this->setColour(Slider::ColourIds::backgroundColourId, Colours::black);
52 | this->setColour(Slider::ColourIds::rotarySliderFillColourId, thumb);
53 | this->setColour(Slider::ColourIds::rotarySliderOutlineColourId, Colours::black);
54 | this->setColour(Slider::ColourIds::textBoxOutlineColourId, Colours::transparentBlack);
55 | this->setColour(Label::outlineColourId, Colours::transparentBlack);
56 | this->setColour(HyperlinkButton::ColourIds::textColourId, CRYPT_BLUE);
57 |
58 | this->setColour(MidiKeyboardComponent::ColourIds::blackNoteColourId, CRYPT_BLUE.darker(0.6f));
59 | this->setColour(MidiKeyboardComponent::ColourIds::whiteNoteColourId, Colours::black);
60 | this->setColour(MidiKeyboardComponent::ColourIds::keySeparatorLineColourId, CRYPT_BLUE);
61 | this->setColour(MidiKeyboardComponent::ColourIds::mouseOverKeyOverlayColourId, CRYPT_BLUE);
62 | this->setColour(MidiKeyboardComponent::ColourIds::keyDownOverlayColourId, CRYPT_BLUE);
63 | this->setColour(MidiKeyboardComponent::ColourIds::textLabelColourId, CRYPT_BLUE);
64 | this->setColour(MidiKeyboardComponent::ColourIds::shadowColourId, Colours::transparentWhite);
65 |
66 | this->setDefaultSansSerifTypeface(fonts.getGothicaBook().getTypefacePtr());
67 |
68 | }
69 |
70 | // After numerous attempts to remove the box from the value label with conventional methods I just gave up and overrid it here
71 | void drawLabel (Graphics& g, Label& label) override {
72 | g.fillAll (label.findColour (Label::backgroundColourId));
73 |
74 | if (! label.isBeingEdited())
75 | {
76 | auto alpha = label.isEnabled() ? 1.0f : 0.5f;
77 | const Font font (getLabelFont (label));
78 |
79 | g.setColour (label.findColour (Label::textColourId).withMultipliedAlpha (alpha));
80 | g.setFont (font);
81 |
82 | auto textArea = getLabelBorderSize (label).subtractedFrom (label.getLocalBounds());
83 |
84 | g.drawFittedText (label.getText(), textArea, label.getJustificationType(),
85 | jmax (1, (int) ((float) textArea.getHeight() / font.getHeight())),
86 | label.getMinimumHorizontalScale());
87 | }
88 | else if (label.isEnabled())
89 | {
90 | g.setColour (label.findColour (Label::outlineColourId));
91 | }
92 | }
93 |
94 | void drawRotarySlider (Graphics& g, int x, int y, int width, int height, float sliderPos,
95 | const float rotaryStartAngle, const float rotaryEndAngle, Slider& slider) override {
96 | auto outline = slider.findColour (Slider::rotarySliderOutlineColourId);
97 | auto fill = slider.findColour (Slider::rotarySliderFillColourId);
98 |
99 | auto bounds = Rectangle (x, y, width, height).toFloat().reduced (3);
100 |
101 | auto radius = jmin (bounds.getWidth(), bounds.getHeight()) / 2.0f;
102 | auto toAngle = rotaryStartAngle + sliderPos * (rotaryEndAngle - rotaryStartAngle);
103 | auto lineW = jmin (8.0f, radius * 0.2f);
104 | auto arcRadius = radius - lineW * 0.2f;
105 |
106 | Path backgroundArc;
107 | backgroundArc.addCentredArc (bounds.getCentreX(),
108 | bounds.getCentreY(),
109 | arcRadius,
110 | arcRadius,
111 | 0.0f,
112 | rotaryStartAngle,
113 | rotaryEndAngle,
114 | true);
115 |
116 | g.setColour (outline);
117 | g.strokePath (backgroundArc, PathStrokeType (lineW, PathStrokeType::curved, PathStrokeType::rounded));
118 |
119 | if (slider.isEnabled())
120 | {
121 | Path valueArc;
122 | valueArc.addCentredArc (bounds.getCentreX(),
123 | bounds.getCentreY(),
124 | arcRadius,
125 | arcRadius,
126 | 0.0f,
127 | rotaryStartAngle,
128 | toAngle,
129 | true);
130 |
131 | g.setColour (fill);
132 | g.strokePath (valueArc, PathStrokeType (lineW, PathStrokeType::curved, PathStrokeType::rounded));
133 | }
134 |
135 | auto thumbWidth = lineW * 2.0f;
136 | Point thumbPoint (bounds.getCentreX() + arcRadius * std::cos (toAngle - MathConstants::halfPi),
137 | bounds.getCentreY() + arcRadius * std::sin (toAngle - MathConstants::halfPi));
138 |
139 | g.setColour (slider.findColour (Slider::thumbColourId));
140 | g.drawLine(bounds.getCentreX(), bounds.getCentreY(), thumbPoint.getX(), thumbPoint.getY(),2);
141 | }
142 |
143 | };
144 |
145 | class LabelledDial: public Component {
146 | private:
147 | AudioProcessorValueTreeState &state;
148 | Slider slider;
149 | Label label;
150 | AudioProcessorValueTreeState::SliderAttachment attachment;
151 |
152 | public:
153 | LabelledDial(AudioProcessorValueTreeState &state, StringRef parameterId, StringRef labelText = "", StringRef suffix = ""):
154 | state(state),
155 | slider(),
156 | attachment(state, parameterId, slider)
157 | {
158 | auto& fonts = getFonts();
159 | slider.setSliderStyle(Slider::SliderStyle::RotaryHorizontalVerticalDrag);
160 | if (suffix.isNotEmpty()) {
161 | slider.setTextValueSuffix(suffix);
162 |
163 | }
164 |
165 | slider.setTextBoxStyle(juce::Slider::TextBoxBelow, false, 70, 20);
166 |
167 | if (labelText.isEmpty()) {
168 | label.setText(CryptParameters::getLabel(parameterId),NotificationType::dontSendNotification);
169 | } else {
170 | label.setText(labelText,NotificationType::dontSendNotification);
171 | }
172 | label.setJustificationType(Justification::centred);
173 | label.setFont(fonts.getGothicaBook().withHeight(20));
174 | addAndMakeVisible(slider);
175 | addAndMakeVisible(label);
176 | }
177 |
178 | void resized() override {
179 | auto area = getLocalBounds();
180 | label.setBounds(area.removeFromTop(20));
181 | slider.setBounds(area);
182 | }
183 | };
184 |
185 | class ControlGroup: public GroupComponent {
186 | private:
187 | String title;
188 | AudioProcessorValueTreeState &state;
189 | std::vector> controls;
190 | Component* visualiser;
191 |
192 | public:
193 |
194 | ControlGroup(StringRef title, AudioProcessorValueTreeState &state, std::list parameters, Component* visualiser = nullptr): title(title), state(state), visualiser(visualiser) {
195 | for (auto param: parameters) {
196 | auto x = std::make_unique(state, param, CryptParameters::getLabel(param), CryptParameters::getUnit(param));
197 | addAndMakeVisible(*x);
198 | controls.push_back(std::move(x));
199 | }
200 | if (visualiser) {
201 | addAndMakeVisible(*visualiser);
202 | }
203 |
204 | setText(title);
205 | }
206 |
207 | void resized() override {
208 | auto contentsBounds = getLocalBounds().reduced(20);
209 |
210 | int width = contentsBounds.getWidth();
211 | int height = 80;
212 |
213 | int nControls = controls.size();
214 |
215 | auto controlBounds = contentsBounds.removeFromTop(height);
216 | if (visualiser) {
217 | visualiser->setBounds(contentsBounds);
218 | }
219 |
220 | float controlWidth = width / nControls;
221 | for (int i = 0 ; i < nControls; i++) {
222 | auto &c = controls[i];
223 | c->setBounds({controlBounds.getX() + i * (int)controlWidth, controlBounds.getY(), (int)controlWidth, height});
224 | }
225 | }
226 |
227 | };
228 |
229 | class ADSREditor: public GroupComponent {
230 |
231 | class Viewer: public Component, public AudioProcessorValueTreeState::Listener, private AsyncUpdater {
232 | private:
233 | AudioProcessorValueTreeState &state;
234 | String prefix;
235 | String attackParam, decayParam, sustainParam, releaseParam;
236 |
237 | void handleAsyncUpdate() override {
238 | repaint();
239 | }
240 |
241 | public:
242 | Viewer(String prefix, AudioProcessorValueTreeState &state)
243 | : prefix(prefix),
244 | state(state),
245 | attackParam(prefix + CryptParameters::Attack),
246 | decayParam(prefix + CryptParameters::Decay),
247 | sustainParam(prefix + CryptParameters::Sustain),
248 | releaseParam(prefix + CryptParameters::Release) {
249 |
250 | state.addParameterListener(attackParam, this);
251 | state.addParameterListener(decayParam, this);
252 | state.addParameterListener(sustainParam, this);
253 | state.addParameterListener(releaseParam, this);
254 | }
255 |
256 | ~Viewer() {
257 | state.removeParameterListener(attackParam, this);
258 | state.removeParameterListener(decayParam, this);
259 | state.removeParameterListener(sustainParam, this);
260 | state.removeParameterListener(releaseParam, this);
261 | }
262 |
263 | void parameterChanged (const String& parameterID, float newValue) override {
264 | triggerAsyncUpdate();
265 | }
266 |
267 | void paint (juce::Graphics& graphics) override {
268 | auto width = getWidth();
269 | auto height = getHeight();
270 |
271 | graphics.fillAll(Colours::black);
272 |
273 | float attack = *state.getRawParameterValue(attackParam);
274 | float decay = *state.getRawParameterValue(decayParam);
275 | float sustain = *state.getRawParameterValue(sustainParam);
276 | float release = *state.getRawParameterValue(releaseParam);
277 |
278 | auto totalTime = attack + decay + release + 1.0;
279 | float xScale = (double) width / totalTime;
280 | float yScale = height-10;
281 |
282 | graphics.setColour(Colours::darkgrey.withAlpha(0.7f));
283 | auto step = totalTime < 2.0 ? 0.1 : totalTime < 8.0 ? 0.5 : 1.0;
284 | for (auto x = 0.0; x < totalTime; x += step) {
285 | if (x < attack + decay || x > attack + decay + 1.0) {
286 | graphics.fillRect(x * xScale, 0, 1, height);
287 | }
288 | }
289 |
290 | graphics.setColour(CRYPT_BLUE);
291 |
292 |
293 | Point start(0, yScale+5),
294 | peak(xScale * attack, 5),
295 | sus1(xScale * (attack + decay), yScale * (1-sustain)+5),
296 | sus2(xScale * (attack + decay + 1.0), yScale * (1-sustain)+5),
297 | end(width, yScale+5);
298 |
299 | float curve = 0;
300 | Path path;
301 | path.startNewSubPath({0.0f, yScale+5});
302 |
303 | path.cubicTo(start.translated(curve,0), peak.translated(-curve, 0), peak);
304 | path.cubicTo(peak.translated(curve,0), sus1.translated(-curve,0), sus1);
305 | path.cubicTo(sus1.translated(curve,0), sus2.translated(-curve,0), sus2);
306 |
307 | path.cubicTo(sus2.translated(curve,0), end.translated(-curve,0), end);
308 |
309 |
310 | PathStrokeType s(2);
311 |
312 | graphics.strokePath(path, s);
313 |
314 | }
315 | };
316 |
317 | private:
318 | LabelledDial a, d, s, r;
319 | Viewer viewer;
320 |
321 | public:
322 | ADSREditor(AudioProcessorValueTreeState& state, String prefix, StringRef title):
323 | a(state, prefix + CryptParameters::Attack, "A", CryptParameters::getUnit(CryptParameters::Attack)),
324 | d(state, prefix + CryptParameters::Decay, "D", CryptParameters::getUnit(CryptParameters::Decay)),
325 | s(state, prefix + CryptParameters::Sustain, "S", CryptParameters::getUnit(CryptParameters::Sustain)),
326 | r(state, prefix + CryptParameters::Release, "R", CryptParameters::getUnit(CryptParameters::Release)),
327 | viewer(prefix, state) {
328 |
329 | addAndMakeVisible(a);
330 | addAndMakeVisible(d);
331 | addAndMakeVisible(s);
332 | addAndMakeVisible(r);
333 |
334 | addAndMakeVisible(viewer);
335 | setText(title);
336 | }
337 |
338 | void resized() override {
339 | auto bounds = getLocalBounds().reduced(15);
340 | auto adsr = bounds.removeFromTop(80);
341 | auto controlWidth = adsr.getWidth() / 4;
342 | a.setBounds(adsr.removeFromLeft(controlWidth));
343 | d.setBounds(adsr.removeFromLeft(controlWidth));
344 | s.setBounds(adsr.removeFromLeft(controlWidth));
345 | r.setBounds(adsr.removeFromLeft(controlWidth));
346 | viewer.setBounds(bounds);
347 | }
348 |
349 | };
350 |
351 |
352 | class DelayDisplay: public Component, public AudioProcessorValueTreeState::Listener, private AsyncUpdater {
353 | private:
354 | float delayTime = 100.0f;
355 | float delayMix = 0.3f;
356 | float delayFeedback = 0.5;
357 |
358 | AudioProcessorValueTreeState &state;
359 |
360 | void handleAsyncUpdate() override
361 | {
362 | repaint();
363 | }
364 |
365 | public:
366 | DelayDisplay(AudioProcessorValueTreeState &state): state(state) {
367 | state.addParameterListener(CryptParameters::DelayTime, this);
368 | state.addParameterListener(CryptParameters::DelayFeedback, this);
369 | state.addParameterListener(CryptParameters::DelayMix, this);
370 | delayTime = *state.getRawParameterValue(CryptParameters::DelayTime);
371 | delayFeedback =*state.getRawParameterValue(CryptParameters::DelayFeedback);
372 | delayMix = *state.getRawParameterValue(CryptParameters::DelayMix);
373 | }
374 |
375 | ~DelayDisplay() {
376 | state.removeParameterListener(CryptParameters::DelayTime, this);
377 | state.removeParameterListener(CryptParameters::DelayFeedback, this);
378 | state.removeParameterListener(CryptParameters::DelayMix, this);
379 | }
380 |
381 | void parameterChanged (const String& parameterID, float newValue) override {
382 | if (parameterID == CryptParameters::DelayTime) {
383 | delayTime = newValue;
384 | } else if (parameterID == CryptParameters::DelayFeedback) {
385 | delayFeedback = newValue;
386 | } else if (parameterID == CryptParameters::DelayMix) {
387 | delayMix = newValue;
388 | }
389 | triggerAsyncUpdate();
390 | }
391 | void paint(Graphics &g) override {
392 |
393 | Rectangle bounds = getLocalBounds().reduced(10);
394 |
395 | // we're thinking in ms
396 | float xResolution = 4000;
397 | g.setColour(CRYPT_BLUE);
398 | g.fillRect(bounds.getX(), bounds.getY(), 5, bounds.getHeight());
399 | float amount = 1.0f;
400 | float x = 0;
401 | g.setColour(CRYPT_BLUE.withAlpha(delayMix * 0.7f + 0.3f));
402 | while (amount > 0.01 && x < xResolution) {
403 | x += delayTime;
404 | auto h = amount * bounds.getHeight();
405 | g.fillRect(bounds.getX() + (x / xResolution) * (float)bounds.getWidth(), (float)bounds.getCentreY() - h/2, 5.0f, h);
406 | amount *= delayFeedback;
407 | }
408 |
409 |
410 | }
411 | };
412 |
413 | // Oscillator visualiser in the oscillator section
414 | class OscDisplay: public Component, public AudioProcessorValueTreeState::Listener, private AsyncUpdater {
415 | private:
416 | AudioProcessorValueTreeState &state;
417 |
418 | static inline float saw(float angle) {
419 | return (2.0f * angle/TAU) - 1;
420 | }
421 |
422 | static inline float square(float angle) {
423 | return angle < (TAU / 2) ? -1.0f : 1.0f;
424 | }
425 |
426 | static inline float cycle(float angle) {
427 | return angle - static_cast(angle / TAU) * TAU;
428 | }
429 |
430 | void handleAsyncUpdate() override
431 | {
432 | repaint();
433 | }
434 |
435 | public:
436 | OscDisplay(AudioProcessorValueTreeState &state): state(state) {
437 | state.addParameterListener(CryptParameters::Shape, this);
438 | state.addParameterListener(CryptParameters::Unison, this);
439 | state.addParameterListener(CryptParameters::Spread, this);
440 | }
441 |
442 | ~OscDisplay() {
443 | state.removeParameterListener(CryptParameters::Shape, this);
444 | state.removeParameterListener(CryptParameters::Unison, this);
445 | state.removeParameterListener(CryptParameters::Spread, this);
446 | }
447 |
448 | void parameterChanged (const String& parameterID, float newValue) override {
449 |
450 | triggerAsyncUpdate();
451 | }
452 | void paint(Graphics &g) override {
453 |
454 | float shape = *state.getRawParameterValue(CryptParameters::Shape);
455 | int unison = static_cast(*state.getRawParameterValue(CryptParameters::Unison));
456 | float spread = *state.getRawParameterValue(CryptParameters::Spread);
457 |
458 | DBG("shape = " << shape << " unison = " << unison << " spread = " << spread);
459 |
460 | auto bounds = getLocalBounds();
461 | Path p;
462 | p.startNewSubPath(0,bounds.getHeight()/2);
463 | for (auto xp = 0; xp < bounds.getWidth(); xp++) {
464 | auto x = jmap((float)xp/bounds.getWidth(), 0, TAU * 8);
465 | auto angle = cycle(x);
466 | auto y = - shape * square(angle) - (1.0f - shape) * saw(angle);
467 | auto yp = jmap((y + 1) / 2, bounds.getHeight() * 0.2, bounds.getHeight() * 0.8);
468 | p.lineTo(xp, yp);
469 | }
470 |
471 | g.setColour(CRYPT_BLUE.withAlpha(0.5f));
472 | for (auto i = 0 ; i < unison; i++) {
473 | float vSpread = (((float)i / unison)* 2.0 - 1.0) * spread * 10;
474 | float distance = vSpread * 30;
475 |
476 | auto transform = AffineTransform::translation(-getWidth()/2.0, 0).scaled((4.0 + vSpread)/4.0, 1.0).translated(getWidth()/2.0, distance);
477 |
478 | g.strokePath(p, PathStrokeType(1), transform);
479 | }
480 | }
481 | };
482 |
483 | // Waveform display running down the middle
484 | class WaveformDisplay: public Component, Timer {
485 | private:
486 | DrawableImage i;
487 | Image img;
488 | SharedBuffer & buffer;
489 | public:
490 |
491 | WaveformDisplay(SharedBuffer & buffer): buffer(buffer), img(Image::PixelFormat::ARGB, 200,500,true) {
492 | i.setImage(img);
493 |
494 | addAndMakeVisible(i);
495 | startTimerHz(30);
496 | }
497 |
498 |
499 | void resized() override {
500 | i.setBounds(getLocalBounds());
501 | i.setTransformToFit(getLocalBounds().toFloat(), RectanglePlacement::stretchToFit);
502 | }
503 |
504 | void timerCallback() override {
505 | update();
506 | }
507 |
508 | float taperFunction(float x) {
509 | return x < 0.5f ? cos((x - 0.5f) * TAU)/2 + 0.5f : 1.0f;
510 | }
511 |
512 | void update() {
513 | img.clear(img.getBounds(), Colours::transparentBlack);
514 | Graphics g(i.getImage());
515 |
516 | buffer.read();
517 | auto & displayBuffer = buffer.get();
518 |
519 | auto area = g.getClipBounds();
520 |
521 | Path waveformPath;
522 | waveformPath.startNewSubPath(area.getCentreX(), 0);
523 |
524 | float max = 0.01f;
525 | for (size_t i = 0; i < displayBuffer.size(); ++i) {
526 | if (abs(displayBuffer[i]) > max) {
527 | max = abs(displayBuffer[i]);
528 | }
529 | }
530 |
531 | float scaleFactor = 0.7f / max;
532 | float dbSize = displayBuffer.size();
533 |
534 | for (size_t i = 0; i < dbSize; ++i)
535 | {
536 | auto value = displayBuffer[i] * scaleFactor * taperFunction((float)i / dbSize);
537 | auto x = jmap(value, -1.0f, 1.0f, area.getRight(), area.getX());
538 | auto y = jmap(i, 0, displayBuffer.size(), 0, area.getHeight());
539 | waveformPath.lineTo(x, y);
540 | }
541 | g.setColour (CRYPT_BLUE.withAlpha(0.5f));
542 | g.strokePath(waveformPath, PathStrokeType(6.0f));
543 |
544 | g.setColour (Colours::white);
545 | g.strokePath(waveformPath, PathStrokeType(2.0f));
546 |
547 | const MessageManagerLock mml;
548 | if (mml.lockWasGained()) {
549 | repaint();
550 | }
551 | }
552 | };
553 |
554 | class KeyboardToggleButton: public Button {
555 |
556 | private:
557 | Image keyboardIcon;
558 | bool isEnabled;
559 |
560 | protected:
561 | void paintButton(Graphics& g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) {
562 | auto mainColor = CRYPT_BLUE;
563 |
564 | g.setColour(CRYPT_BLUE.withAlpha((isEnabled ? 0.8f : 0.4f) + (shouldDrawButtonAsHighlighted ? 0.1f : 0.0f) + (shouldDrawButtonAsDown ? 0.1f : 0.0f)));
565 |
566 | g.drawImage(keyboardIcon, getLocalBounds().toFloat().reduced(10), RectanglePlacement::stretchToFit, true);
567 | }
568 |
569 | public:
570 | KeyboardToggleButton(): Button("Key"), keyboardIcon(ImageCache::getFromMemory(BinaryData::keyboardicon_png, BinaryData::keyboardicon_pngSize)) {
571 | }
572 |
573 | void setEnabled(bool enabled) {
574 | isEnabled = enabled;
575 | repaint();
576 | }
577 |
578 |
579 | };
580 |
581 | class CryptKeyboardComponent: public MidiKeyboardComponent {
582 | public:
583 |
584 | CryptKeyboardComponent(MidiKeyboardState &state): MidiKeyboardComponent(state, MidiKeyboardComponent::horizontalKeyboard) {}
585 |
586 | void drawBlackNote (int /*midiNoteNumber*/, Graphics& g, Rectangle area,
587 | bool isDown, bool isOver, Colour noteFillColour) override {
588 | auto c = noteFillColour;
589 |
590 | if (isDown) c = c.overlaidWith (findColour (keyDownOverlayColourId));
591 | if (isOver) c = c.overlaidWith (findColour (mouseOverKeyOverlayColourId));
592 |
593 | g.setColour (c);
594 | g.fillRect (area);
595 |
596 | if (isDown)
597 | {
598 | g.setColour (noteFillColour);
599 | g.drawRect (area);
600 | }
601 | else
602 | {
603 | // This used to be where the shadow got drawn, but I overrid this method to remove it to
604 | // give myself a flat keyboard
605 | }
606 | }
607 | };
608 |
609 |
610 | /** GUI for the plugin */
611 | class CryptAudioProcessorEditor: public AudioProcessorEditor, public Button::Listener, public ComboBox::Listener {
612 | private:
613 | // Must come first so it's destroyed last
614 | CryptLookAndFeel lookAndFeel;
615 |
616 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CryptAudioProcessorEditor)
617 |
618 | CryptAudioProcessor & processor;
619 |
620 | WaveformDisplay visualiser;
621 |
622 | CryptKeyboardComponent keyboard;
623 | OscDisplay oscDisplay;
624 | DelayDisplay delayDisplay;
625 |
626 | ADSREditor ampEnv, filterEnv;
627 | ControlGroup osc, filter, phaser, delay, theVoid, global;
628 | Label pluginTitle;
629 |
630 | ComboBox presets;
631 | TextButton save;
632 | TextButton load;
633 |
634 | HyperlinkButton bowchurch;
635 | HyperlinkButton vitling;
636 | HyperlinkButton donate;
637 |
638 | TooltipWindow tooltipWindow;
639 |
640 | KeyboardToggleButton keyboardButton;
641 | bool keyboardIsVisible = false;
642 | const int keyboardHeight = 75;
643 |
644 | Image keyboardButtonImage;
645 |
646 | std::unique_ptr fileChooser;
647 |
648 | Label versionNumber;
649 |
650 | public:
651 |
652 | /** Set up the editor */
653 | explicit CryptAudioProcessorEditor(CryptAudioProcessor &processor):
654 | AudioProcessorEditor(processor),
655 | processor(processor),
656 | keyboard(processor.keyboardState),
657 | visualiser(processor.oscBuffer),
658 | ampEnv(processor.state, CryptParameters::Amplitude + ".", "Amp Env"),
659 | filterEnv(processor.state, CryptParameters::Filter + ".", "Filter Env"),
660 | oscDisplay(processor.state),
661 | delayDisplay(processor.state),
662 | osc("Oscillator", processor.state, {CryptParameters::Unison, CryptParameters::Spread, CryptParameters::Shape}, &oscDisplay),
663 | filter("Filter", processor.state, {CryptParameters::Cutoff, CryptParameters::Resonance, CryptParameters::FilterEnv}),
664 | phaser("Phaser", processor.state, {CryptParameters::PhaserDepth, CryptParameters::PhaserRate, CryptParameters::PhaserMix}),
665 | delay("Delay", processor.state, {CryptParameters::DelayTime, CryptParameters::DelayFeedback, CryptParameters::DelayMix}, &delayDisplay),
666 | theVoid("Void", processor.state, {CryptParameters::Dirt, CryptParameters::Space}),
667 | global("Globals", processor.state, {CryptParameters::PitchBendRange, CryptParameters::Master}),
668 | tooltipWindow(this) {
669 |
670 | setLookAndFeel(&lookAndFeel);
671 | auto& fonts = getFonts();
672 |
673 | pluginTitle.setText("CRYPT",NotificationType::dontSendNotification);
674 | pluginTitle.setFont(fonts.getGothicaBook().withHeight(40));
675 | pluginTitle.setJustificationType(Justification::horizontallyCentred);
676 |
677 | setSize(1000,625);
678 | setResizable(true, true);
679 |
680 | setResizeLimits(800,625,1000,625);
681 |
682 | addAndMakeVisible(ampEnv);
683 | addAndMakeVisible(filterEnv);
684 | addAndMakeVisible(osc);
685 | addAndMakeVisible(filter);
686 | addAndMakeVisible(phaser);
687 | addAndMakeVisible(delay);
688 | addAndMakeVisible(theVoid);
689 | addAndMakeVisible(global);
690 | addAndMakeVisible(pluginTitle);
691 | addAndMakeVisible(visualiser);
692 |
693 | auto presetNames = processor.presetManager.listPresets();
694 | int n = 1;
695 | for (auto presetName: presetNames) {
696 | presets.addItem(presetName, n++);
697 | }
698 |
699 | presets.addListener(this);
700 | addAndMakeVisible(presets);
701 |
702 | presets.setTextWhenNothingSelected("-- presets --");
703 |
704 | bowchurch.setButtonText("bow church");
705 | vitling.setButtonText("vitling");
706 | donate.setButtonText("contribute");
707 | bowchurch.setURL(URL{"https://www.vitling.xyz/ext/crypt/bowchurch"});
708 | vitling.setURL(URL{"https://www.vitling.xyz/ext/crypt/vitling"});
709 | donate.setURL(URL{"https://www.vitling.xyz/ext/crypt/donate"});
710 |
711 | bowchurch.setFont(fonts.getGothicaBook().withHeight(24.0f), false);
712 | vitling.setFont(fonts.getGothicaBook().withHeight(24.0f), false);
713 | donate.setFont(fonts.getGothicaBook().withHeight(24.0f), false);
714 | bowchurch.setTooltip("");
715 | vitling.setTooltip("");
716 |
717 | donate.setTooltip("If you find this plugin useful, please contribute a few euros to the development of this and future plugins");
718 |
719 | addAndMakeVisible(bowchurch);
720 | addAndMakeVisible(vitling);
721 | addAndMakeVisible(donate);
722 |
723 | save.setButtonText("Save");
724 | load.setButtonText("Load");
725 |
726 | addAndMakeVisible(save);
727 | addAndMakeVisible(load);
728 |
729 | save.addListener(this);
730 | load.addListener(this);
731 |
732 | keyboardButton.addListener(this);
733 |
734 | addAndMakeVisible(keyboardButton);
735 | addAndMakeVisible(keyboard);
736 | keyboard.setVisible(keyboardIsVisible);
737 | keyboard.setBounds({ 0,625,1000,keyboardHeight });
738 |
739 | versionNumber.setText(String {"v"} + ProjectInfo::versionString, NotificationType::dontSendNotification);
740 | addAndMakeVisible(versionNumber);
741 |
742 | resized();
743 |
744 | }
745 |
746 | ~CryptAudioProcessorEditor() {
747 | setLookAndFeel(nullptr);
748 | }
749 |
750 | void buttonClicked (Button* button) override {
751 | if (button == &save) {
752 | openSaveDialog();
753 | } else if (button == &load) {
754 | openLoadDialog();
755 | } else if (button == &keyboardButton) {
756 | keyboardIsVisible = !keyboardIsVisible;
757 | if (keyboardIsVisible) {
758 | setResizeLimits(800,625 + keyboardHeight,1000,625 + keyboardHeight);
759 | } else {
760 | setResizeLimits(800,625,1000,625);
761 | }
762 | keyboard.setVisible(keyboardIsVisible);
763 | keyboardButton.setEnabled(keyboardIsVisible);
764 | resized();
765 | }
766 | };
767 |
768 | void openLoadDialog() {
769 | fileChooser = std::make_unique("Load preset", File::getSpecialLocation(File::userHomeDirectory), "*.crypt");
770 | auto flags = FileBrowserComponent::openMode | FileBrowserComponent::canSelectFiles;
771 | fileChooser->launchAsync(flags, [this] (const FileChooser& chooser) {
772 | File file (chooser.getResult());
773 | if (file.getFileName().isEmpty()) {
774 | DBG("No file selected");
775 | } else {
776 | auto result = XmlDocument::parse(file);
777 | if (result != nullptr) {
778 | if (result->hasTagName(processor.state.state.getType())) {
779 | processor.state.replaceState(ValueTree::fromXml(*result));
780 | presets.setSelectedId(0, NotificationType::dontSendNotification);
781 | presets.setTextWhenNothingSelected(file.getFileName());
782 | }
783 | }
784 | }
785 | });
786 | }
787 |
788 | void openSaveDialog() {
789 | fileChooser = std::make_unique("Save preset", File::getSpecialLocation(File::userHomeDirectory), "*.crypt");
790 | auto flags = FileBrowserComponent::saveMode;
791 |
792 | fileChooser->launchAsync(flags, [this] (const FileChooser& chooser) {
793 | File file (chooser.getResult());
794 | if (file.getFileName().isEmpty()) {
795 | DBG("Cancelled save");
796 | } else {
797 | DBG("Saving to: " << file.getFullPathName());
798 | auto currentState = processor.state.copyState();
799 | std::unique_ptr xml (currentState.createXml());
800 | xml->writeTo(file);
801 | presets.setSelectedId(0, NotificationType::dontSendNotification);
802 | presets.setTextWhenNothingSelected(file.getFileName());
803 | }
804 | });
805 | }
806 |
807 | void comboBoxChanged (ComboBox* comboBoxThatHasChanged) override {
808 | processor.presetManager.applyPreset(comboBoxThatHasChanged->getSelectedId(), processor.state);
809 | }
810 |
811 | void resized() override {
812 |
813 | auto totalBounds = getLocalBounds();
814 | auto titleBar = totalBounds.removeFromTop(50);
815 |
816 | if (keyboardIsVisible) {
817 | auto keyboardBounds = totalBounds.removeFromBottom(keyboardHeight);
818 | keyboard.setBounds(keyboardBounds);
819 | }
820 |
821 | Rectangle titleText = {titleBar.getCentreX()-102, titleBar.getY(), 200, titleBar.getHeight()};
822 | pluginTitle.setBounds(titleText);
823 |
824 | Rectangle bcBounds = titleBar.withLeft(titleBar.getWidth() - 250).withWidth(150);
825 | Rectangle vitBounds = titleBar.withLeft(titleBar.getWidth() - 100);
826 | Rectangle donateBounds = titleBar.withLeft(titleBar.getWidth() - 350).withWidth(100);
827 | bowchurch.setBounds(bcBounds);
828 | vitling.setBounds(vitBounds);
829 | donate.setBounds(donateBounds);
830 |
831 | presets.setBounds(titleBar.removeFromLeft(200).reduced(10));
832 |
833 | save.setBounds(Rectangle{270,0,70,50}.reduced(10));
834 | load.setBounds(Rectangle{200,0,70,50}.reduced(10));
835 |
836 |
837 | auto leftBounds = totalBounds.removeFromLeft(400);
838 | auto rightBounds = totalBounds.removeFromRight(400);
839 |
840 | visualiser.setBounds(totalBounds.withTrimmedTop(-8));
841 |
842 | // I know it seems a bit silly to use StretchableLayoutManagers for each side when they don't actually stretch,
843 | // but I started with the idea of making it more responsive and only decided to fix it later, and this is working
844 | // fine still and it lets me switch out orders etc. relatively simply or add responsiveness later
845 | StretchableLayoutManager leftLayout;
846 | Component* leftComponents[] = {&osc, &Env, &filter};
847 | leftLayout.setItemLayout(0, 250,250,250);
848 | leftLayout.setItemLayout(1, 200,200,200);
849 | leftLayout.setItemLayout(2, 125,125,125);
850 | leftLayout.layOutComponents(leftComponents, 3, leftBounds.getX(), leftBounds.getY(), leftBounds.getWidth(), leftBounds.getHeight(), true, true);
851 |
852 | auto envBounds = ampEnv.getBounds();
853 | auto ampEnvBounds = envBounds.removeFromLeft(envBounds.getWidth() / 2);
854 | ampEnv.setBounds(ampEnvBounds);
855 | filterEnv.setBounds(envBounds);
856 |
857 | StretchableLayoutManager rightLayout;
858 | Component* rightComponents[] = {&phaser, &delay, &theVoid, &global};
859 | rightLayout.setItemLayout(0, 125,125,125);
860 | rightLayout.setItemLayout(1, 200,200,200);
861 | rightLayout.setItemLayout(2, 125,125,125);
862 | rightLayout.setItemLayout(3, 125,125,125);
863 | rightLayout.layOutComponents(rightComponents, 4, rightBounds.getX(), rightBounds.getY(), rightBounds.getWidth(), rightBounds.getHeight(), true, true);
864 | global.setBounds(global.getBounds().withTrimmedRight(50));
865 | keyboardButton.setBounds({global.getRight(), global.getY() + 30, 50, 50});
866 | versionNumber.setBounds({global.getRight(), global.getY()+90, 50, 20});
867 | }
868 |
869 |
870 | void paint (juce::Graphics& graphics) override {
871 | auto image = ImageCache::getFromMemory(BinaryData::bg_jpg, BinaryData::bg_jpgSize);
872 | graphics.drawImageWithin(image, 0, 0, getWidth(), getHeight(), RectanglePlacement::fillDestination);
873 | }
874 | };
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
--------------------------------------------------------------------------------