Created ladder filter droplet

This commit is contained in:
Christian Colglazier 2022-01-24 21:00:30 -05:00
parent c1aa521f34
commit 149ae9a009
15 changed files with 149 additions and 6 deletions

View File

@ -219,3 +219,5 @@ void ADDroplet::UpdateStateCallback() {
delete title_graph; delete title_graph;
CreateTitleGraph(); CreateTitleGraph();
} }
void ADDroplet::SetControls() {}

View File

@ -155,6 +155,11 @@ public:
* Runs when droplet state is updated. * Runs when droplet state is updated.
*/ */
void UpdateStateCallback(); void UpdateStateCallback();
/*
* Set up the controls for the droplet.
*/
void SetControls();
}; };
#endif // DROPLETS_AD_DROPLET_H_ #endif // DROPLETS_AD_DROPLET_H_

View File

@ -55,6 +55,7 @@ void Droplet::UpdateState(DropletState m_state) {
chn_min = 2; chn_min = 2;
screen_min = SSD1309_WIDTH / 2; screen_min = SSD1309_WIDTH / 2;
} }
SetControls();
UpdateStateCallback(); UpdateStateCallback();
} }

View File

@ -66,6 +66,11 @@ public:
*/ */
virtual void UpdateStateCallback() {} virtual void UpdateStateCallback() {}
/*
* Set up the controls for the droplet.
*/
virtual void SetControls() {}
/* /*
* Returns patch. * Returns patch.
* *

View File

@ -0,0 +1,47 @@
#include "ladder_filter_droplet.h"
LadderFilterDroplet::LadderFilterDroplet(DaisyPatch* m_patch,
DropletState m_state,
float sample_rate) :
Droplet(m_patch,
m_state) {
filter.Init(sample_rate);
SetControls();
}
void LadderFilterDroplet::Control() {}
void LadderFilterDroplet::Process(AudioHandle::InputBuffer in,
AudioHandle::OutputBuffer out,
size_t size) {
freq = freq_ctrl.Process();
res = res_ctrl.Process();
filter.SetFreq(freq);
filter.SetRes(res);
for (size_t i = 0; i < size; i++) {
for (size_t chn = GetChannelMin(); chn < GetChannelMax(); chn++) {
out[chn][i] = filter.Process(in[chn][i]);
}
}
}
void LadderFilterDroplet::Draw() {
DrawName("Ladder");
}
void LadderFilterDroplet::UpdateStateCallback() {}
void LadderFilterDroplet::SetControls() {
if (GetState() == DropletState::kRight) {
freq_ctrl.Init(Patch()->controls[Patch()->CTRL_3],
0.0, 10000.0f, Parameter::LINEAR);
res_ctrl.Init(Patch()->controls[Patch()->CTRL_4],
0.0, 0.75f, Parameter::LINEAR);
} else {
freq_ctrl.Init(Patch()->controls[Patch()->CTRL_1],
0.0, 10000.0f, Parameter::LINEAR);
res_ctrl.Init(Patch()->controls[Patch()->CTRL_2],
0.0, 0.75f, Parameter::LINEAR);
}
}

View File

@ -0,0 +1,61 @@
#pragma once
#ifndef DROPLETS_LADDER_FILTER_DROPLET_H_
#define DROPLETS_LADDER_FILTER_DROPLET_H_
#include "daisysp.h"
#include "daisy_patch.h"
#include "droplet.h"
#include "../util.h"
class LadderFilterDroplet: public Droplet {
private:
MoogLadder filter;
Parameter freq_ctrl, res_ctrl;
float freq, res;
public:
/*
* Constructor for a droplet.
*
* @param m_patch pointer to patch
* @param m_state droplet position
* @param sample_rate audio sample rate
*/
LadderFilterDroplet(DaisyPatch* m_patch,
DropletState m_state,
float sample_rate);
/*
* 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();
/*
* Runs when droplet state is updated.
*/
void UpdateStateCallback();
/*
* Set up the controls for the droplet.
*/
void SetControls();
};
#endif // DROPLETS_LADDER_FILTER_DROPLET_H_

View File

@ -108,7 +108,6 @@ void LFODroplet::Draw() {
void LFODroplet::UpdateStateCallback() { void LFODroplet::UpdateStateCallback() {
delete title_graph; delete title_graph;
CreateTitleGraph(); CreateTitleGraph();
SetControls();
} }
void LFODroplet::SetControls() { void LFODroplet::SetControls() {

View File

@ -28,3 +28,5 @@ void NoiseDroplet::Draw() {
} }
void NoiseDroplet::UpdateStateCallback() {} void NoiseDroplet::UpdateStateCallback() {}
void NoiseDroplet::SetControls() {}

View File

@ -46,6 +46,11 @@ public:
* Runs when droplet state is updated. * Runs when droplet state is updated.
*/ */
void UpdateStateCallback(); void UpdateStateCallback();
/*
* Set up the controls for the droplet.
*/
void SetControls();
}; };
#endif // DROPLETS_NOISE_DROPLET_H_ #endif // DROPLETS_NOISE_DROPLET_H_

View File

@ -1,7 +1,8 @@
#include "template_droplet.h" #include "template_droplet.h"
TemplateDroplet::TemplateDroplet(DaisyPatch* m_patch, TemplateDroplet::TemplateDroplet(DaisyPatch* m_patch,
DropletState m_state) : DropletState m_state,
float sample_rate) :
Droplet(m_patch, Droplet(m_patch,
m_state) { m_state) {
} }
@ -9,8 +10,8 @@ TemplateDroplet::TemplateDroplet(DaisyPatch* m_patch,
void TemplateDroplet::Control() {} void TemplateDroplet::Control() {}
void TemplateDroplet::Process(AudioHandle::InputBuffer in, void TemplateDroplet::Process(AudioHandle::InputBuffer in,
AudioHandle::OutputBuffer out, AudioHandle::OutputBuffer out,
size_t size) { size_t size) {
} }
void TemplateDroplet::Draw() { void TemplateDroplet::Draw() {

View File

@ -17,8 +17,11 @@ public:
* *
* @param m_patch pointer to patch * @param m_patch pointer to patch
* @param m_state droplet position * @param m_state droplet position
* @param sample_rate audio sample rate
*/ */
TemplateDroplet(DaisyPatch*, DropletState); TemplateDroplet(DaisyPatch* m_patch,
DropletState m_state,
float sample_rate);
/* /*
* Processes user controls and inputs. * Processes user controls and inputs.
@ -45,6 +48,11 @@ public:
* Runs when droplet state is updated. * Runs when droplet state is updated.
*/ */
void UpdateStateCallback(); void UpdateStateCallback();
/*
* Set up the controls for the droplet.
*/
void SetControls();
}; };
#endif // DROPLETS_TEMPLATE_DROPLET_H_ #endif // DROPLETS_TEMPLATE_DROPLET_H_

View File

@ -134,6 +134,10 @@ Droplet* GetDroplet(DropletState state,
return new ADDroplet(&patch, return new ADDroplet(&patch,
state, state,
sample_rate); sample_rate);
case MenuState::kLadderFilter:
return new LadderFilterDroplet(&patch,
state,
sample_rate);
case MenuState::kLFO: case MenuState::kLFO:
return new LFODroplet(&patch, return new LFODroplet(&patch,
state, state,

View File

@ -13,6 +13,7 @@
#include "droplets/droplet.h" #include "droplets/droplet.h"
#include "droplets/droplet_manager.h" #include "droplets/droplet_manager.h"
#include "droplets/ad_droplet.h" #include "droplets/ad_droplet.h"
#include "droplets/ladder_filter_droplet.h"
#include "droplets/lfo_droplet.h" #include "droplets/lfo_droplet.h"
#include "droplets/mixer_droplet.h" #include "droplets/mixer_droplet.h"
#include "droplets/noise_droplet.h" #include "droplets/noise_droplet.h"

View File

@ -10,6 +10,7 @@ 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::kAD, "AD")); head->AddItemEnd(new MenuItem(MenuState::kAD, "AD"));
head->AddItemEnd(new MenuItem(MenuState::kLadderFilter, "Ladder Filter"));
head->AddItemEnd(new MenuItem(MenuState::kLFO, "LFO")); head->AddItemEnd(new MenuItem(MenuState::kLFO, "LFO"));
head->AddItemEnd(new MenuItem(MenuState::kMixer, "Mixer")); head->AddItemEnd(new MenuItem(MenuState::kMixer, "Mixer"));
head->AddItemEnd(new MenuItem(MenuState::kNoise, "Noise")); head->AddItemEnd(new MenuItem(MenuState::kNoise, "Noise"));

View File

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