diff --git a/src/droplets/mixer_droplet.cpp b/src/droplets/mixer_droplet.cpp new file mode 100644 index 0000000..41a8159 --- /dev/null +++ b/src/droplets/mixer_droplet.cpp @@ -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"); +} diff --git a/src/droplets/mixer_droplet.h b/src/droplets/mixer_droplet.h new file mode 100644 index 0000000..f68f9e5 --- /dev/null +++ b/src/droplets/mixer_droplet.h @@ -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_ diff --git a/src/main.cpp b/src/main.cpp index 31d3ea4..3dba468 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -114,6 +114,10 @@ static void AudioThrough(AudioHandle::InputBuffer in, Droplet* GetDroplet(DropletState state) { switch(selected_menu->GetState()) { + default: + case MenuState::kMixer: + return new MixerDroplet(&patch, + state); case MenuState::kVCA: return new VCADroplet(&patch, state); @@ -122,7 +126,6 @@ Droplet* GetDroplet(DropletState state) { state, sample_rate); case MenuState::kNoise: - default: return new NoiseDroplet(&patch, state); } diff --git a/src/main.h b/src/main.h index 2055715..e938339 100644 --- a/src/main.h +++ b/src/main.h @@ -12,6 +12,7 @@ #include "menu.h" #include "droplets/droplet.h" #include "droplets/droplet_manager.h" +#include "droplets/mixer_droplet.h" #include "droplets/noise_droplet.h" #include "droplets/vca_droplet.h" #include "droplets/vco_droplet.h" diff --git a/src/menu.cpp b/src/menu.cpp index dd87dac..d7c3adc 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -9,9 +9,10 @@ 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::kMixer, "Mixer")); head->AddItemEnd(new MenuItem(MenuState::kNoise, "Noise")); + head->AddItemEnd(new MenuItem(MenuState::kVCA, "VCA")); + head->AddItemEnd(new MenuItem(MenuState::kVCO, "VCO")); selected = head; buffer = selected; diff --git a/src/menu_item.h b/src/menu_item.h index c0519b4..72adbc8 100644 --- a/src/menu_item.h +++ b/src/menu_item.h @@ -5,7 +5,7 @@ #include -enum class MenuState {kSplit, kChange, kVCA, kVCO, kNoise}; +enum class MenuState {kSplit, kChange, kMixer, kNoise, kVCA, kVCO}; class MenuItem { private: