mirror of
https://github.com/AquaMorph/Droplets.git
synced 2025-04-29 17:35:33 +00:00
Created ladder filter droplet
This commit is contained in:
parent
c1aa521f34
commit
149ae9a009
@ -219,3 +219,5 @@ void ADDroplet::UpdateStateCallback() {
|
||||
delete title_graph;
|
||||
CreateTitleGraph();
|
||||
}
|
||||
|
||||
void ADDroplet::SetControls() {}
|
||||
|
@ -155,6 +155,11 @@ public:
|
||||
* Runs when droplet state is updated.
|
||||
*/
|
||||
void UpdateStateCallback();
|
||||
|
||||
/*
|
||||
* Set up the controls for the droplet.
|
||||
*/
|
||||
void SetControls();
|
||||
};
|
||||
|
||||
#endif // DROPLETS_AD_DROPLET_H_
|
||||
|
@ -55,6 +55,7 @@ void Droplet::UpdateState(DropletState m_state) {
|
||||
chn_min = 2;
|
||||
screen_min = SSD1309_WIDTH / 2;
|
||||
}
|
||||
SetControls();
|
||||
UpdateStateCallback();
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,11 @@ public:
|
||||
*/
|
||||
virtual void UpdateStateCallback() {}
|
||||
|
||||
/*
|
||||
* Set up the controls for the droplet.
|
||||
*/
|
||||
virtual void SetControls() {}
|
||||
|
||||
/*
|
||||
* Returns patch.
|
||||
*
|
||||
|
47
src/droplets/ladder_filter_droplet.cpp
Normal file
47
src/droplets/ladder_filter_droplet.cpp
Normal 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);
|
||||
}
|
||||
}
|
61
src/droplets/ladder_filter_droplet.h
Normal file
61
src/droplets/ladder_filter_droplet.h
Normal 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_
|
@ -108,7 +108,6 @@ void LFODroplet::Draw() {
|
||||
void LFODroplet::UpdateStateCallback() {
|
||||
delete title_graph;
|
||||
CreateTitleGraph();
|
||||
SetControls();
|
||||
}
|
||||
|
||||
void LFODroplet::SetControls() {
|
||||
|
@ -28,3 +28,5 @@ void NoiseDroplet::Draw() {
|
||||
}
|
||||
|
||||
void NoiseDroplet::UpdateStateCallback() {}
|
||||
|
||||
void NoiseDroplet::SetControls() {}
|
||||
|
@ -46,6 +46,11 @@ public:
|
||||
* Runs when droplet state is updated.
|
||||
*/
|
||||
void UpdateStateCallback();
|
||||
|
||||
/*
|
||||
* Set up the controls for the droplet.
|
||||
*/
|
||||
void SetControls();
|
||||
};
|
||||
|
||||
#endif // DROPLETS_NOISE_DROPLET_H_
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "template_droplet.h"
|
||||
|
||||
TemplateDroplet::TemplateDroplet(DaisyPatch* m_patch,
|
||||
DropletState m_state) :
|
||||
DropletState m_state,
|
||||
float sample_rate) :
|
||||
Droplet(m_patch,
|
||||
m_state) {
|
||||
}
|
||||
|
@ -17,8 +17,11 @@ public:
|
||||
*
|
||||
* @param m_patch pointer to patch
|
||||
* @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.
|
||||
@ -45,6 +48,11 @@ public:
|
||||
* Runs when droplet state is updated.
|
||||
*/
|
||||
void UpdateStateCallback();
|
||||
|
||||
/*
|
||||
* Set up the controls for the droplet.
|
||||
*/
|
||||
void SetControls();
|
||||
};
|
||||
|
||||
#endif // DROPLETS_TEMPLATE_DROPLET_H_
|
||||
|
@ -134,6 +134,10 @@ Droplet* GetDroplet(DropletState state,
|
||||
return new ADDroplet(&patch,
|
||||
state,
|
||||
sample_rate);
|
||||
case MenuState::kLadderFilter:
|
||||
return new LadderFilterDroplet(&patch,
|
||||
state,
|
||||
sample_rate);
|
||||
case MenuState::kLFO:
|
||||
return new LFODroplet(&patch,
|
||||
state,
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "droplets/droplet.h"
|
||||
#include "droplets/droplet_manager.h"
|
||||
#include "droplets/ad_droplet.h"
|
||||
#include "droplets/ladder_filter_droplet.h"
|
||||
#include "droplets/lfo_droplet.h"
|
||||
#include "droplets/mixer_droplet.h"
|
||||
#include "droplets/noise_droplet.h"
|
||||
|
@ -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::kAD, "AD"));
|
||||
head->AddItemEnd(new MenuItem(MenuState::kLadderFilter, "Ladder Filter"));
|
||||
head->AddItemEnd(new MenuItem(MenuState::kLFO, "LFO"));
|
||||
head->AddItemEnd(new MenuItem(MenuState::kMixer, "Mixer"));
|
||||
head->AddItemEnd(new MenuItem(MenuState::kNoise, "Noise"));
|
||||
|
@ -5,7 +5,8 @@
|
||||
|
||||
#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 {
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user