mirror of
https://github.com/AquaMorph/Droplets.git
synced 2025-04-30 09:45:35 +00:00
Outline for droplet manager
This commit is contained in:
parent
a08072d35c
commit
fda714d631
9
src/droplets/droplet_manager.cpp
Normal file
9
src/droplets/droplet_manager.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include "droplet_manager.h"
|
||||||
|
|
||||||
|
void DropletManager::ToggleSplit() {
|
||||||
|
split = !split;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DropletManager::GetSplitMode() {
|
||||||
|
return split;
|
||||||
|
}
|
22
src/droplets/droplet_manager.h
Normal file
22
src/droplets/droplet_manager.h
Normal 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_
|
||||||
|
|
12
src/main.cpp
12
src/main.cpp
@ -24,8 +24,8 @@ void ProcessControls() {
|
|||||||
if (patch.encoder.RisingEdge()) {
|
if (patch.encoder.RisingEdge()) {
|
||||||
left_menu.SetInMenu(false);
|
left_menu.SetInMenu(false);
|
||||||
if(left_menu.GetState() == MenuState::kSplit) {
|
if(left_menu.GetState() == MenuState::kSplit) {
|
||||||
split = !split;
|
state->ToggleSplit();
|
||||||
if (split) {
|
if (state->GetSplitMode()) {
|
||||||
droplet_left->UpdateState(DropletState::kLeft);
|
droplet_left->UpdateState(DropletState::kLeft);
|
||||||
droplet_right = GetDroplet(DropletState::kRight);
|
droplet_right = GetDroplet(DropletState::kRight);
|
||||||
} else {
|
} else {
|
||||||
@ -34,7 +34,7 @@ void ProcessControls() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
delete droplet_left;
|
delete droplet_left;
|
||||||
if(split) {
|
if(state->GetSplitMode()) {
|
||||||
droplet_left = GetDroplet(DropletState::kLeft);
|
droplet_left = GetDroplet(DropletState::kLeft);
|
||||||
} else {
|
} else {
|
||||||
droplet_left = GetDroplet(DropletState::kFull);
|
droplet_left = GetDroplet(DropletState::kFull);
|
||||||
@ -54,7 +54,7 @@ void ProcessControls() {
|
|||||||
void ProcessOutputs() {
|
void ProcessOutputs() {
|
||||||
if(!left_menu.InMenu()) {
|
if(!left_menu.InMenu()) {
|
||||||
droplet_left->Control();
|
droplet_left->Control();
|
||||||
if (split) {
|
if (state->GetSplitMode()) {
|
||||||
droplet_right->Control();
|
droplet_right->Control();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ void ProcessOled() {
|
|||||||
left_menu.ProcessMenuOled();
|
left_menu.ProcessMenuOled();
|
||||||
} else {
|
} else {
|
||||||
droplet_left->Draw();
|
droplet_left->Draw();
|
||||||
if (split) {
|
if (state->GetSplitMode()) {
|
||||||
droplet_right->Draw();
|
droplet_right->Draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ static void AudioThrough(float **in,
|
|||||||
float **out,
|
float **out,
|
||||||
size_t size) {
|
size_t size) {
|
||||||
droplet_left->Process(in, out, size);
|
droplet_left->Process(in, out, size);
|
||||||
if (split) {
|
if (state->GetSplitMode()) {
|
||||||
droplet_right->Process(in, out, size);
|
droplet_right->Process(in, out, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,14 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "droplets/droplet.h"
|
#include "droplets/droplet.h"
|
||||||
|
#include "droplets/droplet_manager.h"
|
||||||
#include "droplets/noise_droplet.h"
|
#include "droplets/noise_droplet.h"
|
||||||
#include "droplets/vco_droplet.h"
|
#include "droplets/vco_droplet.h"
|
||||||
|
|
||||||
DaisyPatch patch;
|
DaisyPatch patch;
|
||||||
bool split = false;
|
DropletManager* state = new DropletManager();
|
||||||
Menu left_menu(&patch, "Right", &split);
|
Menu left_menu(&patch, "Right", state);
|
||||||
Menu right_menu(&patch, "Left", &split);
|
Menu right_menu(&patch, "Left", state);
|
||||||
Droplet* droplet_left;
|
Droplet* droplet_left;
|
||||||
Droplet* droplet_right;
|
Droplet* droplet_right;
|
||||||
float sample_rate;
|
float sample_rate;
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
Menu::Menu(DaisyPatch* m_patch,
|
Menu::Menu(DaisyPatch* m_patch,
|
||||||
std::string m_name,
|
std::string m_name,
|
||||||
bool* m_split) {
|
DropletManager* m_state) {
|
||||||
patch = m_patch;
|
patch = m_patch;
|
||||||
name = m_name;
|
name = m_name;
|
||||||
split = m_split;
|
state = m_state;
|
||||||
}
|
}
|
||||||
const std::string MENU_ITEMS[] = {"Split",
|
const std::string MENU_ITEMS[] = {"Split",
|
||||||
"Change",
|
"Change",
|
||||||
@ -38,7 +38,7 @@ std::string Menu::FilterMenuText(int position) {
|
|||||||
if (position >= MENU_SIZE || position < 0) {
|
if (position >= MENU_SIZE || position < 0) {
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
if (ConvertState(position) == MenuState::kSplit && *split) {
|
if (ConvertState(position) == MenuState::kSplit && (*state).GetSplitMode()) {
|
||||||
return "Merge";
|
return "Merge";
|
||||||
} else if (ConvertState(position) == MenuState::kChange) {
|
} else if (ConvertState(position) == MenuState::kChange) {
|
||||||
return name;
|
return name;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "daisy_patch.h"
|
#include "daisy_patch.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "droplets/droplet_manager.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ enum class MenuState {kSplit, kChange, kVCO, kNoise};
|
|||||||
class Menu {
|
class Menu {
|
||||||
private:
|
private:
|
||||||
DaisyPatch* patch;
|
DaisyPatch* patch;
|
||||||
bool* split;
|
DropletManager* state;
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -33,7 +34,7 @@ class Menu {
|
|||||||
* @param m_name name of the menu
|
* @param m_name name of the menu
|
||||||
* @param m_split one or two droplets
|
* @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.
|
* Gives if the user is currently in the menu.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user