Skip to content

Commit

Permalink
Merge pull request #1567 from akumanatt/xyscope
Browse files Browse the repository at this point in the history
Add X-Y Oscilloscope
  • Loading branch information
tildearrow authored Nov 3, 2023
2 parents 9f68c69 + 2e9cfd0 commit 3d168fa
Show file tree
Hide file tree
Showing 6 changed files with 296 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ src/gui/tutorial.cpp
src/gui/util.cpp
src/gui/waveEdit.cpp
src/gui/volMeter.cpp
src/gui/xyOsc.cpp
src/gui/gui.cpp
)

Expand Down
6 changes: 6 additions & 0 deletions src/gui/doAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ void FurnaceGUI::doAction(int what) {
case GUI_ACTION_WINDOW_GROOVES:
nextWindow=GUI_WINDOW_GROOVES;
break;
case GUI_ACTION_WINDOW_XY_OSC:
nextWindow=GUI_WINDOW_XY_OSC;
break;

case GUI_ACTION_COLLAPSE_WINDOW:
collapseWindow=true;
Expand Down Expand Up @@ -375,6 +378,9 @@ void FurnaceGUI::doAction(int what) {
case GUI_WINDOW_GROOVES:
groovesOpen=false;
break;
case GUI_WINDOW_XY_OSC:
xyOscOpen=false;
break;
default:
break;
}
Expand Down
39 changes: 39 additions & 0 deletions src/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3430,6 +3430,7 @@ bool FurnaceGUI::loop() {
DECLARE_METRIC(readOsc)
DECLARE_METRIC(osc)
DECLARE_METRIC(chanOsc)
DECLARE_METRIC(xyOsc)
DECLARE_METRIC(volMeter)
DECLARE_METRIC(settings)
DECLARE_METRIC(debug)
Expand Down Expand Up @@ -4425,6 +4426,7 @@ bool FurnaceGUI::loop() {
if (ImGui::MenuItem("piano/input pad",BIND_FOR(GUI_ACTION_WINDOW_PIANO),pianoOpen)) pianoOpen=!pianoOpen;
if (ImGui::MenuItem("oscilloscope (master)",BIND_FOR(GUI_ACTION_WINDOW_OSCILLOSCOPE),oscOpen)) oscOpen=!oscOpen;
if (ImGui::MenuItem("oscilloscope (per-channel)",BIND_FOR(GUI_ACTION_WINDOW_CHAN_OSC),chanOscOpen)) chanOscOpen=!chanOscOpen;
if (ImGui::MenuItem("oscilloscope (X-Y)",BIND_FOR(GUI_ACTION_WINDOW_XY_OSC),xyOscOpen)) xyOscOpen=!xyOscOpen;
if (ImGui::MenuItem("volume meter",BIND_FOR(GUI_ACTION_WINDOW_VOL_METER),volMeterOpen)) volMeterOpen=!volMeterOpen;
if (ImGui::MenuItem("clock",BIND_FOR(GUI_ACTION_WINDOW_CLOCK),clockOpen)) clockOpen=!clockOpen;
if (ImGui::MenuItem("register view",BIND_FOR(GUI_ACTION_WINDOW_REGISTER_VIEW),regViewOpen)) regViewOpen=!regViewOpen;
Expand Down Expand Up @@ -4645,6 +4647,7 @@ bool FurnaceGUI::loop() {
MEASURE(readOsc,readOsc());
MEASURE(osc,drawOsc());
MEASURE(chanOsc,drawChanOsc());
MEASURE(xyOsc,drawXYOsc());
MEASURE(grooves,drawGrooves());
MEASURE(regView,drawRegView());
} else {
Expand Down Expand Up @@ -4674,6 +4677,7 @@ bool FurnaceGUI::loop() {

MEASURE(osc,drawOsc());
MEASURE(chanOsc,drawChanOsc());
MEASURE(xyOsc,drawXYOsc());
MEASURE(volMeter,drawVolMeter());
MEASURE(settings,drawSettings());
MEASURE(debug,drawDebug());
Expand Down Expand Up @@ -6413,6 +6417,7 @@ bool FurnaceGUI::init() {
mixerOpen=e->getConfBool("mixerOpen",false);
oscOpen=e->getConfBool("oscOpen",true);
chanOscOpen=e->getConfBool("chanOscOpen",false);
xyOscOpen=e->getConfBool("xyOscOpen",false);
volMeterOpen=e->getConfBool("volMeterOpen",true);
statsOpen=e->getConfBool("statsOpen",false);
compatFlagsOpen=e->getConfBool("compatFlagsOpen",false);
Expand Down Expand Up @@ -6521,6 +6526,16 @@ bool FurnaceGUI::init() {
chanOscGrad.fromString(e->getConfString("chanOscGrad",""));
chanOscGrad.render();

xyOscXChannel=e->getConfInt("xyOscXChannel",0);
xyOscXInvert=e->getConfBool("xyOscXInvert",false);
xyOscYChannel=e->getConfInt("xyOscYChannel",1);
xyOscYInvert=e->getConfBool("xyOscYInvert",false);
xyOscZoom=e->getConfFloat("xyOscZoom",1.0f);
xyOscSamples=e->getConfInt("xyOscSamples",32768);
xyOscDecayTime=e->getConfFloat("xyOscDecayTime",10.0f);
xyOscIntensity=e->getConfFloat("xyOscIntensity",2.0f);
xyOscThickness=e->getConfFloat("xyOscThickness",2.0f);

syncSettings();
syncTutorial();

Expand Down Expand Up @@ -6968,6 +6983,7 @@ void FurnaceGUI::commitState() {
e->setConf("mixerOpen",mixerOpen);
e->setConf("oscOpen",oscOpen);
e->setConf("chanOscOpen",chanOscOpen);
e->setConf("xyOscOpen",xyOscOpen);
e->setConf("volMeterOpen",volMeterOpen);
e->setConf("statsOpen",statsOpen);
e->setConf("compatFlagsOpen",compatFlagsOpen);
Expand Down Expand Up @@ -7062,6 +7078,17 @@ void FurnaceGUI::commitState() {
e->setConf("chanOscUseGrad",chanOscUseGrad);
e->setConf("chanOscGrad",chanOscGrad.toString());

// commit x-y osc state
e->setConf("xyOscXChannel",xyOscXChannel);
e->setConf("xyOscXInvert",xyOscXInvert);
e->setConf("xyOscYChannel",xyOscYChannel);
e->setConf("xyOscYInvert",xyOscYInvert);
e->setConf("xyOscZoom",xyOscZoom);
e->setConf("xyOscSamples",xyOscSamples);
e->setConf("xyOscDecayTime",xyOscDecayTime);
e->setConf("xyOscIntensity",xyOscIntensity);
e->setConf("xyOscThickness",xyOscThickness);

// commit recent files
for (int i=0; i<30; i++) {
String key=fmt::sprintf("recentFile%d",i);
Expand Down Expand Up @@ -7301,6 +7328,7 @@ FurnaceGUI::FurnaceGUI():
clockOpen(false),
speedOpen(true),
groovesOpen(false),
xyOscOpen(false),
basicMode(true),
shortIntro(false),
insListDir(false),
Expand Down Expand Up @@ -7541,6 +7569,17 @@ FurnaceGUI::FurnaceGUI():
chanOscGrad(64,64),
chanOscGradTex(NULL),
chanOscWorkPool(NULL),
xyOscPointTex(NULL),
xyOscOptions(false),
xyOscXChannel(0),
xyOscXInvert(false),
xyOscYChannel(1),
xyOscYInvert(false),
xyOscZoom(1.0f),
xyOscSamples(32768),
xyOscDecayTime(10.0f),
xyOscIntensity(2.0f),
xyOscThickness(2.0f),
followLog(true),
#ifdef IS_MOBILE
pianoOctaves(7),
Expand Down
18 changes: 17 additions & 1 deletion src/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ enum FurnaceGUIWindows {
GUI_WINDOW_FIND,
GUI_WINDOW_CLOCK,
GUI_WINDOW_GROOVES,
GUI_WINDOW_XY_OSC,
GUI_WINDOW_INTRO_MON,
GUI_WINDOW_SPOILER
};
Expand Down Expand Up @@ -572,6 +573,7 @@ enum FurnaceGUIActions {
GUI_ACTION_WINDOW_FIND,
GUI_ACTION_WINDOW_CLOCK,
GUI_ACTION_WINDOW_GROOVES,
GUI_ACTION_WINDOW_XY_OSC,

GUI_ACTION_COLLAPSE_WINDOW,
GUI_ACTION_CLOSE_WINDOW,
Expand Down Expand Up @@ -1873,7 +1875,7 @@ class FurnaceGUI {
bool mixerOpen, debugOpen, inspectorOpen, oscOpen, volMeterOpen, statsOpen, compatFlagsOpen;
bool pianoOpen, notesOpen, channelsOpen, regViewOpen, logOpen, effectListOpen, chanOscOpen;
bool subSongsOpen, findOpen, spoilerOpen, patManagerOpen, sysManagerOpen, clockOpen, speedOpen;
bool groovesOpen;
bool groovesOpen, xyOscOpen;

bool basicMode, shortIntro;
bool insListDir, waveListDir, sampleListDir;
Expand Down Expand Up @@ -2167,6 +2169,19 @@ class FurnaceGUI {
planI(NULL) {}
} chanOscChan[DIV_MAX_CHANS];

// x-y oscilloscope
FurnaceGUITexture* xyOscPointTex;
bool xyOscOptions;
int xyOscXChannel;
bool xyOscXInvert;
int xyOscYChannel;
bool xyOscYInvert;
float xyOscZoom;
int xyOscSamples;
float xyOscDecayTime;
float xyOscIntensity;
float xyOscThickness;

// visualizer
float keyHit[DIV_MAX_CHANS];
float keyHit1[DIV_MAX_CHANS];
Expand Down Expand Up @@ -2357,6 +2372,7 @@ class FurnaceGUI {
void drawSpoiler();
void drawClock();
void drawTutorial();
void drawXYOsc();

void parseKeybinds();
void promptKey(int which);
Expand Down
1 change: 1 addition & 0 deletions src/gui/guiConst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={
D("WINDOW_FIND", "Find/Replace", FURKMOD_CMD|SDLK_f),
D("WINDOW_CLOCK", "Clock", 0),
D("WINDOW_GROOVES", "Grooves", 0),
D("WINDOW_XY_OSC", "Oscilloscope (X-Y)", 0),

D("COLLAPSE_WINDOW", "Collapse/expand current window", 0),
D("CLOSE_WINDOW", "Close current window", FURKMOD_SHIFT|SDLK_ESCAPE),
Expand Down
Loading

0 comments on commit 3d168fa

Please sign in to comment.