first commit

This commit is contained in:
VersusTune 2020-04-03 13:23:19 +02:00
commit 452c5cabba
20 changed files with 863 additions and 0 deletions

View file

@ -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<AudioConfig> 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<AudioConfig> getInstance() {
if (!instance)
instance = std::make_shared<AudioConfig>();
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

View file

@ -0,0 +1,73 @@
//
// Created by versustune on 01.03.20.
//
#include "Config.h"
std::shared_ptr<Config> Config::instance = nullptr;
Config::Config() {
// i want to load the config file here...
initConfig();
theme = std::make_shared<Theme>(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<PropertiesFile>(options);
}
std::shared_ptr<Theme> 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();
}

52
Source/Veno/Core/Config.h Normal file
View file

@ -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 <memory>
class Config {
private:
std::shared_ptr<PropertiesFile> config = nullptr;
std::shared_ptr<Theme> theme = nullptr;
static std::shared_ptr<Config> instance;
int currentLook = 0; //nah move the bitch logic from current to next
std::unordered_map<std::string, AudioProcessorEditor *> editors;
public:
static std::shared_ptr<Config> getInstance() {
if (!instance)
instance = std::make_shared<Config>();
return instance;
}
void saveAll();
int getCurrentLook();
void setColourForIndex(Colour *colour, ThemeColour index);
std::shared_ptr<Theme> 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