Added basic mixer

This commit is contained in:
Christian Colglazier 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_

View File

@ -114,6 +114,10 @@ static void AudioThrough(AudioHandle::InputBuffer in,
Droplet* GetDroplet(DropletState state) { Droplet* GetDroplet(DropletState state) {
switch(selected_menu->GetState()) { switch(selected_menu->GetState()) {
default:
case MenuState::kMixer:
return new MixerDroplet(&patch,
state);
case MenuState::kVCA: case MenuState::kVCA:
return new VCADroplet(&patch, return new VCADroplet(&patch,
state); state);
@ -122,7 +126,6 @@ Droplet* GetDroplet(DropletState state) {
state, state,
sample_rate); sample_rate);
case MenuState::kNoise: case MenuState::kNoise:
default:
return new NoiseDroplet(&patch, return new NoiseDroplet(&patch,
state); state);
} }

View File

@ -12,6 +12,7 @@
#include "menu.h" #include "menu.h"
#include "droplets/droplet.h" #include "droplets/droplet.h"
#include "droplets/droplet_manager.h" #include "droplets/droplet_manager.h"
#include "droplets/mixer_droplet.h"
#include "droplets/noise_droplet.h" #include "droplets/noise_droplet.h"
#include "droplets/vca_droplet.h" #include "droplets/vca_droplet.h"
#include "droplets/vco_droplet.h" #include "droplets/vco_droplet.h"

View File

@ -9,9 +9,10 @@ Menu::Menu(DaisyPatch* m_patch,
head = new MenuItem(MenuState::kSplit, "Split"); head = new MenuItem(MenuState::kSplit, "Split");
head->AddItemEnd(new MenuItem(MenuState::kChange, "")); head->AddItemEnd(new MenuItem(MenuState::kChange, ""));
head->AddItemEnd(new MenuItem(MenuState::kVCO, "VCO")); head->AddItemEnd(new MenuItem(MenuState::kMixer, "Mixer"));
head->AddItemEnd(new MenuItem(MenuState::kVCA, "VCA"));
head->AddItemEnd(new MenuItem(MenuState::kNoise, "Noise")); head->AddItemEnd(new MenuItem(MenuState::kNoise, "Noise"));
head->AddItemEnd(new MenuItem(MenuState::kVCA, "VCA"));
head->AddItemEnd(new MenuItem(MenuState::kVCO, "VCO"));
selected = head; selected = head;
buffer = selected; buffer = selected;

View File

@ -5,7 +5,7 @@
#include <string> #include <string>
enum class MenuState {kSplit, kChange, kVCA, kVCO, kNoise}; enum class MenuState {kSplit, kChange, kMixer, kNoise, kVCA, kVCO};
class MenuItem { class MenuItem {
private: private: