- reformat to JUCE-Guidelines

- added Matrix => half working ;)
This commit is contained in:
Maurice Grönwoldt 2020-06-13 16:52:16 +02:00
parent 26a2935e1c
commit ac22ea5e75
58 changed files with 1220 additions and 799 deletions

View file

@ -4,30 +4,35 @@
#include "Veno/Utils/Logger.h" #include "Veno/Utils/Logger.h"
#include "Veno/Fonts/Fonts.h" #include "Veno/Fonts/Fonts.h"
VenoAudioProcessorEditor::VenoAudioProcessorEditor(VenoAudioProcessor &p) VenoAudioProcessorEditor::VenoAudioProcessorEditor (VenoAudioProcessor& p)
: AudioProcessorEditor(&p), processor(p) { : AudioProcessorEditor (&p), processor (p)
{
m_id = p.m_id; m_id = p.m_id;
Config::getInstance()->registerEditor(this, m_id); Config::getInstance ()->registerEditor (this, m_id);
LookAndFeel::setDefaultLookAndFeel(m_look); LookAndFeel::setDefaultLookAndFeel (m_look);
waveform = std::make_unique<SidebarLCD>(m_id); waveform = std::make_unique<SidebarLCD> (m_id);
setSize(600, 400); setSize (600, 400);
addAndMakeVisible(*waveform); addAndMakeVisible (*waveform);
} }
VenoAudioProcessorEditor::~VenoAudioProcessorEditor() { VenoAudioProcessorEditor::~VenoAudioProcessorEditor ()
LookAndFeel::setDefaultLookAndFeel(nullptr); {
waveform.reset(nullptr); LookAndFeel::setDefaultLookAndFeel (nullptr);
waveform.reset (nullptr);
delete m_look; delete m_look;
Config::getInstance()->removeEditor(m_id); Config::getInstance ()->removeEditor (m_id);
} }
void VenoAudioProcessorEditor::paint(Graphics &g) { void VenoAudioProcessorEditor::paint (Graphics& g)
g.setFont(VenoFonts::getNormal()); {
g.fillAll(Colour(0, 0, 0)); g.setFont (*VenoFonts::getNormal ());
g.fillAll (Colour (0, 0, 0));
} }
void VenoAudioProcessorEditor::resized() { void VenoAudioProcessorEditor::resized ()
if (waveform != nullptr) { {
waveform->setBounds(0, 0, getWidth(), getHeight()); if (waveform != nullptr)
{
waveform->setBounds (0, 0, getWidth (), getHeight ());
} }
} }

View file

@ -5,19 +5,17 @@
#include "Veno/GUI/LookAndFeel/LookHandler.h" #include "Veno/GUI/LookAndFeel/LookHandler.h"
#include "Veno/GUI/Components/LCD/SidebarLCD.h" #include "Veno/GUI/Components/LCD/SidebarLCD.h"
class VenoAudioProcessorEditor : public AudioProcessorEditor class VenoAudioProcessorEditor : public AudioProcessorEditor
{ {
public: public:
VenoAudioProcessorEditor (VenoAudioProcessor&); VenoAudioProcessorEditor (VenoAudioProcessor&);
~VenoAudioProcessorEditor(); ~VenoAudioProcessorEditor ();
void paint (Graphics&) override; void paint (Graphics&) override;
void resized() override; void resized () override;
private: private:
VenoAudioProcessor& processor; VenoAudioProcessor& processor;
std::string m_id = ""; std::string m_id = "";
LookAndFeel_V4 *m_look = new LookHandler(); LookAndFeel_V4* m_look = new LookHandler ();
std::unique_ptr<SidebarLCD> waveform; std::unique_ptr<SidebarLCD> waveform;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VenoAudioProcessorEditor) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VenoAudioProcessorEditor)
}; };

View file

@ -2,7 +2,7 @@
#include "PluginEditor.h" #include "PluginEditor.h"
#include "Veno/Core/AudioConfig.h" #include "Veno/Core/AudioConfig.h"
VenoAudioProcessor::VenoAudioProcessor() VenoAudioProcessor::VenoAudioProcessor ()
/*#ifndef JucePlugin_PreferredChannelConfigurations /*#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor (BusesProperties() : AudioProcessor (BusesProperties()
#if ! JucePlugin_IsMidiEffect #if ! JucePlugin_IsMidiEffect
@ -13,21 +13,25 @@ VenoAudioProcessor::VenoAudioProcessor()
#endif #endif
) )
#endif*/ #endif*/
: AudioProcessor(BusesProperties().withInput("Input", AudioChannelSet::stereo(), true).withOutput("Output", : AudioProcessor (BusesProperties ().withInput ("Input", AudioChannelSet::stereo (), true).withOutput ("Output",
AudioChannelSet::stereo(), AudioChannelSet::stereo (),
true)) { true))
instance = VenoInstance::createInstance(m_id); {
instance = VenoInstance::createInstance (m_id);
} }
VenoAudioProcessor::~VenoAudioProcessor() { VenoAudioProcessor::~VenoAudioProcessor ()
VenoInstance::deleteInstance(m_id); {
VenoInstance::deleteInstance (m_id);
} }
const String VenoAudioProcessor::getName() const { const String VenoAudioProcessor::getName () const
{
return JucePlugin_Name; return JucePlugin_Name;
} }
bool VenoAudioProcessor::acceptsMidi() const { bool VenoAudioProcessor::acceptsMidi () const
{
#if JucePlugin_WantsMidiInput #if JucePlugin_WantsMidiInput
return true; return true;
#else #else
@ -35,7 +39,8 @@ bool VenoAudioProcessor::acceptsMidi() const {
#endif #endif
} }
bool VenoAudioProcessor::producesMidi() const { bool VenoAudioProcessor::producesMidi () const
{
#if JucePlugin_ProducesMidiOutput #if JucePlugin_ProducesMidiOutput
return true; return true;
#else #else
@ -43,7 +48,8 @@ bool VenoAudioProcessor::producesMidi() const {
#endif #endif
} }
bool VenoAudioProcessor::isMidiEffect() const { bool VenoAudioProcessor::isMidiEffect () const
{
#if JucePlugin_IsMidiEffect #if JucePlugin_IsMidiEffect
return true; return true;
#else #else
@ -51,96 +57,113 @@ bool VenoAudioProcessor::isMidiEffect() const {
#endif #endif
} }
double VenoAudioProcessor::getTailLengthSeconds() const { double VenoAudioProcessor::getTailLengthSeconds () const
{
return 0.0; return 0.0;
} }
int VenoAudioProcessor::getNumPrograms() { int VenoAudioProcessor::getNumPrograms ()
{
return 1; return 1;
} }
int VenoAudioProcessor::getCurrentProgram() { int VenoAudioProcessor::getCurrentProgram ()
{
return 0; 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 {}; return {};
} }
void VenoAudioProcessor::changeProgramName(int index, const String &newName) { void VenoAudioProcessor::changeProgramName (int index, const String& newName)
{
} }
//============================================================================== //==============================================================================
void VenoAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock) { void VenoAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
auto audioConfig = AudioConfig::getInstance(); {
audioConfig->setSampleRate(sampleRate); auto audioConfig = AudioConfig::getInstance ();
audioConfig->initWaveTables(); audioConfig->setSampleRate (sampleRate);
audioConfig->initWaveTables ();
} }
void VenoAudioProcessor::releaseResources() { void VenoAudioProcessor::releaseResources ()
{
} }
#ifndef JucePlugin_PreferredChannelConfigurations #ifndef JucePlugin_PreferredChannelConfigurations
bool VenoAudioProcessor::isBusesLayoutSupported(const BusesLayout &layouts) const { bool VenoAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect #if JucePlugin_IsMidiEffect
ignoreUnused (layouts); ignoreUnused (layouts);
return true; return true;
#else #else
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() if (layouts.getMainOutputChannelSet () != AudioChannelSet::mono ()
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) && layouts.getMainOutputChannelSet () != AudioChannelSet::stereo ())
return false; return false;
#if !JucePlugin_IsSynth #if !JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false; return false;
#endif #endif
return true; return true;
#endif #endif
} }
#endif #endif
void VenoAudioProcessor::processBlock(AudioBuffer<float> &buffer, MidiBuffer &midiMessages) { void VenoAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
ScopedNoDenormals noDenormals; ScopedNoDenormals noDenormals;
instance->matrix.updateSlots ();
instance->audioBuffer->reset(buffer.getNumSamples()); instance->audioBuffer->reset (buffer.getNumSamples ());
int numChannels = buffer.getNumChannels(); int numChannels = buffer.getNumChannels ();
for (int i = 0; i < numChannels; ++i) { for (int i = 0; i < numChannels; ++i)
auto c = buffer.getReadPointer(i); {
for (int j = 0; j < buffer.getNumSamples(); ++j) { auto c = buffer.getReadPointer (i);
instance->fft.pushNextSampleIntoFifo(c[j]); for (int j = 0; j < buffer.getNumSamples (); ++j)
instance->audioBuffer->addMonoSample(c[j], j); {
if (i == 0) { instance->fft.pushNextSampleIntoFifo (c[j]);
instance->audioBuffer->addLeftSample(c[j], j); instance->audioBuffer->addMonoSample (c[j], j);
if (i == 0)
{
instance->audioBuffer->addLeftSample (c[j], j);
} }
if (i == 1 || numChannels == 1) { if (i == 1 || numChannels == 1)
instance->audioBuffer->addRightSample(c[j], j); {
instance->audioBuffer->addRightSample (c[j], j);
} }
} }
} }
} }
//============================================================================== //==============================================================================
bool VenoAudioProcessor::hasEditor() const { bool VenoAudioProcessor::hasEditor () const
{
return true; return true;
} }
AudioProcessorEditor *VenoAudioProcessor::createEditor() { AudioProcessorEditor* VenoAudioProcessor::createEditor ()
return new VenoAudioProcessorEditor(*this); {
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() { AudioProcessor* JUCE_CALLTYPE createPluginFilter ()
return new VenoAudioProcessor(); {
return new VenoAudioProcessor ();
} }

View file

@ -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 ()
{
}

View file

@ -0,0 +1,25 @@
//
// Created by versustune on 13.06.20.
//
#ifndef VENO_MODULATEVALUE_H
#define VENO_MODULATEVALUE_H
#include <string>
// 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

View file

@ -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 ()
{
}

View file

@ -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

View file

@ -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<const std::string&, ModulateValue*> (name, modulateValue));
}
void VenoMatrix::addModulator (const std::string& name, Modulator* modulator)
{
m_modulators.emplace (std::pair<const std::string&, Modulator*> (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);
}
}
}
}
}
}

View file

@ -0,0 +1,42 @@
//
// Created by versustune on 13.06.20.
//
#ifndef VENO_VENOMATRIX_H
#define VENO_VENOMATRIX_H
#include <string>
#include <unordered_map>
#include <vector>
#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<std::string, Modulator*> m_modulators; //all sources
std::unordered_map<std::string, ModulateValue*> m_modulationValues;
VenoMatrixSlot* m_slots[8]{}; // 8 source slots
std::string m_processId;
};
#endif //VENO_VENOMATRIX_H

View file

@ -3,9 +3,9 @@
// //
#include "SynthInstance.h" #include "SynthInstance.h"
#include <utility> #include <utility>
SynthInstance::SynthInstance(std::string processId) SynthInstance::SynthInstance (std::string processId)
: m_processId(std::move(processId)) { : m_processId (std::move (processId))
{
} }

View file

@ -5,18 +5,16 @@
#ifndef VENO_SYNTHINSTANCE_H #ifndef VENO_SYNTHINSTANCE_H
#define VENO_SYNTHINSTANCE_H #define VENO_SYNTHINSTANCE_H
#include <string> #include <string>
// class that hold all voices, oscillators and other stuff :) // class that hold all voices, oscillators and other stuff :)
class SynthInstance { class SynthInstance
{
private: private:
std::string m_processId; std::string m_processId;
public: public:
explicit SynthInstance(std::string processId); explicit SynthInstance (std::string processId);
~SynthInstance() = default; ~SynthInstance () = default;
protected: protected:
}; };
#endif //VENO_SYNTHINSTANCE_H #endif //VENO_SYNTHINSTANCE_H

View file

@ -5,24 +5,29 @@
#include <cmath> #include <cmath>
#include "VenoBuffer.h" #include "VenoBuffer.h"
VenoBuffer::VenoBuffer() { VenoBuffer::VenoBuffer ()
{
} }
VenoBuffer::~VenoBuffer() { VenoBuffer::~VenoBuffer ()
buffer.clear(); {
right.clear(); buffer.clear ();
left.clear(); right.clear ();
left.clear ();
} }
void VenoBuffer::reset(int size) { void VenoBuffer::reset (int size)
if (size != buffer.size()) { {
buffer.resize(size); if (size != buffer.size ())
right.resize(size); {
left.resize(size); buffer.resize (size);
right.resize (size);
left.resize (size);
} }
// reset to 0 dc :D // reset to 0 dc :D
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i)
{
buffer[i] = 0; buffer[i] = 0;
left[i] = 0; left[i] = 0;
right[i] = 0; right[i] = 0;
@ -32,43 +37,54 @@ void VenoBuffer::reset(int size) {
monoPeak = 0; monoPeak = 0;
} }
void VenoBuffer::addMonoSample(float value, int index) { void VenoBuffer::addMonoSample (float value, int index)
{
buffer[index] = value; buffer[index] = value;
} }
void VenoBuffer::addLeftSample(float value, int index) { void VenoBuffer::addLeftSample (float value, int index)
{
left[index] = value; left[index] = value;
} }
void VenoBuffer::addRightSample(float value, int index) { void VenoBuffer::addRightSample (float value, int index)
{
right[index] = value; right[index] = value;
} }
void VenoBuffer::calcPeak() { void VenoBuffer::calcPeak ()
for (int i = 0; i < buffer.size(); ++i) { {
auto l = std::abs(left[i]); for (int i = 0; i < buffer.size (); ++i)
auto r = std::abs(right[i]); {
auto m = std::abs(buffer[i]); auto l = std::abs (left[i]);
if (m > monoPeak) { auto r = std::abs (right[i]);
auto m = std::abs (buffer[i]);
if (m > monoPeak)
{
monoPeak = m; monoPeak = m;
} }
if (l > leftPeak) { if (l > leftPeak)
{
leftPeak = l; leftPeak = l;
} }
if (r > rightPeak) { if (r > rightPeak)
{
rightPeak = r; rightPeak = r;
} }
} }
} }
const std::vector<float> &VenoBuffer::getBuffer() const { const std::vector<float>& VenoBuffer::getBuffer () const
{
return buffer; return buffer;
} }
const std::vector<float> &VenoBuffer::getRight() const { const std::vector<float>& VenoBuffer::getRight () const
{
return right; return right;
} }
const std::vector<float> &VenoBuffer::getLeft() const { const std::vector<float>& VenoBuffer::getLeft () const
{
return left; return left;
} }

View file

@ -5,33 +5,27 @@
#ifndef VENO_VENOBUFFER_H #ifndef VENO_VENOBUFFER_H
#define VENO_VENOBUFFER_H #define VENO_VENOBUFFER_H
#include <vector> #include <vector>
class VenoBuffer { class VenoBuffer
{
private: private:
std::vector<float> buffer; std::vector<float> buffer;
std::vector<float> right; std::vector<float> right;
std::vector<float> left; std::vector<float> left;
public: public:
VenoBuffer(); VenoBuffer ();
~VenoBuffer(); ~VenoBuffer ();
void reset(int size); void reset (int size);
void addMonoSample(float value, int index); void addMonoSample (float value, int index);
void addLeftSample(float value, int index); void addLeftSample (float value, int index);
void addRightSample(float value, int index); void addRightSample (float value, int index);
void calcPeak ();
void calcPeak();
float leftPeak; float leftPeak;
float rightPeak; float rightPeak;
float monoPeak; float monoPeak;
const std::vector<float>& getBuffer () const;
const std::vector<float> &getBuffer() const; const std::vector<float>& getRight () const;
const std::vector<float>& getLeft () const;
const std::vector<float> &getRight() const;
const std::vector<float> &getLeft() const;
}; };
#endif //VENO_VENOBUFFER_H #endif //VENO_VENOBUFFER_H

View file

@ -6,23 +6,26 @@
#include "../../Utils/Logger.h" #include "../../Utils/Logger.h"
#include "TableHelper.h" #include "TableHelper.h"
void generateSaw(WaveTableGroup *group) { void generateSaw (WaveTableGroup* group)
if (group == nullptr) { {
if (group == nullptr)
{
return; return;
} }
int tableLen = findTableLen(); int tableLen = findTableLen ();
int idx; int idx;
auto *freqWaveRe = new double[tableLen]; auto* freqWaveRe = new double[tableLen];
auto *freqWaveIm = new double[tableLen]; auto* freqWaveIm = new double[tableLen];
for (idx = 0; idx < tableLen; idx++)
for (idx = 0; idx < tableLen; idx++) { {
freqWaveIm[idx] = 0.0; freqWaveIm[idx] = 0.0;
} }
freqWaveRe[0] = freqWaveRe[tableLen >> 1] = 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[idx] = 1.0 / idx; // sawtooth spectrum
freqWaveRe[tableLen - idx] = -freqWaveRe[idx]; // mirror freqWaveRe[tableLen - idx] = -freqWaveRe[idx]; // mirror
} }
fillTables(group, freqWaveRe, freqWaveIm, tableLen); fillTables (group, freqWaveRe, freqWaveIm, tableLen);
VeNo::Logger::infoDebugMessage("Generated clean Saw Wave"); VeNo::Logger::infoDebugMessage ("Generated clean Saw Wave");
} }

View file

@ -4,8 +4,5 @@
#ifndef VENO_SAWWAVES_H #ifndef VENO_SAWWAVES_H
#define VENO_SAWWAVES_H #define VENO_SAWWAVES_H
void generateSaw (WaveTableGroup* group);
void generateSaw(WaveTableGroup *group);
#endif //VENO_SAWWAVES_H #endif //VENO_SAWWAVES_H

View file

@ -4,11 +4,8 @@
#ifndef VENO_SINEWAVES_H #ifndef VENO_SINEWAVES_H
#define VENO_SINEWAVES_H #define VENO_SINEWAVES_H
class SineWaves
{
class SineWaves {
}; };
#endif //VENO_SINEWAVES_H #endif //VENO_SINEWAVES_H

View file

@ -4,11 +4,8 @@
#ifndef VENO_SQUAREWAVES_H #ifndef VENO_SQUAREWAVES_H
#define VENO_SQUAREWAVES_H #define VENO_SQUAREWAVES_H
class SquareWaves
{
class SquareWaves {
}; };
#endif //VENO_SQUAREWAVES_H #endif //VENO_SQUAREWAVES_H

View file

@ -6,7 +6,8 @@
#include "../../Core/AudioConfig.h" #include "../../Core/AudioConfig.h"
#include "../../Utils.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 i, j, k, L; /* indexes */
int M, TEMP, LE, LE1, ip; /* M = log N */ int M, TEMP, LE, LE1, ip; /* M = log N */
int NV2, NM1; int NV2, NM1;
@ -24,8 +25,10 @@ void fft(int N, double *ar, double *ai) {
/* shuffle */ /* shuffle */
j = 1; j = 1;
for (i = 1; i <= NM1; i++) { for (i = 1; i <= NM1; i++)
if (i < j) { /* swap a[i] and a[j] */ {
if (i < j)
{ /* swap a[i] and a[j] */
t = ar[j - 1]; t = ar[j - 1];
ar[j - 1] = ar[i - 1]; ar[j - 1] = ar[i - 1];
ar[i - 1] = t; ar[i - 1] = t;
@ -33,26 +36,27 @@ void fft(int N, double *ar, double *ai) {
ai[j - 1] = ai[i - 1]; ai[j - 1] = ai[i - 1];
ai[i - 1] = t; ai[i - 1] = t;
} }
k = NV2; /* bit-reversed counter */ k = NV2; /* bit-reversed counter */
while (k < j) { while (k < j)
{
j -= k; j -= k;
k /= 2; k /= 2;
} }
j += k; j += k;
} }
LE = 1.; LE = 1.;
for (L = 1; L <= M; L++) { // stage L for (L = 1; L <= M; L++)
{ // stage L
LE1 = LE; // (LE1 = LE/2) LE1 = LE; // (LE1 = LE/2)
LE *= 2; // (LE = 2^L) LE *= 2; // (LE = 2^L)
Ur = 1.0; Ur = 1.0;
Ui = 0.; Ui = 0.;
Wr = std::cos(M_PI / (float) LE1); Wr = std::cos (M_PI / (float) LE1);
Wi = -std::sin(M_PI / (float) LE1); // Cooley, Lewis, and Welch have "+" here Wi = -std::sin (M_PI / (float) LE1); // Cooley, Lewis, and Welch have "+" here
for (j = 1; j <= LE1; j++) { for (j = 1; j <= LE1; j++)
for (i = j; i <= N; i += LE) { // butterfly {
for (i = j; i <= N; i += LE)
{ // butterfly
ip = i + LE1; ip = i + LE1;
Tr = ar[ip - 1] * Ur - ai[ip - 1] * Ui; Tr = ar[ip - 1] * Ur - ai[ip - 1] * Ui;
Ti = ar[ip - 1] * Ui + ai[ip - 1] * Ur; 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) { float makeWaveTable (WaveTableGroup* group, int len, double* ar, double* ai, double scale, double topFreq)
fft(len, ar, ai); {
fft (len, ar, ai);
if (scale == 0.0) { if (scale == 0.0)
{
// calc normal // calc normal
double max = 0; double max = 0;
for (int idx = 0; idx < len; idx++) { for (int idx = 0; idx < len; idx++)
double temp = fabs(ai[idx]); {
double temp = fabs (ai[idx]);
if (max < temp) if (max < temp)
max = temp; max = temp;
} }
@ -83,13 +89,13 @@ float makeWaveTable(WaveTableGroup *group, int len, double *ar, double *ai, doub
} }
// normalize // normalize
auto *wave = new float[len]; auto* wave = new float[len];
for (int idx = 0; idx < len; idx++) for (int idx = 0; idx < len; idx++)
wave[idx] = ai[idx] * scale; wave[idx] = ai[idx] * scale;
if (group->m_numWaveTables < WaveTableGroup::numWaveTableSlots)
if (group->m_numWaveTables < WaveTableGroup::numWaveTableSlots) { {
auto table = group->m_WaveTables[group->m_numWaveTables] = new WaveTableObject(); auto table = group->m_WaveTables[group->m_numWaveTables] = new WaveTableObject ();
float *waveTable = group->m_WaveTables[group->m_numWaveTables]->m_waveTable = new float[len + 1]; float* waveTable = group->m_WaveTables[group->m_numWaveTables]->m_waveTable = new float[len + 1];
table->m_waveTableLen = len; table->m_waveTableLen = len;
table->m_topFreq = topFreq; table->m_topFreq = topFreq;
++group->m_numWaveTables; ++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 waveTable[len] = waveTable[0]; // duplicate for interpolation wraparound
return 0; return 0;
} else { }
else
{
scale = 0.0; scale = 0.0;
} }
return (float) scale; 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; int idx;
freqWaveRe[0] = freqWaveIm[0] = 0.0; freqWaveRe[0] = freqWaveIm[0] = 0.0;
freqWaveRe[numSamples >> 1] = freqWaveIm[numSamples >> 1] = 0.0; freqWaveRe[numSamples >> 1] = freqWaveIm[numSamples >> 1] = 0.0;
int maxHarmonic = numSamples >> 1; int maxHarmonic = numSamples >> 1;
const double minVal = 0.000001; // -120 dB 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 topFreq = 2.0 / 3.0 / maxHarmonic;
double* ar = new double[numSamples];
double *ar = new double[numSamples]; double* ai = new double[numSamples];
double *ai = new double[numSamples];
double scale = 0.0; double scale = 0.0;
int numTables = 0; int numTables = 0;
while (maxHarmonic) { while (maxHarmonic)
{
// fill the table in with the needed harmonics // fill the table in with the needed harmonics
for (idx = 0; idx < numSamples; idx++) for (idx = 0; idx < numSamples; idx++)
ar[idx] = ai[idx] = 0.0; ar[idx] = ai[idx] = 0.0;
for (idx = 1; idx <= maxHarmonic; idx++) { for (idx = 1; idx <= maxHarmonic; idx++)
{
ar[idx] = freqWaveRe[idx]; ar[idx] = freqWaveRe[idx];
ai[idx] = freqWaveIm[idx]; ai[idx] = freqWaveIm[idx];
ar[numSamples - idx] = freqWaveRe[numSamples - idx]; ar[numSamples - idx] = freqWaveRe[numSamples - idx];
@ -134,7 +141,7 @@ int fillTables(WaveTableGroup *group, double *freqWaveRe, double *freqWaveIm, in
} }
// make the wavetable // make the wavetable
scale = makeWaveTable(group, numSamples, ar, ai, scale, topFreq); scale = makeWaveTable (group, numSamples, ar, ai, scale, topFreq);
numTables++; numTables++;
// prepare for next table // prepare for next table
@ -144,11 +151,13 @@ int fillTables(WaveTableGroup *group, double *freqWaveRe, double *freqWaveIm, in
return numTables; return numTables;
} }
float getNextRand() { float getNextRand ()
return std::rand() / double(RAND_MAX); {
return std::rand () / double (RAND_MAX);
} }
int findTableLen() { int findTableLen ()
int maxHarms = AudioConfig::getInstance()->getSampleRate() / (5.0 * 20) + 0.5; {
return VeNo::Utils::nextPowerOfTwo(maxHarms) * 2; int maxHarms = AudioConfig::getInstance ()->getSampleRate () / (5.0 * 20) + 0.5;
return VeNo::Utils::nextPowerOfTwo (maxHarms) * 2;
} }

View file

@ -11,7 +11,6 @@
#define M_PI 3.14159265358979323846 #define M_PI 3.14159265358979323846
#define DOUBLE_PI 6.283185307179586476925286766559 #define DOUBLE_PI 6.283185307179586476925286766559
/* /*
in-place complex fft in-place complex fft
After Cooley, Lewis, and Welch; from Rabiner & Gold (1975) After Cooley, Lewis, and Welch; from Rabiner & Gold (1975)
@ -20,15 +19,10 @@
Computer Science Dept. Computer Science Dept.
Princeton University 08544 Princeton University 08544
*/ */
void fft(int N, double *ar, double *ai); void fft (int N, double* ar, double* ai);
float makeWaveTable (WaveTableGroup* group, int len, double* ar, double* ai, double scale, double topFreq);
float makeWaveTable(WaveTableGroup *group, int len, double *ar, double *ai, double scale, double topFreq);
// utils stuff // utils stuff
int fillTables(WaveTableGroup *group, double *freqWaveRe, double *freqWaveIm, int numSamples); int fillTables (WaveTableGroup* group, double* freqWaveRe, double* freqWaveIm, int numSamples);
int findTableLen ();
int findTableLen(); float getNextRand ();
float getNextRand();
#endif //VENO_TABLEHELPER_H #endif //VENO_TABLEHELPER_H

View file

@ -4,11 +4,8 @@
#ifndef VENO_TRIANGLEWAVES_H #ifndef VENO_TRIANGLEWAVES_H
#define VENO_TRIANGLEWAVES_H #define VENO_TRIANGLEWAVES_H
class TriangleWaves
{
class TriangleWaves {
}; };
#endif //VENO_TRIANGLEWAVES_H #endif //VENO_TRIANGLEWAVES_H

View file

@ -4,11 +4,8 @@
#ifndef VENO_VENOXWAVES_H #ifndef VENO_VENOXWAVES_H
#define VENO_VENOXWAVES_H #define VENO_VENOXWAVES_H
class VeNoXWaves
{
class VeNoXWaves {
}; };
#endif //VENO_VENOXWAVES_H #endif //VENO_VENOXWAVES_H

View file

@ -6,41 +6,48 @@
#include "../../Core/AudioConfig.h" #include "../../Core/AudioConfig.h"
#include "WavesInlcuder.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 the sampleRate changed... the WaveTables are not harmonic Save anymore and are needed to rebuild... pls stay save later!
if (AudioConfig::getInstance()->isNeedToReInit()) { if (AudioConfig::getInstance ()->isNeedToReInit ())
cleanTables(); {
AudioConfig::getInstance()->setNeedToReInit(false); cleanTables ();
AudioConfig::getInstance ()->setNeedToReInit (false);
} }
if (m_isInit) { if (m_isInit)
{
return; return;
} }
m_waveTables[WaveForms::SAW] = new WaveTableGroup(); m_waveTables[WaveForms::SAW] = new WaveTableGroup ();
m_waveTables[WaveForms::SINE] = new WaveTableGroup(); m_waveTables[WaveForms::SINE] = new WaveTableGroup ();
m_waveTables[WaveForms::SQUARE] = new WaveTableGroup(); m_waveTables[WaveForms::SQUARE] = new WaveTableGroup ();
m_waveTables[WaveForms::TRIANGLE] = new WaveTableGroup(); m_waveTables[WaveForms::TRIANGLE] = new WaveTableGroup ();
m_waveTables[WaveForms::wSaw] = new WaveTableGroup(); m_waveTables[WaveForms::wSaw] = new WaveTableGroup ();
m_waveTables[WaveForms::wSQUARE] = new WaveTableGroup(); m_waveTables[WaveForms::wSQUARE] = new WaveTableGroup ();
m_waveTables[WaveForms::SYNTHONE] = new WaveTableGroup(); m_waveTables[WaveForms::SYNTHONE] = new WaveTableGroup ();
m_waveTables[WaveForms::SYNTHTWO] = new WaveTableGroup(); m_waveTables[WaveForms::SYNTHTWO] = new WaveTableGroup ();
m_waveTables[WaveForms::VENOX] = new WaveTableGroup(); m_waveTables[WaveForms::VENOX] = new WaveTableGroup ();
generateSaw (m_waveTables[WaveForms::SAW]);
generateSaw(m_waveTables[WaveForms::SAW]);
m_isInit = true; m_isInit = true;
} }
WaveTableGroup *WaveTableGenerator::getGroup(int id) { WaveTableGroup* WaveTableGenerator::getGroup (int id)
if (!m_isInit) { {
init(); if (!m_isInit)
{
init ();
} }
if (id < 40) { if (id < 40)
{
return m_waveTables[id]; return m_waveTables[id];
} }
return nullptr; return nullptr;
} }
void WaveTableGenerator::cleanTables() { void WaveTableGenerator::cleanTables ()
for (auto & m_waveTable : m_waveTables) { {
for (auto& m_waveTable : m_waveTables)
{
delete m_waveTable; delete m_waveTable;
} }
m_isInit = false; m_isInit = false;

View file

@ -4,20 +4,20 @@
#ifndef VENO_WAVETABLEGENERATOR_H #ifndef VENO_WAVETABLEGENERATOR_H
#define VENO_WAVETABLEGENERATOR_H #define VENO_WAVETABLEGENERATOR_H
struct WaveTableObject
struct WaveTableObject { {
double m_topFreq; double m_topFreq;
int m_waveTableLen; int m_waveTableLen;
float *m_waveTable; float* m_waveTable;
}; };
struct WaveTableGroup
struct WaveTableGroup { {
static constexpr int numWaveTableSlots = 40; static constexpr int numWaveTableSlots = 40;
WaveTableObject *m_WaveTables[numWaveTableSlots] = {}; WaveTableObject* m_WaveTables[numWaveTableSlots] = {};
int m_numWaveTables = 0; int m_numWaveTables = 0;
}; };
enum WaveForms
enum WaveForms { {
SAW = 0, SAW = 0,
SINE, SINE,
SQUARE, SQUARE,
@ -28,26 +28,24 @@ enum WaveForms {
SYNTHTWO, SYNTHTWO,
VENOX VENOX
}; };
class WaveTableGenerator
class WaveTableGenerator { {
private: private:
static constexpr int numWaveTableSlots = 40; static constexpr int numWaveTableSlots = 40;
WaveTableGroup *m_waveTables[numWaveTableSlots] = {}; WaveTableGroup* m_waveTables[numWaveTableSlots] = {};
public: public:
static WaveTableGenerator &getInstance() { static WaveTableGenerator& getInstance ()
{
static WaveTableGenerator instance; static WaveTableGenerator instance;
return instance; return instance;
} }
WaveTableGroup *getGroup(int id);
void init();
void cleanTables();
WaveTableGroup* getGroup (int id);
void init ();
void cleanTables ();
protected: protected:
bool m_isInit = false; bool m_isInit = false;
WaveTableGenerator() = default; WaveTableGenerator () = default;
~WaveTableGenerator() = default; ~WaveTableGenerator () = default;
}; };
#endif //VENO_WAVETABLEGENERATOR_H #endif //VENO_WAVETABLEGENERATOR_H

View file

@ -5,43 +5,54 @@
#include "../Audio/WaveTable/WaveTableGenerator.h" #include "../Audio/WaveTable/WaveTableGenerator.h"
std::shared_ptr<AudioConfig> AudioConfig::m_instance; std::shared_ptr<AudioConfig> AudioConfig::m_instance;
float AudioConfig::getSampleRate() {
float AudioConfig::getSampleRate ()
{
return m_sampleRate; return m_sampleRate;
} }
void AudioConfig::setSampleRate(float _sampleRate) { void AudioConfig::setSampleRate (float _sampleRate)
if (m_sampleRate != _sampleRate) { {
if (m_sampleRate != _sampleRate)
{
m_sampleRate = _sampleRate; m_sampleRate = _sampleRate;
m_needToReInit = true; m_needToReInit = true;
} }
} }
float AudioConfig::getBufferSize() { float AudioConfig::getBufferSize ()
{
return m_bufferSize; return m_bufferSize;
} }
void AudioConfig::setBufferSize(float _bufferSize) { void AudioConfig::setBufferSize (float _bufferSize)
{
m_bufferSize = _bufferSize; m_bufferSize = _bufferSize;
} }
bool AudioConfig::isNeedToReInit() const { bool AudioConfig::isNeedToReInit () const
{
return m_needToReInit; return m_needToReInit;
} }
void AudioConfig::setNeedToReInit(bool _needToReInit) { void AudioConfig::setNeedToReInit (bool _needToReInit)
{
m_needToReInit = _needToReInit; m_needToReInit = _needToReInit;
} }
std::shared_ptr<AudioConfig> AudioConfig::getInstance() { std::shared_ptr<AudioConfig> AudioConfig::getInstance ()
{
if (AudioConfig::m_instance == nullptr) if (AudioConfig::m_instance == nullptr)
AudioConfig::m_instance = std::make_shared<AudioConfig>(); AudioConfig::m_instance = std::make_shared<AudioConfig> ();
return m_instance; return m_instance;
} }
void AudioConfig::initWaveTables() { void AudioConfig::initWaveTables ()
WaveTableGenerator::getInstance().init(); {
WaveTableGenerator::getInstance ().init ();
} }
AudioConfig::~AudioConfig() { AudioConfig::~AudioConfig ()
WaveTableGenerator::getInstance().cleanTables(); {
WaveTableGenerator::getInstance ().cleanTables ();
} }

View file

@ -10,33 +10,23 @@
/** /**
* holds SampleRate and other needed sound information's :) * holds SampleRate and other needed sound information's :)
*/ */
class AudioConfig { class AudioConfig
{
private: private:
static std::shared_ptr<AudioConfig> m_instance; static std::shared_ptr<AudioConfig> m_instance;
float m_sampleRate = 44100; float m_sampleRate = 44100;
float m_bufferSize = 512; //maybe we need that... but this will update always! 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 bool m_needToReInit = false; //this is to reInit the Oscillators, ADSR and other stuff
public: public:
static std::shared_ptr<AudioConfig> getInstance(); static std::shared_ptr<AudioConfig> getInstance ();
float getSampleRate ();
float getSampleRate(); void setSampleRate (float _sampleRate);
float getBufferSize ();
void setSampleRate(float _sampleRate); void setBufferSize (float _bufferSize);
bool isNeedToReInit () const;
float getBufferSize(); void setNeedToReInit (bool _needToReInit);
static void initWaveTables ();
void setBufferSize(float _bufferSize); ~AudioConfig ();
bool isNeedToReInit() const;
void setNeedToReInit(bool _needToReInit);
static void initWaveTables();
~AudioConfig();
protected: protected:
}; };
#endif //VENO_AUDIOCONFIG_H #endif //VENO_AUDIOCONFIG_H

View file

@ -3,82 +3,100 @@
// //
#include "Config.h" #include "Config.h"
#include "../Fonts/Fonts.h"
std::shared_ptr<Config> Config::m_instance = nullptr; std::shared_ptr<Config> Config::m_instance = nullptr;
Config::Config() { Config::Config ()
{
// i want to load the m_config file here... // i want to load the m_config file here...
initConfig(); initConfig ();
m_theme = std::make_shared<Theme> (m_config);
m_theme = std::make_shared<Theme>(m_config); m_theme->init ();
m_theme->init(); m_fps = m_config->getIntValue ("waveform_fps", 60);
m_fps = m_config->getIntValue("waveform_fps", 60);
} }
void Config::saveAll() { void Config::saveAll ()
if (m_config != nullptr) { {
m_config->saveIfNeeded(); if (m_config != nullptr)
{
m_config->saveIfNeeded ();
} }
} }
int Config::getCurrentLook() { int Config::getCurrentLook ()
if (m_currentLook > 1) { {
if (m_currentLook > 1)
{
m_currentLook = 0; m_currentLook = 0;
} }
return m_currentLook; return m_currentLook;
} }
void Config::initConfig() { void Config::initConfig ()
{
PropertiesFile::Options options; PropertiesFile::Options options;
options.applicationName = "config"; options.applicationName = "config";
options.folderName = "veno"; options.folderName = "veno";
options.filenameSuffix = "xml"; options.filenameSuffix = "xml";
m_config = std::make_unique<PropertiesFile>(options); m_config = std::make_unique<PropertiesFile> (options);
} }
std::shared_ptr<Theme> Config::getCurrentTheme() { std::shared_ptr<Theme> Config::getCurrentTheme ()
{
return m_theme; return m_theme;
} }
double Config::getScale() { double Config::getScale ()
{
return 1; return 1;
} }
void Config::setColourForIndex(Colour *colour, ThemeColour index) { void Config::setColourForIndex (Colour* colour, ThemeColour index)
if (m_theme) { {
m_theme->setColour(index, colour); if (m_theme)
{
m_theme->setColour (index, colour);
} }
} }
Config::~Config() { Config::~Config ()
m_config->save(); {
m_theme.reset(); m_config->save ();
m_config.reset(); m_theme.reset ();
m_config.reset ();
} }
//LEAK DETECTOR FIX! //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; m_editors[name] = editor;
} }
void Config::removeEditor(const std::string &name) { void Config::removeEditor (const std::string& name)
m_editors.erase(name); {
if (m_editors.empty()) { m_editors.erase (name);
if (m_editors.empty ())
{
VenoFonts::destroyAll ();
m_instance = nullptr; m_instance = nullptr;
} }
} }
//for LCD :P let's be a bit funny xD //for LCD :P let's be a bit funny xD
int Config::getEditorCount() { int Config::getEditorCount ()
return m_editors.size(); {
return m_editors.size ();
} }
std::shared_ptr<Config> Config::getInstance() { std::shared_ptr<Config> Config::getInstance ()
{
if (m_instance == nullptr) if (m_instance == nullptr)
m_instance = std::make_shared<Config>(); m_instance = std::make_shared<Config> ();
return m_instance; return m_instance;
} }
int Config::getFps() const { int Config::getFps () const
{
return m_fps; return m_fps;
} }

View file

@ -10,42 +10,30 @@
#include "../GUI/Theme/Theme.h" #include "../GUI/Theme/Theme.h"
#include <memory> #include <memory>
class Config { class Config
{
private: private:
std::shared_ptr<PropertiesFile> m_config = nullptr; std::shared_ptr<PropertiesFile> m_config = nullptr;
std::shared_ptr<Theme> m_theme = nullptr; std::shared_ptr<Theme> m_theme = nullptr;
static std::shared_ptr<Config> m_instance; static std::shared_ptr<Config> m_instance;
int m_currentLook = 0; //nah move the bitch logic from current to next int m_currentLook = 0; //nah move the bitch logic from current to next
std::unordered_map<std::string, AudioProcessorEditor *> m_editors; std::unordered_map<std::string, AudioProcessorEditor*> m_editors;
int m_fps = 60; int m_fps = 60;
public: public:
static std::shared_ptr<Config> getInstance(); static std::shared_ptr<Config> getInstance ();
void saveAll ();
void saveAll(); int getCurrentLook ();
void setColourForIndex (Colour* colour, ThemeColour index);
int getCurrentLook(); std::shared_ptr<Theme> getCurrentTheme ();
double getScale ();
void setColourForIndex(Colour *colour, ThemeColour index);
std::shared_ptr<Theme> getCurrentTheme();
double getScale();
// can be public but doesnt need! // can be public but doesnt need!
Config(); Config ();
~Config ();
~Config(); void registerEditor (AudioProcessorEditor* editor, const std::string& name);
void removeEditor (const std::string& name);
void registerEditor(AudioProcessorEditor *editor, const std::string& name); int getEditorCount ();
int getFps () const;
void removeEditor(const std::string& name);
int getEditorCount();
int getFps() const;
protected: protected:
void initConfig(); void initConfig ();
}; };
#endif //VENO_CONFIG_H #endif //VENO_CONFIG_H

View file

@ -4,11 +4,8 @@
#ifndef VENO_PRESETMANAGER_H #ifndef VENO_PRESETMANAGER_H
#define VENO_PRESETMANAGER_H #define VENO_PRESETMANAGER_H
class PresetManager
{
class PresetManager {
}; };
#endif //VENO_PRESETMANAGER_H #endif //VENO_PRESETMANAGER_H

View file

@ -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;
}

View file

@ -7,19 +7,18 @@
#include "JuceHeader.h" #include "JuceHeader.h"
class VenoFonts { class VenoFonts
{
protected:
static VenoFonts* instance;
Font* lcdFont;
Font* arvo;
public: public:
static const Font &getLCD() { VenoFonts ();
static Font lcd(Font(Typeface::createSystemTypefaceFor(BinaryData::lcd_ttf, ~VenoFonts ();
BinaryData::lcd_ttfSize))); static void destroyAll ();
return lcd; static Font* getLCD ();
} static Font* getNormal ();
static VenoFonts* getInstance ();
static const Font &getNormal() {
static Font arvo(Font(Typeface::createSystemTypefaceFor(BinaryData::arvo_ttf,
BinaryData::arvo_ttfSize)));
return arvo;
}
}; };
#endif //VENO_FONTS_H #endif //VENO_FONTS_H

View file

@ -4,40 +4,49 @@
#include "BaseComponent.h" #include "BaseComponent.h"
#include "../../Fonts/Fonts.h" #include "../../Fonts/Fonts.h"
#include <utility> #include <utility>
BaseComponent::BaseComponent(const std::string& processId) { BaseComponent::BaseComponent (const std::string& processId)
{
m_processId = processId; m_processId = processId;
} }
BaseComponent::~BaseComponent() { BaseComponent::~BaseComponent ()
m_label.reset(); {
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_enableLabel = true;
m_label = std::make_shared<LabelComponent>(this, label_text); m_label = std::make_shared<LabelComponent> (this, label_text);
m_label->setPosition(labelPosition); m_label->setPosition (labelPosition);
} }
void BaseComponent::resized() { void BaseComponent::resized ()
if (m_enableLabel && m_label != nullptr) { {
LabelPosition position = m_label->getLabelPosition(); if (m_enableLabel && m_label != nullptr)
if (position == LabelPosition::TOP) { {
m_label->setBounds(0, 0, getWidth(), 15); LabelPosition position = m_label->getLabelPosition ();
} else if (position == LabelPosition::BOTTOM) { if (position == LabelPosition::TOP)
m_label->setBounds(0, getHeight() - 20, getWidth(), 15); {
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) { void BaseComponent::paint (Graphics& g)
g.setFont(VenoFonts::getNormal()); {
g.setFont (*VenoFonts::getNormal ());
} }
void BaseComponent::setParameter(std::string name, std::string group) { void BaseComponent::setParameter (std::string name, std::string group)
m_name = std::move(name); {
m_group = std::move(group); m_name = std::move (name);
setName(m_name); m_group = std::move (group);
setName (m_name);
} }

View file

@ -13,22 +13,21 @@
/** /**
* this is the base Component of all VeNo Components... it has all important Methods * this is the base Component of all VeNo Components... it has all important Methods
*/ */
class BaseComponent : public Component { class BaseComponent : public Component
{
private: private:
std::string m_group; std::string m_group;
std::string m_name; std::string m_name;
bool m_enableLabel = false; bool m_enableLabel = false;
std::shared_ptr<LabelComponent> m_label; std::shared_ptr<LabelComponent> m_label;
public: public:
explicit BaseComponent(const std::string& processId); explicit BaseComponent (const std::string& processId);
~BaseComponent() override; ~BaseComponent () override;
void addLabel(const std::string& label, LabelPosition labelPosition); void addLabel (const std::string& label, LabelPosition labelPosition);
void setParameter(std::string name, std::string group); void setParameter (std::string name, std::string group);
void resized() override; void resized () override;
void paint(Graphics &g) override; void paint (Graphics& g) override;
protected: protected:
std::string m_processId; std::string m_processId;
}; };
#endif //VENO_BASECOMPONENT_H #endif //VENO_BASECOMPONENT_H

View file

@ -7,49 +7,56 @@
#include "../../../Core/Config.h" #include "../../../Core/Config.h"
#include "../../../Fonts/Fonts.h" #include "../../../Fonts/Fonts.h"
SidebarLCD::SidebarLCD(const std::string &process_id) : BaseComponent(process_id) { SidebarLCD::SidebarLCD (const std::string& process_id) : BaseComponent (process_id)
waveform = std::make_unique<Waveforms>(process_id); {
addAndMakeVisible(*waveform); waveform = std::make_unique<Waveforms> (process_id);
addAndMakeVisible (*waveform);
} }
SidebarLCD::~SidebarLCD() { SidebarLCD::~SidebarLCD ()
waveform.reset(nullptr); {
waveform.reset (nullptr);
} }
void SidebarLCD::drawHeadline(Graphics &g) { void SidebarLCD::drawHeadline (Graphics& g)
float fontSize = VeNo::Utils::setFontSize(12.0f, g) + 2; {
float fontSize = VeNo::Utils::setFontSize (12.0f, g) + 2;
int line = m_innerY + fontSize + 2; int line = m_innerY + fontSize + 2;
g.drawText(">>> VeNo <<<", 0, m_innerY, getWidth() - m_width, fontSize, g.drawText (">>> VeNo <<<", 0, m_innerY, getWidth () - m_width, fontSize,
Justification::centred, Justification::centred,
true); true);
g.drawLine(0, line, getWidth(), line); g.drawLine (0, line, getWidth (), line);
} }
void SidebarLCD::drawFooter(Graphics &g) { void SidebarLCD::drawFooter (Graphics& g)
float fontSize = VeNo::Utils::setFontSize(8.0f, g) + 4; {
float fontSize = VeNo::Utils::setFontSize (8.0f, g) + 4;
int space = m_innerY + fontSize; int space = m_innerY + fontSize;
int line = getHeight() - space; int line = getHeight () - space;
g.drawText("by VersusTuneZ", 0, line, getWidth() - m_width, fontSize, g.drawText ("by VersusTuneZ", 0, line, getWidth () - m_width, fontSize,
Justification::horizontallyCentred, Justification::horizontallyCentred,
true); true);
g.drawLine(0, line - 4, getWidth(), line - 4); g.drawLine (0, line - 4, getWidth (), line - 4);
} }
void SidebarLCD::resized() { void SidebarLCD::resized ()
float topSpace = (12 * Config::getInstance()->getScale()) + 4 + m_innerY; {
if (waveform != nullptr) { float topSpace = (12 * Config::getInstance ()->getScale ()) + 4 + m_innerY;
waveform->setBounds(0, topSpace*2, getWidth(), getHeight() - (topSpace*4)); if (waveform != nullptr)
{
waveform->setBounds (0, topSpace * 2, getWidth (), getHeight () - (topSpace * 4));
} }
} }
void SidebarLCD::paint(Graphics &g) { void SidebarLCD::paint (Graphics& g)
std::shared_ptr<Theme> theme = Config::getInstance()->getCurrentTheme(); {
auto colour = theme->getColour(ThemeColour::lcd_bg); std::shared_ptr<Theme> theme = Config::getInstance ()->getCurrentTheme ();
g.fillAll(colour); auto colour = theme->getColour (ThemeColour::lcd_bg);
g.fillAll (colour);
// background // background
auto accent = theme->getColour(ThemeColour::lcd); auto accent = theme->getColour (ThemeColour::lcd);
g.setColour(accent); g.setColour (accent);
g.setFont(VenoFonts::getLCD()); g.setFont (*VenoFonts::getLCD ());
drawHeadline(g); drawHeadline (g);
drawFooter(g); drawFooter (g);
} }

View file

@ -9,24 +9,20 @@
#include "../BaseComponent.h" #include "../BaseComponent.h"
#include "Waveforms.h" #include "Waveforms.h"
class SidebarLCD : public BaseComponent { class SidebarLCD : public BaseComponent
{
private: private:
int m_innerX = 5; int m_innerX = 5;
int m_innerY = 5; int m_innerY = 5;
int m_width = m_innerX * 2; int m_width = m_innerX * 2;
public: public:
explicit SidebarLCD(const std::string &process_id); explicit SidebarLCD (const std::string& process_id);
~SidebarLCD(); ~SidebarLCD ();
void resized () override;
void resized() override; void paint (Graphics& g) override;
void paint(Graphics &g) override;
protected: protected:
void drawHeadline(Graphics &g); void drawHeadline (Graphics& g);
void drawFooter(Graphics &g); void drawFooter (Graphics& g);
std::unique_ptr<Waveforms> waveform; std::unique_ptr<Waveforms> waveform;
}; };
#endif //VENO_SIDEBARLCD_H #endif //VENO_SIDEBARLCD_H

View file

@ -9,227 +9,270 @@
#include "../../../VenoInstance.h" #include "../../../VenoInstance.h"
#include "../../../Fonts/Fonts.h" #include "../../../Fonts/Fonts.h"
Waveforms::Waveforms(const std::string &processId) : BaseComponent(processId) { Waveforms::Waveforms (const std::string& processId) : BaseComponent (processId)
m_context.setOpenGLVersionRequired(OpenGLContext::OpenGLVersion::openGL3_2); {
m_context.setRenderer(this); m_context.setOpenGLVersionRequired (OpenGLContext::OpenGLVersion::openGL3_2);
m_context.setContinuousRepainting(false); m_context.setRenderer (this);
m_context.setComponentPaintingEnabled(true); m_context.setContinuousRepainting (false);
m_context.attachTo(*this); m_context.setComponentPaintingEnabled (true);
auto fps = Config::getInstance()->getFps(); m_context.attachTo (*this);
startTimerHz(Config::getInstance()->getFps()); auto fps = Config::getInstance ()->getFps ();
std::srand(unsigned(time(nullptr))); startTimerHz (Config::getInstance ()->getFps ());
pickRandomText = (std::rand() % RANDOM_TEXT_COUNT); std::srand (unsigned (time (nullptr)));
pickRandomText = (std::rand () % RANDOM_TEXT_COUNT);
m_ticks = 0; m_ticks = 0;
// is something that // is something that
m_time_needed = roundToInt(4000 / (1000 / fps)); m_time_needed = roundToInt (4000 / (1000 / fps));
m_time_needed_startup = roundToInt(1000 / (1000 / fps)); m_time_needed_startup = roundToInt (1000 / (1000 / fps));
} }
Waveforms::~Waveforms() { Waveforms::~Waveforms ()
stopTimer(); {
shaderProgram.reset(); stopTimer ();
m_context.detach(); shaderProgram.reset ();
m_context.detach ();
} }
void Waveforms::newOpenGLContextCreated() { void Waveforms::newOpenGLContextCreated ()
compileOpenGLShaderProgram(); {
compileOpenGLShaderProgram ();
} }
void Waveforms::openGLContextClosing() { void Waveforms::openGLContextClosing ()
{
} }
void Waveforms::renderOpenGL() { void Waveforms::renderOpenGL ()
if (!isShowing() || shaderProgram == nullptr || !shaderProgram->getLastError().isEmpty()) { {
if (!isShowing () || shaderProgram == nullptr || !shaderProgram->getLastError ().isEmpty ())
{
return; return;
} }
auto theme = Config::getInstance()->getCurrentTheme(); auto theme = Config::getInstance ()->getCurrentTheme ();
if (theme == nullptr) { if (theme == nullptr)
{
return; return;
} }
glViewport(0, 0, getWidth(), getHeight()); glViewport (0, 0, getWidth (), getHeight ());
OpenGLHelpers::clear(theme->getColour(ThemeColour::lcd_bg)); OpenGLHelpers::clear (theme->getColour (ThemeColour::lcd_bg));
glEnable(GL_BLEND); glEnable (GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
shaderProgram->use(); shaderProgram->use ();
auto color = theme->getColour(ThemeColour::lcd); auto color = theme->getColour (ThemeColour::lcd);
shaderProgram->setUniform("color", color.getFloatRed(), color.getFloatGreen(), color.getFloatBlue(), shaderProgram->setUniform ("color", color.getFloatRed (), color.getFloatGreen (), color.getFloatBlue (),
color.getFloatAlpha()); color.getFloatAlpha ());
if (m_isWelcome || m_isStarting || m_isChangingData) { if (m_isWelcome || m_isStarting || m_isChangingData)
{
return; return;
} }
switch (m_mode) { switch (m_mode)
{
case 1: case 1:
drawAudioOutput(); drawAudioOutput ();
break; break;
case 2: case 2:
drawWaveTable(); drawWaveTable ();
break; break;
case 3: case 3:
drawSpectrum(); drawSpectrum ();
break; break;
default: default:
drawPeakMeter(); drawPeakMeter ();
} }
} }
void Waveforms::handleAsyncUpdate() { void Waveforms::handleAsyncUpdate ()
{
} }
void Waveforms::compileOpenGLShaderProgram() { void Waveforms::compileOpenGLShaderProgram ()
{
std::unique_ptr<OpenGLShaderProgram> shaderProgramAttempt std::unique_ptr<OpenGLShaderProgram> shaderProgramAttempt
= std::make_unique<OpenGLShaderProgram>(m_context); = std::make_unique<OpenGLShaderProgram> (m_context);
if (shaderProgramAttempt->addVertexShader ({BinaryData::WaveForm_vertex_glsl})
if (shaderProgramAttempt->addVertexShader({BinaryData::WaveForm_vertex_glsl}) && shaderProgramAttempt->addFragmentShader ({BinaryData::WaveForm_fragment_glsl})
&& shaderProgramAttempt->addFragmentShader({BinaryData::WaveForm_fragment_glsl}) && shaderProgramAttempt->link ())
&& shaderProgramAttempt->link()) { {
shaderProgram = std::move(shaderProgramAttempt); shaderProgram = std::move (shaderProgramAttempt);
} }
} }
void Waveforms::mouseDown(const MouseEvent &e) { void Waveforms::mouseDown (const MouseEvent& e)
if (!m_enableModeToggle) { {
if (!m_enableModeToggle)
{
return; return;
} }
m_mode++; m_mode++;
if (m_mode > 3) { if (m_mode > 3)
{
m_mode = 0; m_mode = 0;
} }
} }
void Waveforms::mouseDrag(const MouseEvent &e) { void Waveforms::mouseDrag (const MouseEvent& e)
{
//do nothing... you faggot //do nothing... you faggot
} }
void Waveforms::timerCallback() { void Waveforms::timerCallback ()
if (m_isWelcome || m_isStarting || m_isChangingData || needToClear) { {
repaint(); if (m_isWelcome || m_isStarting || m_isChangingData || needToClear)
} else { {
if (m_context.isAttached()) { repaint ();
m_context.triggerRepaint(); }
else
{
if (m_context.isAttached ())
{
m_context.triggerRepaint ();
} }
} }
} }
void Waveforms::drawWaveTable() { void Waveforms::drawWaveTable ()
{
// this will draw the current selected oscillator :D // this will draw the current selected oscillator :D
} }
void Waveforms::drawAudioOutput() { void Waveforms::drawAudioOutput ()
{
// draw audio from the oscillators // draw audio from the oscillators
auto instance = VenoInstance::getInstance(BaseComponent::m_processId); auto instance = VenoInstance::getInstance (BaseComponent::m_processId);
auto buffer = instance->audioBuffer->getBuffer(); auto buffer = instance->audioBuffer->getBuffer ();
glBegin(GL_LINE_STRIP); glBegin (GL_LINE_STRIP);
float posX = -1; float posX = -1;
float inc = 2.0f / buffer.size(); float inc = 2.0f / buffer.size ();
for (float i : buffer) { for (float i : buffer)
glVertex2f(posX, i); {
glVertex2f (posX, i);
posX += inc; posX += inc;
} }
glEnd(); glEnd ();
} }
void Waveforms::drawPeakMeter() { void Waveforms::drawPeakMeter ()
auto theme = Config::getInstance()->getCurrentTheme(); {
if (theme == nullptr) { auto theme = Config::getInstance ()->getCurrentTheme ();
if (theme == nullptr)
{
return; return;
} }
auto instance = VenoInstance::getInstance(BaseComponent::m_processId); auto instance = VenoInstance::getInstance (BaseComponent::m_processId);
instance->audioBuffer->calcPeak(); instance->audioBuffer->calcPeak ();
// draw peak signal // draw peak signal
auto leftChannel = jmap(Decibels::gainToDecibels(instance->audioBuffer->leftPeak, -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(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); 1.0f);
selectColourByPeak(rightChannel); selectColourByPeak (leftChannel);
glBegin(GL_TRIANGLES); glBegin (GL_TRIANGLES);
glVertex2f(0.9f, rightChannel); glVertex2f (-0.9f, leftChannel);
glVertex2f(0.9f, -1.0f); glVertex2f (-0.9f, -1.0f);
glVertex2f(0.01f, -1.0f); glVertex2f (-0.01f, -1.0f);
glVertex2f(0.9f, rightChannel); glVertex2f (-0.9f, leftChannel);
glVertex2f(0.01f, rightChannel); glVertex2f (-0.01f, leftChannel);
glVertex2f(0.01f, -1.0f); glVertex2f (-0.01f, -1.0f);
glEnd(); 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) { void Waveforms::paint (Graphics& g)
std::shared_ptr<Theme> theme = Config::getInstance()->getCurrentTheme(); {
auto accent = theme->getColour(ThemeColour::lcd); std::shared_ptr<Theme> theme = Config::getInstance ()->getCurrentTheme ();
g.setColour(accent); auto accent = theme->getColour (ThemeColour::lcd);
g.setFont(VenoFonts::getLCD()); g.setColour (accent);
VeNo::Utils::setFontSize(16.0f, g); g.setFont (*VenoFonts::getLCD ());
if (m_isWelcome) { VeNo::Utils::setFontSize (16.0f, g);
drawWelcome(g, getWidth(), getHeight(), 0, 0); if (m_isWelcome)
{
drawWelcome (g, getWidth (), getHeight (), 0, 0);
m_ticks++; m_ticks++;
if (m_ticks > m_time_needed_startup) { if (m_ticks > m_time_needed_startup)
{
m_isWelcome = false; m_isWelcome = false;
m_ticks = 0; m_ticks = 0;
needToClear = true; needToClear = true;
} }
} else if (m_isStarting) { }
g.drawText(m_warmUpText[pickRandomText], 0, 0, getWidth(), getHeight(), else if (m_isStarting)
Justification::centred, true); {
g.drawText (m_warmUpText[pickRandomText], 0, 0, getWidth (), getHeight (),
Justification::centred, true);
m_ticks++; m_ticks++;
if (m_ticks > m_time_needed_startup) { if (m_ticks > m_time_needed_startup)
{
m_isStarting = false; m_isStarting = false;
m_ticks = 0; m_ticks = 0;
needToClear = true; needToClear = true;
} }
} else if (m_isChangingData) { }
drawChangedParameter(g, getWidth(), getHeight(), 0, 0); else if (m_isChangingData)
{
drawChangedParameter (g, getWidth (), getHeight (), 0, 0);
m_ticks++; m_ticks++;
if (m_ticks > m_time_needed) { if (m_ticks > m_time_needed)
{
m_isChangingData = false; m_isChangingData = false;
m_ticks = 0; m_ticks = 0;
needToClear = true; needToClear = true;
} }
} else { }
g.resetToDefaultState(); else
{
g.resetToDefaultState ();
needToClear = false; 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; int halfHeight = h / 2;
float font = VeNo::Utils::setFontSize(12, g); float font = VeNo::Utils::setFontSize (12, g);
g.drawText(changingParameter, x, y + halfHeight - font, w, font, Justification::centred, true); 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, g.drawText (std::to_string (changedValue), x, y + halfHeight + 4, w, font, Justification::centred,
true); true);
} }
void Waveforms::drawWelcome(Graphics &g, int w, int h, int x, int y) { void Waveforms::drawWelcome (Graphics& g, int w, int h, int x, int y)
float font = VeNo::Utils::setFontSize(12, g); {
float font = VeNo::Utils::setFontSize (12, g);
int halfHeight = h / 2; int halfHeight = h / 2;
g.drawText(m_readyText, x, y + halfHeight - font, 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, g.drawText (SystemStats::getLogonName (), x, y + halfHeight + 4, w, font, Justification::centred,
true); true);
} }
void Waveforms::drawSpectrum() { void Waveforms::drawSpectrum ()
{
} }
void Waveforms::selectColourByPeak(float value) { void Waveforms::selectColourByPeak (float value)
auto theme = Config::getInstance()->getCurrentTheme(); {
if (theme == nullptr) { auto theme = Config::getInstance ()->getCurrentTheme ();
if (theme == nullptr)
{
return; return;
} }
auto color = theme->getColour(ThemeColour::lcd); auto color = theme->getColour (ThemeColour::lcd);
if (value > 0.8 && value < 0.9) { if (value > 0.8 && value < 0.9)
color = theme->getColour(ThemeColour::warning); {
color = theme->getColour (ThemeColour::warning);
} }
if (value > 0.9) { if (value > 0.9)
color = theme->getColour(ThemeColour::clip); {
color = theme->getColour (ThemeColour::clip);
} }
shaderProgram->setUniform("color", color.getFloatRed(), color.getFloatGreen(), color.getFloatBlue(), shaderProgram->setUniform ("color", color.getFloatRed (), color.getFloatGreen (), color.getFloatBlue (),
color.getFloatAlpha()); color.getFloatAlpha ());
} }

View file

@ -9,17 +9,18 @@
#include "../BaseComponent.h" #include "../BaseComponent.h"
#define RANDOM_TEXT_COUNT 5 #define RANDOM_TEXT_COUNT 5
// opengl context :D // opengl context :D
class Waveforms : public BaseComponent, class Waveforms : public BaseComponent,
private OpenGLRenderer, private OpenGLRenderer,
private AsyncUpdater, private AsyncUpdater,
private Timer { private Timer
{
protected: protected:
bool m_enableModeToggle = true; bool m_enableModeToggle = true;
int m_mode = 0; int m_mode = 0;
std::string m_readyText = "=WELCOME="; 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; int pickRandomText = 0;
bool m_isWelcome = true; bool m_isWelcome = true;
bool m_isStarting = true; bool m_isStarting = true;
@ -28,46 +29,29 @@ protected:
int m_time_needed = 0; int m_time_needed = 0;
bool needToClear = false; bool needToClear = false;
public: public:
explicit Waveforms(const std::string &processId); explicit Waveforms (const std::string& processId);
~Waveforms () override;
~Waveforms() override; void newOpenGLContextCreated () override;
void openGLContextClosing () override;
void newOpenGLContextCreated() override; void renderOpenGL () override;
void handleAsyncUpdate () override;
void openGLContextClosing() override; void mouseDown (const MouseEvent& e) override;
void mouseDrag (const MouseEvent& e) override;
void renderOpenGL() override; void paint (Graphics& g) 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; bool m_isChangingData = false;
std::string changingParameter = ""; std::string changingParameter = "";
float changedValue = 0; float changedValue = 0;
private: private:
void timerCallback() override; void timerCallback () override;
void drawWaveTable ();
void drawWaveTable(); void drawAudioOutput ();
void drawSpectrum ();
void drawAudioOutput(); void drawPeakMeter (); //?!
void drawSpectrum(); 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 drawPeakMeter(); //?! void compileOpenGLShaderProgram ();
void drawChangedParameter(Graphics &g, int w, int h, int x, int y) const; void selectColourByPeak (float value);
void drawWelcome(Graphics &g, int w, int h, int x, int y);
void compileOpenGLShaderProgram();
void selectColourByPeak(float value);
OpenGLContext m_context; OpenGLContext m_context;
std::unique_ptr<OpenGLShaderProgram> shaderProgram; std::unique_ptr<OpenGLShaderProgram> shaderProgram;
}; };
#endif //VENO_WAVEFORMS_H #endif //VENO_WAVEFORMS_H

View file

@ -4,29 +4,36 @@
#include "LabelComponent.h" #include "LabelComponent.h"
LabelComponent::LabelComponent(Component *parent, std::string name) { LabelComponent::LabelComponent (Component* parent, std::string name)
{
m_text = name; m_text = name;
m_parent = parent; m_parent = parent;
m_label = std::make_shared<Label>(m_parent->getName(), name); m_label = std::make_shared<Label> (m_parent->getName (), name);
} }
LabelComponent::~LabelComponent() { LabelComponent::~LabelComponent ()
m_label.reset(); {
m_label.reset ();
} }
void LabelComponent::resized() { void LabelComponent::resized ()
if (m_label != nullptr) { {
m_label->setBounds(0, 0, getWidth(), getHeight()); if (m_label != nullptr)
{
m_label->setBounds (0, 0, getWidth (), getHeight ());
} }
} }
void LabelComponent::paint(Graphics &g) { void LabelComponent::paint (Graphics& g)
{
} }
void LabelComponent::setPosition(LabelPosition position) { void LabelComponent::setPosition (LabelPosition position)
{
m_position = position; m_position = position;
} }
LabelPosition LabelComponent::getLabelPosition() { LabelPosition LabelComponent::getLabelPosition ()
{
return m_position; return m_position;
} }

View file

@ -7,28 +7,26 @@
#include "JuceHeader.h" #include "JuceHeader.h"
enum LabelPosition { enum LabelPosition
{
NO_LABEL, NO_LABEL,
TOP, TOP,
BOTTOM BOTTOM
}; };
class LabelComponent : public Component { class LabelComponent : public Component
{
public: public:
LabelComponent(Component *parent, std::string name); LabelComponent (Component* parent, std::string name);
~LabelComponent() override; ~LabelComponent () override;
void resized () override;
void resized() override; void paint (Graphics& g) override;
void setPosition (LabelPosition position);
void paint(Graphics &g) override; LabelPosition getLabelPosition ();
void setPosition(LabelPosition position);
LabelPosition getLabelPosition();
protected: protected:
private: private:
std::string m_text; std::string m_text;
Component *m_parent; Component* m_parent;
LabelPosition m_position = LabelPosition::NO_LABEL; LabelPosition m_position = LabelPosition::NO_LABEL;
std::shared_ptr<Label> m_label; std::shared_ptr<Label> m_label;
}; };
#endif //VENO_LABELCOMPONENT_H #endif //VENO_LABELCOMPONENT_H

View file

@ -0,0 +1,5 @@
//
// Created by versustune on 13.06.20.
//
#include "Sidebar.h"

View file

@ -0,0 +1,19 @@
//
// Created by versustune on 13.06.20.
//
#ifndef VENO_SIDEBAR_H
#define VENO_SIDEBAR_H
#include "JuceHeader.h"
#include "../../Components/BaseComponent.h"
class Sidebar : public BaseComponent
{
private:
public:
Sidebar ();
~Sidebar ();
protected:
};
#endif //VENO_SIDEBAR_H

View file

@ -0,0 +1,5 @@
//
// Created by versustune on 13.06.20.
//
#include "SidebarMixer.h"

View file

@ -0,0 +1,11 @@
//
// Created by versustune on 13.06.20.
//
#ifndef VENO_SIDEBARMIXER_H
#define VENO_SIDEBARMIXER_H
class SidebarMixer
{
};
#endif //VENO_SIDEBARMIXER_H

View file

@ -7,11 +7,10 @@
#include "JuceHeader.h" #include "JuceHeader.h"
class CrazyLook : public LookAndFeel_V4 { class CrazyLook : public LookAndFeel_V4
{
private: private:
public: public:
protected: protected:
}; };
#endif //VENO_CRAZYLOOK_H #endif //VENO_CRAZYLOOK_H

View file

@ -7,11 +7,10 @@
#include "JuceHeader.h" #include "JuceHeader.h"
class FlatLook : public LookAndFeel_V4 { class FlatLook : public LookAndFeel_V4
{
private: private:
public: public:
protected: protected:
}; };
#endif //VENO_FLATLOOK_H #endif //VENO_FLATLOOK_H

View file

@ -5,20 +5,24 @@
#include "LookHandler.h" #include "LookHandler.h"
#include "../../Core/Config.h" #include "../../Core/Config.h"
LookHandler::LookHandler() { LookHandler::LookHandler ()
selectLook(Config::getInstance()->getCurrentLook()); {
selectLook (Config::getInstance ()->getCurrentLook ());
} }
LookHandler::~LookHandler() { LookHandler::~LookHandler ()
{
//delete this shit! //delete this shit!
delete m_feels[0]; delete m_feels[0];
delete m_feels[1]; delete m_feels[1];
} }
void LookHandler::selectLook(int index) { void LookHandler::selectLook (int index)
{
m_currentLook = index; m_currentLook = index;
} }
LookAndFeel_V4* LookHandler::getLook() { LookAndFeel_V4* LookHandler::getLook ()
{
return m_feels[m_currentLook]; return m_feels[m_currentLook];
} }

View file

@ -13,19 +13,18 @@
/** /**
* overwrite the basic m_look and feel based on the selected Look and Feel :) * overwrite the basic m_look and feel based on the selected Look and Feel :)
*/ */
class LookHandler : public LookAndFeel_V4 { class LookHandler : public LookAndFeel_V4
{
private: private:
std::shared_ptr<LookAndFeel_V4> m_look; std::shared_ptr<LookAndFeel_V4> m_look;
int m_currentLook = 0; int m_currentLook = 0;
public: public:
LookHandler(); LookHandler ();
~LookHandler() override; ~LookHandler () override;
void selectLook(int index); void selectLook (int index);
LookAndFeel_V4* getLook(); LookAndFeel_V4* getLook ();
protected: protected:
//currently both available themes are CrazyLook <-- (this is a fun one xD) and FlatLook //currently both available themes are CrazyLook <-- (this is a fun one xD) and FlatLook
LookAndFeel_V4 *m_feels[2] = {new FlatLook(), new CrazyLook()}; LookAndFeel_V4* m_feels[2] = {new FlatLook (), new CrazyLook ()};
}; };
#endif //VENO_LOOKHANDLER_H #endif //VENO_LOOKHANDLER_H

View file

@ -5,73 +5,87 @@
#include "Theme.h" #include "Theme.h"
#include "ThemePresets.cpp" #include "ThemePresets.cpp"
Theme::Theme(std::shared_ptr<PropertiesFile> file) { Theme::Theme (std::shared_ptr<PropertiesFile> file)
{
m_configFile = file; m_configFile = file;
} }
Theme::~Theme ()
Theme::~Theme() { {
m_colours.clear(); m_colours.clear ();
m_configFile.reset(); m_configFile.reset ();
} }
void Theme::setColour(ThemeColour index, Colour *colour) { void Theme::setColour (ThemeColour index, Colour* colour)
{
auto c = m_colours[index]; auto c = m_colours[index];
if (c) { if (c)
{
delete c; delete c;
m_colours[index] = colour; m_colours[index] = colour;
} else { }
else
{
m_colours[index] = colour; m_colours[index] = colour;
} }
m_configFile->setValue(ThemeColourToString(index), colour->toString()); m_configFile->setValue (ThemeColourToString (index), colour->toString ());
m_configFile->save(); m_configFile->save ();
} }
void Theme::init() { void Theme::init ()
getColourFromConfig(ThemeColour::bg); {
getColourFromConfig(ThemeColour::bg_two); getColourFromConfig (ThemeColour::bg);
getColourFromConfig(ThemeColour::accent); getColourFromConfig (ThemeColour::bg_two);
getColourFromConfig(ThemeColour::accent_two); getColourFromConfig (ThemeColour::accent);
getColourFromConfig(ThemeColour::warning); getColourFromConfig (ThemeColour::accent_two);
getColourFromConfig(ThemeColour::clip); getColourFromConfig (ThemeColour::warning);
getColourFromConfig(ThemeColour::lcd_bg); getColourFromConfig (ThemeColour::clip);
getColourFromConfig(ThemeColour::lcd); getColourFromConfig (ThemeColour::lcd_bg);
getColourFromConfig (ThemeColour::lcd);
} }
void Theme::getColourFromConfig(ThemeColour index) { void Theme::getColourFromConfig (ThemeColour index)
std::string key = ThemeColourToString(index); {
if (m_configFile->containsKey(key)) { std::string key = ThemeColourToString (index);
auto baseColour = Colour::fromString(m_configFile->getValue(key)); if (m_configFile->containsKey (key))
auto *colour = new Colour(baseColour.getRed(), baseColour.getGreen(), baseColour.getBlue()); {
auto baseColour = Colour::fromString (m_configFile->getValue (key));
auto* colour = new Colour (baseColour.getRed (), baseColour.getGreen (), baseColour.getBlue ());
delete m_colours[index]; delete m_colours[index];
m_colours[index] = colour; m_colours[index] = colour;
} else { }
else
{
// should only trigger if config is broken or empty :) // should only trigger if config is broken or empty :)
setLEDTheme(this); setLEDTheme (this);
} }
} }
Colour Theme::getColour(ThemeColour index) { Colour Theme::getColour (ThemeColour index)
if (m_colours[index] != nullptr) { {
if (m_colours[index] != nullptr)
{
return *m_colours[index]; return *m_colours[index];
} }
return Colour(255, 255, 255); return Colour (255, 255, 255);
} }
void Theme::setColourThemeById(int id) { void Theme::setColourThemeById (int id)
switch (id) { {
switch (id)
{
case 1: case 1:
setLEDTheme(this); setLEDTheme (this);
break; break;
case 2: case 2:
setOrangeDreamTheme(this); setOrangeDreamTheme (this);
break; break;
case 3: case 3:
setBloodTheme(this); setBloodTheme (this);
break; break;
case 4: case 4:
setOceanTheme(this); setOceanTheme (this);
default: default:
break; break;
} }

View file

@ -8,25 +8,23 @@
#include "JuceHeader.h" #include "JuceHeader.h"
#include <vector> #include <vector>
enum class ThemeColour { enum class ThemeColour
{
bg = 0, bg_two, accent, accent_two, warning, clip, lcd_bg, lcd bg = 0, bg_two, accent, accent_two, warning, clip, lcd_bg, lcd
}; };
class Theme
class Theme { {
private: private:
public: public:
explicit Theme(std::shared_ptr<PropertiesFile> file); explicit Theme (std::shared_ptr<PropertiesFile> file);
~Theme(); ~Theme ();
void setColour (ThemeColour index, Colour* colour);
void setColour(ThemeColour index, Colour *colour); void setColourThemeById (int id);
void setColourThemeById(int id); void init ();
void init(); void getColourFromConfig (ThemeColour index);
void getColourFromConfig(ThemeColour index); Colour getColour (ThemeColour index);
Colour getColour(ThemeColour index);
protected: protected:
std::map<ThemeColour, Colour*> m_colours; std::map<ThemeColour, Colour*> m_colours;
std::shared_ptr<PropertiesFile> m_configFile; std::shared_ptr<PropertiesFile> m_configFile;
}; };
#endif //VENO_THEME_H #endif //VENO_THEME_H

View file

@ -9,53 +9,58 @@
* maybe i want a double m_look and feel... that's make it easier to implement different knob styles, slider styles and co * maybe i want a double m_look and feel... that's make it easier to implement different knob styles, slider styles and co
*/ */
void setLEDTheme(Theme *theme) { 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::bg, new Colour (41, 47, 54));
theme->setColour(ThemeColour::accent, new Colour(169, 208, 142)); theme->setColour (ThemeColour::bg_two, new Colour (217, 217, 217));
theme->setColour(ThemeColour::accent_two, new Colour(139, 171, 117)); theme->setColour (ThemeColour::accent, new Colour (169, 208, 142));
theme->setColour(ThemeColour::clip, new Colour(255, 23, 68)); theme->setColour (ThemeColour::accent_two, new Colour (139, 171, 117));
theme->setColour(ThemeColour::warning, new Colour(255, 143, 0)); theme->setColour (ThemeColour::clip, new Colour (255, 23, 68));
theme->setColour(ThemeColour::lcd_bg, new Colour(21, 21, 21)); theme->setColour (ThemeColour::warning, new Colour (255, 143, 0));
theme->setColour(ThemeColour::lcd, new Colour(169, 208, 142)); theme->setColour (ThemeColour::lcd_bg, new Colour (21, 21, 21));
theme->setColour (ThemeColour::lcd, new Colour (169, 208, 142));
} }
void setBloodTheme(Theme *theme) { void setBloodTheme (Theme* theme)
theme->setColour(ThemeColour::bg, new Colour(41, 47, 54)); {
theme->setColour(ThemeColour::bg_two, new Colour(64, 67, 78)); theme->setColour (ThemeColour::bg, new Colour (41, 47, 54));
theme->setColour(ThemeColour::accent, new Colour(180, 38, 50)); theme->setColour (ThemeColour::bg_two, new Colour (64, 67, 78));
theme->setColour(ThemeColour::accent_two, new Colour(115, 47, 64)); theme->setColour (ThemeColour::accent, new Colour (180, 38, 50));
theme->setColour(ThemeColour::clip, new Colour(255, 23, 68)); theme->setColour (ThemeColour::accent_two, new Colour (115, 47, 64));
theme->setColour(ThemeColour::warning, new Colour(255, 143, 0)); theme->setColour (ThemeColour::clip, new Colour (255, 23, 68));
theme->setColour(ThemeColour::lcd_bg, new Colour(0, 0, 0)); theme->setColour (ThemeColour::warning, new Colour (255, 143, 0));
theme->setColour(ThemeColour::lcd, new Colour(180, 38, 78)); theme->setColour (ThemeColour::lcd_bg, new Colour (0, 0, 0));
theme->setColour (ThemeColour::lcd, new Colour (180, 38, 78));
} }
void setOrangeDreamTheme(Theme *theme) { void setOrangeDreamTheme (Theme* theme)
theme->setColour(ThemeColour::bg, new Colour(21, 21, 21)); {
theme->setColour(ThemeColour::bg_two, new Colour(42, 42, 42)); theme->setColour (ThemeColour::bg, new Colour (21, 21, 21));
theme->setColour(ThemeColour::accent, new Colour(255, 160, 0)); theme->setColour (ThemeColour::bg_two, new Colour (42, 42, 42));
theme->setColour(ThemeColour::accent_two, new Colour(255, 11, 0)); theme->setColour (ThemeColour::accent, new Colour (255, 160, 0));
theme->setColour(ThemeColour::clip, new Colour(255, 23, 68)); theme->setColour (ThemeColour::accent_two, new Colour (255, 11, 0));
theme->setColour(ThemeColour::warning, new Colour(255, 143, 0)); theme->setColour (ThemeColour::clip, new Colour (255, 23, 68));
theme->setColour(ThemeColour::lcd_bg, new Colour(33, 33, 33)); theme->setColour (ThemeColour::warning, new Colour (255, 143, 0));
theme->setColour(ThemeColour::lcd, new Colour(255, 160, 0)); theme->setColour (ThemeColour::lcd_bg, new Colour (33, 33, 33));
theme->setColour (ThemeColour::lcd, new Colour (255, 160, 0));
} }
void setOceanTheme(Theme *theme) { void setOceanTheme (Theme* theme)
theme->setColour(ThemeColour::bg, new Colour(55, 63, 81)); {
theme->setColour(ThemeColour::bg_two, new Colour(64, 67, 78)); theme->setColour (ThemeColour::bg, new Colour (55, 63, 81));
theme->setColour(ThemeColour::accent, new Colour(0, 141, 213)); theme->setColour (ThemeColour::bg_two, new Colour (64, 67, 78));
theme->setColour(ThemeColour::accent_two, new Colour(0, 129, 194)); theme->setColour (ThemeColour::accent, new Colour (0, 141, 213));
theme->setColour(ThemeColour::clip, new Colour(255, 23, 68)); theme->setColour (ThemeColour::accent_two, new Colour (0, 129, 194));
theme->setColour(ThemeColour::warning, new Colour(255, 143, 0)); theme->setColour (ThemeColour::clip, new Colour (255, 23, 68));
theme->setColour(ThemeColour::lcd_bg, new Colour(21, 21, 21)); theme->setColour (ThemeColour::warning, new Colour (255, 143, 0));
theme->setColour(ThemeColour::lcd, new Colour(0, 129, 194)); theme->setColour (ThemeColour::lcd_bg, new Colour (21, 21, 21));
theme->setColour (ThemeColour::lcd, new Colour (0, 129, 194));
} }
std::string ThemeColourToString (ThemeColour index)
std::string ThemeColourToString(ThemeColour index) { {
switch (index) { switch (index)
{
case ThemeColour::bg: case ThemeColour::bg:
return "colour_bg"; return "colour_bg";
case ThemeColour::bg_two: case ThemeColour::bg_two:

View file

@ -5,7 +5,8 @@
#include "Utils.h" #include "Utils.h"
#include "Core/Config.h" #include "Core/Config.h"
int VeNo::Utils::nextPowerOfTwo(float value) { int VeNo::Utils::nextPowerOfTwo (float value)
{
unsigned int v = value; unsigned int v = value;
v--; v--;
v |= v >> 1; v |= v >> 1;
@ -17,9 +18,10 @@ int VeNo::Utils::nextPowerOfTwo(float value) {
return v; return v;
} }
float VeNo::Utils::setFontSize(float size, Graphics &g) { float VeNo::Utils::setFontSize (float size, Graphics& g)
double scale = Config::getInstance()->getScale(); {
double scale = Config::getInstance ()->getScale ();
float s = size * scale; float s = size * scale;
g.setFont(s); g.setFont (s);
return s; return s;
} }

View file

@ -7,16 +7,15 @@
#include "JuceHeader.h" #include "JuceHeader.h"
namespace VeNo { namespace VeNo
class Utils { {
class Utils
{
public: public:
Utils() = default; Utils () = default;
~Utils() = default; ~Utils () = default;
static int nextPowerOfTwo(float value); static int nextPowerOfTwo (float value);
static float setFontSize (float size, Graphics& g);
static float setFontSize(float size, Graphics &g);
}; };
} }
#endif //VENO_UTILS_H #endif //VENO_UTILS_H

View file

@ -4,32 +4,33 @@
#include "FFT.h" #include "FFT.h"
void FFT::pushNextSampleIntoFifo(float sample) noexcept { void FFT::pushNextSampleIntoFifo (float sample) noexcept
{
{ {
if (fifoIndex == fftSize) // [11] if (fifoIndex == fftSize) // [11]
{ {
if (!nextFFTBlockReady) // [12] if (!nextFFTBlockReady) // [12]
{ {
zeromem(fftData, sizeof(fftData)); zeromem (fftData, sizeof (fftData));
memcpy(fftData, fifo, sizeof(fifo)); memcpy (fftData, fifo, sizeof (fifo));
nextFFTBlockReady = true; nextFFTBlockReady = true;
} }
fifoIndex = 0; fifoIndex = 0;
} }
fifo[fifoIndex++] = sample; // [12] fifo[fifoIndex++] = sample; // [12]
} }
} }
void FFT::drawNextFrameOfSpectrum() { void FFT::drawNextFrameOfSpectrum ()
window.multiplyWithWindowingTable(fftData, fftSize); // [1] {
fft.performFrequencyOnlyForwardTransform(fftData); // [2] window.multiplyWithWindowingTable (fftData, fftSize); // [1]
fft.performFrequencyOnlyForwardTransform (fftData); // [2]
auto mindB = -80.0f; auto mindB = -80.0f;
auto maxdB = 0.0f; auto maxdB = 0.0f;
for (int i = 0; i < scopeSize; ++i) for (int i = 0; i < scopeSize; ++i)
{ {
auto level = jmap(Decibels::gainToDecibels(fftData[i], mindB), mindB, maxdB, -1.0f, 1.0f); auto level = jmap (Decibels::gainToDecibels (fftData[i], mindB), mindB, maxdB, -1.0f, 1.0f);
scopeData[i] = level; scopeData[i] = level;
} }
} }

View file

@ -7,28 +7,27 @@
#include "JuceHeader.h" #include "JuceHeader.h"
class FFT { class FFT
{
private: private:
public: public:
FFT() = default; FFT () = default;
~FFT() = default; ~FFT () = default;
void pushNextSampleIntoFifo (float sample) noexcept; void pushNextSampleIntoFifo (float sample) noexcept;
enum enum
{ {
fftOrder = 11, // [1] fftOrder = 11, // [1]
fftSize = 1 << fftOrder, // [2] fftSize = 1 << fftOrder, // [2]
scopeSize = 512 // [3] scopeSize = 512 // [3]
}; };
void drawNextFrameOfSpectrum(); void drawNextFrameOfSpectrum ();
bool nextFFTBlockReady = false; bool nextFFTBlockReady = false;
float scopeData [scopeSize]{}; float scopeData[scopeSize]{};
float fftData [2 * fftSize]{}; float fftData[2 * fftSize]{};
protected: protected:
dsp::FFT fft{fftOrder}; dsp::FFT fft{fftOrder};
dsp::WindowingFunction<float> window{fftSize, dsp::WindowingFunction<float>::hann}; dsp::WindowingFunction<float> window{fftSize, dsp::WindowingFunction<float>::hann};
float fifo [fftSize]{}; float fifo[fftSize]{};
int fifoIndex = 0; int fifoIndex = 0;
}; };
#endif //VENO_FFT_H #endif //VENO_FFT_H

View file

@ -4,13 +4,15 @@
#include "Logger.h" #include "Logger.h"
void VeNo::Logger::debugMessage(const std::string &message) { void VeNo::Logger::debugMessage (const std::string& message)
{
#ifdef DEBUG #ifdef DEBUG
std::cout << "\u001b[38;5;172m[DEBUG]\u001b[0m\t" << message << "\n"; std::cout << "\u001b[38;5;172m[DEBUG]\u001b[0m\t" << message << "\n";
#endif #endif
} }
void VeNo::Logger::infoDebugMessage(const std::string &message) { void VeNo::Logger::infoDebugMessage (const std::string& message)
{
#ifdef DEBUG #ifdef DEBUG
std::cout << "\u001b[38;5;111m[INFO]\u001b[0m\t" << message << "\n"; std::cout << "\u001b[38;5;111m[INFO]\u001b[0m\t" << message << "\n";
#endif #endif

View file

@ -1,16 +1,15 @@
#ifndef VENO_LOGGER_H #ifndef VENO_LOGGER_H
#define VENO_LOGGER_H #define VENO_LOGGER_H
#include <iostream> #include <iostream>
namespace VeNo { namespace VeNo
class Logger { {
class Logger
{
public: public:
static void debugMessage(const std::string &message); static void debugMessage (const std::string& message);
static void infoDebugMessage(const std::string &message); static void infoDebugMessage (const std::string& message);
}; };
} }
#endif //VENO_LOGGER_H #endif //VENO_LOGGER_H

View file

@ -3,46 +3,53 @@
// //
#include "VenoInstance.h" #include "VenoInstance.h"
#include <utility> #include <utility>
#include "Utils/Logger.h" #include "Utils/Logger.h"
std::unordered_map<std::string, std::shared_ptr<VenoInstance>> VenoInstance::instances; std::unordered_map<std::string, std::shared_ptr<VenoInstance>> VenoInstance::instances;
VenoInstance::VenoInstance(std::string id) { VenoInstance::VenoInstance (std::string id)
m_id = std::move(id); {
m_synthInstance = std::make_shared<SynthInstance>(id); m_id = std::move (id);
audioBuffer = std::make_shared<VenoBuffer>(); m_synthInstance = std::make_shared<SynthInstance> (id);
audioBuffer = std::make_shared<VenoBuffer> ();
} }
VenoInstance::~VenoInstance() { VenoInstance::~VenoInstance ()
m_synthInstance.reset(); {
audioBuffer.reset(); m_synthInstance.reset ();
audioBuffer.reset ();
} }
std::shared_ptr<VenoInstance> VenoInstance::createInstance(const std::string &id) { std::shared_ptr<VenoInstance> VenoInstance::createInstance (const std::string& id)
auto instance = std::make_shared<VenoInstance>(id); {
instances.insert(std::pair<std::string, std::shared_ptr<VenoInstance>>(id, instance)); auto instance = std::make_shared<VenoInstance> (id);
VeNo::Logger::debugMessage("Created VenoInstance with id: " + id); instances.insert (std::pair<std::string, std::shared_ptr<VenoInstance>> (id, instance));
VeNo::Logger::debugMessage ("Created VenoInstance with id: " + id);
return instance; return instance;
} }
// will return the instance or a empty new on... can find out because the id is fucked! // will return the instance or a empty new on... can find out because the id is fucked!
std::shared_ptr<VenoInstance> VenoInstance::getInstance(const std::string &id) { std::shared_ptr<VenoInstance> VenoInstance::getInstance (const std::string& id)
if (instances.find(id) != instances.end()) { {
if (instances.find (id) != instances.end ())
{
return instances[id]; return instances[id];
} }
return createInstance(id); return createInstance (id);
} }
const std::shared_ptr<SynthInstance> &VenoInstance::getSynthInstance() const { const std::shared_ptr<SynthInstance>& VenoInstance::getSynthInstance () const
{
return m_synthInstance; return m_synthInstance;
} }
void VenoInstance::deleteInstance(const std::string &processId) { void VenoInstance::deleteInstance (const std::string& processId)
if (instances.find(processId) != instances.end()) { {
instances[processId].reset(); if (instances.find (processId) != instances.end ())
instances.erase(processId); {
VeNo::Logger::debugMessage("Removed VenoInstance with id: " + processId); instances[processId].reset ();
instances.erase (processId);
VeNo::Logger::debugMessage ("Removed VenoInstance with id: " + processId);
} }
} }

View file

@ -9,23 +9,24 @@
#include "Audio/Synth/SynthInstance.h" #include "Audio/Synth/SynthInstance.h"
#include "Utils/FFT.h" #include "Utils/FFT.h"
#include "Audio/VenoBuffer.h" #include "Audio/VenoBuffer.h"
#include "Audio/Engine/VenoMatrix.h"
#include <unordered_map> #include <unordered_map>
class VenoInstance { class VenoInstance
{
private: private:
std::shared_ptr<SynthInstance> m_synthInstance; std::shared_ptr<SynthInstance> m_synthInstance;
static std::unordered_map<std::string, std::shared_ptr<VenoInstance>> instances; static std::unordered_map<std::string, std::shared_ptr<VenoInstance>> instances;
std::string m_id; std::string m_id;
public: public:
static std::shared_ptr<VenoInstance> createInstance(const std::string& id); explicit VenoInstance (std::string id);
static std::shared_ptr<VenoInstance> getInstance(const std::string& id); ~VenoInstance ();
explicit VenoInstance(std::string id); static std::shared_ptr<VenoInstance> createInstance (const std::string& id);
~VenoInstance(); static std::shared_ptr<VenoInstance> getInstance (const std::string& id);
const std::shared_ptr<SynthInstance> &getSynthInstance() const; static void deleteInstance (const std::string& processId);
static void deleteInstance(const std::string& processId); const std::shared_ptr<SynthInstance>& getSynthInstance () const;
FFT fft; FFT fft;
std::shared_ptr<VenoBuffer> audioBuffer; std::shared_ptr<VenoBuffer> audioBuffer;
VenoMatrix matrix{m_id}; //matrix need a own xml profile to save and restore!
}; };
#endif //VENO_VENOINSTANCE_H #endif //VENO_VENOINSTANCE_H

View file

@ -19,6 +19,7 @@
</GROUP> </GROUP>
<GROUP id="{5791B3F9-67EA-BE3E-0208-47B8AF81F72F}" name="Veno"> <GROUP id="{5791B3F9-67EA-BE3E-0208-47B8AF81F72F}" name="Veno">
<GROUP id="{BD05234A-1BBB-5055-FA22-C66F1E78CC81}" name="Fonts"> <GROUP id="{BD05234A-1BBB-5055-FA22-C66F1E78CC81}" name="Fonts">
<FILE id="D4zlai" name="Fonts.cpp" compile="1" resource="0" file="Source/Veno/Fonts/Fonts.cpp"/>
<FILE id="ytenkm" name="Fonts.h" compile="0" resource="0" file="Source/Veno/Fonts/Fonts.h"/> <FILE id="ytenkm" name="Fonts.h" compile="0" resource="0" file="Source/Veno/Fonts/Fonts.h"/>
</GROUP> </GROUP>
<GROUP id="{857B8B89-43D1-9083-E43D-8CE49DC48C2E}" name="Utils"> <GROUP id="{857B8B89-43D1-9083-E43D-8CE49DC48C2E}" name="Utils">
@ -33,6 +34,15 @@
<FILE id="nB3dnt" name="Utils.h" compile="0" resource="0" file="Source/Veno/Utils.h"/> <FILE id="nB3dnt" name="Utils.h" compile="0" resource="0" file="Source/Veno/Utils.h"/>
<FILE id="jHgT3X" name="Utils.cpp" compile="1" resource="0" file="Source/Veno/Utils.cpp"/> <FILE id="jHgT3X" name="Utils.cpp" compile="1" resource="0" file="Source/Veno/Utils.cpp"/>
<GROUP id="{95543E53-EBB6-70D0-E280-A334ED5EAB84}" name="Audio"> <GROUP id="{95543E53-EBB6-70D0-E280-A334ED5EAB84}" name="Audio">
<GROUP id="{54E62D70-D597-6F59-0770-96E3824F110B}" name="Engine">
<FILE id="tKRVBt" name="ModulateValue.cpp" compile="1" resource="0"
file="Source/Veno/Audio/Engine/ModulateValue.cpp"/>
<FILE id="Tpzeeh" name="ModulateValue.h" compile="0" resource="0" file="Source/Veno/Audio/Engine/ModulateValue.h"/>
<FILE id="dB1Djv" name="Modulator.cpp" compile="1" resource="0" file="Source/Veno/Audio/Engine/Modulator.cpp"/>
<FILE id="eA6ftc" name="Modulator.h" compile="0" resource="0" file="Source/Veno/Audio/Engine/Modulator.h"/>
<FILE id="rkTKQ1" name="VenoMatrix.cpp" compile="1" resource="0" file="Source/Veno/Audio/Engine/VenoMatrix.cpp"/>
<FILE id="v4AuOK" name="VenoMatrix.h" compile="0" resource="0" file="Source/Veno/Audio/Engine/VenoMatrix.h"/>
</GROUP>
<FILE id="tHbIrz" name="VenoBuffer.cpp" compile="1" resource="0" file="Source/Veno/Audio/VenoBuffer.cpp"/> <FILE id="tHbIrz" name="VenoBuffer.cpp" compile="1" resource="0" file="Source/Veno/Audio/VenoBuffer.cpp"/>
<FILE id="ufeJaH" name="VenoBuffer.h" compile="0" resource="0" file="Source/Veno/Audio/VenoBuffer.h"/> <FILE id="ufeJaH" name="VenoBuffer.h" compile="0" resource="0" file="Source/Veno/Audio/VenoBuffer.h"/>
<GROUP id="{A8A2C90F-3822-64F1-4430-4E6163B67B9A}" name="Synth"> <GROUP id="{A8A2C90F-3822-64F1-4430-4E6163B67B9A}" name="Synth">
@ -64,6 +74,15 @@
<GROUP id="{A224AFA7-CD28-E0FE-3B5A-8203BFD9467B}" name="FX"/> <GROUP id="{A224AFA7-CD28-E0FE-3B5A-8203BFD9467B}" name="FX"/>
</GROUP> </GROUP>
<GROUP id="{EFD25B6B-987D-435F-F8DE-BD6C2B831E62}" name="GUI"> <GROUP id="{EFD25B6B-987D-435F-F8DE-BD6C2B831E62}" name="GUI">
<GROUP id="{9C28E1EA-57BD-A04E-6ED6-3C46B5BC7FC7}" name="GUIParts">
<GROUP id="{B7626B9F-22D9-713A-B543-1D7B34AF77B7}" name="Sidebar">
<FILE id="aGx0eJ" name="Sidebar.cpp" compile="1" resource="0" file="Source/Veno/GUI/GUIParts/Sidebar/Sidebar.cpp"/>
<FILE id="uL7MJ3" name="Sidebar.h" compile="0" resource="0" file="Source/Veno/GUI/GUIParts/Sidebar/Sidebar.h"/>
<FILE id="lNXOQs" name="SidebarMixer.cpp" compile="1" resource="0"
file="Source/Veno/GUI/GUIParts/Sidebar/SidebarMixer.cpp"/>
<FILE id="onzdTZ" name="SidebarMixer.h" compile="0" resource="0" file="Source/Veno/GUI/GUIParts/Sidebar/SidebarMixer.h"/>
</GROUP>
</GROUP>
<GROUP id="{53C33AC6-67D7-762E-FFD5-C82B7F51DA5F}" name="Components"> <GROUP id="{53C33AC6-67D7-762E-FFD5-C82B7F51DA5F}" name="Components">
<GROUP id="{7C37E6D2-F2F7-6BF7-5D9B-2DDABFFE993F}" name="LCD"> <GROUP id="{7C37E6D2-F2F7-6BF7-5D9B-2DDABFFE993F}" name="LCD">
<FILE id="LpeTfD" name="SidebarLCD.cpp" compile="1" resource="0" file="Source/Veno/GUI/Components/LCD/SidebarLCD.cpp"/> <FILE id="LpeTfD" name="SidebarLCD.cpp" compile="1" resource="0" file="Source/Veno/GUI/Components/LCD/SidebarLCD.cpp"/>