Added basic mixer

This commit is contained in:
2021-11-04 20:43:25 -04:00
parent a8a2340ac4
commit 175a836715
6 changed files with 125 additions and 4 deletions

View File

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

View File

@ -0,0 +1,56 @@
#pragma once
#ifndef CASCADE_DROPLETS_MIXER_DROPLET_H_
#define CASCADE_DROPLETS_MIXER_DROPLET_H_
#include "daisysp.h"
#include "daisy_patch.h"
#include "droplet.h"
#include "../util.h"
using namespace daisy;
using namespace daisysp;
class MixerDroplet: public Droplet {
private:
Parameter mix[4];
public:
/*
* Constructor for a mixer droplet.
*
* @param m_patch pointer to patch
* @param m_state droplet position
*/
MixerDroplet(DaisyPatch* m_patch,
DropletState m_state);
/*
* Destructor for vco droplet.
*/
~MixerDroplet();
/*
* 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_