diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index a6e7880..ed5a69f 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -4,30 +4,35 @@ #include "Veno/Utils/Logger.h" #include "Veno/Fonts/Fonts.h" -VenoAudioProcessorEditor::VenoAudioProcessorEditor(VenoAudioProcessor &p) - : AudioProcessorEditor(&p), processor(p) { +VenoAudioProcessorEditor::VenoAudioProcessorEditor (VenoAudioProcessor& p) + : AudioProcessorEditor (&p), processor (p) +{ m_id = p.m_id; - Config::getInstance()->registerEditor(this, m_id); - LookAndFeel::setDefaultLookAndFeel(m_look); - waveform = std::make_unique(m_id); - setSize(600, 400); - addAndMakeVisible(*waveform); + Config::getInstance ()->registerEditor (this, m_id); + LookAndFeel::setDefaultLookAndFeel (m_look); + waveform = std::make_unique (m_id); + setSize (600, 400); + addAndMakeVisible (*waveform); } -VenoAudioProcessorEditor::~VenoAudioProcessorEditor() { - LookAndFeel::setDefaultLookAndFeel(nullptr); - waveform.reset(nullptr); +VenoAudioProcessorEditor::~VenoAudioProcessorEditor () +{ + LookAndFeel::setDefaultLookAndFeel (nullptr); + waveform.reset (nullptr); delete m_look; - Config::getInstance()->removeEditor(m_id); + Config::getInstance ()->removeEditor (m_id); } -void VenoAudioProcessorEditor::paint(Graphics &g) { - g.setFont(VenoFonts::getNormal()); - g.fillAll(Colour(0, 0, 0)); +void VenoAudioProcessorEditor::paint (Graphics& g) +{ + g.setFont (*VenoFonts::getNormal ()); + g.fillAll (Colour (0, 0, 0)); } -void VenoAudioProcessorEditor::resized() { - if (waveform != nullptr) { - waveform->setBounds(0, 0, getWidth(), getHeight()); +void VenoAudioProcessorEditor::resized () +{ + if (waveform != nullptr) + { + waveform->setBounds (0, 0, getWidth (), getHeight ()); } } diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 9c307ca..cbbb03e 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -5,19 +5,17 @@ #include "Veno/GUI/LookAndFeel/LookHandler.h" #include "Veno/GUI/Components/LCD/SidebarLCD.h" -class VenoAudioProcessorEditor : public AudioProcessorEditor +class VenoAudioProcessorEditor : public AudioProcessorEditor { public: VenoAudioProcessorEditor (VenoAudioProcessor&); - ~VenoAudioProcessorEditor(); + ~VenoAudioProcessorEditor (); void paint (Graphics&) override; - void resized() override; - + void resized () override; private: VenoAudioProcessor& processor; std::string m_id = ""; - LookAndFeel_V4 *m_look = new LookHandler(); + LookAndFeel_V4* m_look = new LookHandler (); std::unique_ptr waveform; - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VenoAudioProcessorEditor) }; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 1d61c27..c0f00b8 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -2,7 +2,7 @@ #include "PluginEditor.h" #include "Veno/Core/AudioConfig.h" -VenoAudioProcessor::VenoAudioProcessor() +VenoAudioProcessor::VenoAudioProcessor () /*#ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor (BusesProperties() #if ! JucePlugin_IsMidiEffect @@ -13,21 +13,25 @@ VenoAudioProcessor::VenoAudioProcessor() #endif ) #endif*/ - : AudioProcessor(BusesProperties().withInput("Input", AudioChannelSet::stereo(), true).withOutput("Output", - AudioChannelSet::stereo(), - true)) { - instance = VenoInstance::createInstance(m_id); + : AudioProcessor (BusesProperties ().withInput ("Input", AudioChannelSet::stereo (), true).withOutput ("Output", + AudioChannelSet::stereo (), + true)) +{ + instance = VenoInstance::createInstance (m_id); } -VenoAudioProcessor::~VenoAudioProcessor() { - VenoInstance::deleteInstance(m_id); +VenoAudioProcessor::~VenoAudioProcessor () +{ + VenoInstance::deleteInstance (m_id); } -const String VenoAudioProcessor::getName() const { +const String VenoAudioProcessor::getName () const +{ return JucePlugin_Name; } -bool VenoAudioProcessor::acceptsMidi() const { +bool VenoAudioProcessor::acceptsMidi () const +{ #if JucePlugin_WantsMidiInput return true; #else @@ -35,7 +39,8 @@ bool VenoAudioProcessor::acceptsMidi() const { #endif } -bool VenoAudioProcessor::producesMidi() const { +bool VenoAudioProcessor::producesMidi () const +{ #if JucePlugin_ProducesMidiOutput return true; #else @@ -43,7 +48,8 @@ bool VenoAudioProcessor::producesMidi() const { #endif } -bool VenoAudioProcessor::isMidiEffect() const { +bool VenoAudioProcessor::isMidiEffect () const +{ #if JucePlugin_IsMidiEffect return true; #else @@ -51,96 +57,113 @@ bool VenoAudioProcessor::isMidiEffect() const { #endif } -double VenoAudioProcessor::getTailLengthSeconds() const { +double VenoAudioProcessor::getTailLengthSeconds () const +{ return 0.0; } -int VenoAudioProcessor::getNumPrograms() { +int VenoAudioProcessor::getNumPrograms () +{ return 1; } -int VenoAudioProcessor::getCurrentProgram() { +int VenoAudioProcessor::getCurrentProgram () +{ return 0; } -void VenoAudioProcessor::setCurrentProgram(int index) { +void VenoAudioProcessor::setCurrentProgram (int index) +{ } -const String VenoAudioProcessor::getProgramName(int index) { +const String VenoAudioProcessor::getProgramName (int index) +{ return {}; } -void VenoAudioProcessor::changeProgramName(int index, const String &newName) { +void VenoAudioProcessor::changeProgramName (int index, const String& newName) +{ } //============================================================================== -void VenoAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock) { - auto audioConfig = AudioConfig::getInstance(); - audioConfig->setSampleRate(sampleRate); - audioConfig->initWaveTables(); +void VenoAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) +{ + auto audioConfig = AudioConfig::getInstance (); + audioConfig->setSampleRate (sampleRate); + audioConfig->initWaveTables (); } -void VenoAudioProcessor::releaseResources() { +void VenoAudioProcessor::releaseResources () +{ } #ifndef JucePlugin_PreferredChannelConfigurations -bool VenoAudioProcessor::isBusesLayoutSupported(const BusesLayout &layouts) const { +bool VenoAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const +{ #if JucePlugin_IsMidiEffect ignoreUnused (layouts); return true; #else - if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() - && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) + if (layouts.getMainOutputChannelSet () != AudioChannelSet::mono () + && layouts.getMainOutputChannelSet () != AudioChannelSet::stereo ()) return false; - #if !JucePlugin_IsSynth if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false; #endif - return true; #endif } #endif -void VenoAudioProcessor::processBlock(AudioBuffer &buffer, MidiBuffer &midiMessages) { +void VenoAudioProcessor::processBlock (AudioBuffer& buffer, MidiBuffer& midiMessages) +{ ScopedNoDenormals noDenormals; - - instance->audioBuffer->reset(buffer.getNumSamples()); - int numChannels = buffer.getNumChannels(); - for (int i = 0; i < numChannels; ++i) { - auto c = buffer.getReadPointer(i); - for (int j = 0; j < buffer.getNumSamples(); ++j) { - instance->fft.pushNextSampleIntoFifo(c[j]); - instance->audioBuffer->addMonoSample(c[j], j); - if (i == 0) { - instance->audioBuffer->addLeftSample(c[j], j); + instance->matrix.updateSlots (); + instance->audioBuffer->reset (buffer.getNumSamples ()); + int numChannels = buffer.getNumChannels (); + for (int i = 0; i < numChannels; ++i) + { + auto c = buffer.getReadPointer (i); + for (int j = 0; j < buffer.getNumSamples (); ++j) + { + instance->fft.pushNextSampleIntoFifo (c[j]); + instance->audioBuffer->addMonoSample (c[j], j); + if (i == 0) + { + instance->audioBuffer->addLeftSample (c[j], j); } - if (i == 1 || numChannels == 1) { - instance->audioBuffer->addRightSample(c[j], j); + if (i == 1 || numChannels == 1) + { + instance->audioBuffer->addRightSample (c[j], j); } } } } //============================================================================== -bool VenoAudioProcessor::hasEditor() const { +bool VenoAudioProcessor::hasEditor () const +{ return true; } -AudioProcessorEditor *VenoAudioProcessor::createEditor() { - return new VenoAudioProcessorEditor(*this); +AudioProcessorEditor* VenoAudioProcessor::createEditor () +{ + return new VenoAudioProcessorEditor (*this); } //============================================================================== -void VenoAudioProcessor::getStateInformation(MemoryBlock &destData) { +void VenoAudioProcessor::getStateInformation (MemoryBlock& destData) +{ } -void VenoAudioProcessor::setStateInformation(const void *data, int sizeInBytes) { +void VenoAudioProcessor::setStateInformation (const void* data, int sizeInBytes) +{ } -AudioProcessor *JUCE_CALLTYPE createPluginFilter() { - return new VenoAudioProcessor(); +AudioProcessor* JUCE_CALLTYPE createPluginFilter () +{ + return new VenoAudioProcessor (); } diff --git a/Source/Veno/Audio/Engine/ModulateValue.cpp b/Source/Veno/Audio/Engine/ModulateValue.cpp new file mode 100644 index 0000000..7324060 --- /dev/null +++ b/Source/Veno/Audio/Engine/ModulateValue.cpp @@ -0,0 +1,21 @@ +// +// Created by versustune on 13.06.20. +// + +#include "ModulateValue.h" + +ModulateValue::ModulateValue (const std::string& name, const std::string& processId) +{ + m_name = name; + m_processId = processId; +} + +void ModulateValue::addValue (float d) +{ + +} + +ModulateValue::~ModulateValue () +{ + +} diff --git a/Source/Veno/Audio/Engine/ModulateValue.h b/Source/Veno/Audio/Engine/ModulateValue.h new file mode 100644 index 0000000..e95dcfa --- /dev/null +++ b/Source/Veno/Audio/Engine/ModulateValue.h @@ -0,0 +1,25 @@ +// +// Created by versustune on 13.06.20. +// + +#ifndef VENO_MODULATEVALUE_H +#define VENO_MODULATEVALUE_H + +#include + +// a class that is used to can handle the value from a "gui-part" and the matrix and all other modulation +class ModulateValue +{ +public: + ModulateValue (const std::string& name, const std::string& processId); + ~ModulateValue (); + void addValue (float d); +private: + std::string m_name; + std::string m_processId; + float m_value; + float m_baseValue = 0; + float m_maxValue = 1; + float m_minValue = -1; +}; +#endif //VENO_MODULATEVALUE_H diff --git a/Source/Veno/Audio/Engine/Modulator.cpp b/Source/Veno/Audio/Engine/Modulator.cpp new file mode 100644 index 0000000..c6781a1 --- /dev/null +++ b/Source/Veno/Audio/Engine/Modulator.cpp @@ -0,0 +1,24 @@ +// +// Created by versustune on 13.06.20. +// + +#include "Modulator.h" + +float Modulator::getValue () +{ + return m_value; +} + +Modulator::Modulator () +{ + +} + +Modulator::~Modulator () +{ + +} + +void Modulator::update () +{ +} diff --git a/Source/Veno/Audio/Engine/Modulator.h b/Source/Veno/Audio/Engine/Modulator.h new file mode 100644 index 0000000..fbf7d53 --- /dev/null +++ b/Source/Veno/Audio/Engine/Modulator.h @@ -0,0 +1,19 @@ +// +// Created by versustune on 13.06.20. +// + +#ifndef VENO_MODULATOR_H +#define VENO_MODULATOR_H +// class that define if it can be a modulator on not +// like LFO, Envelope, maybe also OSCILLATORS :P VELOCITY AND OTHER STUFF IS ALSO A MODULATOR! +class Modulator +{ +public: + Modulator (); + ~Modulator (); + float getValue (); + void update (); +protected: + float m_value; +}; +#endif //VENO_MODULATOR_H diff --git a/Source/Veno/Audio/Engine/VenoMatrix.cpp b/Source/Veno/Audio/Engine/VenoMatrix.cpp new file mode 100644 index 0000000..84c4697 --- /dev/null +++ b/Source/Veno/Audio/Engine/VenoMatrix.cpp @@ -0,0 +1,81 @@ +// +// Created by versustune on 13.06.20. +// + +#include "VenoMatrix.h" + +VenoMatrix::VenoMatrix (const std::string& processId) : m_processId (processId) +{ + for (auto& m_slot : m_slots) + { + m_slot = new VenoMatrixSlot (); + } +} + +VenoMatrix::~VenoMatrix () +{ + for (auto& m_slot : m_slots) + { + delete m_slot; + } +} + +VenoMatrixSlot* VenoMatrix::getSlotById (int id) +{ + return m_slots[id]; +} + +void VenoMatrix::removeModulateValue (const std::string& name) +{ + m_modulationValues.erase (name); +} + +void VenoMatrix::removeModulator (const std::string& name) +{ + m_modulators.erase (name); +} + +void VenoMatrix::addModulateValue (const std::string& name, ModulateValue* modulateValue) +{ + m_modulationValues.emplace (std::pair (name, modulateValue)); +} + +void VenoMatrix::addModulator (const std::string& name, Modulator* modulator) +{ + m_modulators.emplace (std::pair (name, modulator)); +} + +void VenoMatrix::updateSlots () +{ + for (auto& m_slot : m_slots) + { + if (m_slot->sourceName == "none") + { + continue; + } + if (m_modulators.find (m_slot->sourceName) != m_modulators.end ()) + { + auto modulator = m_modulators[m_slot->sourceName]; + if (modulator == nullptr) + { + continue; + } + modulator->update (); + for (auto& value : m_slot->targets) + { + if (value.name != "none") + { + if (m_modulationValues.find (value.name) != m_modulationValues.end ()) + { + auto modValue = m_modulationValues[value.name]; + if (modValue == nullptr) + { + continue; + } + modValue->addValue (modulator->getValue () * value.amount); + } + } + } + } + } +} \ No newline at end of file diff --git a/Source/Veno/Audio/Engine/VenoMatrix.h b/Source/Veno/Audio/Engine/VenoMatrix.h new file mode 100644 index 0000000..3d9dd90 --- /dev/null +++ b/Source/Veno/Audio/Engine/VenoMatrix.h @@ -0,0 +1,42 @@ +// +// Created by versustune on 13.06.20. +// + +#ifndef VENO_VENOMATRIX_H +#define VENO_VENOMATRIX_H + +#include +#include +#include +#include "Modulator.h" +#include "ModulateValue.h" + +// class that modulate everything :D +struct VenoMatrixTarget +{ + std::string name; + float amount = 0; // always 0 to 1 <-- apply amount to modulator +}; +struct VenoMatrixSlot +{ + std::string sourceName; + VenoMatrixTarget targets[8]; +}; +class VenoMatrix +{ +public: + explicit VenoMatrix (const std::string& processId); + ~VenoMatrix (); + void updateSlots (); + void addModulator (const std::string& name, Modulator* modulator); + void addModulateValue (const std::string& name, ModulateValue* modulateValue); + void removeModulator (const std::string& name); + void removeModulateValue (const std::string& name); + VenoMatrixSlot* getSlotById (int id); +private: + std::unordered_map m_modulators; //all sources + std::unordered_map m_modulationValues; + VenoMatrixSlot* m_slots[8]{}; // 8 source slots + std::string m_processId; +}; +#endif //VENO_VENOMATRIX_H diff --git a/Source/Veno/Audio/Synth/SynthInstance.cpp b/Source/Veno/Audio/Synth/SynthInstance.cpp index fce0d00..3e3a660 100644 --- a/Source/Veno/Audio/Synth/SynthInstance.cpp +++ b/Source/Veno/Audio/Synth/SynthInstance.cpp @@ -3,9 +3,9 @@ // #include "SynthInstance.h" - #include -SynthInstance::SynthInstance(std::string processId) - : m_processId(std::move(processId)) { +SynthInstance::SynthInstance (std::string processId) + : m_processId (std::move (processId)) +{ } diff --git a/Source/Veno/Audio/Synth/SynthInstance.h b/Source/Veno/Audio/Synth/SynthInstance.h index 4df65ee..e0fe173 100644 --- a/Source/Veno/Audio/Synth/SynthInstance.h +++ b/Source/Veno/Audio/Synth/SynthInstance.h @@ -5,18 +5,16 @@ #ifndef VENO_SYNTHINSTANCE_H #define VENO_SYNTHINSTANCE_H - #include // class that hold all voices, oscillators and other stuff :) -class SynthInstance { +class SynthInstance +{ private: std::string m_processId; public: - explicit SynthInstance(std::string processId); - ~SynthInstance() = default; + explicit SynthInstance (std::string processId); + ~SynthInstance () = default; protected: }; - - #endif //VENO_SYNTHINSTANCE_H diff --git a/Source/Veno/Audio/VenoBuffer.cpp b/Source/Veno/Audio/VenoBuffer.cpp index 0795f2d..874609b 100644 --- a/Source/Veno/Audio/VenoBuffer.cpp +++ b/Source/Veno/Audio/VenoBuffer.cpp @@ -5,24 +5,29 @@ #include #include "VenoBuffer.h" -VenoBuffer::VenoBuffer() { +VenoBuffer::VenoBuffer () +{ } -VenoBuffer::~VenoBuffer() { - buffer.clear(); - right.clear(); - left.clear(); +VenoBuffer::~VenoBuffer () +{ + buffer.clear (); + right.clear (); + left.clear (); } -void VenoBuffer::reset(int size) { - if (size != buffer.size()) { - buffer.resize(size); - right.resize(size); - left.resize(size); +void VenoBuffer::reset (int size) +{ + if (size != buffer.size ()) + { + buffer.resize (size); + right.resize (size); + left.resize (size); } // reset to 0 dc :D - for (int i = 0; i < size; ++i) { + for (int i = 0; i < size; ++i) + { buffer[i] = 0; left[i] = 0; right[i] = 0; @@ -32,43 +37,54 @@ void VenoBuffer::reset(int size) { monoPeak = 0; } -void VenoBuffer::addMonoSample(float value, int index) { +void VenoBuffer::addMonoSample (float value, int index) +{ buffer[index] = value; } -void VenoBuffer::addLeftSample(float value, int index) { +void VenoBuffer::addLeftSample (float value, int index) +{ left[index] = value; } -void VenoBuffer::addRightSample(float value, int index) { +void VenoBuffer::addRightSample (float value, int index) +{ right[index] = value; } -void VenoBuffer::calcPeak() { - for (int i = 0; i < buffer.size(); ++i) { - auto l = std::abs(left[i]); - auto r = std::abs(right[i]); - auto m = std::abs(buffer[i]); - if (m > monoPeak) { +void VenoBuffer::calcPeak () +{ + for (int i = 0; i < buffer.size (); ++i) + { + auto l = std::abs (left[i]); + auto r = std::abs (right[i]); + auto m = std::abs (buffer[i]); + if (m > monoPeak) + { monoPeak = m; } - if (l > leftPeak) { + if (l > leftPeak) + { leftPeak = l; } - if (r > rightPeak) { + if (r > rightPeak) + { rightPeak = r; } } } -const std::vector &VenoBuffer::getBuffer() const { +const std::vector& VenoBuffer::getBuffer () const +{ return buffer; } -const std::vector &VenoBuffer::getRight() const { +const std::vector& VenoBuffer::getRight () const +{ return right; } -const std::vector &VenoBuffer::getLeft() const { +const std::vector& VenoBuffer::getLeft () const +{ return left; } diff --git a/Source/Veno/Audio/VenoBuffer.h b/Source/Veno/Audio/VenoBuffer.h index 7cd52e9..20a30b7 100644 --- a/Source/Veno/Audio/VenoBuffer.h +++ b/Source/Veno/Audio/VenoBuffer.h @@ -5,33 +5,27 @@ #ifndef VENO_VENOBUFFER_H #define VENO_VENOBUFFER_H - #include -class VenoBuffer { +class VenoBuffer +{ private: std::vector buffer; std::vector right; std::vector left; public: - VenoBuffer(); - ~VenoBuffer(); - void reset(int size); - void addMonoSample(float value, int index); - void addLeftSample(float value, int index); - void addRightSample(float value, int index); - - void calcPeak(); + VenoBuffer (); + ~VenoBuffer (); + void reset (int size); + void addMonoSample (float value, int index); + void addLeftSample (float value, int index); + void addRightSample (float value, int index); + void calcPeak (); float leftPeak; float rightPeak; float monoPeak; - - const std::vector &getBuffer() const; - - const std::vector &getRight() const; - - const std::vector &getLeft() const; + const std::vector& getBuffer () const; + const std::vector& getRight () const; + const std::vector& getLeft () const; }; - - #endif //VENO_VENOBUFFER_H diff --git a/Source/Veno/Audio/WaveTable/SawWaves.cpp b/Source/Veno/Audio/WaveTable/SawWaves.cpp index 595df55..bb6333b 100644 --- a/Source/Veno/Audio/WaveTable/SawWaves.cpp +++ b/Source/Veno/Audio/WaveTable/SawWaves.cpp @@ -6,23 +6,26 @@ #include "../../Utils/Logger.h" #include "TableHelper.h" -void generateSaw(WaveTableGroup *group) { - if (group == nullptr) { +void generateSaw (WaveTableGroup* group) +{ + if (group == nullptr) + { return; } - int tableLen = findTableLen(); + int tableLen = findTableLen (); int idx; - auto *freqWaveRe = new double[tableLen]; - auto *freqWaveIm = new double[tableLen]; - - for (idx = 0; idx < tableLen; idx++) { + auto* freqWaveRe = new double[tableLen]; + auto* freqWaveIm = new double[tableLen]; + for (idx = 0; idx < tableLen; idx++) + { freqWaveIm[idx] = 0.0; } freqWaveRe[0] = freqWaveRe[tableLen >> 1] = 0.0; - for (idx = 1; idx < (tableLen >> 1); idx++) { + for (idx = 1; idx < (tableLen >> 1); idx++) + { freqWaveRe[idx] = 1.0 / idx; // sawtooth spectrum freqWaveRe[tableLen - idx] = -freqWaveRe[idx]; // mirror } - fillTables(group, freqWaveRe, freqWaveIm, tableLen); - VeNo::Logger::infoDebugMessage("Generated clean Saw Wave"); + fillTables (group, freqWaveRe, freqWaveIm, tableLen); + VeNo::Logger::infoDebugMessage ("Generated clean Saw Wave"); } \ No newline at end of file diff --git a/Source/Veno/Audio/WaveTable/SawWaves.h b/Source/Veno/Audio/WaveTable/SawWaves.h index 4e9d3c6..8cf4bed 100644 --- a/Source/Veno/Audio/WaveTable/SawWaves.h +++ b/Source/Veno/Audio/WaveTable/SawWaves.h @@ -4,8 +4,5 @@ #ifndef VENO_SAWWAVES_H #define VENO_SAWWAVES_H - -void generateSaw(WaveTableGroup *group); - - +void generateSaw (WaveTableGroup* group); #endif //VENO_SAWWAVES_H diff --git a/Source/Veno/Audio/WaveTable/SineWaves.h b/Source/Veno/Audio/WaveTable/SineWaves.h index a42ce4a..06771e7 100644 --- a/Source/Veno/Audio/WaveTable/SineWaves.h +++ b/Source/Veno/Audio/WaveTable/SineWaves.h @@ -4,11 +4,8 @@ #ifndef VENO_SINEWAVES_H #define VENO_SINEWAVES_H - - -class SineWaves { +class SineWaves +{ }; - - #endif //VENO_SINEWAVES_H diff --git a/Source/Veno/Audio/WaveTable/SquareWaves.h b/Source/Veno/Audio/WaveTable/SquareWaves.h index aa05eac..ee99165 100644 --- a/Source/Veno/Audio/WaveTable/SquareWaves.h +++ b/Source/Veno/Audio/WaveTable/SquareWaves.h @@ -4,11 +4,8 @@ #ifndef VENO_SQUAREWAVES_H #define VENO_SQUAREWAVES_H - - -class SquareWaves { +class SquareWaves +{ }; - - #endif //VENO_SQUAREWAVES_H diff --git a/Source/Veno/Audio/WaveTable/TableHelper.cpp b/Source/Veno/Audio/WaveTable/TableHelper.cpp index 5c8e746..6a8ea41 100644 --- a/Source/Veno/Audio/WaveTable/TableHelper.cpp +++ b/Source/Veno/Audio/WaveTable/TableHelper.cpp @@ -6,7 +6,8 @@ #include "../../Core/AudioConfig.h" #include "../../Utils.h" -void fft(int N, double *ar, double *ai) { +void fft (int N, double* ar, double* ai) +{ int i, j, k, L; /* indexes */ int M, TEMP, LE, LE1, ip; /* M = log N */ int NV2, NM1; @@ -24,8 +25,10 @@ void fft(int N, double *ar, double *ai) { /* shuffle */ j = 1; - for (i = 1; i <= NM1; i++) { - if (i < j) { /* swap a[i] and a[j] */ + for (i = 1; i <= NM1; i++) + { + if (i < j) + { /* swap a[i] and a[j] */ t = ar[j - 1]; ar[j - 1] = ar[i - 1]; ar[i - 1] = t; @@ -33,26 +36,27 @@ void fft(int N, double *ar, double *ai) { ai[j - 1] = ai[i - 1]; ai[i - 1] = t; } - k = NV2; /* bit-reversed counter */ - while (k < j) { + while (k < j) + { j -= k; k /= 2; } - j += k; } - LE = 1.; - for (L = 1; L <= M; L++) { // stage L + for (L = 1; L <= M; L++) + { // stage L LE1 = LE; // (LE1 = LE/2) LE *= 2; // (LE = 2^L) Ur = 1.0; Ui = 0.; - Wr = std::cos(M_PI / (float) LE1); - Wi = -std::sin(M_PI / (float) LE1); // Cooley, Lewis, and Welch have "+" here - for (j = 1; j <= LE1; j++) { - for (i = j; i <= N; i += LE) { // butterfly + Wr = std::cos (M_PI / (float) LE1); + Wi = -std::sin (M_PI / (float) LE1); // Cooley, Lewis, and Welch have "+" here + for (j = 1; j <= LE1; j++) + { + for (i = j; i <= N; i += LE) + { // butterfly ip = i + LE1; Tr = ar[ip - 1] * Ur - ai[ip - 1] * Ui; Ti = ar[ip - 1] * Ui + ai[ip - 1] * Ur; @@ -68,14 +72,16 @@ void fft(int N, double *ar, double *ai) { } } -float makeWaveTable(WaveTableGroup *group, int len, double *ar, double *ai, double scale, double topFreq) { - fft(len, ar, ai); - - if (scale == 0.0) { +float makeWaveTable (WaveTableGroup* group, int len, double* ar, double* ai, double scale, double topFreq) +{ + fft (len, ar, ai); + if (scale == 0.0) + { // calc normal double max = 0; - for (int idx = 0; idx < len; idx++) { - double temp = fabs(ai[idx]); + for (int idx = 0; idx < len; idx++) + { + double temp = fabs (ai[idx]); if (max < temp) max = temp; } @@ -83,13 +89,13 @@ float makeWaveTable(WaveTableGroup *group, int len, double *ar, double *ai, doub } // normalize - auto *wave = new float[len]; + auto* wave = new float[len]; for (int idx = 0; idx < len; idx++) wave[idx] = ai[idx] * scale; - - if (group->m_numWaveTables < WaveTableGroup::numWaveTableSlots) { - auto table = group->m_WaveTables[group->m_numWaveTables] = new WaveTableObject(); - float *waveTable = group->m_WaveTables[group->m_numWaveTables]->m_waveTable = new float[len + 1]; + if (group->m_numWaveTables < WaveTableGroup::numWaveTableSlots) + { + auto table = group->m_WaveTables[group->m_numWaveTables] = new WaveTableObject (); + float* waveTable = group->m_WaveTables[group->m_numWaveTables]->m_waveTable = new float[len + 1]; table->m_waveTableLen = len; table->m_topFreq = topFreq; ++group->m_numWaveTables; @@ -100,33 +106,34 @@ float makeWaveTable(WaveTableGroup *group, int len, double *ar, double *ai, doub waveTable[len] = waveTable[0]; // duplicate for interpolation wraparound return 0; - } else { + } + else + { scale = 0.0; } return (float) scale; } -int fillTables(WaveTableGroup *group, double *freqWaveRe, double *freqWaveIm, int numSamples) { +int fillTables (WaveTableGroup* group, double* freqWaveRe, double* freqWaveIm, int numSamples) +{ int idx; - freqWaveRe[0] = freqWaveIm[0] = 0.0; freqWaveRe[numSamples >> 1] = freqWaveIm[numSamples >> 1] = 0.0; - int maxHarmonic = numSamples >> 1; const double minVal = 0.000001; // -120 dB - while ((fabs(freqWaveRe[maxHarmonic]) + fabs(freqWaveIm[maxHarmonic]) < minVal) && maxHarmonic) --maxHarmonic; - + while ((fabs (freqWaveRe[maxHarmonic]) + fabs (freqWaveIm[maxHarmonic]) < minVal) && maxHarmonic) --maxHarmonic; double topFreq = 2.0 / 3.0 / maxHarmonic; - - double *ar = new double[numSamples]; - double *ai = new double[numSamples]; + double* ar = new double[numSamples]; + double* ai = new double[numSamples]; double scale = 0.0; int numTables = 0; - while (maxHarmonic) { + while (maxHarmonic) + { // fill the table in with the needed harmonics for (idx = 0; idx < numSamples; idx++) ar[idx] = ai[idx] = 0.0; - for (idx = 1; idx <= maxHarmonic; idx++) { + for (idx = 1; idx <= maxHarmonic; idx++) + { ar[idx] = freqWaveRe[idx]; ai[idx] = freqWaveIm[idx]; ar[numSamples - idx] = freqWaveRe[numSamples - idx]; @@ -134,7 +141,7 @@ int fillTables(WaveTableGroup *group, double *freqWaveRe, double *freqWaveIm, in } // make the wavetable - scale = makeWaveTable(group, numSamples, ar, ai, scale, topFreq); + scale = makeWaveTable (group, numSamples, ar, ai, scale, topFreq); numTables++; // prepare for next table @@ -144,11 +151,13 @@ int fillTables(WaveTableGroup *group, double *freqWaveRe, double *freqWaveIm, in return numTables; } -float getNextRand() { - return std::rand() / double(RAND_MAX); +float getNextRand () +{ + return std::rand () / double (RAND_MAX); } -int findTableLen() { - int maxHarms = AudioConfig::getInstance()->getSampleRate() / (5.0 * 20) + 0.5; - return VeNo::Utils::nextPowerOfTwo(maxHarms) * 2; +int findTableLen () +{ + int maxHarms = AudioConfig::getInstance ()->getSampleRate () / (5.0 * 20) + 0.5; + return VeNo::Utils::nextPowerOfTwo (maxHarms) * 2; } \ No newline at end of file diff --git a/Source/Veno/Audio/WaveTable/TableHelper.h b/Source/Veno/Audio/WaveTable/TableHelper.h index 3e8bc1b..3d6f2d5 100644 --- a/Source/Veno/Audio/WaveTable/TableHelper.h +++ b/Source/Veno/Audio/WaveTable/TableHelper.h @@ -11,7 +11,6 @@ #define M_PI 3.14159265358979323846 #define DOUBLE_PI 6.283185307179586476925286766559 - /* in-place complex fft After Cooley, Lewis, and Welch; from Rabiner & Gold (1975) @@ -20,15 +19,10 @@ Computer Science Dept. Princeton University 08544 */ -void fft(int N, double *ar, double *ai); - -float makeWaveTable(WaveTableGroup *group, int len, double *ar, double *ai, double scale, double topFreq); - +void fft (int N, double* ar, double* ai); +float makeWaveTable (WaveTableGroup* group, int len, double* ar, double* ai, double scale, double topFreq); // utils stuff -int fillTables(WaveTableGroup *group, double *freqWaveRe, double *freqWaveIm, int numSamples); - -int findTableLen(); - -float getNextRand(); - +int fillTables (WaveTableGroup* group, double* freqWaveRe, double* freqWaveIm, int numSamples); +int findTableLen (); +float getNextRand (); #endif //VENO_TABLEHELPER_H diff --git a/Source/Veno/Audio/WaveTable/TriangleWaves.h b/Source/Veno/Audio/WaveTable/TriangleWaves.h index 3267cd3..07f299f 100644 --- a/Source/Veno/Audio/WaveTable/TriangleWaves.h +++ b/Source/Veno/Audio/WaveTable/TriangleWaves.h @@ -4,11 +4,8 @@ #ifndef VENO_TRIANGLEWAVES_H #define VENO_TRIANGLEWAVES_H - - -class TriangleWaves { +class TriangleWaves +{ }; - - #endif //VENO_TRIANGLEWAVES_H diff --git a/Source/Veno/Audio/WaveTable/VeNoXWaves.h b/Source/Veno/Audio/WaveTable/VeNoXWaves.h index fb6ec5d..8a3a002 100644 --- a/Source/Veno/Audio/WaveTable/VeNoXWaves.h +++ b/Source/Veno/Audio/WaveTable/VeNoXWaves.h @@ -4,11 +4,8 @@ #ifndef VENO_VENOXWAVES_H #define VENO_VENOXWAVES_H - - -class VeNoXWaves { +class VeNoXWaves +{ }; - - #endif //VENO_VENOXWAVES_H diff --git a/Source/Veno/Audio/WaveTable/WaveTableGenerator.cpp b/Source/Veno/Audio/WaveTable/WaveTableGenerator.cpp index 496ffd3..f7ccac8 100644 --- a/Source/Veno/Audio/WaveTable/WaveTableGenerator.cpp +++ b/Source/Veno/Audio/WaveTable/WaveTableGenerator.cpp @@ -6,41 +6,48 @@ #include "../../Core/AudioConfig.h" #include "WavesInlcuder.h" -void WaveTableGenerator::init() { +void WaveTableGenerator::init () +{ //if the sampleRate changed... the WaveTables are not harmonic Save anymore and are needed to rebuild... pls stay save later! - if (AudioConfig::getInstance()->isNeedToReInit()) { - cleanTables(); - AudioConfig::getInstance()->setNeedToReInit(false); + if (AudioConfig::getInstance ()->isNeedToReInit ()) + { + cleanTables (); + AudioConfig::getInstance ()->setNeedToReInit (false); } - if (m_isInit) { + if (m_isInit) + { return; } - m_waveTables[WaveForms::SAW] = new WaveTableGroup(); - m_waveTables[WaveForms::SINE] = new WaveTableGroup(); - m_waveTables[WaveForms::SQUARE] = new WaveTableGroup(); - m_waveTables[WaveForms::TRIANGLE] = new WaveTableGroup(); - m_waveTables[WaveForms::wSaw] = new WaveTableGroup(); - m_waveTables[WaveForms::wSQUARE] = new WaveTableGroup(); - m_waveTables[WaveForms::SYNTHONE] = new WaveTableGroup(); - m_waveTables[WaveForms::SYNTHTWO] = new WaveTableGroup(); - m_waveTables[WaveForms::VENOX] = new WaveTableGroup(); - - generateSaw(m_waveTables[WaveForms::SAW]); + m_waveTables[WaveForms::SAW] = new WaveTableGroup (); + m_waveTables[WaveForms::SINE] = new WaveTableGroup (); + m_waveTables[WaveForms::SQUARE] = new WaveTableGroup (); + m_waveTables[WaveForms::TRIANGLE] = new WaveTableGroup (); + m_waveTables[WaveForms::wSaw] = new WaveTableGroup (); + m_waveTables[WaveForms::wSQUARE] = new WaveTableGroup (); + m_waveTables[WaveForms::SYNTHONE] = new WaveTableGroup (); + m_waveTables[WaveForms::SYNTHTWO] = new WaveTableGroup (); + m_waveTables[WaveForms::VENOX] = new WaveTableGroup (); + generateSaw (m_waveTables[WaveForms::SAW]); m_isInit = true; } -WaveTableGroup *WaveTableGenerator::getGroup(int id) { - if (!m_isInit) { - init(); +WaveTableGroup* WaveTableGenerator::getGroup (int id) +{ + if (!m_isInit) + { + init (); } - if (id < 40) { + if (id < 40) + { return m_waveTables[id]; } return nullptr; } -void WaveTableGenerator::cleanTables() { - for (auto & m_waveTable : m_waveTables) { +void WaveTableGenerator::cleanTables () +{ + for (auto& m_waveTable : m_waveTables) + { delete m_waveTable; } m_isInit = false; diff --git a/Source/Veno/Audio/WaveTable/WaveTableGenerator.h b/Source/Veno/Audio/WaveTable/WaveTableGenerator.h index 8ee5c11..4124f37 100644 --- a/Source/Veno/Audio/WaveTable/WaveTableGenerator.h +++ b/Source/Veno/Audio/WaveTable/WaveTableGenerator.h @@ -4,20 +4,20 @@ #ifndef VENO_WAVETABLEGENERATOR_H #define VENO_WAVETABLEGENERATOR_H - -struct WaveTableObject { +struct WaveTableObject +{ double m_topFreq; int m_waveTableLen; - float *m_waveTable; + float* m_waveTable; }; - -struct WaveTableGroup { +struct WaveTableGroup +{ static constexpr int numWaveTableSlots = 40; - WaveTableObject *m_WaveTables[numWaveTableSlots] = {}; + WaveTableObject* m_WaveTables[numWaveTableSlots] = {}; int m_numWaveTables = 0; }; - -enum WaveForms { +enum WaveForms +{ SAW = 0, SINE, SQUARE, @@ -28,26 +28,24 @@ enum WaveForms { SYNTHTWO, VENOX }; - -class WaveTableGenerator { +class WaveTableGenerator +{ private: static constexpr int numWaveTableSlots = 40; - WaveTableGroup *m_waveTables[numWaveTableSlots] = {}; + WaveTableGroup* m_waveTables[numWaveTableSlots] = {}; public: - static WaveTableGenerator &getInstance() { + static WaveTableGenerator& getInstance () + { static WaveTableGenerator instance; return instance; } - WaveTableGroup *getGroup(int id); - void init(); - - void cleanTables(); + WaveTableGroup* getGroup (int id); + void init (); + void cleanTables (); protected: bool m_isInit = false; - WaveTableGenerator() = default; - ~WaveTableGenerator() = default; + WaveTableGenerator () = default; + ~WaveTableGenerator () = default; }; - - #endif //VENO_WAVETABLEGENERATOR_H diff --git a/Source/Veno/Core/AudioConfig.cpp b/Source/Veno/Core/AudioConfig.cpp index 59b0854..dd8d139 100644 --- a/Source/Veno/Core/AudioConfig.cpp +++ b/Source/Veno/Core/AudioConfig.cpp @@ -5,43 +5,54 @@ #include "../Audio/WaveTable/WaveTableGenerator.h" std::shared_ptr AudioConfig::m_instance; -float AudioConfig::getSampleRate() { + +float AudioConfig::getSampleRate () +{ return m_sampleRate; } -void AudioConfig::setSampleRate(float _sampleRate) { - if (m_sampleRate != _sampleRate) { +void AudioConfig::setSampleRate (float _sampleRate) +{ + if (m_sampleRate != _sampleRate) + { m_sampleRate = _sampleRate; m_needToReInit = true; } } -float AudioConfig::getBufferSize() { +float AudioConfig::getBufferSize () +{ return m_bufferSize; } -void AudioConfig::setBufferSize(float _bufferSize) { +void AudioConfig::setBufferSize (float _bufferSize) +{ m_bufferSize = _bufferSize; } -bool AudioConfig::isNeedToReInit() const { +bool AudioConfig::isNeedToReInit () const +{ return m_needToReInit; } -void AudioConfig::setNeedToReInit(bool _needToReInit) { +void AudioConfig::setNeedToReInit (bool _needToReInit) +{ m_needToReInit = _needToReInit; } -std::shared_ptr AudioConfig::getInstance() { +std::shared_ptr AudioConfig::getInstance () +{ if (AudioConfig::m_instance == nullptr) - AudioConfig::m_instance = std::make_shared(); + AudioConfig::m_instance = std::make_shared (); return m_instance; } -void AudioConfig::initWaveTables() { - WaveTableGenerator::getInstance().init(); +void AudioConfig::initWaveTables () +{ + WaveTableGenerator::getInstance ().init (); } -AudioConfig::~AudioConfig() { - WaveTableGenerator::getInstance().cleanTables(); +AudioConfig::~AudioConfig () +{ + WaveTableGenerator::getInstance ().cleanTables (); } diff --git a/Source/Veno/Core/AudioConfig.h b/Source/Veno/Core/AudioConfig.h index 8dbdbbe..86a1109 100644 --- a/Source/Veno/Core/AudioConfig.h +++ b/Source/Veno/Core/AudioConfig.h @@ -10,33 +10,23 @@ /** * holds SampleRate and other needed sound information's :) */ -class AudioConfig { +class AudioConfig +{ private: static std::shared_ptr m_instance; float m_sampleRate = 44100; float m_bufferSize = 512; //maybe we need that... but this will update always! bool m_needToReInit = false; //this is to reInit the Oscillators, ADSR and other stuff public: - static std::shared_ptr getInstance(); - - float getSampleRate(); - - void setSampleRate(float _sampleRate); - - float getBufferSize(); - - void setBufferSize(float _bufferSize); - - bool isNeedToReInit() const; - - void setNeedToReInit(bool _needToReInit); - - static void initWaveTables(); - - ~AudioConfig(); - + static std::shared_ptr getInstance (); + float getSampleRate (); + void setSampleRate (float _sampleRate); + float getBufferSize (); + void setBufferSize (float _bufferSize); + bool isNeedToReInit () const; + void setNeedToReInit (bool _needToReInit); + static void initWaveTables (); + ~AudioConfig (); protected: }; - - #endif //VENO_AUDIOCONFIG_H diff --git a/Source/Veno/Core/Config.cpp b/Source/Veno/Core/Config.cpp index a8a5016..69caa4e 100644 --- a/Source/Veno/Core/Config.cpp +++ b/Source/Veno/Core/Config.cpp @@ -3,82 +3,100 @@ // #include "Config.h" +#include "../Fonts/Fonts.h" std::shared_ptr Config::m_instance = nullptr; -Config::Config() { +Config::Config () +{ // i want to load the m_config file here... - initConfig(); - - m_theme = std::make_shared(m_config); - m_theme->init(); - m_fps = m_config->getIntValue("waveform_fps", 60); + initConfig (); + m_theme = std::make_shared (m_config); + m_theme->init (); + m_fps = m_config->getIntValue ("waveform_fps", 60); } -void Config::saveAll() { - if (m_config != nullptr) { - m_config->saveIfNeeded(); +void Config::saveAll () +{ + if (m_config != nullptr) + { + m_config->saveIfNeeded (); } } -int Config::getCurrentLook() { - if (m_currentLook > 1) { +int Config::getCurrentLook () +{ + if (m_currentLook > 1) + { m_currentLook = 0; } return m_currentLook; } -void Config::initConfig() { +void Config::initConfig () +{ PropertiesFile::Options options; options.applicationName = "config"; options.folderName = "veno"; options.filenameSuffix = "xml"; - m_config = std::make_unique(options); + m_config = std::make_unique (options); } -std::shared_ptr Config::getCurrentTheme() { +std::shared_ptr Config::getCurrentTheme () +{ return m_theme; } -double Config::getScale() { +double Config::getScale () +{ return 1; } -void Config::setColourForIndex(Colour *colour, ThemeColour index) { - if (m_theme) { - m_theme->setColour(index, colour); +void Config::setColourForIndex (Colour* colour, ThemeColour index) +{ + if (m_theme) + { + m_theme->setColour (index, colour); } } -Config::~Config() { - m_config->save(); - m_theme.reset(); - m_config.reset(); +Config::~Config () +{ + m_config->save (); + m_theme.reset (); + m_config.reset (); } //LEAK DETECTOR FIX! -void Config::registerEditor(AudioProcessorEditor *editor, const std::string &name) { +void Config::registerEditor (AudioProcessorEditor* editor, const std::string& name) +{ m_editors[name] = editor; } -void Config::removeEditor(const std::string &name) { - m_editors.erase(name); - if (m_editors.empty()) { +void Config::removeEditor (const std::string& name) +{ + m_editors.erase (name); + if (m_editors.empty ()) + { + VenoFonts::destroyAll (); m_instance = nullptr; } } //for LCD :P let's be a bit funny xD -int Config::getEditorCount() { - return m_editors.size(); +int Config::getEditorCount () +{ + return m_editors.size (); } -std::shared_ptr Config::getInstance() { +std::shared_ptr Config::getInstance () +{ if (m_instance == nullptr) - m_instance = std::make_shared(); + m_instance = std::make_shared (); return m_instance; } -int Config::getFps() const { +int Config::getFps () const +{ return m_fps; } diff --git a/Source/Veno/Core/Config.h b/Source/Veno/Core/Config.h index 2b74d01..cf4fc17 100644 --- a/Source/Veno/Core/Config.h +++ b/Source/Veno/Core/Config.h @@ -10,42 +10,30 @@ #include "../GUI/Theme/Theme.h" #include -class Config { +class Config +{ private: std::shared_ptr m_config = nullptr; std::shared_ptr m_theme = nullptr; static std::shared_ptr m_instance; int m_currentLook = 0; //nah move the bitch logic from current to next - std::unordered_map m_editors; + std::unordered_map m_editors; int m_fps = 60; public: - static std::shared_ptr getInstance(); - - void saveAll(); - - int getCurrentLook(); - - void setColourForIndex(Colour *colour, ThemeColour index); - - std::shared_ptr getCurrentTheme(); - - double getScale(); - + static std::shared_ptr getInstance (); + 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(); - - int getFps() const; - + Config (); + ~Config (); + void registerEditor (AudioProcessorEditor* editor, const std::string& name); + void removeEditor (const std::string& name); + int getEditorCount (); + int getFps () const; protected: - void initConfig(); + void initConfig (); }; - #endif //VENO_CONFIG_H diff --git a/Source/Veno/Core/PresetManager.h b/Source/Veno/Core/PresetManager.h index 8ddc914..cac6ec6 100644 --- a/Source/Veno/Core/PresetManager.h +++ b/Source/Veno/Core/PresetManager.h @@ -4,11 +4,8 @@ #ifndef VENO_PRESETMANAGER_H #define VENO_PRESETMANAGER_H - - -class PresetManager { +class PresetManager +{ }; - - #endif //VENO_PRESETMANAGER_H diff --git a/Source/Veno/Fonts/Fonts.cpp b/Source/Veno/Fonts/Fonts.cpp new file mode 100644 index 0000000..3d232bc --- /dev/null +++ b/Source/Veno/Fonts/Fonts.cpp @@ -0,0 +1,46 @@ +// +// Created by versustune on 13.06.20. +// + +#include "Fonts.h" + +VenoFonts* VenoFonts::instance = new VenoFonts (); + +Font* VenoFonts::getNormal () +{ + return getInstance ()->arvo; +} + +Font* VenoFonts::getLCD () +{ + return getInstance ()->lcdFont; +} + +VenoFonts* VenoFonts::getInstance () +{ + if (instance == nullptr) + { + instance = new VenoFonts (); + } + return instance; +} + +void VenoFonts::destroyAll () +{ + delete instance; + instance = nullptr; +} + +VenoFonts::VenoFonts () +{ + arvo = new Font (Typeface::createSystemTypefaceFor (BinaryData::arvo_ttf, + BinaryData::arvo_ttfSize)); + lcdFont = new Font (Typeface::createSystemTypefaceFor (BinaryData::lcd_ttf, + BinaryData::lcd_ttfSize)); +} + +VenoFonts::~VenoFonts () +{ + delete arvo; + delete lcdFont; +} diff --git a/Source/Veno/Fonts/Fonts.h b/Source/Veno/Fonts/Fonts.h index 26a5e83..c5f32f8 100644 --- a/Source/Veno/Fonts/Fonts.h +++ b/Source/Veno/Fonts/Fonts.h @@ -7,19 +7,18 @@ #include "JuceHeader.h" -class VenoFonts { +class VenoFonts +{ +protected: + static VenoFonts* instance; + Font* lcdFont; + Font* arvo; public: - static const Font &getLCD() { - static Font lcd(Font(Typeface::createSystemTypefaceFor(BinaryData::lcd_ttf, - BinaryData::lcd_ttfSize))); - return lcd; - } - - static const Font &getNormal() { - static Font arvo(Font(Typeface::createSystemTypefaceFor(BinaryData::arvo_ttf, - BinaryData::arvo_ttfSize))); - return arvo; - } + VenoFonts (); + ~VenoFonts (); + static void destroyAll (); + static Font* getLCD (); + static Font* getNormal (); + static VenoFonts* getInstance (); }; - #endif //VENO_FONTS_H diff --git a/Source/Veno/GUI/Components/BaseComponent.cpp b/Source/Veno/GUI/Components/BaseComponent.cpp index 4ad3a32..f9a5408 100644 --- a/Source/Veno/GUI/Components/BaseComponent.cpp +++ b/Source/Veno/GUI/Components/BaseComponent.cpp @@ -4,40 +4,49 @@ #include "BaseComponent.h" #include "../../Fonts/Fonts.h" - #include -BaseComponent::BaseComponent(const std::string& processId) { +BaseComponent::BaseComponent (const std::string& processId) +{ m_processId = processId; } -BaseComponent::~BaseComponent() { - m_label.reset(); +BaseComponent::~BaseComponent () +{ + m_label.reset (); } -void BaseComponent::addLabel(const std::string &label_text, LabelPosition labelPosition) { +void BaseComponent::addLabel (const std::string& label_text, LabelPosition labelPosition) +{ m_enableLabel = true; - m_label = std::make_shared(this, label_text); - m_label->setPosition(labelPosition); + m_label = std::make_shared (this, label_text); + m_label->setPosition (labelPosition); } -void BaseComponent::resized() { - if (m_enableLabel && m_label != nullptr) { - LabelPosition position = m_label->getLabelPosition(); - if (position == LabelPosition::TOP) { - m_label->setBounds(0, 0, getWidth(), 15); - } else if (position == LabelPosition::BOTTOM) { - m_label->setBounds(0, getHeight() - 20, getWidth(), 15); +void BaseComponent::resized () +{ + if (m_enableLabel && m_label != nullptr) + { + LabelPosition position = m_label->getLabelPosition (); + if (position == LabelPosition::TOP) + { + m_label->setBounds (0, 0, getWidth (), 15); + } + else if (position == LabelPosition::BOTTOM) + { + m_label->setBounds (0, getHeight () - 20, getWidth (), 15); } } } -void BaseComponent::paint(Graphics &g) { - g.setFont(VenoFonts::getNormal()); +void BaseComponent::paint (Graphics& g) +{ + g.setFont (*VenoFonts::getNormal ()); } -void BaseComponent::setParameter(std::string name, std::string group) { - m_name = std::move(name); - m_group = std::move(group); - setName(m_name); +void BaseComponent::setParameter (std::string name, std::string group) +{ + m_name = std::move (name); + m_group = std::move (group); + setName (m_name); } diff --git a/Source/Veno/GUI/Components/BaseComponent.h b/Source/Veno/GUI/Components/BaseComponent.h index b712b1c..48fde32 100644 --- a/Source/Veno/GUI/Components/BaseComponent.h +++ b/Source/Veno/GUI/Components/BaseComponent.h @@ -13,22 +13,21 @@ /** * this is the base Component of all VeNo Components... it has all important Methods */ -class BaseComponent : public Component { +class BaseComponent : public Component +{ private: std::string m_group; std::string m_name; bool m_enableLabel = false; std::shared_ptr m_label; public: - explicit BaseComponent(const std::string& processId); - ~BaseComponent() override; - void addLabel(const std::string& label, LabelPosition labelPosition); - void setParameter(std::string name, std::string group); - void resized() override; - void paint(Graphics &g) override; + explicit BaseComponent (const std::string& processId); + ~BaseComponent () override; + void addLabel (const std::string& label, LabelPosition labelPosition); + void setParameter (std::string name, std::string group); + void resized () override; + void paint (Graphics& g) override; protected: std::string m_processId; }; - - #endif //VENO_BASECOMPONENT_H diff --git a/Source/Veno/GUI/Components/LCD/SidebarLCD.cpp b/Source/Veno/GUI/Components/LCD/SidebarLCD.cpp index 8bdb562..8bc8089 100644 --- a/Source/Veno/GUI/Components/LCD/SidebarLCD.cpp +++ b/Source/Veno/GUI/Components/LCD/SidebarLCD.cpp @@ -7,49 +7,56 @@ #include "../../../Core/Config.h" #include "../../../Fonts/Fonts.h" -SidebarLCD::SidebarLCD(const std::string &process_id) : BaseComponent(process_id) { - waveform = std::make_unique(process_id); - addAndMakeVisible(*waveform); +SidebarLCD::SidebarLCD (const std::string& process_id) : BaseComponent (process_id) +{ + waveform = std::make_unique (process_id); + addAndMakeVisible (*waveform); } -SidebarLCD::~SidebarLCD() { - waveform.reset(nullptr); +SidebarLCD::~SidebarLCD () +{ + waveform.reset (nullptr); } -void SidebarLCD::drawHeadline(Graphics &g) { - float fontSize = VeNo::Utils::setFontSize(12.0f, g) + 2; +void SidebarLCD::drawHeadline (Graphics& g) +{ + float fontSize = VeNo::Utils::setFontSize (12.0f, g) + 2; int line = m_innerY + fontSize + 2; - g.drawText(">>> VeNo <<<", 0, m_innerY, getWidth() - m_width, fontSize, - Justification::centred, - true); - g.drawLine(0, line, getWidth(), line); + g.drawText (">>> VeNo <<<", 0, m_innerY, getWidth () - m_width, fontSize, + Justification::centred, + true); + g.drawLine (0, line, getWidth (), line); } -void SidebarLCD::drawFooter(Graphics &g) { - float fontSize = VeNo::Utils::setFontSize(8.0f, g) + 4; +void SidebarLCD::drawFooter (Graphics& g) +{ + float fontSize = VeNo::Utils::setFontSize (8.0f, g) + 4; int space = m_innerY + fontSize; - int line = getHeight() - space; - g.drawText("by VersusTuneZ", 0, line, getWidth() - m_width, fontSize, - Justification::horizontallyCentred, - true); - g.drawLine(0, line - 4, getWidth(), line - 4); + int line = getHeight () - space; + g.drawText ("by VersusTuneZ", 0, line, getWidth () - m_width, fontSize, + Justification::horizontallyCentred, + true); + g.drawLine (0, line - 4, getWidth (), line - 4); } -void SidebarLCD::resized() { - float topSpace = (12 * Config::getInstance()->getScale()) + 4 + m_innerY; - if (waveform != nullptr) { - waveform->setBounds(0, topSpace*2, getWidth(), getHeight() - (topSpace*4)); +void SidebarLCD::resized () +{ + float topSpace = (12 * Config::getInstance ()->getScale ()) + 4 + m_innerY; + if (waveform != nullptr) + { + waveform->setBounds (0, topSpace * 2, getWidth (), getHeight () - (topSpace * 4)); } } -void SidebarLCD::paint(Graphics &g) { - std::shared_ptr theme = Config::getInstance()->getCurrentTheme(); - auto colour = theme->getColour(ThemeColour::lcd_bg); - g.fillAll(colour); +void SidebarLCD::paint (Graphics& g) +{ + std::shared_ptr theme = Config::getInstance ()->getCurrentTheme (); + auto colour = theme->getColour (ThemeColour::lcd_bg); + g.fillAll (colour); // background - auto accent = theme->getColour(ThemeColour::lcd); - g.setColour(accent); - g.setFont(VenoFonts::getLCD()); - drawHeadline(g); - drawFooter(g); + auto accent = theme->getColour (ThemeColour::lcd); + g.setColour (accent); + g.setFont (*VenoFonts::getLCD ()); + drawHeadline (g); + drawFooter (g); } \ No newline at end of file diff --git a/Source/Veno/GUI/Components/LCD/SidebarLCD.h b/Source/Veno/GUI/Components/LCD/SidebarLCD.h index 79caa96..f837e1b 100644 --- a/Source/Veno/GUI/Components/LCD/SidebarLCD.h +++ b/Source/Veno/GUI/Components/LCD/SidebarLCD.h @@ -9,24 +9,20 @@ #include "../BaseComponent.h" #include "Waveforms.h" -class SidebarLCD : public BaseComponent { +class SidebarLCD : public BaseComponent +{ private: int m_innerX = 5; int m_innerY = 5; int m_width = m_innerX * 2; public: - explicit SidebarLCD(const std::string &process_id); - ~SidebarLCD(); - - void resized() override; - void paint(Graphics &g) override; - + explicit SidebarLCD (const std::string& process_id); + ~SidebarLCD (); + void resized () override; + void paint (Graphics& g) override; protected: - void drawHeadline(Graphics &g); - void drawFooter(Graphics &g); - + void drawHeadline (Graphics& g); + void drawFooter (Graphics& g); std::unique_ptr waveform; }; - - #endif //VENO_SIDEBARLCD_H diff --git a/Source/Veno/GUI/Components/LCD/Waveforms.cpp b/Source/Veno/GUI/Components/LCD/Waveforms.cpp index 8c197af..2d630fe 100644 --- a/Source/Veno/GUI/Components/LCD/Waveforms.cpp +++ b/Source/Veno/GUI/Components/LCD/Waveforms.cpp @@ -9,227 +9,270 @@ #include "../../../VenoInstance.h" #include "../../../Fonts/Fonts.h" -Waveforms::Waveforms(const std::string &processId) : BaseComponent(processId) { - m_context.setOpenGLVersionRequired(OpenGLContext::OpenGLVersion::openGL3_2); - m_context.setRenderer(this); - m_context.setContinuousRepainting(false); - m_context.setComponentPaintingEnabled(true); - m_context.attachTo(*this); - auto fps = Config::getInstance()->getFps(); - startTimerHz(Config::getInstance()->getFps()); - std::srand(unsigned(time(nullptr))); - pickRandomText = (std::rand() % RANDOM_TEXT_COUNT); +Waveforms::Waveforms (const std::string& processId) : BaseComponent (processId) +{ + m_context.setOpenGLVersionRequired (OpenGLContext::OpenGLVersion::openGL3_2); + m_context.setRenderer (this); + m_context.setContinuousRepainting (false); + m_context.setComponentPaintingEnabled (true); + m_context.attachTo (*this); + auto fps = Config::getInstance ()->getFps (); + startTimerHz (Config::getInstance ()->getFps ()); + std::srand (unsigned (time (nullptr))); + pickRandomText = (std::rand () % RANDOM_TEXT_COUNT); m_ticks = 0; // is something that - m_time_needed = roundToInt(4000 / (1000 / fps)); - m_time_needed_startup = roundToInt(1000 / (1000 / fps)); + m_time_needed = roundToInt (4000 / (1000 / fps)); + m_time_needed_startup = roundToInt (1000 / (1000 / fps)); } -Waveforms::~Waveforms() { - stopTimer(); - shaderProgram.reset(); - m_context.detach(); +Waveforms::~Waveforms () +{ + stopTimer (); + shaderProgram.reset (); + m_context.detach (); } -void Waveforms::newOpenGLContextCreated() { - compileOpenGLShaderProgram(); +void Waveforms::newOpenGLContextCreated () +{ + compileOpenGLShaderProgram (); } -void Waveforms::openGLContextClosing() { +void Waveforms::openGLContextClosing () +{ } -void Waveforms::renderOpenGL() { - if (!isShowing() || shaderProgram == nullptr || !shaderProgram->getLastError().isEmpty()) { +void Waveforms::renderOpenGL () +{ + if (!isShowing () || shaderProgram == nullptr || !shaderProgram->getLastError ().isEmpty ()) + { return; } - auto theme = Config::getInstance()->getCurrentTheme(); - if (theme == nullptr) { + auto theme = Config::getInstance ()->getCurrentTheme (); + if (theme == nullptr) + { return; } - glViewport(0, 0, getWidth(), getHeight()); - OpenGLHelpers::clear(theme->getColour(ThemeColour::lcd_bg)); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - shaderProgram->use(); - auto color = theme->getColour(ThemeColour::lcd); - shaderProgram->setUniform("color", color.getFloatRed(), color.getFloatGreen(), color.getFloatBlue(), - color.getFloatAlpha()); - if (m_isWelcome || m_isStarting || m_isChangingData) { + glViewport (0, 0, getWidth (), getHeight ()); + OpenGLHelpers::clear (theme->getColour (ThemeColour::lcd_bg)); + glEnable (GL_BLEND); + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + shaderProgram->use (); + auto color = theme->getColour (ThemeColour::lcd); + shaderProgram->setUniform ("color", color.getFloatRed (), color.getFloatGreen (), color.getFloatBlue (), + color.getFloatAlpha ()); + if (m_isWelcome || m_isStarting || m_isChangingData) + { return; } - switch (m_mode) { + switch (m_mode) + { case 1: - drawAudioOutput(); + drawAudioOutput (); break; case 2: - drawWaveTable(); + drawWaveTable (); break; case 3: - drawSpectrum(); + drawSpectrum (); break; default: - drawPeakMeter(); + drawPeakMeter (); } } -void Waveforms::handleAsyncUpdate() { +void Waveforms::handleAsyncUpdate () +{ } -void Waveforms::compileOpenGLShaderProgram() { +void Waveforms::compileOpenGLShaderProgram () +{ std::unique_ptr shaderProgramAttempt - = std::make_unique(m_context); - - if (shaderProgramAttempt->addVertexShader({BinaryData::WaveForm_vertex_glsl}) - && shaderProgramAttempt->addFragmentShader({BinaryData::WaveForm_fragment_glsl}) - && shaderProgramAttempt->link()) { - shaderProgram = std::move(shaderProgramAttempt); + = std::make_unique (m_context); + if (shaderProgramAttempt->addVertexShader ({BinaryData::WaveForm_vertex_glsl}) + && shaderProgramAttempt->addFragmentShader ({BinaryData::WaveForm_fragment_glsl}) + && shaderProgramAttempt->link ()) + { + shaderProgram = std::move (shaderProgramAttempt); } } -void Waveforms::mouseDown(const MouseEvent &e) { - if (!m_enableModeToggle) { +void Waveforms::mouseDown (const MouseEvent& e) +{ + if (!m_enableModeToggle) + { return; } m_mode++; - if (m_mode > 3) { + if (m_mode > 3) + { m_mode = 0; } } -void Waveforms::mouseDrag(const MouseEvent &e) { +void Waveforms::mouseDrag (const MouseEvent& e) +{ //do nothing... you faggot } -void Waveforms::timerCallback() { - if (m_isWelcome || m_isStarting || m_isChangingData || needToClear) { - repaint(); - } else { - if (m_context.isAttached()) { - m_context.triggerRepaint(); +void Waveforms::timerCallback () +{ + if (m_isWelcome || m_isStarting || m_isChangingData || needToClear) + { + repaint (); + } + else + { + if (m_context.isAttached ()) + { + m_context.triggerRepaint (); } } } -void Waveforms::drawWaveTable() { +void Waveforms::drawWaveTable () +{ // this will draw the current selected oscillator :D } -void Waveforms::drawAudioOutput() { +void Waveforms::drawAudioOutput () +{ // draw audio from the oscillators - auto instance = VenoInstance::getInstance(BaseComponent::m_processId); - auto buffer = instance->audioBuffer->getBuffer(); - glBegin(GL_LINE_STRIP); + auto instance = VenoInstance::getInstance (BaseComponent::m_processId); + auto buffer = instance->audioBuffer->getBuffer (); + glBegin (GL_LINE_STRIP); float posX = -1; - float inc = 2.0f / buffer.size(); - for (float i : buffer) { - glVertex2f(posX, i); + float inc = 2.0f / buffer.size (); + for (float i : buffer) + { + glVertex2f (posX, i); posX += inc; } - glEnd(); + glEnd (); } -void Waveforms::drawPeakMeter() { - auto theme = Config::getInstance()->getCurrentTheme(); - if (theme == nullptr) { +void Waveforms::drawPeakMeter () +{ + auto theme = Config::getInstance ()->getCurrentTheme (); + if (theme == nullptr) + { return; } - auto instance = VenoInstance::getInstance(BaseComponent::m_processId); - instance->audioBuffer->calcPeak(); + auto instance = VenoInstance::getInstance (BaseComponent::m_processId); + instance->audioBuffer->calcPeak (); // draw peak signal - auto leftChannel = jmap(Decibels::gainToDecibels(instance->audioBuffer->leftPeak, -80.0f), -80.0f, 6.0f, -1.0f, - 1.0f); - selectColourByPeak(leftChannel); - glBegin(GL_TRIANGLES); - glVertex2f(-0.9f, leftChannel); - glVertex2f(-0.9f, -1.0f); - glVertex2f(-0.01f, -1.0f); - glVertex2f(-0.9f, leftChannel); - glVertex2f(-0.01f, leftChannel); - glVertex2f(-0.01f, -1.0f); - glEnd(); - auto rightChannel = jmap(Decibels::gainToDecibels(instance->audioBuffer->rightPeak, -80.0f), -80.0f, 6.0f, -1.0f, + auto leftChannel = jmap (Decibels::gainToDecibels (instance->audioBuffer->leftPeak, -80.0f), -80.0f, 6.0f, -1.0f, 1.0f); - selectColourByPeak(rightChannel); - glBegin(GL_TRIANGLES); - glVertex2f(0.9f, rightChannel); - glVertex2f(0.9f, -1.0f); - glVertex2f(0.01f, -1.0f); - glVertex2f(0.9f, rightChannel); - glVertex2f(0.01f, rightChannel); - glVertex2f(0.01f, -1.0f); - glEnd(); + selectColourByPeak (leftChannel); + glBegin (GL_TRIANGLES); + glVertex2f (-0.9f, leftChannel); + glVertex2f (-0.9f, -1.0f); + glVertex2f (-0.01f, -1.0f); + glVertex2f (-0.9f, leftChannel); + glVertex2f (-0.01f, leftChannel); + glVertex2f (-0.01f, -1.0f); + glEnd (); + auto rightChannel = jmap (Decibels::gainToDecibels (instance->audioBuffer->rightPeak, -80.0f), -80.0f, 6.0f, -1.0f, + 1.0f); + selectColourByPeak (rightChannel); + glBegin (GL_TRIANGLES); + glVertex2f (0.9f, rightChannel); + glVertex2f (0.9f, -1.0f); + glVertex2f (0.01f, -1.0f); + glVertex2f (0.9f, rightChannel); + glVertex2f (0.01f, rightChannel); + glVertex2f (0.01f, -1.0f); + glEnd (); } -void Waveforms::paint(Graphics &g) { - std::shared_ptr theme = Config::getInstance()->getCurrentTheme(); - auto accent = theme->getColour(ThemeColour::lcd); - g.setColour(accent); - g.setFont(VenoFonts::getLCD()); - VeNo::Utils::setFontSize(16.0f, g); - if (m_isWelcome) { - drawWelcome(g, getWidth(), getHeight(), 0, 0); +void Waveforms::paint (Graphics& g) +{ + std::shared_ptr theme = Config::getInstance ()->getCurrentTheme (); + auto accent = theme->getColour (ThemeColour::lcd); + g.setColour (accent); + g.setFont (*VenoFonts::getLCD ()); + VeNo::Utils::setFontSize (16.0f, g); + if (m_isWelcome) + { + drawWelcome (g, getWidth (), getHeight (), 0, 0); m_ticks++; - if (m_ticks > m_time_needed_startup) { + if (m_ticks > m_time_needed_startup) + { m_isWelcome = false; m_ticks = 0; needToClear = true; } - } else if (m_isStarting) { - g.drawText(m_warmUpText[pickRandomText], 0, 0, getWidth(), getHeight(), - Justification::centred, true); + } + else if (m_isStarting) + { + g.drawText (m_warmUpText[pickRandomText], 0, 0, getWidth (), getHeight (), + Justification::centred, true); m_ticks++; - if (m_ticks > m_time_needed_startup) { + if (m_ticks > m_time_needed_startup) + { m_isStarting = false; m_ticks = 0; needToClear = true; } - } else if (m_isChangingData) { - drawChangedParameter(g, getWidth(), getHeight(), 0, 0); + } + else if (m_isChangingData) + { + drawChangedParameter (g, getWidth (), getHeight (), 0, 0); m_ticks++; - if (m_ticks > m_time_needed) { + if (m_ticks > m_time_needed) + { m_isChangingData = false; m_ticks = 0; needToClear = true; } - } else { - g.resetToDefaultState(); + } + else + { + g.resetToDefaultState (); needToClear = false; } } -void Waveforms::drawChangedParameter(Graphics &g, int w, int h, int x, int y) const { +void Waveforms::drawChangedParameter (Graphics& g, int w, int h, int x, int y) const +{ int halfHeight = h / 2; - float font = VeNo::Utils::setFontSize(12, g); - g.drawText(changingParameter, x, y + halfHeight - font, w, font, Justification::centred, true); - g.drawText(std::to_string(changedValue), x, y + halfHeight + 4, w, font, Justification::centred, - true); + float font = VeNo::Utils::setFontSize (12, g); + g.drawText (changingParameter, x, y + halfHeight - font, w, font, Justification::centred, true); + g.drawText (std::to_string (changedValue), x, y + halfHeight + 4, w, font, Justification::centred, + true); } -void Waveforms::drawWelcome(Graphics &g, int w, int h, int x, int y) { - float font = VeNo::Utils::setFontSize(12, g); +void Waveforms::drawWelcome (Graphics& g, int w, int h, int x, int y) +{ + float font = VeNo::Utils::setFontSize (12, g); int halfHeight = h / 2; - g.drawText(m_readyText, x, y + halfHeight - font, w, font, Justification::centred, true); - g.drawText(SystemStats::getLogonName(), x, y + halfHeight + 4, w, font, Justification::centred, - true); + g.drawText (m_readyText, x, y + halfHeight - font, w, font, Justification::centred, true); + g.drawText (SystemStats::getLogonName (), x, y + halfHeight + 4, w, font, Justification::centred, + true); } -void Waveforms::drawSpectrum() { +void Waveforms::drawSpectrum () +{ } -void Waveforms::selectColourByPeak(float value) { - auto theme = Config::getInstance()->getCurrentTheme(); - if (theme == nullptr) { +void Waveforms::selectColourByPeak (float value) +{ + auto theme = Config::getInstance ()->getCurrentTheme (); + if (theme == nullptr) + { return; } - auto color = theme->getColour(ThemeColour::lcd); - if (value > 0.8 && value < 0.9) { - color = theme->getColour(ThemeColour::warning); + auto color = theme->getColour (ThemeColour::lcd); + if (value > 0.8 && value < 0.9) + { + color = theme->getColour (ThemeColour::warning); } - if (value > 0.9) { - color = theme->getColour(ThemeColour::clip); + if (value > 0.9) + { + color = theme->getColour (ThemeColour::clip); } - shaderProgram->setUniform("color", color.getFloatRed(), color.getFloatGreen(), color.getFloatBlue(), - color.getFloatAlpha()); + shaderProgram->setUniform ("color", color.getFloatRed (), color.getFloatGreen (), color.getFloatBlue (), + color.getFloatAlpha ()); } diff --git a/Source/Veno/GUI/Components/LCD/Waveforms.h b/Source/Veno/GUI/Components/LCD/Waveforms.h index 9718b8e..98c5364 100644 --- a/Source/Veno/GUI/Components/LCD/Waveforms.h +++ b/Source/Veno/GUI/Components/LCD/Waveforms.h @@ -9,17 +9,18 @@ #include "../BaseComponent.h" #define RANDOM_TEXT_COUNT 5 - // opengl context :D class Waveforms : public BaseComponent, private OpenGLRenderer, private AsyncUpdater, - private Timer { + private Timer +{ protected: bool m_enableModeToggle = true; int m_mode = 0; std::string m_readyText = "=WELCOME="; - std::string m_warmUpText[RANDOM_TEXT_COUNT] = {"Warmup...", "Mayonnaise", "Dont shake the baby", "Awesome stuff", "drink beer"}; + std::string m_warmUpText[RANDOM_TEXT_COUNT] = {"Warmup...", "Mayonnaise", "Dont shake the baby", "Awesome stuff", + "drink beer"}; int pickRandomText = 0; bool m_isWelcome = true; bool m_isStarting = true; @@ -28,46 +29,29 @@ protected: int m_time_needed = 0; bool needToClear = false; public: - explicit Waveforms(const std::string &processId); - - ~Waveforms() override; - - void newOpenGLContextCreated() override; - - void openGLContextClosing() override; - - void renderOpenGL() override; - - void handleAsyncUpdate() override; - - void mouseDown(const MouseEvent &e) override; - - void mouseDrag(const MouseEvent &e) override; - - void paint(Graphics &g) override; - + explicit Waveforms (const std::string& processId); + ~Waveforms () override; + void newOpenGLContextCreated () override; + void openGLContextClosing () override; + void renderOpenGL () override; + void handleAsyncUpdate () override; + void mouseDown (const MouseEvent& e) override; + void mouseDrag (const MouseEvent& e) override; + void paint (Graphics& g) override; bool m_isChangingData = false; std::string changingParameter = ""; float changedValue = 0; - private: - void timerCallback() override; - - void drawWaveTable(); - - void drawAudioOutput(); - void drawSpectrum(); - - void drawPeakMeter(); //?! - void drawChangedParameter(Graphics &g, int w, int h, int x, int y) const; - void drawWelcome(Graphics &g, int w, int h, int x, int y); - - void compileOpenGLShaderProgram(); - void selectColourByPeak(float value); - + void timerCallback () override; + void drawWaveTable (); + void drawAudioOutput (); + void drawSpectrum (); + void drawPeakMeter (); //?! + void drawChangedParameter (Graphics& g, int w, int h, int x, int y) const; + void drawWelcome (Graphics& g, int w, int h, int x, int y); + void compileOpenGLShaderProgram (); + void selectColourByPeak (float value); OpenGLContext m_context; std::unique_ptr shaderProgram; }; - - #endif //VENO_WAVEFORMS_H diff --git a/Source/Veno/GUI/Components/LabelComponent.cpp b/Source/Veno/GUI/Components/LabelComponent.cpp index 7781a69..0293bfe 100644 --- a/Source/Veno/GUI/Components/LabelComponent.cpp +++ b/Source/Veno/GUI/Components/LabelComponent.cpp @@ -4,29 +4,36 @@ #include "LabelComponent.h" -LabelComponent::LabelComponent(Component *parent, std::string name) { +LabelComponent::LabelComponent (Component* parent, std::string name) +{ m_text = name; m_parent = parent; - m_label = std::make_shared