WIP
This commit is contained in:
parent
d735c1d076
commit
26a2935e1c
52 changed files with 1513 additions and 107 deletions
|
@ -1,26 +1,33 @@
|
|||
#include "PluginProcessor.h"
|
||||
#include "PluginEditor.h"
|
||||
#include "Veno/Core/Config.h"
|
||||
#include "Veno/Utils/Logger.h"
|
||||
#include "Veno/Fonts/Fonts.h"
|
||||
|
||||
VenoAudioProcessorEditor::VenoAudioProcessorEditor(VenoAudioProcessor &p)
|
||||
: AudioProcessorEditor(&p), processor(p) {
|
||||
m_id = p.m_id;
|
||||
Config::getInstance()->registerEditor(this, m_id);
|
||||
LookAndFeel::setDefaultLookAndFeel(m_look);
|
||||
setSize(400, 300);
|
||||
waveform = std::make_unique<SidebarLCD>(m_id);
|
||||
setSize(600, 400);
|
||||
addAndMakeVisible(*waveform);
|
||||
}
|
||||
|
||||
VenoAudioProcessorEditor::~VenoAudioProcessorEditor() {
|
||||
LookAndFeel::setDefaultLookAndFeel(nullptr);
|
||||
Config::getInstance()->removeEditor(m_id);
|
||||
waveform.reset(nullptr);
|
||||
delete m_look;
|
||||
Config::getInstance()->removeEditor(m_id);
|
||||
}
|
||||
|
||||
void VenoAudioProcessorEditor::paint(Graphics &g) {
|
||||
g.fillAll(getLookAndFeel().findColour(ResizableWindow::backgroundColourId));
|
||||
g.setColour(Colours::white);
|
||||
g.setFont(15.0f);
|
||||
g.setFont(VenoFonts::getNormal());
|
||||
g.fillAll(Colour(0, 0, 0));
|
||||
}
|
||||
|
||||
void VenoAudioProcessorEditor::resized() {
|
||||
if (waveform != nullptr) {
|
||||
waveform->setBounds(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <JuceHeader.h>
|
||||
#include "PluginProcessor.h"
|
||||
#include "Veno/GUI/LookAndFeel/LookHandler.h"
|
||||
#include "Veno/GUI/Components/LCD/SidebarLCD.h"
|
||||
|
||||
class VenoAudioProcessorEditor : public AudioProcessorEditor
|
||||
{
|
||||
|
@ -16,6 +17,7 @@ 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)
|
||||
};
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#include "PluginProcessor.h"
|
||||
#include "PluginEditor.h"
|
||||
#include "Veno/Core/AudioConfig.h"
|
||||
|
||||
VenoAudioProcessor::VenoAudioProcessor()
|
||||
#ifndef JucePlugin_PreferredChannelConfigurations
|
||||
/*#ifndef JucePlugin_PreferredChannelConfigurations
|
||||
: AudioProcessor (BusesProperties()
|
||||
#if ! JucePlugin_IsMidiEffect
|
||||
#if ! JucePlugin_IsSynth
|
||||
|
@ -10,138 +12,135 @@ VenoAudioProcessor::VenoAudioProcessor()
|
|||
.withOutput ("Output", AudioChannelSet::stereo(), true)
|
||||
#endif
|
||||
)
|
||||
#endif
|
||||
{
|
||||
#endif*/
|
||||
: AudioProcessor(BusesProperties().withInput("Input", AudioChannelSet::stereo(), true).withOutput("Output",
|
||||
AudioChannelSet::stereo(),
|
||||
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
|
||||
{
|
||||
#if JucePlugin_WantsMidiInput
|
||||
bool VenoAudioProcessor::acceptsMidi() const {
|
||||
#if JucePlugin_WantsMidiInput
|
||||
return true;
|
||||
#else
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
bool VenoAudioProcessor::producesMidi() const
|
||||
{
|
||||
#if JucePlugin_ProducesMidiOutput
|
||||
bool VenoAudioProcessor::producesMidi() const {
|
||||
#if JucePlugin_ProducesMidiOutput
|
||||
return true;
|
||||
#else
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
bool VenoAudioProcessor::isMidiEffect() const
|
||||
{
|
||||
#if JucePlugin_IsMidiEffect
|
||||
bool VenoAudioProcessor::isMidiEffect() const {
|
||||
#if JucePlugin_IsMidiEffect
|
||||
return true;
|
||||
#else
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
#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
|
||||
{
|
||||
#if JucePlugin_IsMidiEffect
|
||||
|
||||
bool VenoAudioProcessor::isBusesLayoutSupported(const BusesLayout &layouts) const {
|
||||
#if JucePlugin_IsMidiEffect
|
||||
ignoreUnused (layouts);
|
||||
return true;
|
||||
#else
|
||||
#else
|
||||
if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
|
||||
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
|
||||
&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
|
||||
return false;
|
||||
|
||||
#if ! JucePlugin_IsSynth
|
||||
#if !JucePlugin_IsSynth
|
||||
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void VenoAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
|
||||
{
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void VenoAudioProcessor::processBlock(AudioBuffer<float> &buffer, MidiBuffer &midiMessages) {
|
||||
ScopedNoDenormals noDenormals;
|
||||
auto totalNumInputChannels = getTotalNumInputChannels();
|
||||
auto totalNumOutputChannels = getTotalNumOutputChannels();
|
||||
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
|
||||
buffer.clear (i, 0, buffer.getNumSamples());
|
||||
for (int channel = 0; channel < totalNumInputChannels; ++channel)
|
||||
{
|
||||
auto* channelData = buffer.getWritePointer (channel);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
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()
|
||||
{
|
||||
AudioProcessor *JUCE_CALLTYPE createPluginFilter() {
|
||||
return new VenoAudioProcessor();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <JuceHeader.h>
|
||||
#include "Veno/VenoInstance.h"
|
||||
|
||||
class VenoAudioProcessor : public AudioProcessor {
|
||||
public:
|
||||
|
@ -51,6 +52,8 @@ public:
|
|||
|
||||
// Variable to communicate with the GUI and the Processor
|
||||
std::string m_id = Uuid().toString().toStdString();
|
||||
std::shared_ptr<VenoInstance> instance;
|
||||
|
||||
private:
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VenoAudioProcessor)
|
||||
};
|
||||
|
|
8
Source/Resources/GL/WaveForm.fragment.glsl
Normal file
8
Source/Resources/GL/WaveForm.fragment.glsl
Normal file
|
@ -0,0 +1,8 @@
|
|||
#version 330 core
|
||||
in vec4 newColor;
|
||||
|
||||
out vec4 fragColor;
|
||||
void main()
|
||||
{
|
||||
fragColor = newColor;
|
||||
}
|
10
Source/Resources/GL/WaveForm.vertex.glsl
Normal file
10
Source/Resources/GL/WaveForm.vertex.glsl
Normal file
|
@ -0,0 +1,10 @@
|
|||
#version 330 core
|
||||
in vec4 position;
|
||||
uniform vec4 color = vec4(1f, 1f, 1f, 1f);
|
||||
|
||||
out vec4 newColor;
|
||||
void main()
|
||||
{
|
||||
gl_Position = position;
|
||||
newColor = color;
|
||||
}
|
BIN
Source/Resources/arvo.ttf
Normal file
BIN
Source/Resources/arvo.ttf
Normal file
Binary file not shown.
BIN
Source/Resources/lcd.ttf
Normal file
BIN
Source/Resources/lcd.ttf
Normal file
Binary file not shown.
11
Source/Veno/Audio/Synth/SynthInstance.cpp
Normal file
11
Source/Veno/Audio/Synth/SynthInstance.cpp
Normal file
|
@ -0,0 +1,11 @@
|
|||
//
|
||||
// Created by versustune on 09.06.20.
|
||||
//
|
||||
|
||||
#include "SynthInstance.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
SynthInstance::SynthInstance(std::string processId)
|
||||
: m_processId(std::move(processId)) {
|
||||
}
|
22
Source/Veno/Audio/Synth/SynthInstance.h
Normal file
22
Source/Veno/Audio/Synth/SynthInstance.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// Created by versustune on 09.06.20.
|
||||
//
|
||||
|
||||
#ifndef VENO_SYNTHINSTANCE_H
|
||||
#define VENO_SYNTHINSTANCE_H
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
// class that hold all voices, oscillators and other stuff :)
|
||||
class SynthInstance {
|
||||
private:
|
||||
std::string m_processId;
|
||||
public:
|
||||
explicit SynthInstance(std::string processId);
|
||||
~SynthInstance() = default;
|
||||
protected:
|
||||
};
|
||||
|
||||
|
||||
#endif //VENO_SYNTHINSTANCE_H
|
74
Source/Veno/Audio/VenoBuffer.cpp
Normal file
74
Source/Veno/Audio/VenoBuffer.cpp
Normal file
|
@ -0,0 +1,74 @@
|
|||
//
|
||||
// Created by versustune on 12.06.20.
|
||||
//
|
||||
|
||||
#include <cmath>
|
||||
#include "VenoBuffer.h"
|
||||
|
||||
VenoBuffer::VenoBuffer() {
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
// reset to 0 dc :D
|
||||
for (int i = 0; i < size; ++i) {
|
||||
buffer[i] = 0;
|
||||
left[i] = 0;
|
||||
right[i] = 0;
|
||||
}
|
||||
leftPeak = 0;
|
||||
rightPeak = 0;
|
||||
monoPeak = 0;
|
||||
}
|
||||
|
||||
void VenoBuffer::addMonoSample(float value, int index) {
|
||||
buffer[index] = value;
|
||||
}
|
||||
|
||||
void VenoBuffer::addLeftSample(float value, int index) {
|
||||
left[index] = value;
|
||||
}
|
||||
|
||||
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) {
|
||||
monoPeak = m;
|
||||
}
|
||||
if (l > leftPeak) {
|
||||
leftPeak = l;
|
||||
}
|
||||
if (r > rightPeak) {
|
||||
rightPeak = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<float> &VenoBuffer::getBuffer() const {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
const std::vector<float> &VenoBuffer::getRight() const {
|
||||
return right;
|
||||
}
|
||||
|
||||
const std::vector<float> &VenoBuffer::getLeft() const {
|
||||
return left;
|
||||
}
|
37
Source/Veno/Audio/VenoBuffer.h
Normal file
37
Source/Veno/Audio/VenoBuffer.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
//
|
||||
// Created by versustune on 12.06.20.
|
||||
//
|
||||
|
||||
#ifndef VENO_VENOBUFFER_H
|
||||
#define VENO_VENOBUFFER_H
|
||||
|
||||
|
||||
#include <vector>
|
||||
|
||||
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();
|
||||
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
|
28
Source/Veno/Audio/WaveTable/SawWaves.cpp
Normal file
28
Source/Veno/Audio/WaveTable/SawWaves.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
//
|
||||
// Created by versustune on 08.06.20.
|
||||
//
|
||||
|
||||
#include "WaveTableGenerator.h"
|
||||
#include "../../Utils/Logger.h"
|
||||
#include "TableHelper.h"
|
||||
|
||||
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++) {
|
||||
freqWaveIm[idx] = 0.0;
|
||||
}
|
||||
freqWaveRe[0] = freqWaveRe[tableLen >> 1] = 0.0;
|
||||
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");
|
||||
}
|
11
Source/Veno/Audio/WaveTable/SawWaves.h
Normal file
11
Source/Veno/Audio/WaveTable/SawWaves.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
//
|
||||
// Created by versustune on 08.06.20.
|
||||
//
|
||||
|
||||
#ifndef VENO_SAWWAVES_H
|
||||
#define VENO_SAWWAVES_H
|
||||
|
||||
void generateSaw(WaveTableGroup *group);
|
||||
|
||||
|
||||
#endif //VENO_SAWWAVES_H
|
5
Source/Veno/Audio/WaveTable/SineWaves.cpp
Normal file
5
Source/Veno/Audio/WaveTable/SineWaves.cpp
Normal file
|
@ -0,0 +1,5 @@
|
|||
//
|
||||
// Created by versustune on 08.06.20.
|
||||
//
|
||||
|
||||
#include "SineWaves.h"
|
14
Source/Veno/Audio/WaveTable/SineWaves.h
Normal file
14
Source/Veno/Audio/WaveTable/SineWaves.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Created by versustune on 08.06.20.
|
||||
//
|
||||
|
||||
#ifndef VENO_SINEWAVES_H
|
||||
#define VENO_SINEWAVES_H
|
||||
|
||||
|
||||
class SineWaves {
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //VENO_SINEWAVES_H
|
5
Source/Veno/Audio/WaveTable/SquareWaves.cpp
Normal file
5
Source/Veno/Audio/WaveTable/SquareWaves.cpp
Normal file
|
@ -0,0 +1,5 @@
|
|||
//
|
||||
// Created by versustune on 08.06.20.
|
||||
//
|
||||
|
||||
#include "SquareWaves.h"
|
14
Source/Veno/Audio/WaveTable/SquareWaves.h
Normal file
14
Source/Veno/Audio/WaveTable/SquareWaves.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Created by versustune on 08.06.20.
|
||||
//
|
||||
|
||||
#ifndef VENO_SQUAREWAVES_H
|
||||
#define VENO_SQUAREWAVES_H
|
||||
|
||||
|
||||
class SquareWaves {
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //VENO_SQUAREWAVES_H
|
154
Source/Veno/Audio/WaveTable/TableHelper.cpp
Normal file
154
Source/Veno/Audio/WaveTable/TableHelper.cpp
Normal file
|
@ -0,0 +1,154 @@
|
|||
//
|
||||
// Created by versustune on 08.06.20.
|
||||
//
|
||||
|
||||
#include "TableHelper.h"
|
||||
#include "../../Core/AudioConfig.h"
|
||||
#include "../../Utils.h"
|
||||
|
||||
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;
|
||||
double t; /* temp */
|
||||
double Ur, Ui, Wr, Wi, Tr, Ti;
|
||||
double Ur_old;
|
||||
|
||||
// if ((N > 1) && !(N & (N - 1))) // make sure we have a power of 2
|
||||
|
||||
NV2 = N >> 1;
|
||||
NM1 = N - 1;
|
||||
TEMP = N; /* get M = log N */
|
||||
M = 0;
|
||||
while (TEMP >>= 1) ++M;
|
||||
|
||||
/* shuffle */
|
||||
j = 1;
|
||||
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;
|
||||
t = ai[j - 1];
|
||||
ai[j - 1] = ai[i - 1];
|
||||
ai[i - 1] = t;
|
||||
}
|
||||
|
||||
k = NV2; /* bit-reversed counter */
|
||||
while (k < j) {
|
||||
j -= k;
|
||||
k /= 2;
|
||||
}
|
||||
|
||||
j += k;
|
||||
}
|
||||
|
||||
LE = 1.;
|
||||
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
|
||||
ip = i + LE1;
|
||||
Tr = ar[ip - 1] * Ur - ai[ip - 1] * Ui;
|
||||
Ti = ar[ip - 1] * Ui + ai[ip - 1] * Ur;
|
||||
ar[ip - 1] = ar[i - 1] - Tr;
|
||||
ai[ip - 1] = ai[i - 1] - Ti;
|
||||
ar[i - 1] = ar[i - 1] + Tr;
|
||||
ai[i - 1] = ai[i - 1] + Ti;
|
||||
}
|
||||
Ur_old = Ur;
|
||||
Ur = Ur_old * Wr - Ui * Wi;
|
||||
Ui = Ur_old * Wi + Ui * Wr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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]);
|
||||
if (max < temp)
|
||||
max = temp;
|
||||
}
|
||||
scale = 1.0 / max * .999;
|
||||
}
|
||||
|
||||
// normalize
|
||||
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];
|
||||
table->m_waveTableLen = len;
|
||||
table->m_topFreq = topFreq;
|
||||
++group->m_numWaveTables;
|
||||
|
||||
// fill in wave
|
||||
for (long idx = 0; idx < len; idx++)
|
||||
waveTable[idx] = wave[idx];
|
||||
waveTable[len] = waveTable[0]; // duplicate for interpolation wraparound
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
scale = 0.0;
|
||||
}
|
||||
return (float) scale;
|
||||
}
|
||||
|
||||
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) {
|
||||
// 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++) {
|
||||
ar[idx] = freqWaveRe[idx];
|
||||
ai[idx] = freqWaveIm[idx];
|
||||
ar[numSamples - idx] = freqWaveRe[numSamples - idx];
|
||||
ai[numSamples - idx] = freqWaveIm[numSamples - idx];
|
||||
}
|
||||
|
||||
// make the wavetable
|
||||
scale = makeWaveTable(group, numSamples, ar, ai, scale, topFreq);
|
||||
numTables++;
|
||||
|
||||
// prepare for next table
|
||||
topFreq *= 2;
|
||||
maxHarmonic >>= 1;
|
||||
}
|
||||
return numTables;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
34
Source/Veno/Audio/WaveTable/TableHelper.h
Normal file
34
Source/Veno/Audio/WaveTable/TableHelper.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// Created by versustune on 08.06.20.
|
||||
//
|
||||
|
||||
#ifndef VENO_TABLEHELPER_H
|
||||
#define VENO_TABLEHELPER_H
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include "WaveTableGenerator.h"
|
||||
|
||||
#define M_PI 3.14159265358979323846
|
||||
#define DOUBLE_PI 6.283185307179586476925286766559
|
||||
|
||||
/*
|
||||
in-place complex fft
|
||||
After Cooley, Lewis, and Welch; from Rabiner & Gold (1975)
|
||||
program adapted from FORTRAN
|
||||
by K. Steiglitz (ken@princeton.edu)
|
||||
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);
|
||||
|
||||
// utils stuff
|
||||
int fillTables(WaveTableGroup *group, double *freqWaveRe, double *freqWaveIm, int numSamples);
|
||||
|
||||
int findTableLen();
|
||||
|
||||
float getNextRand();
|
||||
|
||||
#endif //VENO_TABLEHELPER_H
|
5
Source/Veno/Audio/WaveTable/TriangleWaves.cpp
Normal file
5
Source/Veno/Audio/WaveTable/TriangleWaves.cpp
Normal file
|
@ -0,0 +1,5 @@
|
|||
//
|
||||
// Created by versustune on 08.06.20.
|
||||
//
|
||||
|
||||
#include "TriangleWaves.h"
|
14
Source/Veno/Audio/WaveTable/TriangleWaves.h
Normal file
14
Source/Veno/Audio/WaveTable/TriangleWaves.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Created by versustune on 08.06.20.
|
||||
//
|
||||
|
||||
#ifndef VENO_TRIANGLEWAVES_H
|
||||
#define VENO_TRIANGLEWAVES_H
|
||||
|
||||
|
||||
class TriangleWaves {
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //VENO_TRIANGLEWAVES_H
|
5
Source/Veno/Audio/WaveTable/VeNoXWaves.cpp
Normal file
5
Source/Veno/Audio/WaveTable/VeNoXWaves.cpp
Normal file
|
@ -0,0 +1,5 @@
|
|||
//
|
||||
// Created by versustune on 08.06.20.
|
||||
//
|
||||
|
||||
#include "VeNoXWaves.h"
|
14
Source/Veno/Audio/WaveTable/VeNoXWaves.h
Normal file
14
Source/Veno/Audio/WaveTable/VeNoXWaves.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Created by versustune on 08.06.20.
|
||||
//
|
||||
|
||||
#ifndef VENO_VENOXWAVES_H
|
||||
#define VENO_VENOXWAVES_H
|
||||
|
||||
|
||||
class VeNoXWaves {
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //VENO_VENOXWAVES_H
|
47
Source/Veno/Audio/WaveTable/WaveTableGenerator.cpp
Normal file
47
Source/Veno/Audio/WaveTable/WaveTableGenerator.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// Created by versustune on 08.06.20.
|
||||
//
|
||||
|
||||
#include "WaveTableGenerator.h"
|
||||
#include "../../Core/AudioConfig.h"
|
||||
#include "WavesInlcuder.h"
|
||||
|
||||
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 (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_isInit = true;
|
||||
}
|
||||
|
||||
WaveTableGroup *WaveTableGenerator::getGroup(int id) {
|
||||
if (!m_isInit) {
|
||||
init();
|
||||
}
|
||||
if (id < 40) {
|
||||
return m_waveTables[id];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WaveTableGenerator::cleanTables() {
|
||||
for (auto & m_waveTable : m_waveTables) {
|
||||
delete m_waveTable;
|
||||
}
|
||||
m_isInit = false;
|
||||
}
|
53
Source/Veno/Audio/WaveTable/WaveTableGenerator.h
Normal file
53
Source/Veno/Audio/WaveTable/WaveTableGenerator.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
//
|
||||
// Created by versustune on 08.06.20.
|
||||
//
|
||||
|
||||
#ifndef VENO_WAVETABLEGENERATOR_H
|
||||
#define VENO_WAVETABLEGENERATOR_H
|
||||
|
||||
struct WaveTableObject {
|
||||
double m_topFreq;
|
||||
int m_waveTableLen;
|
||||
float *m_waveTable;
|
||||
};
|
||||
|
||||
struct WaveTableGroup {
|
||||
static constexpr int numWaveTableSlots = 40;
|
||||
WaveTableObject *m_WaveTables[numWaveTableSlots] = {};
|
||||
int m_numWaveTables = 0;
|
||||
};
|
||||
|
||||
enum WaveForms {
|
||||
SAW = 0,
|
||||
SINE,
|
||||
SQUARE,
|
||||
TRIANGLE,
|
||||
wSaw,
|
||||
wSQUARE, //that stuff is to dirty xD,
|
||||
SYNTHONE,
|
||||
SYNTHTWO,
|
||||
VENOX
|
||||
};
|
||||
|
||||
class WaveTableGenerator {
|
||||
private:
|
||||
static constexpr int numWaveTableSlots = 40;
|
||||
WaveTableGroup *m_waveTables[numWaveTableSlots] = {};
|
||||
public:
|
||||
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
|
6
Source/Veno/Audio/WaveTable/WavesInlcuder.h
Normal file
6
Source/Veno/Audio/WaveTable/WavesInlcuder.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#include "TableHelper.h"
|
||||
#include "SawWaves.h"
|
||||
#include "SineWaves.h"
|
||||
#include "SquareWaves.h"
|
||||
#include "TriangleWaves.h"
|
||||
#include "VeNoXWaves.h"
|
|
@ -2,7 +2,9 @@
|
|||
// Created by versustune on 22.03.20.
|
||||
//
|
||||
#include "AudioConfig.h"
|
||||
#include "../Audio/WaveTable/WaveTableGenerator.h"
|
||||
|
||||
std::shared_ptr<AudioConfig> AudioConfig::m_instance;
|
||||
float AudioConfig::getSampleRate() {
|
||||
return m_sampleRate;
|
||||
}
|
||||
|
@ -22,7 +24,7 @@ void AudioConfig::setBufferSize(float _bufferSize) {
|
|||
m_bufferSize = _bufferSize;
|
||||
}
|
||||
|
||||
bool AudioConfig::isNeedToReInit() {
|
||||
bool AudioConfig::isNeedToReInit() const {
|
||||
return m_needToReInit;
|
||||
}
|
||||
|
||||
|
@ -31,7 +33,15 @@ void AudioConfig::setNeedToReInit(bool _needToReInit) {
|
|||
}
|
||||
|
||||
std::shared_ptr<AudioConfig> AudioConfig::getInstance() {
|
||||
if (!m_instance)
|
||||
m_instance = std::make_shared<AudioConfig>();
|
||||
if (AudioConfig::m_instance == nullptr)
|
||||
AudioConfig::m_instance = std::make_shared<AudioConfig>();
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
void AudioConfig::initWaveTables() {
|
||||
WaveTableGenerator::getInstance().init();
|
||||
}
|
||||
|
||||
AudioConfig::~AudioConfig() {
|
||||
WaveTableGenerator::getInstance().cleanTables();
|
||||
}
|
||||
|
|
|
@ -27,10 +27,14 @@ public:
|
|||
|
||||
void setBufferSize(float _bufferSize);
|
||||
|
||||
bool isNeedToReInit();
|
||||
bool isNeedToReInit() const;
|
||||
|
||||
void setNeedToReInit(bool _needToReInit);
|
||||
|
||||
static void initWaveTables();
|
||||
|
||||
~AudioConfig();
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ Config::Config() {
|
|||
|
||||
m_theme = std::make_shared<Theme>(m_config);
|
||||
m_theme->init();
|
||||
m_fps = m_config->getIntValue("waveform_fps", 60);
|
||||
}
|
||||
|
||||
void Config::saveAll() {
|
||||
|
@ -29,7 +30,7 @@ int Config::getCurrentLook() {
|
|||
|
||||
void Config::initConfig() {
|
||||
PropertiesFile::Options options;
|
||||
options.applicationName = "m_config";
|
||||
options.applicationName = "config";
|
||||
options.folderName = "veno";
|
||||
options.filenameSuffix = "xml";
|
||||
m_config = std::make_unique<PropertiesFile>(options);
|
||||
|
@ -40,7 +41,7 @@ std::shared_ptr<Theme> Config::getCurrentTheme() {
|
|||
}
|
||||
|
||||
double Config::getScale() {
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Config::setColourForIndex(Colour *colour, ThemeColour index) {
|
||||
|
@ -73,7 +74,11 @@ int Config::getEditorCount() {
|
|||
}
|
||||
|
||||
std::shared_ptr<Config> Config::getInstance() {
|
||||
if (!m_instance)
|
||||
if (m_instance == nullptr)
|
||||
m_instance = std::make_shared<Config>();
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
int Config::getFps() const {
|
||||
return m_fps;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ private:
|
|||
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;
|
||||
int m_fps = 60;
|
||||
public:
|
||||
static std::shared_ptr<Config> getInstance();
|
||||
|
||||
|
@ -41,6 +42,8 @@ public:
|
|||
|
||||
int getEditorCount();
|
||||
|
||||
int getFps() const;
|
||||
|
||||
protected:
|
||||
void initConfig();
|
||||
};
|
||||
|
|
5
Source/Veno/Core/PresetManager.cpp
Normal file
5
Source/Veno/Core/PresetManager.cpp
Normal file
|
@ -0,0 +1,5 @@
|
|||
//
|
||||
// Created by versustune on 11.06.20.
|
||||
//
|
||||
|
||||
#include "PresetManager.h"
|
14
Source/Veno/Core/PresetManager.h
Normal file
14
Source/Veno/Core/PresetManager.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Created by versustune on 11.06.20.
|
||||
//
|
||||
|
||||
#ifndef VENO_PRESETMANAGER_H
|
||||
#define VENO_PRESETMANAGER_H
|
||||
|
||||
|
||||
class PresetManager {
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //VENO_PRESETMANAGER_H
|
25
Source/Veno/Fonts/Fonts.h
Normal file
25
Source/Veno/Fonts/Fonts.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
// Created by versustune on 19.01.20.
|
||||
//
|
||||
|
||||
#ifndef VENO_FONTS_H
|
||||
#define VENO_FONTS_H
|
||||
|
||||
#include "JuceHeader.h"
|
||||
|
||||
class VenoFonts {
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //VENO_FONTS_H
|
|
@ -3,13 +3,16 @@
|
|||
//
|
||||
|
||||
#include "BaseComponent.h"
|
||||
#include "../../Fonts/Fonts.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
BaseComponent::BaseComponent(const std::string& processId) {
|
||||
m_processId = processId;
|
||||
}
|
||||
|
||||
BaseComponent::~BaseComponent() {
|
||||
m_label.reset();
|
||||
setLookAndFeel(nullptr);
|
||||
m_lookHandler.reset();
|
||||
}
|
||||
|
||||
void BaseComponent::addLabel(const std::string &label_text, LabelPosition labelPosition) {
|
||||
|
@ -30,11 +33,7 @@ void BaseComponent::resized() {
|
|||
}
|
||||
|
||||
void BaseComponent::paint(Graphics &g) {
|
||||
}
|
||||
|
||||
BaseComponent::BaseComponent() {
|
||||
m_lookHandler = std::make_shared<LookHandler>();
|
||||
setLookAndFeel(m_lookHandler->getLook());
|
||||
g.setFont(VenoFonts::getNormal());
|
||||
}
|
||||
|
||||
void BaseComponent::setParameter(std::string name, std::string group) {
|
||||
|
|
|
@ -19,15 +19,15 @@ private:
|
|||
std::string m_name;
|
||||
bool m_enableLabel = false;
|
||||
std::shared_ptr<LabelComponent> m_label;
|
||||
std::shared_ptr<LookHandler> m_lookHandler;
|
||||
public:
|
||||
BaseComponent();
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
|
|
55
Source/Veno/GUI/Components/LCD/SidebarLCD.cpp
Normal file
55
Source/Veno/GUI/Components/LCD/SidebarLCD.cpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
//
|
||||
// Created by versustune on 11.06.20.
|
||||
//
|
||||
|
||||
#include "SidebarLCD.h"
|
||||
#include "../../../Utils.h"
|
||||
#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() {
|
||||
waveform.reset(nullptr);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
// background
|
||||
auto accent = theme->getColour(ThemeColour::lcd);
|
||||
g.setColour(accent);
|
||||
g.setFont(VenoFonts::getLCD());
|
||||
drawHeadline(g);
|
||||
drawFooter(g);
|
||||
}
|
32
Source/Veno/GUI/Components/LCD/SidebarLCD.h
Normal file
32
Source/Veno/GUI/Components/LCD/SidebarLCD.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// Created by versustune on 11.06.20.
|
||||
//
|
||||
|
||||
#ifndef VENO_SIDEBARLCD_H
|
||||
#define VENO_SIDEBARLCD_H
|
||||
|
||||
#include "JuceHeader.h"
|
||||
#include "../BaseComponent.h"
|
||||
#include "Waveforms.h"
|
||||
|
||||
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;
|
||||
|
||||
protected:
|
||||
void drawHeadline(Graphics &g);
|
||||
void drawFooter(Graphics &g);
|
||||
|
||||
std::unique_ptr<Waveforms> waveform;
|
||||
};
|
||||
|
||||
|
||||
#endif //VENO_SIDEBARLCD_H
|
235
Source/Veno/GUI/Components/LCD/Waveforms.cpp
Normal file
235
Source/Veno/GUI/Components/LCD/Waveforms.cpp
Normal file
|
@ -0,0 +1,235 @@
|
|||
//
|
||||
// Created by versustune on 11.06.20.
|
||||
//
|
||||
|
||||
#include "Waveforms.h"
|
||||
#include <utility>
|
||||
#include "../../../Core/Config.h"
|
||||
#include "../../../Utils.h"
|
||||
#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);
|
||||
m_ticks = 0;
|
||||
// is something that
|
||||
m_time_needed = roundToInt(4000 / (1000 / fps));
|
||||
m_time_needed_startup = roundToInt(1000 / (1000 / fps));
|
||||
}
|
||||
|
||||
Waveforms::~Waveforms() {
|
||||
stopTimer();
|
||||
shaderProgram.reset();
|
||||
m_context.detach();
|
||||
}
|
||||
|
||||
void Waveforms::newOpenGLContextCreated() {
|
||||
compileOpenGLShaderProgram();
|
||||
}
|
||||
|
||||
void Waveforms::openGLContextClosing() {
|
||||
|
||||
}
|
||||
|
||||
void Waveforms::renderOpenGL() {
|
||||
if (!isShowing() || shaderProgram == nullptr || !shaderProgram->getLastError().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
switch (m_mode) {
|
||||
case 1:
|
||||
drawAudioOutput();
|
||||
break;
|
||||
case 2:
|
||||
drawWaveTable();
|
||||
break;
|
||||
case 3:
|
||||
drawSpectrum();
|
||||
break;
|
||||
default:
|
||||
drawPeakMeter();
|
||||
}
|
||||
}
|
||||
|
||||
void Waveforms::handleAsyncUpdate() {
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void Waveforms::mouseDown(const MouseEvent &e) {
|
||||
if (!m_enableModeToggle) {
|
||||
return;
|
||||
}
|
||||
m_mode++;
|
||||
if (m_mode > 3) {
|
||||
m_mode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
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::drawWaveTable() {
|
||||
// this will draw the current selected oscillator :D
|
||||
}
|
||||
|
||||
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) {
|
||||
glVertex2f(posX, i);
|
||||
posX += inc;
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void Waveforms::drawPeakMeter() {
|
||||
auto theme = Config::getInstance()->getCurrentTheme();
|
||||
if (theme == nullptr) {
|
||||
return;
|
||||
}
|
||||
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,
|
||||
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);
|
||||
m_ticks++;
|
||||
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);
|
||||
m_ticks++;
|
||||
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);
|
||||
m_ticks++;
|
||||
if (m_ticks > m_time_needed) {
|
||||
m_isChangingData = false;
|
||||
m_ticks = 0;
|
||||
needToClear = true;
|
||||
}
|
||||
} else {
|
||||
g.resetToDefaultState();
|
||||
needToClear = false;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void Waveforms::drawSpectrum() {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
if (value > 0.9) {
|
||||
color = theme->getColour(ThemeColour::clip);
|
||||
}
|
||||
shaderProgram->setUniform("color", color.getFloatRed(), color.getFloatGreen(), color.getFloatBlue(),
|
||||
color.getFloatAlpha());
|
||||
}
|
73
Source/Veno/GUI/Components/LCD/Waveforms.h
Normal file
73
Source/Veno/GUI/Components/LCD/Waveforms.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
//
|
||||
// Created by versustune on 11.06.20.
|
||||
//
|
||||
|
||||
#ifndef VENO_WAVEFORMS_H
|
||||
#define VENO_WAVEFORMS_H
|
||||
|
||||
#include "JuceHeader.h"
|
||||
#include "../BaseComponent.h"
|
||||
|
||||
#define RANDOM_TEXT_COUNT 5
|
||||
|
||||
// opengl context :D
|
||||
class Waveforms : public BaseComponent,
|
||||
private OpenGLRenderer,
|
||||
private AsyncUpdater,
|
||||
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"};
|
||||
int pickRandomText = 0;
|
||||
bool m_isWelcome = true;
|
||||
bool m_isStarting = true;
|
||||
int m_ticks = 0;
|
||||
int m_time_needed_startup = 0;
|
||||
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;
|
||||
|
||||
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
|
|
@ -29,7 +29,6 @@ void Theme::setColour(ThemeColour index, Colour *colour) {
|
|||
}
|
||||
|
||||
void Theme::init() {
|
||||
setLEDTheme(this);
|
||||
getColourFromConfig(ThemeColour::bg);
|
||||
getColourFromConfig(ThemeColour::bg_two);
|
||||
getColourFromConfig(ThemeColour::accent);
|
||||
|
@ -45,6 +44,35 @@ void Theme::getColourFromConfig(ThemeColour index) {
|
|||
if (m_configFile->containsKey(key)) {
|
||||
auto baseColour = Colour::fromString(m_configFile->getValue(key));
|
||||
auto *colour = new Colour(baseColour.getRed(), baseColour.getGreen(), baseColour.getBlue());
|
||||
setColour(index, colour);
|
||||
delete m_colours[index];
|
||||
m_colours[index] = colour;
|
||||
} else {
|
||||
// should only trigger if config is broken or empty :)
|
||||
setLEDTheme(this);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
case 1:
|
||||
setLEDTheme(this);
|
||||
break;
|
||||
case 2:
|
||||
setOrangeDreamTheme(this);
|
||||
break;
|
||||
case 3:
|
||||
setBloodTheme(this);
|
||||
break;
|
||||
case 4:
|
||||
setOceanTheme(this);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,12 +15,14 @@ enum class ThemeColour {
|
|||
class Theme {
|
||||
private:
|
||||
public:
|
||||
Theme(std::shared_ptr<PropertiesFile> file);
|
||||
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;
|
||||
|
|
|
@ -20,18 +20,59 @@ void setLEDTheme(Theme *theme) {
|
|||
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 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));
|
||||
}
|
||||
|
||||
|
||||
std::string ThemeColourToString(ThemeColour index) {
|
||||
switch (index)
|
||||
{
|
||||
case ThemeColour::bg: return "colour_bg";
|
||||
case ThemeColour::bg_two: return "colour_bg_two";
|
||||
case ThemeColour::accent: return "colour_accent";
|
||||
case ThemeColour::accent_two: return "colour_accent_two";
|
||||
case ThemeColour::clip: return "colour_clip";
|
||||
case ThemeColour::warning: return "colour_warning";
|
||||
case ThemeColour::lcd_bg: return "colour_lcd_bg";
|
||||
case ThemeColour::lcd: return "colour_lcd";
|
||||
default: return "";
|
||||
switch (index) {
|
||||
case ThemeColour::bg:
|
||||
return "colour_bg";
|
||||
case ThemeColour::bg_two:
|
||||
return "colour_bg_two";
|
||||
case ThemeColour::accent:
|
||||
return "colour_accent";
|
||||
case ThemeColour::accent_two:
|
||||
return "colour_accent_two";
|
||||
case ThemeColour::clip:
|
||||
return "colour_clip";
|
||||
case ThemeColour::warning:
|
||||
return "colour_warning";
|
||||
case ThemeColour::lcd_bg:
|
||||
return "colour_lcd_bg";
|
||||
case ThemeColour::lcd:
|
||||
return "colour_lcd";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
25
Source/Veno/Utils.cpp
Normal file
25
Source/Veno/Utils.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
// Created by versustune on 08.06.20.
|
||||
//
|
||||
|
||||
#include "Utils.h"
|
||||
#include "Core/Config.h"
|
||||
|
||||
int VeNo::Utils::nextPowerOfTwo(float value) {
|
||||
unsigned int v = value;
|
||||
v--;
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
v |= v >> 4;
|
||||
v |= v >> 8;
|
||||
v |= v >> 16;
|
||||
v++;
|
||||
return v;
|
||||
}
|
||||
|
||||
float VeNo::Utils::setFontSize(float size, Graphics &g) {
|
||||
double scale = Config::getInstance()->getScale();
|
||||
float s = size * scale;
|
||||
g.setFont(s);
|
||||
return s;
|
||||
}
|
22
Source/Veno/Utils.h
Normal file
22
Source/Veno/Utils.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// Created by versustune on 08.06.20.
|
||||
//
|
||||
|
||||
#ifndef VENO_UTILS_H
|
||||
#define VENO_UTILS_H
|
||||
|
||||
#include "JuceHeader.h"
|
||||
|
||||
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
|
35
Source/Veno/Utils/FFT.cpp
Normal file
35
Source/Veno/Utils/FFT.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
//
|
||||
// Created by versustune on 12.06.20.
|
||||
//
|
||||
|
||||
#include "FFT.h"
|
||||
|
||||
void FFT::pushNextSampleIntoFifo(float sample) noexcept {
|
||||
{
|
||||
if (fifoIndex == fftSize) // [11]
|
||||
{
|
||||
if (!nextFFTBlockReady) // [12]
|
||||
{
|
||||
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]
|
||||
|
||||
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);
|
||||
scopeData[i] = level;
|
||||
}
|
||||
}
|
34
Source/Veno/Utils/FFT.h
Normal file
34
Source/Veno/Utils/FFT.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// Created by versustune on 12.06.20.
|
||||
//
|
||||
|
||||
#ifndef VENO_FFT_H
|
||||
#define VENO_FFT_H
|
||||
|
||||
#include "JuceHeader.h"
|
||||
|
||||
class FFT {
|
||||
private:
|
||||
public:
|
||||
FFT() = default;
|
||||
~FFT() = default;
|
||||
void pushNextSampleIntoFifo (float sample) noexcept;
|
||||
enum
|
||||
{
|
||||
fftOrder = 11, // [1]
|
||||
fftSize = 1 << fftOrder, // [2]
|
||||
scopeSize = 512 // [3]
|
||||
};
|
||||
void drawNextFrameOfSpectrum();
|
||||
bool nextFFTBlockReady = false;
|
||||
float scopeData [scopeSize]{};
|
||||
float fftData [2 * fftSize]{};
|
||||
protected:
|
||||
dsp::FFT fft{fftOrder};
|
||||
dsp::WindowingFunction<float> window{fftSize, dsp::WindowingFunction<float>::hann};
|
||||
float fifo [fftSize]{};
|
||||
int fifoIndex = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif //VENO_FFT_H
|
17
Source/Veno/Utils/Logger.cpp
Normal file
17
Source/Veno/Utils/Logger.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// Created by versustune on 09.06.20.
|
||||
//
|
||||
|
||||
#include "Logger.h"
|
||||
|
||||
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) {
|
||||
#ifdef DEBUG
|
||||
std::cout << "\u001b[38;5;111m[INFO]\u001b[0m\t" << message << "\n";
|
||||
#endif
|
||||
}
|
16
Source/Veno/Utils/Logger.h
Normal file
16
Source/Veno/Utils/Logger.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef VENO_LOGGER_H
|
||||
#define VENO_LOGGER_H
|
||||
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace VeNo {
|
||||
class Logger {
|
||||
public:
|
||||
static void debugMessage(const std::string &message);
|
||||
static void infoDebugMessage(const std::string &message);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif //VENO_LOGGER_H
|
48
Source/Veno/VenoInstance.cpp
Normal file
48
Source/Veno/VenoInstance.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// Created by versustune on 09.06.20.
|
||||
//
|
||||
|
||||
#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() {
|
||||
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);
|
||||
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()) {
|
||||
return instances[id];
|
||||
}
|
||||
return createInstance(id);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
31
Source/Veno/VenoInstance.h
Normal file
31
Source/Veno/VenoInstance.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
// Created by versustune on 09.06.20.
|
||||
//
|
||||
|
||||
#ifndef VENO_VENOINSTANCE_H
|
||||
#define VENO_VENOINSTANCE_H
|
||||
|
||||
#include "JuceHeader.h"
|
||||
#include "Audio/Synth/SynthInstance.h"
|
||||
#include "Utils/FFT.h"
|
||||
#include "Audio/VenoBuffer.h"
|
||||
#include <unordered_map>
|
||||
|
||||
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);
|
||||
FFT fft;
|
||||
std::shared_ptr<VenoBuffer> audioBuffer;
|
||||
};
|
||||
|
||||
|
||||
#endif //VENO_VENOINSTANCE_H
|
71
Veno.jucer
71
Veno.jucer
|
@ -7,11 +7,70 @@
|
|||
cppLanguageStandard="17" version="1.0.0" companyCopyright="Copyright VersusTuneZ 2019-2020">
|
||||
<MAINGROUP id="m9l7SJ" name="VeNo">
|
||||
<GROUP id="{AAF9955A-D1A2-45FF-2C17-02C73D8064D3}" name="Source">
|
||||
<GROUP id="{12946A85-B629-A60C-6A3F-4FD136126888}" name="Resources">
|
||||
<GROUP id="{4AC597AA-FCB4-EFDC-BFFC-F4FE85035F06}" name="GL">
|
||||
<FILE id="sMJWAN" name="WaveForm.fragment.glsl" compile="0" resource="1"
|
||||
file="Source/Resources/GL/WaveForm.fragment.glsl"/>
|
||||
<FILE id="RZABPZ" name="WaveForm.vertex.glsl" compile="0" resource="1"
|
||||
file="Source/Resources/GL/WaveForm.vertex.glsl"/>
|
||||
</GROUP>
|
||||
<FILE id="gB4Xst" name="arvo.ttf" compile="0" resource="1" file="Source/Resources/arvo.ttf"/>
|
||||
<FILE id="QG10mY" name="lcd.ttf" compile="0" resource="1" file="Source/Resources/lcd.ttf"/>
|
||||
</GROUP>
|
||||
<GROUP id="{5791B3F9-67EA-BE3E-0208-47B8AF81F72F}" name="Veno">
|
||||
<GROUP id="{B6FC2EBB-E15D-DE35-7ACC-81D051410D51}" name="Utils"/>
|
||||
<GROUP id="{00F06C9B-B6B7-5466-5846-495A9FF5EC4A}" name="Static"/>
|
||||
<GROUP id="{BD05234A-1BBB-5055-FA22-C66F1E78CC81}" name="Fonts">
|
||||
<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">
|
||||
<FILE id="bQgR0Y" name="FFT.cpp" compile="1" resource="0" file="Source/Veno/Utils/FFT.cpp"/>
|
||||
<FILE id="McoT9E" name="FFT.h" compile="0" resource="0" file="Source/Veno/Utils/FFT.h"/>
|
||||
<FILE id="fnGWyM" name="Logger.cpp" compile="1" resource="0" file="Source/Veno/Utils/Logger.cpp"/>
|
||||
<FILE id="wYGzZw" name="Logger.h" compile="0" resource="0" file="Source/Veno/Utils/Logger.h"/>
|
||||
</GROUP>
|
||||
<FILE id="XtqjAL" name="VenoInstance.h" compile="0" resource="0" file="Source/Veno/VenoInstance.h"/>
|
||||
<FILE id="LItgbD" name="VenoInstance.cpp" compile="1" resource="0"
|
||||
file="Source/Veno/VenoInstance.cpp"/>
|
||||
<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">
|
||||
<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">
|
||||
<FILE id="kPIbsd" name="SynthInstance.cpp" compile="1" resource="0"
|
||||
file="Source/Veno/Audio/Synth/SynthInstance.cpp"/>
|
||||
<FILE id="cn8tWc" name="SynthInstance.h" compile="0" resource="0" file="Source/Veno/Audio/Synth/SynthInstance.h"/>
|
||||
</GROUP>
|
||||
<GROUP id="{06DB92E3-6D1E-CFC5-096E-315C4121F8AD}" name="WaveTable">
|
||||
<FILE id="aK5Pjz" name="SawWaves.cpp" compile="1" resource="0" file="Source/Veno/Audio/WaveTable/SawWaves.cpp"/>
|
||||
<FILE id="xIMCot" name="SawWaves.h" compile="0" resource="0" file="Source/Veno/Audio/WaveTable/SawWaves.h"/>
|
||||
<FILE id="dF6Ci9" name="SineWaves.cpp" compile="1" resource="0" file="Source/Veno/Audio/WaveTable/SineWaves.cpp"/>
|
||||
<FILE id="lmInYK" name="SineWaves.h" compile="0" resource="0" file="Source/Veno/Audio/WaveTable/SineWaves.h"/>
|
||||
<FILE id="HZwgeM" name="SquareWaves.cpp" compile="1" resource="0" file="Source/Veno/Audio/WaveTable/SquareWaves.cpp"/>
|
||||
<FILE id="HJUsG7" name="SquareWaves.h" compile="0" resource="0" file="Source/Veno/Audio/WaveTable/SquareWaves.h"/>
|
||||
<FILE id="H81SA7" name="TableHelper.cpp" compile="1" resource="0" file="Source/Veno/Audio/WaveTable/TableHelper.cpp"/>
|
||||
<FILE id="uSJMy6" name="TableHelper.h" compile="0" resource="0" file="Source/Veno/Audio/WaveTable/TableHelper.h"/>
|
||||
<FILE id="pzpArE" name="TriangleWaves.cpp" compile="1" resource="0"
|
||||
file="Source/Veno/Audio/WaveTable/TriangleWaves.cpp"/>
|
||||
<FILE id="uJANqm" name="TriangleWaves.h" compile="0" resource="0" file="Source/Veno/Audio/WaveTable/TriangleWaves.h"/>
|
||||
<FILE id="HEHVy9" name="VeNoXWaves.cpp" compile="1" resource="0" file="Source/Veno/Audio/WaveTable/VeNoXWaves.cpp"/>
|
||||
<FILE id="rMLam7" name="VeNoXWaves.h" compile="0" resource="0" file="Source/Veno/Audio/WaveTable/VeNoXWaves.h"/>
|
||||
<FILE id="PFmKTU" name="WavesInlcuder.h" compile="0" resource="0" file="Source/Veno/Audio/WaveTable/WavesInlcuder.h"/>
|
||||
<FILE id="iWkNs3" name="WaveTableGenerator.cpp" compile="1" resource="0"
|
||||
file="Source/Veno/Audio/WaveTable/WaveTableGenerator.cpp"/>
|
||||
<FILE id="yI9w2X" name="WaveTableGenerator.h" compile="0" resource="0"
|
||||
file="Source/Veno/Audio/WaveTable/WaveTableGenerator.h"/>
|
||||
</GROUP>
|
||||
<GROUP id="{16AA5D0B-E67A-8176-4F36-1180ADAFA480}" name="Oscillator"/>
|
||||
<GROUP id="{A224AFA7-CD28-E0FE-3B5A-8203BFD9467B}" name="FX"/>
|
||||
</GROUP>
|
||||
<GROUP id="{EFD25B6B-987D-435F-F8DE-BD6C2B831E62}" name="GUI">
|
||||
<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"/>
|
||||
<FILE id="Y5kUlM" name="SidebarLCD.h" compile="0" resource="0" file="Source/Veno/GUI/Components/LCD/SidebarLCD.h"/>
|
||||
<FILE id="Ox2oOB" name="Waveforms.cpp" compile="1" resource="0" file="Source/Veno/GUI/Components/LCD/Waveforms.cpp"/>
|
||||
<FILE id="vMrsGE" name="Waveforms.h" compile="0" resource="0" file="Source/Veno/GUI/Components/LCD/Waveforms.h"/>
|
||||
</GROUP>
|
||||
<FILE id="BobUXL" name="BaseComponent.cpp" compile="1" resource="0"
|
||||
file="Source/Veno/GUI/Components/BaseComponent.cpp"/>
|
||||
<FILE id="AbXWzA" name="BaseComponent.h" compile="0" resource="0" file="Source/Veno/GUI/Components/BaseComponent.h"/>
|
||||
|
@ -35,12 +94,14 @@
|
|||
file="Source/Veno/GUI/Theme/ThemePresets.cpp"/>
|
||||
</GROUP>
|
||||
</GROUP>
|
||||
<GROUP id="{2E9A4660-1408-92E7-A653-7BA5E2FEE2DA}" name="Engine"/>
|
||||
<GROUP id="{ACC73001-EF99-9282-8ADC-7BBE2EB85E06}" name="Core">
|
||||
<FILE id="PFeyYY" name="AudioConfig.cpp" compile="1" resource="0" file="Source/Veno/Core/AudioConfig.cpp"/>
|
||||
<FILE id="pu5RZU" name="AudioConfig.h" compile="0" resource="0" file="Source/Veno/Core/AudioConfig.h"/>
|
||||
<FILE id="AfXpWs" name="Config.cpp" compile="1" resource="0" file="Source/Veno/Core/Config.cpp"/>
|
||||
<FILE id="e1wHY7" name="Config.h" compile="0" resource="0" file="Source/Veno/Core/Config.h"/>
|
||||
<FILE id="i3vbdH" name="PresetManager.cpp" compile="1" resource="0"
|
||||
file="Source/Veno/Core/PresetManager.cpp"/>
|
||||
<FILE id="WV2uuz" name="PresetManager.h" compile="0" resource="0" file="Source/Veno/Core/PresetManager.h"/>
|
||||
</GROUP>
|
||||
</GROUP>
|
||||
<FILE id="zASeb7" name="PluginProcessor.cpp" compile="1" resource="0"
|
||||
|
@ -73,6 +134,7 @@
|
|||
<MODULEPATH id="juce_gui_basics" path="../../Tools/JUCE/modules"/>
|
||||
<MODULEPATH id="juce_gui_extra" path="../../Tools/JUCE/modules"/>
|
||||
<MODULEPATH id="juce_opengl" path="../../Tools/JUCE/modules"/>
|
||||
<MODULEPATH id="juce_dsp" path="../../tools/JUCE/modules"/>
|
||||
</MODULEPATHS>
|
||||
</VS2019>
|
||||
<LINUX_MAKE targetFolder="Builds/LinuxMakefile">
|
||||
|
@ -95,6 +157,7 @@
|
|||
<MODULEPATH id="juce_gui_basics" path="../../Tools/JUCE/modules"/>
|
||||
<MODULEPATH id="juce_gui_extra" path="../../Tools/JUCE/modules"/>
|
||||
<MODULEPATH id="juce_opengl" path="../../Tools/JUCE/modules"/>
|
||||
<MODULEPATH id="juce_dsp" path="../../tools/JUCE/modules"/>
|
||||
</MODULEPATHS>
|
||||
</LINUX_MAKE>
|
||||
<CLION targetFolder="Builds/CLion" clionMakefileEnabled="1">
|
||||
|
@ -113,6 +176,7 @@
|
|||
<MODULEPATH id="juce_gui_basics" path="../../Tools/JUCE/modules"/>
|
||||
<MODULEPATH id="juce_gui_extra" path="../../Tools/JUCE/modules"/>
|
||||
<MODULEPATH id="juce_opengl" path="../../Tools/JUCE/modules"/>
|
||||
<MODULEPATH id="juce_dsp" path="../../tools/JUCE/modules"/>
|
||||
</MODULEPATHS>
|
||||
</CLION>
|
||||
</EXPORTFORMATS>
|
||||
|
@ -127,6 +191,7 @@
|
|||
<MODULE id="juce_core" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
|
||||
<MODULE id="juce_cryptography" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
|
||||
<MODULE id="juce_data_structures" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
|
||||
<MODULE id="juce_dsp" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
|
||||
<MODULE id="juce_events" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
|
||||
<MODULE id="juce_graphics" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
|
||||
<MODULE id="juce_gui_basics" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
|
||||
|
|
Loading…
Reference in a new issue