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

View File

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

View File

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

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 <utility>
SynthInstance::SynthInstance(std::string processId)
: m_processId(std::move(processId)) {
SynthInstance::SynthInstance (std::string processId)
: m_processId (std::move (processId))
{
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,42 +10,30 @@
#include "../GUI/Theme/Theme.h"
#include <memory>
class Config {
class Config
{
private:
std::shared_ptr<PropertiesFile> m_config = nullptr;
std::shared_ptr<Theme> m_theme = nullptr;
static std::shared_ptr<Config> m_instance;
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;
public:
static std::shared_ptr<Config> getInstance();
void saveAll();
int getCurrentLook();
void setColourForIndex(Colour *colour, ThemeColour index);
std::shared_ptr<Theme> getCurrentTheme();
double getScale();
static std::shared_ptr<Config> getInstance ();
void saveAll ();
int getCurrentLook ();
void setColourForIndex (Colour* colour, ThemeColour index);
std::shared_ptr<Theme> getCurrentTheme ();
double getScale ();
// can be public but doesnt need!
Config();
~Config();
void registerEditor(AudioProcessorEditor *editor, const std::string& name);
void removeEditor(const std::string& name);
int getEditorCount();
int getFps() const;
Config ();
~Config ();
void registerEditor (AudioProcessorEditor* editor, const std::string& name);
void removeEditor (const std::string& name);
int getEditorCount ();
int getFps () const;
protected:
void initConfig();
void initConfig ();
};
#endif //VENO_CONFIG_H

View File

@ -4,11 +4,8 @@
#ifndef VENO_PRESETMANAGER_H
#define VENO_PRESETMANAGER_H
class PresetManager {
class PresetManager
{
};
#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"
class VenoFonts {
class VenoFonts
{
protected:
static VenoFonts* instance;
Font* lcdFont;
Font* arvo;
public:
static const Font &getLCD() {
static Font lcd(Font(Typeface::createSystemTypefaceFor(BinaryData::lcd_ttf,
BinaryData::lcd_ttfSize)));
return lcd;
}
static const Font &getNormal() {
static Font arvo(Font(Typeface::createSystemTypefaceFor(BinaryData::arvo_ttf,
BinaryData::arvo_ttfSize)));
return arvo;
}
VenoFonts ();
~VenoFonts ();
static void destroyAll ();
static Font* getLCD ();
static Font* getNormal ();
static VenoFonts* getInstance ();
};
#endif //VENO_FONTS_H

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,20 +5,24 @@
#include "LookHandler.h"
#include "../../Core/Config.h"
LookHandler::LookHandler() {
selectLook(Config::getInstance()->getCurrentLook());
LookHandler::LookHandler ()
{
selectLook (Config::getInstance ()->getCurrentLook ());
}
LookHandler::~LookHandler() {
LookHandler::~LookHandler ()
{
//delete this shit!
delete m_feels[0];
delete m_feels[1];
}
void LookHandler::selectLook(int index) {
void LookHandler::selectLook (int index)
{
m_currentLook = index;
}
LookAndFeel_V4* LookHandler::getLook() {
LookAndFeel_V4* LookHandler::getLook ()
{
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 :)
*/
class LookHandler : public LookAndFeel_V4 {
class LookHandler : public LookAndFeel_V4
{
private:
std::shared_ptr<LookAndFeel_V4> m_look;
int m_currentLook = 0;
public:
LookHandler();
~LookHandler() override;
void selectLook(int index);
LookAndFeel_V4* getLook();
LookHandler ();
~LookHandler () override;
void selectLook (int index);
LookAndFeel_V4* getLook ();
protected:
//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

View File

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

View File

@ -8,25 +8,23 @@
#include "JuceHeader.h"
#include <vector>
enum class ThemeColour {
enum class ThemeColour
{
bg = 0, bg_two, accent, accent_two, warning, clip, lcd_bg, lcd
};
class Theme {
class Theme
{
private:
public:
explicit Theme(std::shared_ptr<PropertiesFile> file);
~Theme();
void setColour(ThemeColour index, Colour *colour);
void setColourThemeById(int id);
void init();
void getColourFromConfig(ThemeColour index);
Colour getColour(ThemeColour index);
explicit Theme (std::shared_ptr<PropertiesFile> file);
~Theme ();
void setColour (ThemeColour index, Colour* colour);
void setColourThemeById (int id);
void init ();
void getColourFromConfig (ThemeColour index);
Colour getColour (ThemeColour index);
protected:
std::map<ThemeColour, Colour*> m_colours;
std::shared_ptr<PropertiesFile> m_configFile;
};
#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
*/
void setLEDTheme(Theme *theme) {
theme->setColour(ThemeColour::bg, new Colour(41, 47, 54));
theme->setColour(ThemeColour::bg_two, new Colour(217, 217, 217));
theme->setColour(ThemeColour::accent, new Colour(169, 208, 142));
theme->setColour(ThemeColour::accent_two, new Colour(139, 171, 117));
theme->setColour(ThemeColour::clip, new Colour(255, 23, 68));
theme->setColour(ThemeColour::warning, new Colour(255, 143, 0));
theme->setColour(ThemeColour::lcd_bg, new Colour(21, 21, 21));
theme->setColour(ThemeColour::lcd, new Colour(169, 208, 142));
void setLEDTheme (Theme* theme)
{
theme->setColour (ThemeColour::bg, new Colour (41, 47, 54));
theme->setColour (ThemeColour::bg_two, new Colour (217, 217, 217));
theme->setColour (ThemeColour::accent, new Colour (169, 208, 142));
theme->setColour (ThemeColour::accent_two, new Colour (139, 171, 117));
theme->setColour (ThemeColour::clip, new Colour (255, 23, 68));
theme->setColour (ThemeColour::warning, new Colour (255, 143, 0));
theme->setColour (ThemeColour::lcd_bg, new Colour (21, 21, 21));
theme->setColour (ThemeColour::lcd, new Colour (169, 208, 142));
}
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::accent, new Colour(180, 38, 50));
theme->setColour(ThemeColour::accent_two, new Colour(115, 47, 64));
theme->setColour(ThemeColour::clip, new Colour(255, 23, 68));
theme->setColour(ThemeColour::warning, new Colour(255, 143, 0));
theme->setColour(ThemeColour::lcd_bg, new Colour(0, 0, 0));
theme->setColour(ThemeColour::lcd, new Colour(180, 38, 78));
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::accent, new Colour (180, 38, 50));
theme->setColour (ThemeColour::accent_two, new Colour (115, 47, 64));
theme->setColour (ThemeColour::clip, new Colour (255, 23, 68));
theme->setColour (ThemeColour::warning, new Colour (255, 143, 0));
theme->setColour (ThemeColour::lcd_bg, new Colour (0, 0, 0));
theme->setColour (ThemeColour::lcd, new Colour (180, 38, 78));
}
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::accent, new Colour(255, 160, 0));
theme->setColour(ThemeColour::accent_two, new Colour(255, 11, 0));
theme->setColour(ThemeColour::clip, new Colour(255, 23, 68));
theme->setColour(ThemeColour::warning, new Colour(255, 143, 0));
theme->setColour(ThemeColour::lcd_bg, new Colour(33, 33, 33));
theme->setColour(ThemeColour::lcd, new Colour(255, 160, 0));
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::accent, new Colour (255, 160, 0));
theme->setColour (ThemeColour::accent_two, new Colour (255, 11, 0));
theme->setColour (ThemeColour::clip, new Colour (255, 23, 68));
theme->setColour (ThemeColour::warning, new Colour (255, 143, 0));
theme->setColour (ThemeColour::lcd_bg, new Colour (33, 33, 33));
theme->setColour (ThemeColour::lcd, new Colour (255, 160, 0));
}
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::accent, new Colour(0, 141, 213));
theme->setColour(ThemeColour::accent_two, new Colour(0, 129, 194));
theme->setColour(ThemeColour::clip, new Colour(255, 23, 68));
theme->setColour(ThemeColour::warning, new Colour(255, 143, 0));
theme->setColour(ThemeColour::lcd_bg, new Colour(21, 21, 21));
theme->setColour(ThemeColour::lcd, new Colour(0, 129, 194));
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::accent, new Colour (0, 141, 213));
theme->setColour (ThemeColour::accent_two, new Colour (0, 129, 194));
theme->setColour (ThemeColour::clip, new Colour (255, 23, 68));
theme->setColour (ThemeColour::warning, new Colour (255, 143, 0));
theme->setColour (ThemeColour::lcd_bg, new Colour (21, 21, 21));
theme->setColour (ThemeColour::lcd, new Colour (0, 129, 194));
}
std::string ThemeColourToString(ThemeColour index) {
switch (index) {
std::string ThemeColourToString (ThemeColour index)
{
switch (index)
{
case ThemeColour::bg:
return "colour_bg";
case ThemeColour::bg_two:

View File

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

View File

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

View File

@ -4,32 +4,33 @@
#include "FFT.h"
void FFT::pushNextSampleIntoFifo(float sample) noexcept {
void FFT::pushNextSampleIntoFifo (float sample) noexcept
{
{
if (fifoIndex == fftSize) // [11]
{
if (!nextFFTBlockReady) // [12]
{
zeromem(fftData, sizeof(fftData));
memcpy(fftData, fifo, sizeof(fifo));
zeromem (fftData, sizeof (fftData));
memcpy (fftData, fifo, sizeof (fifo));
nextFFTBlockReady = true;
}
fifoIndex = 0;
}
fifo[fifoIndex++] = sample; // [12]
}
}
void FFT::drawNextFrameOfSpectrum() {
window.multiplyWithWindowingTable(fftData, fftSize); // [1]
fft.performFrequencyOnlyForwardTransform(fftData); // [2]
void FFT::drawNextFrameOfSpectrum ()
{
window.multiplyWithWindowingTable (fftData, fftSize); // [1]
fft.performFrequencyOnlyForwardTransform (fftData); // [2]
auto mindB = -80.0f;
auto maxdB = 0.0f;
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;
}
}

View File

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

View File

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

View File

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

View File

@ -3,46 +3,53 @@
//
#include "VenoInstance.h"
#include <utility>
#include "Utils/Logger.h"
std::unordered_map<std::string, std::shared_ptr<VenoInstance>> VenoInstance::instances;
VenoInstance::VenoInstance(std::string id) {
m_id = std::move(id);
m_synthInstance = std::make_shared<SynthInstance>(id);
audioBuffer = std::make_shared<VenoBuffer>();
VenoInstance::VenoInstance (std::string id)
{
m_id = std::move (id);
m_synthInstance = std::make_shared<SynthInstance> (id);
audioBuffer = std::make_shared<VenoBuffer> ();
}
VenoInstance::~VenoInstance() {
m_synthInstance.reset();
audioBuffer.reset();
VenoInstance::~VenoInstance ()
{
m_synthInstance.reset ();
audioBuffer.reset ();
}
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));
VeNo::Logger::debugMessage("Created VenoInstance with id: " + 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));
VeNo::Logger::debugMessage ("Created VenoInstance with id: " + id);
return instance;
}
// 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) {
if (instances.find(id) != instances.end()) {
std::shared_ptr<VenoInstance> VenoInstance::getInstance (const std::string& id)
{
if (instances.find (id) != instances.end ())
{
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;
}
void VenoInstance::deleteInstance(const std::string &processId) {
if (instances.find(processId) != instances.end()) {
instances[processId].reset();
instances.erase(processId);
VeNo::Logger::debugMessage("Removed VenoInstance with id: " + processId);
void VenoInstance::deleteInstance (const std::string& processId)
{
if (instances.find (processId) != instances.end ())
{
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 "Utils/FFT.h"
#include "Audio/VenoBuffer.h"
#include "Audio/Engine/VenoMatrix.h"
#include <unordered_map>
class VenoInstance {
class VenoInstance
{
private:
std::shared_ptr<SynthInstance> m_synthInstance;
static std::unordered_map<std::string, std::shared_ptr<VenoInstance>> instances;
std::string m_id;
public:
static std::shared_ptr<VenoInstance> createInstance(const std::string& id);
static std::shared_ptr<VenoInstance> getInstance(const std::string& id);
explicit VenoInstance(std::string id);
~VenoInstance();
const std::shared_ptr<SynthInstance> &getSynthInstance() const;
static void deleteInstance(const std::string& processId);
explicit VenoInstance (std::string id);
~VenoInstance ();
static std::shared_ptr<VenoInstance> createInstance (const std::string& id);
static std::shared_ptr<VenoInstance> getInstance (const std::string& id);
static void deleteInstance (const std::string& processId);
const std::shared_ptr<SynthInstance>& getSynthInstance () const;
FFT fft;
std::shared_ptr<VenoBuffer> audioBuffer;
VenoMatrix matrix{m_id}; //matrix need a own xml profile to save and restore!
};
#endif //VENO_VENOINSTANCE_H

View File

@ -19,6 +19,7 @@
</GROUP>
<GROUP id="{5791B3F9-67EA-BE3E-0208-47B8AF81F72F}" name="Veno">
<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"/>
</GROUP>
<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="jHgT3X" name="Utils.cpp" compile="1" resource="0" file="Source/Veno/Utils.cpp"/>
<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="ufeJaH" name="VenoBuffer.h" compile="0" resource="0" file="Source/Veno/Audio/VenoBuffer.h"/>
<GROUP id="{A8A2C90F-3822-64F1-4430-4E6163B67B9A}" name="Synth">
@ -64,6 +74,15 @@
<GROUP id="{A224AFA7-CD28-E0FE-3B5A-8203BFD9467B}" name="FX"/>
</GROUP>
<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="{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"/>