Basic VCA

This commit is contained in:
2021-11-01 21:08:10 -04:00
parent 874bd8072a
commit 3c5e5b46a3
6 changed files with 112 additions and 1 deletions

View File

@ -0,0 +1,50 @@
#include "vca_droplet.h"
VCADroplet::VCADroplet(DaisyPatch* m_patch,
DropletState m_state) :
Droplet(m_patch,
m_state) {
switch (GetState()) {
default:
case DropletState::kFull:
vca[0].Init(Patch()->controls[Patch()->CTRL_1],
0.0, 1.0f, Parameter::LINEAR);
vca[1].Init(Patch()->controls[Patch()->CTRL_2],
0.0, 1.0f, Parameter::LINEAR);
vca[2].Init(Patch()->controls[Patch()->CTRL_3],
0.0, 1.0f, Parameter::LINEAR);
vca[3].Init(Patch()->controls[Patch()->CTRL_4],
0.0, 1.0f, Parameter::LINEAR);
break;
case DropletState::kLeft:
vca[0].Init(Patch()->controls[Patch()->CTRL_1],
0.0, 1.0f, Parameter::LINEAR);
vca[1].Init(Patch()->controls[Patch()->CTRL_2],
0.0, 1.0f, Parameter::LINEAR);
break;
case DropletState::kRight:
vca[2].Init(Patch()->controls[Patch()->CTRL_3],
0.0, 1.0f, Parameter::LINEAR);
vca[3].Init(Patch()->controls[Patch()->CTRL_3],
0.0, 1.0f, Parameter::LINEAR);
break;
}
}
VCADroplet::~VCADroplet() {}
void VCADroplet::Control() {}
void VCADroplet::Process(AudioHandle::InputBuffer in, AudioHandle::OutputBuffer out, size_t size) {
Patch()->ProcessAnalogControls();
for (size_t i = 0; i < size; i++) {
for (size_t chn = GetChannelMin(); chn < GetChannelMax(); chn++) {
out[chn][i] = in[chn][i] * vca[chn].Process();
}
}
}
void VCADroplet::Draw() {
DrawName("VCA");
}

View File

@ -0,0 +1,56 @@
#pragma once
#ifndef CASCADE_DROPLETS_VCA_DROPLET_H_
#define CASCADE_DROPLETS_VCA_DROPLET_H_
#include "daisysp.h"
#include "daisy_patch.h"
#include "droplet.h"
#include "../util.h"
using namespace daisy;
using namespace daisysp;
class VCADroplet: public Droplet {
private:
Parameter vca[4];
public:
/*
* Constructor for voltage amplifier droplet.
*
* @param m_patch pointer to patch
* @param m_state droplet position
*/
VCADroplet(DaisyPatch* m_patch,
DropletState m_state);
/*
* Destructor for vco droplet.
*/
~VCADroplet();
/*
* Processes user controls and inputs.
*/
void Control();
/*
* Processes audio input and outputs.
*
* @param in the audio inputs for the patch
* @param out the audio outputs for the patch
* @param size the number of inputs and outputs
*/
void Process(AudioHandle::InputBuffer in,
AudioHandle::OutputBuffer out,
size_t size);
/*
* Processes information to be shown on the display.
*/
void Draw();
};
#endif // CASCADE_DROPLETS_VCA_DROPLET_H_