- 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

@ -5,7 +5,8 @@
#include "Veno/Fonts/Fonts.h"
VenoAudioProcessorEditor::VenoAudioProcessorEditor (VenoAudioProcessor& p)
: AudioProcessorEditor(&p), processor(p) {
: AudioProcessorEditor (&p), processor (p)
{
m_id = p.m_id;
Config::getInstance ()->registerEditor (this, m_id);
LookAndFeel::setDefaultLookAndFeel (m_look);
@ -14,20 +15,24 @@ VenoAudioProcessorEditor::VenoAudioProcessorEditor(VenoAudioProcessor &p)
addAndMakeVisible (*waveform);
}
VenoAudioProcessorEditor::~VenoAudioProcessorEditor() {
VenoAudioProcessorEditor::~VenoAudioProcessorEditor ()
{
LookAndFeel::setDefaultLookAndFeel (nullptr);
waveform.reset (nullptr);
delete m_look;
Config::getInstance ()->removeEditor (m_id);
}
void VenoAudioProcessorEditor::paint(Graphics &g) {
g.setFont(VenoFonts::getNormal());
void VenoAudioProcessorEditor::paint (Graphics& g)
{
g.setFont (*VenoFonts::getNormal ());
g.fillAll (Colour (0, 0, 0));
}
void VenoAudioProcessorEditor::resized() {
if (waveform != nullptr) {
void VenoAudioProcessorEditor::resized ()
{
if (waveform != nullptr)
{
waveform->setBounds (0, 0, getWidth (), getHeight ());
}
}

View file

@ -12,12 +12,10 @@ public:
~VenoAudioProcessorEditor ();
void paint (Graphics&) override;
void resized () override;
private:
VenoAudioProcessor& processor;
std::string m_id = "";
LookAndFeel_V4* m_look = new LookHandler ();
std::unique_ptr<SidebarLCD> waveform;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VenoAudioProcessorEditor)
};

View file

@ -15,19 +15,23 @@ VenoAudioProcessor::VenoAudioProcessor()
#endif*/
: AudioProcessor (BusesProperties ().withInput ("Input", AudioChannelSet::stereo (), true).withOutput ("Output",
AudioChannelSet::stereo (),
true)) {
true))
{
instance = VenoInstance::createInstance (m_id);
}
VenoAudioProcessor::~VenoAudioProcessor() {
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,41 +57,50 @@ 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) {
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;
@ -93,32 +108,35 @@ bool VenoAudioProcessor::isBusesLayoutSupported(const BusesLayout &layouts) cons
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->matrix.updateSlots ();
instance->audioBuffer->reset (buffer.getNumSamples ());
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) {
for (int j = 0; j < buffer.getNumSamples (); ++j)
{
instance->fft.pushNextSampleIntoFifo (c[j]);
instance->audioBuffer->addMonoSample (c[j], j);
if (i == 0) {
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);
}
}
@ -126,21 +144,26 @@ void VenoAudioProcessor::processBlock(AudioBuffer<float> &buffer, MidiBuffer &mi
}
//==============================================================================
bool VenoAudioProcessor::hasEditor() const {
bool VenoAudioProcessor::hasEditor () const
{
return true;
}
AudioProcessorEditor *VenoAudioProcessor::createEditor() {
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() {
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)) {
: m_processId (std::move (processId))
{
}

View file

@ -5,11 +5,11 @@
#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:
@ -17,6 +17,4 @@ public:
~SynthInstance () = default;
protected:
};
#endif //VENO_SYNTHINSTANCE_H

View file

@ -5,24 +5,29 @@
#include <cmath>
#include "VenoBuffer.h"
VenoBuffer::VenoBuffer() {
VenoBuffer::VenoBuffer ()
{
}
VenoBuffer::~VenoBuffer() {
VenoBuffer::~VenoBuffer ()
{
buffer.clear ();
right.clear ();
left.clear ();
}
void VenoBuffer::reset(int size) {
if (size != buffer.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) {
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) {
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,10 +5,10 @@
#ifndef VENO_VENOBUFFER_H
#define VENO_VENOBUFFER_H
#include <vector>
class VenoBuffer {
class VenoBuffer
{
private:
std::vector<float> buffer;
std::vector<float> right;
@ -20,18 +20,12 @@ public:
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;
};
#endif //VENO_VENOBUFFER_H

View file

@ -6,20 +6,23 @@
#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 idx;
auto* freqWaveRe = new double[tableLen];
auto* freqWaveIm = new double[tableLen];
for (idx = 0; idx < tableLen; idx++) {
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
}

View file

@ -4,8 +4,5 @@
#ifndef VENO_SAWWAVES_H
#define VENO_SAWWAVES_H
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
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,13 +72,15 @@ 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);
if (scale == 0.0) {
if (scale == 0.0)
{
// calc normal
double max = 0;
for (int idx = 0; idx < len; idx++) {
for (int idx = 0; idx < len; idx++)
{
double temp = fabs (ai[idx]);
if (max < temp)
max = temp;
@ -86,8 +92,8 @@ float makeWaveTable(WaveTableGroup *group, int len, double *ar, double *ai, doub
auto* wave = new float[len];
for (int idx = 0; idx < len; idx++)
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 ();
float* waveTable = group->m_WaveTables[group->m_numWaveTables]->m_waveTable = new float[len + 1];
table->m_waveTableLen = len;
@ -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;
double topFreq = 2.0 / 3.0 / maxHarmonic;
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];
@ -144,11 +151,13 @@ int fillTables(WaveTableGroup *group, double *freqWaveRe, double *freqWaveIm, in
return numTables;
}
float getNextRand() {
float getNextRand ()
{
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;
}

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)
@ -21,14 +20,9 @@
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);
// utils stuff
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,13 +6,16 @@
#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()) {
if (AudioConfig::getInstance ()->isNeedToReInit ())
{
cleanTables ();
AudioConfig::getInstance ()->setNeedToReInit (false);
}
if (m_isInit) {
if (m_isInit)
{
return;
}
m_waveTables[WaveForms::SAW] = new WaveTableGroup ();
@ -24,23 +27,27 @@ void WaveTableGenerator::init() {
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) {
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;
};
struct WaveTableGroup {
struct WaveTableGroup
{
static constexpr int numWaveTableSlots = 40;
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] = {};
public:
static WaveTableGenerator &getInstance() {
static WaveTableGenerator& getInstance ()
{
static WaveTableGenerator instance;
return instance;
}
WaveTableGroup* getGroup (int id);
void init ();
void cleanTables ();
protected:
bool m_isInit = false;
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> ();
return m_instance;
}
void AudioConfig::initWaveTables() {
void AudioConfig::initWaveTables ()
{
WaveTableGenerator::getInstance ().init ();
}
AudioConfig::~AudioConfig() {
AudioConfig::~AudioConfig ()
{
WaveTableGenerator::getInstance ().cleanTables ();
}

View file

@ -10,7 +10,8 @@
/**
* holds SampleRate and other needed sound information's :)
*/
class AudioConfig {
class AudioConfig
{
private:
static std::shared_ptr<AudioConfig> m_instance;
float m_sampleRate = 44100;
@ -18,25 +19,14 @@ private:
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 ();
protected:
};
#endif //VENO_AUDIOCONFIG_H

View file

@ -3,32 +3,38 @@
//
#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);
}
void Config::saveAll() {
if (m_config != nullptr) {
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";
@ -36,49 +42,61 @@ void Config::initConfig() {
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) {
void Config::setColourForIndex (Colour* colour, ThemeColour index)
{
if (m_theme)
{
m_theme->setColour (index, colour);
}
}
Config::~Config() {
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) {
void Config::removeEditor (const std::string& name)
{
m_editors.erase (name);
if (m_editors.empty()) {
if (m_editors.empty ())
{
VenoFonts::destroyAll ();
m_instance = nullptr;
}
}
//for LCD :P let's be a bit funny xD
int Config::getEditorCount() {
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> ();
return m_instance;
}
int Config::getFps() const {
int Config::getFps () const
{
return m_fps;
}

View file

@ -10,7 +10,8 @@
#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;
@ -20,32 +21,19 @@ private:
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 ();
// 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;
protected:
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,39 +4,48 @@
#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() {
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);
}
void BaseComponent::resized() {
if (m_enableLabel && m_label != nullptr) {
void BaseComponent::resized ()
{
if (m_enableLabel && m_label != nullptr)
{
LabelPosition position = m_label->getLabelPosition ();
if (position == LabelPosition::TOP) {
if (position == LabelPosition::TOP)
{
m_label->setBounds (0, 0, getWidth (), 15);
} else if (position == LabelPosition::BOTTOM) {
}
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) {
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,7 +13,8 @@
/**
* 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;
@ -29,6 +30,4 @@ public:
protected:
std::string m_processId;
};
#endif //VENO_BASECOMPONENT_H

View file

@ -7,16 +7,19 @@
#include "../../../Core/Config.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);
}
SidebarLCD::~SidebarLCD() {
SidebarLCD::~SidebarLCD ()
{
waveform.reset (nullptr);
}
void SidebarLCD::drawHeadline(Graphics &g) {
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,
@ -25,7 +28,8 @@ void SidebarLCD::drawHeadline(Graphics &g) {
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;
int space = m_innerY + fontSize;
int line = getHeight () - space;
@ -35,21 +39,24 @@ void SidebarLCD::drawFooter(Graphics &g) {
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) {
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);
g.fillAll (colour);
// background
auto accent = theme->getColour (ThemeColour::lcd);
g.setColour (accent);
g.setFont(VenoFonts::getLCD());
g.setFont (*VenoFonts::getLCD ());
drawHeadline (g);
drawFooter (g);
}

View file

@ -9,7 +9,8 @@
#include "../BaseComponent.h"
#include "Waveforms.h"
class SidebarLCD : public BaseComponent {
class SidebarLCD : public BaseComponent
{
private:
int m_innerX = 5;
int m_innerY = 5;
@ -17,16 +18,11 @@ private:
public:
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);
std::unique_ptr<Waveforms> waveform;
};
#endif //VENO_SIDEBARLCD_H

View file

@ -9,7 +9,8 @@
#include "../../../VenoInstance.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.setContinuousRepainting (false);
@ -25,26 +26,32 @@ Waveforms::Waveforms(const std::string &processId) : BaseComponent(processId) {
m_time_needed_startup = roundToInt (1000 / (1000 / fps));
}
Waveforms::~Waveforms() {
Waveforms::~Waveforms ()
{
stopTimer ();
shaderProgram.reset ();
m_context.detach ();
}
void Waveforms::newOpenGLContextCreated() {
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) {
if (theme == nullptr)
{
return;
}
glViewport (0, 0, getWidth (), getHeight ());
@ -55,10 +62,12 @@ void Waveforms::renderOpenGL() {
auto color = theme->getColour (ThemeColour::lcd);
shaderProgram->setUniform ("color", color.getFloatRed (), color.getFloatGreen (), color.getFloatBlue (),
color.getFloatAlpha ());
if (m_isWelcome || m_isStarting || m_isChangingData) {
if (m_isWelcome || m_isStarting || m_isChangingData)
{
return;
}
switch (m_mode) {
switch (m_mode)
{
case 1:
drawAudioOutput ();
break;
@ -73,66 +82,82 @@ void Waveforms::renderOpenGL() {
}
}
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()) {
&& 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) {
void Waveforms::timerCallback ()
{
if (m_isWelcome || m_isStarting || m_isChangingData || needToClear)
{
repaint ();
} else {
if (m_context.isAttached()) {
}
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);
float posX = -1;
float inc = 2.0f / buffer.size ();
for (float i : buffer) {
for (float i : buffer)
{
glVertex2f (posX, i);
posX += inc;
}
glEnd ();
}
void Waveforms::drawPeakMeter() {
void Waveforms::drawPeakMeter ()
{
auto theme = Config::getInstance ()->getCurrentTheme ();
if (theme == nullptr) {
if (theme == nullptr)
{
return;
}
auto instance = VenoInstance::getInstance (BaseComponent::m_processId);
@ -162,44 +187,56 @@ void Waveforms::drawPeakMeter() {
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);
g.setColour (accent);
g.setFont(VenoFonts::getLCD());
g.setFont (*VenoFonts::getLCD ());
VeNo::Utils::setFontSize (16.0f, g);
if (m_isWelcome) {
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) {
}
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) {
}
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 {
}
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);
@ -207,7 +244,8 @@ void Waveforms::drawChangedParameter(Graphics &g, int w, int h, int x, int y) co
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);
int halfHeight = h / 2;
g.drawText (m_readyText, x, y + halfHeight - font, w, font, Justification::centred, true);
@ -215,19 +253,24 @@ void Waveforms::drawWelcome(Graphics &g, int w, int h, int x, int y) {
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) {
if (theme == nullptr)
{
return;
}
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);
}
if (value > 0.9) {
if (value > 0.9)
{
color = theme->getColour (ThemeColour::clip);
}
shaderProgram->setUniform ("color", color.getFloatRed (), color.getFloatGreen (), color.getFloatBlue (),

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;
@ -29,45 +30,28 @@ protected:
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;
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);
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);
}
LabelComponent::~LabelComponent() {
LabelComponent::~LabelComponent ()
{
m_label.reset ();
}
void LabelComponent::resized() {
if (m_label != nullptr) {
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,18 +7,18 @@
#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 ();
@ -29,6 +29,4 @@ private:
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() {
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,7 +13,8 @@
/**
* 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;
@ -26,6 +27,4 @@ protected:
//currently both available themes are CrazyLook <-- (this is a fun one xD) and FlatLook
LookAndFeel_V4* m_feels[2] = {new FlatLook (), new CrazyLook ()};
};
#endif //VENO_LOOKHANDLER_H

View file

@ -5,22 +5,27 @@
#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() {
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 ());
@ -28,7 +33,8 @@ void Theme::setColour(ThemeColour index, Colour *colour) {
}
void Theme::init() {
void Theme::init ()
{
getColourFromConfig (ThemeColour::bg);
getColourFromConfig (ThemeColour::bg_two);
getColourFromConfig (ThemeColour::accent);
@ -39,28 +45,36 @@ void Theme::init() {
getColourFromConfig (ThemeColour::lcd);
}
void Theme::getColourFromConfig(ThemeColour index) {
void Theme::getColourFromConfig (ThemeColour index)
{
std::string key = ThemeColourToString (index);
if (m_configFile->containsKey(key)) {
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);
}
}
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);
}
void Theme::setColourThemeById(int id) {
switch (id) {
void Theme::setColourThemeById (int id)
{
switch (id)
{
case 1:
setLEDTheme (this);
break;

View file

@ -8,16 +8,16 @@
#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 ();
@ -27,6 +27,4 @@ protected:
std::map<ThemeColour, Colour*> m_colours;
std::shared_ptr<PropertiesFile> m_configFile;
};
#endif //VENO_THEME_H

View file

@ -9,7 +9,8 @@
* 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::accent, new Colour (169, 208, 142));
@ -20,7 +21,8 @@ void setLEDTheme(Theme *theme) {
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::accent, new Colour (180, 38, 50));
@ -31,7 +33,8 @@ void setBloodTheme(Theme *theme) {
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::accent, new Colour (255, 160, 0));
@ -42,7 +45,8 @@ void setOrangeDreamTheme(Theme *theme) {
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::accent, new Colour (0, 141, 213));
@ -53,9 +57,10 @@ void setOceanTheme(Theme *theme) {
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,7 +18,8 @@ int VeNo::Utils::nextPowerOfTwo(float value) {
return v;
}
float VeNo::Utils::setFontSize(float size, Graphics &g) {
float VeNo::Utils::setFontSize (float size, Graphics& g)
{
double scale = Config::getInstance ()->getScale ();
float s = size * scale;
g.setFont (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);
};
}
#endif //VENO_UTILS_H

View file

@ -4,7 +4,8 @@
#include "FFT.h"
void FFT::pushNextSampleIntoFifo(float sample) noexcept {
void FFT::pushNextSampleIntoFifo (float sample) noexcept
{
{
if (fifoIndex == fftSize) // [11]
{
@ -16,12 +17,12 @@ void FFT::pushNextSampleIntoFifo(float sample) noexcept {
}
fifoIndex = 0;
}
fifo[fifoIndex++] = sample; // [12]
}
}
void FFT::drawNextFrameOfSpectrum() {
void FFT::drawNextFrameOfSpectrum ()
{
window.multiplyWithWindowingTable (fftData, fftSize); // [1]
fft.performFrequencyOnlyForwardTransform (fftData); // [2]

View file

@ -7,7 +7,8 @@
#include "JuceHeader.h"
class FFT {
class FFT
{
private:
public:
FFT () = default;
@ -29,6 +30,4 @@ protected:
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);
};
}
#endif //VENO_LOGGER_H

View file

@ -3,24 +3,26 @@
//
#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) {
VenoInstance::VenoInstance (std::string id)
{
m_id = std::move (id);
m_synthInstance = std::make_shared<SynthInstance> (id);
audioBuffer = std::make_shared<VenoBuffer> ();
}
VenoInstance::~VenoInstance() {
VenoInstance::~VenoInstance ()
{
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));
VeNo::Logger::debugMessage ("Created VenoInstance with id: " + id);
@ -28,19 +30,24 @@ std::shared_ptr<VenoInstance> VenoInstance::createInstance(const std::string &id
}
// 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);
}
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()) {
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 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"/>