commit 452c5cabba298619b885a56babe14fbc32fbb586 Author: VersusTune Date: Fri Apr 3 13:23:19 2020 +0200 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..64e5bdb --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/Builds/ +/JuceLibraryCode/ +.idea +.iml \ No newline at end of file diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp new file mode 100644 index 0000000..9901ebc --- /dev/null +++ b/Source/PluginEditor.cpp @@ -0,0 +1,28 @@ +#include "PluginProcessor.h" +#include "PluginEditor.h" +#include "Veno/Core/Config.h" + +//============================================================================== +VenoAudioProcessorEditor::VenoAudioProcessorEditor(VenoAudioProcessor &p) + : AudioProcessorEditor(&p), processor(p) { + Config::getInstance()->registerEditor(this, id); + LookAndFeel::setDefaultLookAndFeel(look); + setSize(400, 300); +} + +VenoAudioProcessorEditor::~VenoAudioProcessorEditor() { + LookAndFeel::setDefaultLookAndFeel(nullptr); + Config::getInstance()->removeEditor(id); + delete look; +} + +//============================================================================== +void VenoAudioProcessorEditor::paint(Graphics &g) { + g.fillAll(getLookAndFeel().findColour(ResizableWindow::backgroundColourId)); + g.setColour(Colours::white); + g.setFont(15.0f); + g.drawFittedText("Hello World!", getLocalBounds(), Justification::centred, 1); +} + +void VenoAudioProcessorEditor::resized() { +} diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h new file mode 100644 index 0000000..ed105e3 --- /dev/null +++ b/Source/PluginEditor.h @@ -0,0 +1,21 @@ +#pragma once + +#include +#include "PluginProcessor.h" +#include "Veno/GUI/LookAndFeel/LookHandler.h" + +class VenoAudioProcessorEditor : public AudioProcessorEditor +{ +public: + VenoAudioProcessorEditor (VenoAudioProcessor&); + ~VenoAudioProcessorEditor(); + void paint (Graphics&) override; + void resized() override; + +private: + VenoAudioProcessor& processor; + std::string id = Uuid().toString().toStdString(); + LookAndFeel_V4 *look = new LookHandler(); + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VenoAudioProcessorEditor) +}; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp new file mode 100644 index 0000000..5a80c66 --- /dev/null +++ b/Source/PluginProcessor.cpp @@ -0,0 +1,191 @@ +/* + ============================================================================== + + This file was auto-generated! + + It contains the basic framework code for a JUCE plugin processor. + + ============================================================================== +*/ + +#include "PluginProcessor.h" +#include "PluginEditor.h" + +//============================================================================== +VenoAudioProcessor::VenoAudioProcessor() +#ifndef JucePlugin_PreferredChannelConfigurations + : AudioProcessor (BusesProperties() + #if ! JucePlugin_IsMidiEffect + #if ! JucePlugin_IsSynth + .withInput ("Input", AudioChannelSet::stereo(), true) + #endif + .withOutput ("Output", AudioChannelSet::stereo(), true) + #endif + ) +#endif +{ +} + +VenoAudioProcessor::~VenoAudioProcessor() +{ +} + +//============================================================================== +const String VenoAudioProcessor::getName() const +{ + return JucePlugin_Name; +} + +bool VenoAudioProcessor::acceptsMidi() const +{ + #if JucePlugin_WantsMidiInput + return true; + #else + return false; + #endif +} + +bool VenoAudioProcessor::producesMidi() const +{ + #if JucePlugin_ProducesMidiOutput + return true; + #else + return false; + #endif +} + +bool VenoAudioProcessor::isMidiEffect() const +{ + #if JucePlugin_IsMidiEffect + return true; + #else + return false; + #endif +} + +double VenoAudioProcessor::getTailLengthSeconds() const +{ + return 0.0; +} + +int VenoAudioProcessor::getNumPrograms() +{ + return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, + // so this should be at least 1, even if you're not really implementing programs. +} + +int VenoAudioProcessor::getCurrentProgram() +{ + return 0; +} + +void VenoAudioProcessor::setCurrentProgram (int index) +{ +} + +const String VenoAudioProcessor::getProgramName (int index) +{ + return {}; +} + +void VenoAudioProcessor::changeProgramName (int index, const String& newName) +{ +} + +//============================================================================== +void VenoAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) +{ + // Use this method as the place to do any pre-playback + // initialisation that you need.. +} + +void VenoAudioProcessor::releaseResources() +{ + // When playback stops, you can use this as an opportunity to free up any + // spare memory, etc. +} + +#ifndef JucePlugin_PreferredChannelConfigurations +bool VenoAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const +{ + #if JucePlugin_IsMidiEffect + ignoreUnused (layouts); + return true; + #else + // This is the place where you check if the layout is supported. + // In this template code we only support mono or stereo. + if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() + && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) + return false; + + // This checks if the input layout matches the output layout + #if ! JucePlugin_IsSynth + if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) + return false; + #endif + + return true; + #endif +} +#endif + +void VenoAudioProcessor::processBlock (AudioBuffer& buffer, MidiBuffer& midiMessages) +{ + ScopedNoDenormals noDenormals; + auto totalNumInputChannels = getTotalNumInputChannels(); + auto totalNumOutputChannels = getTotalNumOutputChannels(); + + // In case we have more outputs than inputs, this code clears any output + // channels that didn't contain input data, (because these aren't + // guaranteed to be empty - they may contain garbage). + // This is here to avoid people getting screaming feedback + // when they first compile a plugin, but obviously you don't need to keep + // this code if your algorithm always overwrites all the output channels. + for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) + buffer.clear (i, 0, buffer.getNumSamples()); + + // This is the place where you'd normally do the guts of your plugin's + // audio processing... + // Make sure to reset the state if your inner loop is processing + // the samples and the outer loop is handling the channels. + // Alternatively, you can process the samples with the channels + // interleaved by keeping the same state. + for (int channel = 0; channel < totalNumInputChannels; ++channel) + { + auto* channelData = buffer.getWritePointer (channel); + + // ..do something to the data... + } +} + +//============================================================================== +bool VenoAudioProcessor::hasEditor() const +{ + return true; // (change this to false if you choose to not supply an editor) +} + +AudioProcessorEditor* VenoAudioProcessor::createEditor() +{ + return new VenoAudioProcessorEditor (*this); +} + +//============================================================================== +void VenoAudioProcessor::getStateInformation (MemoryBlock& destData) +{ + // You should use this method to store your parameters in the memory block. + // You could do that either as raw data, or use the XML or ValueTree classes + // as intermediaries to make it easy to save and load complex data. +} + +void VenoAudioProcessor::setStateInformation (const void* data, int sizeInBytes) +{ + // You should use this method to restore your parameters from this memory block, + // whose contents will have been created by the getStateInformation() call. +} + +//============================================================================== +// This creates new instances of the plugin.. +AudioProcessor* JUCE_CALLTYPE createPluginFilter() +{ + return new VenoAudioProcessor(); +} diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h new file mode 100644 index 0000000..80bc10e --- /dev/null +++ b/Source/PluginProcessor.h @@ -0,0 +1,61 @@ +/* + ============================================================================== + + This file was auto-generated! + + It contains the basic framework code for a JUCE plugin processor. + + ============================================================================== +*/ + +#pragma once + +#include + +//============================================================================== +/** +*/ +class VenoAudioProcessor : public AudioProcessor +{ +public: + //============================================================================== + VenoAudioProcessor(); + ~VenoAudioProcessor(); + + //============================================================================== + void prepareToPlay (double sampleRate, int samplesPerBlock) override; + void releaseResources() override; + + #ifndef JucePlugin_PreferredChannelConfigurations + bool isBusesLayoutSupported (const BusesLayout& layouts) const override; + #endif + + void processBlock (AudioBuffer&, MidiBuffer&) override; + + //============================================================================== + AudioProcessorEditor* createEditor() override; + bool hasEditor() const override; + + //============================================================================== + const String getName() const override; + + bool acceptsMidi() const override; + bool producesMidi() const override; + bool isMidiEffect() const override; + double getTailLengthSeconds() const override; + + //============================================================================== + int getNumPrograms() override; + int getCurrentProgram() override; + void setCurrentProgram (int index) override; + const String getProgramName (int index) override; + void changeProgramName (int index, const String& newName) override; + + //============================================================================== + void getStateInformation (MemoryBlock& destData) override; + void setStateInformation (const void* data, int sizeInBytes) override; + +private: + //============================================================================== + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VenoAudioProcessor) +}; diff --git a/Source/Veno/Core/AudioConfig.h b/Source/Veno/Core/AudioConfig.h new file mode 100644 index 0000000..30c67d0 --- /dev/null +++ b/Source/Veno/Core/AudioConfig.h @@ -0,0 +1,57 @@ +// +// Created by versustune on 22.03.20. +// + +#ifndef VENO_AUDIOCONFIG_H +#define VENO_AUDIOCONFIG_H + +#include "JuceHeader.h" + +/** + * holds SampleRate and other needed sound information's :) + */ +class AudioConfig { +private: + static std::shared_ptr instance; + float sampleRate = 44100; + float bufferSize = 512; //maybe we need that... but this will update always! + bool needToReInit = false; //this is to reInit the Oscillators, ADSR and other stuff +public: + static std::shared_ptr getInstance() { + if (!instance) + instance = std::make_shared(); + return instance; + } + + float getSampleRate() const { + return sampleRate; + } + + void setSampleRate(float _sampleRate) { + if (sampleRate != _sampleRate) { + sampleRate = _sampleRate; + needToReInit = true; + } + } + + float getBufferSize() const { + return bufferSize; + } + + void setBufferSize(float _bufferSize) { + AudioConfig::bufferSize = _bufferSize; + } + + bool isNeedToReInit() const { + return needToReInit; + } + + void setNeedToReInit(bool _needToReInit) { + AudioConfig::needToReInit = _needToReInit; + } + +protected: +}; + + +#endif //VENO_AUDIOCONFIG_H diff --git a/Source/Veno/Core/Config.cpp b/Source/Veno/Core/Config.cpp new file mode 100644 index 0000000..af5fe6e --- /dev/null +++ b/Source/Veno/Core/Config.cpp @@ -0,0 +1,73 @@ +// +// Created by versustune on 01.03.20. +// + +#include "Config.h" + +std::shared_ptr Config::instance = nullptr; + +Config::Config() { + // i want to load the config file here... + initConfig(); + + theme = std::make_shared(config); + theme->init(); +} + +void Config::saveAll() { + if (config != nullptr) { + config->saveIfNeeded(); + } +} + +int Config::getCurrentLook() { + if (currentLook > 1) { + currentLook = 0; + } + return currentLook; +} + +void Config::initConfig() { + PropertiesFile::Options options; + options.applicationName = "config"; + options.folderName = "veno"; + options.filenameSuffix = "xml"; + config = std::make_unique(options); +} + +std::shared_ptr Config::getCurrentTheme() { + return theme; +} + +double Config::getScale() { + return 0; +} + +void Config::setColourForIndex(Colour *colour, ThemeColour index) { + if (theme) { + theme->setColour(index, colour); + } +} + +Config::~Config() { + config->save(); + theme.reset(); + config.reset(); +} + +//LEAK DETECTOR FIX! +void Config::registerEditor(AudioProcessorEditor *editor, const std::string &name) { + editors[name] = editor; +} + +void Config::removeEditor(const std::string &name) { + editors.erase(name); + if (editors.empty()) { + instance = nullptr; + } +} + +//for LCD :P let's be a bit funny xD +int Config::getEditorCount() { + editors.size(); +} diff --git a/Source/Veno/Core/Config.h b/Source/Veno/Core/Config.h new file mode 100644 index 0000000..94a1ee6 --- /dev/null +++ b/Source/Veno/Core/Config.h @@ -0,0 +1,52 @@ +// +// Created by versustune on 01.03.20. +// + +#ifndef VENO_CONFIG_H +#define VENO_CONFIG_H + +#include "JuceHeader.h" +#include "../GUI/LookAndFeel/LookHandler.h" +#include "../GUI/Theme/Theme.h" +#include + +class Config { +private: + std::shared_ptr config = nullptr; + std::shared_ptr theme = nullptr; + static std::shared_ptr instance; + int currentLook = 0; //nah move the bitch logic from current to next + std::unordered_map editors; +public: + static std::shared_ptr getInstance() { + if (!instance) + instance = std::make_shared(); + return instance; + } + + void saveAll(); + + int getCurrentLook(); + + void setColourForIndex(Colour *colour, ThemeColour index); + + std::shared_ptr getCurrentTheme(); + + double getScale(); + + // can be public but doesnt need! + Config(); + + ~Config(); + + void registerEditor(AudioProcessorEditor *editor, const std::string& name); + + void removeEditor(const std::string& name); + + int getEditorCount(); + +protected: + void initConfig(); +}; + +#endif //VENO_CONFIG_H diff --git a/Source/Veno/GUI/Components/BaseComponent.cpp b/Source/Veno/GUI/Components/BaseComponent.cpp new file mode 100644 index 0000000..e7e0b8d --- /dev/null +++ b/Source/Veno/GUI/Components/BaseComponent.cpp @@ -0,0 +1,5 @@ +// +// Created by versustune on 17.03.20. +// + +#include "BaseComponent.h" diff --git a/Source/Veno/GUI/Components/BaseComponent.h b/Source/Veno/GUI/Components/BaseComponent.h new file mode 100644 index 0000000..47e8f54 --- /dev/null +++ b/Source/Veno/GUI/Components/BaseComponent.h @@ -0,0 +1,25 @@ +// +// Created by versustune on 17.03.20. +// + +#ifndef VENO_BASECOMPONENT_H +#define VENO_BASECOMPONENT_H + +#include "JuceHeader.h" +#include + +/** + * this is the base Component of all VeNo Components... it has all important Methods + */ +class BaseComponent : public Component { +private: + std::string prefix; +public: + BaseComponent() = default; + ~BaseComponent() = default; + +protected: +}; + + +#endif //VENO_BASECOMPONENT_H diff --git a/Source/Veno/GUI/LookAndFeel/CrazyLook.cpp b/Source/Veno/GUI/LookAndFeel/CrazyLook.cpp new file mode 100644 index 0000000..98b6999 --- /dev/null +++ b/Source/Veno/GUI/LookAndFeel/CrazyLook.cpp @@ -0,0 +1,5 @@ +// +// Created by versustune on 17.03.20. +// + +#include "CrazyLook.h" diff --git a/Source/Veno/GUI/LookAndFeel/CrazyLook.h b/Source/Veno/GUI/LookAndFeel/CrazyLook.h new file mode 100644 index 0000000..4a58622 --- /dev/null +++ b/Source/Veno/GUI/LookAndFeel/CrazyLook.h @@ -0,0 +1,17 @@ +// +// Created by versustune on 17.03.20. +// + +#ifndef VENO_CRAZYLOOK_H +#define VENO_CRAZYLOOK_H + +#include "JuceHeader.h" + +class CrazyLook : public LookAndFeel_V4 { +private: +public: +protected: +}; + + +#endif //VENO_CRAZYLOOK_H diff --git a/Source/Veno/GUI/LookAndFeel/FlatLook.cpp b/Source/Veno/GUI/LookAndFeel/FlatLook.cpp new file mode 100644 index 0000000..d121fb6 --- /dev/null +++ b/Source/Veno/GUI/LookAndFeel/FlatLook.cpp @@ -0,0 +1,5 @@ +// +// Created by versustune on 17.03.20. +// + +#include "FlatLook.h" diff --git a/Source/Veno/GUI/LookAndFeel/FlatLook.h b/Source/Veno/GUI/LookAndFeel/FlatLook.h new file mode 100644 index 0000000..d3ea116 --- /dev/null +++ b/Source/Veno/GUI/LookAndFeel/FlatLook.h @@ -0,0 +1,17 @@ +// +// Created by versustune on 17.03.20. +// + +#ifndef VENO_FLATLOOK_H +#define VENO_FLATLOOK_H + +#include "JuceHeader.h" + +class FlatLook : public LookAndFeel_V4 { +private: +public: +protected: +}; + + +#endif //VENO_FLATLOOK_H diff --git a/Source/Veno/GUI/LookAndFeel/LookHandler.cpp b/Source/Veno/GUI/LookAndFeel/LookHandler.cpp new file mode 100644 index 0000000..8e6c4b3 --- /dev/null +++ b/Source/Veno/GUI/LookAndFeel/LookHandler.cpp @@ -0,0 +1,20 @@ +// +// Created by versustune on 17.03.20. +// + +#include "LookHandler.h" +#include "../../Core/Config.h" + +LookHandler::LookHandler() { + selectLook(Config::getInstance()->getCurrentLook()); +} + +LookHandler::~LookHandler() { + //delete this shit! + delete feels[0]; + delete feels[1]; +} + +void LookHandler::selectLook(int index) { + currentLook = index; +} diff --git a/Source/Veno/GUI/LookAndFeel/LookHandler.h b/Source/Veno/GUI/LookAndFeel/LookHandler.h new file mode 100644 index 0000000..8e4b873 --- /dev/null +++ b/Source/Veno/GUI/LookAndFeel/LookHandler.h @@ -0,0 +1,30 @@ +// +// Created by versustune on 17.03.20. +// + +#ifndef VENO_LOOKHANDLER_H +#define VENO_LOOKHANDLER_H + +#include "JuceHeader.h" +#include "CrazyLook.h" +#include "FlatLook.h" +#include + +/** + * overwrite the basic look and feel based on the selected Look and Feel :) + */ +class LookHandler : public LookAndFeel_V4 { +private: + std::shared_ptr look; + int currentLook = 0; +public: + LookHandler(); + ~LookHandler(); + void selectLook(int index); +protected: + //currently both available themes are CrazyLook <-- (this is a fun one xD) and FlatLook + LookAndFeel_V4 *feels[2] = {new FlatLook(), new CrazyLook()}; +}; + + +#endif //VENO_LOOKHANDLER_H diff --git a/Source/Veno/GUI/Theme/Theme.cpp b/Source/Veno/GUI/Theme/Theme.cpp new file mode 100644 index 0000000..9012ef8 --- /dev/null +++ b/Source/Veno/GUI/Theme/Theme.cpp @@ -0,0 +1,50 @@ +// +// Created by versustune on 01.03.20. +// + +#include "Theme.h" +#include "ThemePresets.cpp" + +Theme::Theme(std::shared_ptr file) { + configFile = file; +} + + +Theme::~Theme() { + colours.clear(); + configFile.reset(); +} + +void Theme::setColour(ThemeColour index, Colour *colour) { + auto c = colours[index]; + if (c) { + delete c; + colours[index] = colour; + } else { + colours[index] = colour; + } + configFile->setValue(ThemeColourToString(index), colour->toString()); + configFile->save(); + +} + +void Theme::init() { + setLEDTheme(this); + getColourFromConfig(ThemeColour::bg); + getColourFromConfig(ThemeColour::bg_two); + getColourFromConfig(ThemeColour::accent); + getColourFromConfig(ThemeColour::accent_two); + getColourFromConfig(ThemeColour::warning); + getColourFromConfig(ThemeColour::clip); + getColourFromConfig(ThemeColour::lcd_bg); + getColourFromConfig(ThemeColour::lcd); +} + +void Theme::getColourFromConfig(ThemeColour index) { + std::string key = ThemeColourToString(index); + if (configFile->containsKey(key)) { + auto baseColour = Colour::fromString(configFile->getValue(key)); + auto *colour = new Colour(baseColour.getRed(), baseColour.getGreen(), baseColour.getBlue()); + setColour(index, colour); + } +} diff --git a/Source/Veno/GUI/Theme/Theme.h b/Source/Veno/GUI/Theme/Theme.h new file mode 100644 index 0000000..1cc4d72 --- /dev/null +++ b/Source/Veno/GUI/Theme/Theme.h @@ -0,0 +1,30 @@ +// +// Created by versustune on 01.03.20. +// + +#ifndef VENO_THEME_H +#define VENO_THEME_H + +#include "JuceHeader.h" +#include + +enum class ThemeColour { + bg = 0, bg_two, accent, accent_two, warning, clip, lcd_bg, lcd +}; + +class Theme { +private: +public: + Theme(std::shared_ptr file); + ~Theme(); + + void setColour(ThemeColour index, Colour *colour); + void init(); + void getColourFromConfig(ThemeColour index); +protected: + std::map colours; + std::shared_ptr configFile; +}; + + +#endif //VENO_THEME_H diff --git a/Source/Veno/GUI/Theme/ThemePresets.cpp b/Source/Veno/GUI/Theme/ThemePresets.cpp new file mode 100644 index 0000000..eb883ae --- /dev/null +++ b/Source/Veno/GUI/Theme/ThemePresets.cpp @@ -0,0 +1,37 @@ +#include "Theme.h" + +/* + * this file holds function that read some presets + * in the current Theme class + * so we doesn't have lot's of classes that only save some hex codes... and make the coding harder + * also good on this is that the user can slightly change the preset theme and doesn't have to make all of them himself + * + * maybe i want a double look and feel... that's make it easier to implement different knob styles, slider styles and co + */ + +void setLEDTheme(Theme *theme) { + theme->setColour(ThemeColour::bg, new Colour(41, 47, 54)); + theme->setColour(ThemeColour::bg_two, new Colour(217, 217, 217)); + theme->setColour(ThemeColour::accent, new Colour(169, 208, 142)); + theme->setColour(ThemeColour::accent_two, new Colour(139, 171, 117)); + theme->setColour(ThemeColour::clip, new Colour(255, 23, 68)); + theme->setColour(ThemeColour::warning, new Colour(255, 143, 0)); + theme->setColour(ThemeColour::lcd_bg, new Colour(21, 21, 21)); + theme->setColour(ThemeColour::lcd, new Colour(169, 208, 142)); +} + + +std::string ThemeColourToString(ThemeColour index) { + switch (index) + { + case ThemeColour::bg: return "colour_bg"; + case ThemeColour::bg_two: return "colour_bg_two"; + case ThemeColour::accent: return "colour_accent"; + case ThemeColour::accent_two: return "colour_accent_two"; + case ThemeColour::clip: return "colour_clip"; + case ThemeColour::warning: return "colour_warning"; + case ThemeColour::lcd_bg: return "colour_lcd_bg"; + case ThemeColour::lcd: return "colour_lcd"; + default: return ""; + } +} \ No newline at end of file diff --git a/Veno.jucer b/Veno.jucer new file mode 100644 index 0000000..ace11a6 --- /dev/null +++ b/Veno.jucer @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +