Outline for droplet manager

This commit is contained in:
Christian Colglazier 2020-09-30 21:28:34 -04:00
parent a08072d35c
commit fda714d631
6 changed files with 47 additions and 14 deletions

View File

@ -0,0 +1,9 @@
#include "droplet_manager.h"
void DropletManager::ToggleSplit() {
split = !split;
}
bool DropletManager::GetSplitMode() {
return split;
}

View File

@ -0,0 +1,22 @@
#pragma once
#ifndef CASCADE_DROPLETS_DROPLET_MANAGER_H_
#define CASCADE_DROPLETS_DROPLET_MANAGER_H_
class DropletManager {
private:
bool split = false;
public:
/*
* Toggle droplet split mode.
*/
void ToggleSplit();
/*
* Droplet split mode.
*/
bool GetSplitMode();
};
#endif // CASCADE_DROPLETS_DROPLET_MANAGER_H_

View File

@ -24,8 +24,8 @@ void ProcessControls() {
if (patch.encoder.RisingEdge()) {
left_menu.SetInMenu(false);
if(left_menu.GetState() == MenuState::kSplit) {
split = !split;
if (split) {
state->ToggleSplit();
if (state->GetSplitMode()) {
droplet_left->UpdateState(DropletState::kLeft);
droplet_right = GetDroplet(DropletState::kRight);
} else {
@ -34,7 +34,7 @@ void ProcessControls() {
}
} else {
delete droplet_left;
if(split) {
if(state->GetSplitMode()) {
droplet_left = GetDroplet(DropletState::kLeft);
} else {
droplet_left = GetDroplet(DropletState::kFull);
@ -54,7 +54,7 @@ void ProcessControls() {
void ProcessOutputs() {
if(!left_menu.InMenu()) {
droplet_left->Control();
if (split) {
if (state->GetSplitMode()) {
droplet_right->Control();
}
}
@ -66,7 +66,7 @@ void ProcessOled() {
left_menu.ProcessMenuOled();
} else {
droplet_left->Draw();
if (split) {
if (state->GetSplitMode()) {
droplet_right->Draw();
}
}
@ -77,7 +77,7 @@ static void AudioThrough(float **in,
float **out,
size_t size) {
droplet_left->Process(in, out, size);
if (split) {
if (state->GetSplitMode()) {
droplet_right->Process(in, out, size);
}
}

View File

@ -11,13 +11,14 @@
#include "util.h"
#include "menu.h"
#include "droplets/droplet.h"
#include "droplets/droplet_manager.h"
#include "droplets/noise_droplet.h"
#include "droplets/vco_droplet.h"
DaisyPatch patch;
bool split = false;
Menu left_menu(&patch, "Right", &split);
Menu right_menu(&patch, "Left", &split);
DropletManager* state = new DropletManager();
Menu left_menu(&patch, "Right", state);
Menu right_menu(&patch, "Left", state);
Droplet* droplet_left;
Droplet* droplet_right;
float sample_rate;

View File

@ -2,10 +2,10 @@
Menu::Menu(DaisyPatch* m_patch,
std::string m_name,
bool* m_split) {
DropletManager* m_state) {
patch = m_patch;
name = m_name;
split = m_split;
state = m_state;
}
const std::string MENU_ITEMS[] = {"Split",
"Change",
@ -38,7 +38,7 @@ std::string Menu::FilterMenuText(int position) {
if (position >= MENU_SIZE || position < 0) {
return "";
} else {
if (ConvertState(position) == MenuState::kSplit && *split) {
if (ConvertState(position) == MenuState::kSplit && (*state).GetSplitMode()) {
return "Merge";
} else if (ConvertState(position) == MenuState::kChange) {
return name;

View File

@ -5,6 +5,7 @@
#include "daisy_patch.h"
#include "util.h"
#include "droplets/droplet_manager.h"
#include <string>
@ -15,7 +16,7 @@ enum class MenuState {kSplit, kChange, kVCO, kNoise};
class Menu {
private:
DaisyPatch* patch;
bool* split;
DropletManager* state;
std::string name;
/*
@ -33,7 +34,7 @@ class Menu {
* @param m_name name of the menu
* @param m_split one or two droplets
*/
Menu(DaisyPatch* m_patch, std::string m_name, bool* m_split);
Menu(DaisyPatch* m_patch, std::string m_name, DropletManager* m_state);
/*
* Gives if the user is currently in the menu.