mirror of
https://github.com/AquaMorph/Droplets.git
synced 2025-04-30 01:35:34 +00:00
Basic VCA
This commit is contained in:
parent
874bd8072a
commit
3c5e5b46a3
50
src/droplets/vca_droplet.cpp
Normal file
50
src/droplets/vca_droplet.cpp
Normal 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");
|
||||
}
|
56
src/droplets/vca_droplet.h
Normal file
56
src/droplets/vca_droplet.h
Normal 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_
|
@ -114,6 +114,9 @@ static void AudioThrough(AudioHandle::InputBuffer in,
|
||||
|
||||
Droplet* GetDroplet(DropletState state) {
|
||||
switch(selected_menu->GetState()) {
|
||||
case MenuState::kVCA:
|
||||
return new VCADroplet(&patch,
|
||||
state);
|
||||
case MenuState::kVCO:
|
||||
return new VCODroplet(&patch,
|
||||
state,
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "droplets/droplet.h"
|
||||
#include "droplets/droplet_manager.h"
|
||||
#include "droplets/noise_droplet.h"
|
||||
#include "droplets/vca_droplet.h"
|
||||
#include "droplets/vco_droplet.h"
|
||||
|
||||
DaisyPatch patch;
|
||||
|
@ -10,6 +10,7 @@ Menu::Menu(DaisyPatch* m_patch,
|
||||
head = new MenuItem(MenuState::kSplit, "Split");
|
||||
head->AddItemEnd(new MenuItem(MenuState::kChange, ""));
|
||||
head->AddItemEnd(new MenuItem(MenuState::kVCO, "VCO"));
|
||||
head->AddItemEnd(new MenuItem(MenuState::kVCA, "VCA"));
|
||||
head->AddItemEnd(new MenuItem(MenuState::kNoise, "Noise"));
|
||||
|
||||
selected = head;
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
enum class MenuState {kSplit, kChange, kVCO, kNoise};
|
||||
enum class MenuState {kSplit, kChange, kVCA, kVCO, kNoise};
|
||||
|
||||
class MenuItem {
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user