GUI: add oscilloscope window size setting

and also remember last zoom/winSize value
This commit is contained in:
tildearrow 2022-05-30 21:40:07 -05:00
parent 2119675b10
commit fc0a51ed56
4 changed files with 24 additions and 4 deletions

View file

@ -2973,6 +2973,9 @@ bool DivEngine::init() {
oscBuf[0]=new float[32768];
oscBuf[1]=new float[32768];
memset(oscBuf[0],0,32768*sizeof(float));
memset(oscBuf[1],0,32768*sizeof(float));
initDispatch();
renderSamples();
reset();

View file

@ -3927,6 +3927,9 @@ bool FurnaceGUI::init() {
if (orderEditMode<0) orderEditMode=0;
if (orderEditMode>3) orderEditMode=3;
oscZoom=e->getConfFloat("oscZoom",0.5f);
oscWindowSize=e->getConfFloat("oscWindowSize",20.0f);
pianoOctaves=e->getConfInt("pianoOctaves",pianoOctaves);
pianoOctavesEdit=e->getConfInt("pianoOctavesEdit",pianoOctavesEdit);
pianoOptions=e->getConfBool("pianoOptions",pianoOptions);
@ -4137,6 +4140,10 @@ bool FurnaceGUI::finish() {
e->setConf("followPattern",followPattern);
e->setConf("orderEditMode",orderEditMode);
// commit oscilloscope state
e->setConf("oscZoom",oscZoom);
e->setConf("oscWindowSize",oscWindowSize);
// commit piano state
e->setConf("pianoOctaves",pianoOctaves);
e->setConf("pianoOctavesEdit",pianoOctavesEdit);
@ -4422,6 +4429,7 @@ FurnaceGUI::FurnaceGUI():
openSampleFilterOpt(false),
oscTotal(0),
oscZoom(0.5f),
oscWindowSize(20.0f),
oscZoomSlider(false),
chanOscCols(3),
chanOscWindowSize(20.0f),

View file

@ -1240,6 +1240,7 @@ class FurnaceGUI {
int oscTotal;
float oscValues[512];
float oscZoom;
float oscWindowSize;
bool oscZoomSlider;
// per-channel oscilloscope

View file

@ -21,9 +21,6 @@
#include "imgui_internal.h"
#include <imgui.h>
// TODO:
// - potentially move oscilloscope seek position to the end, and read the last samples
// - this allows for setting up the window size
void FurnaceGUI::readOsc() {
int writePos=e->oscWritePos;
int readPos=e->oscReadPos;
@ -47,8 +44,11 @@ void FurnaceGUI::readOsc() {
total=oscTotal+(bias>>6);
if (total>avail) total=avail;
//printf("total: %d. avail: %d bias: %d\n",total,avail,bias);
int winSize=e->getAudioDescGot().rate*(oscWindowSize/1000.0);
int oscReadPos=(writePos-winSize)&0x7fff;
for (int i=0; i<512; i++) {
int pos=(readPos+(i*total/512))&0x7fff;
int pos=(oscReadPos+(i*winSize/512))&0x7fff;
oscValues[i]=(e->oscBuf[0][pos]+e->oscBuf[1][pos])*0.5f;
if (oscValues[i]>0.001f || oscValues[i]<-0.001f) {
WAKE_UP;
@ -97,6 +97,14 @@ void FurnaceGUI::drawOsc() {
if (oscZoom>2.0) oscZoom=2.0;
}
ImGui::SameLine();
if (ImGui::VSliderFloat("##OscWinSize",ImVec2(20.0f*dpiScale,ImGui::GetContentRegionAvail().y),&oscWindowSize,5.0,100.0)) {
if (oscWindowSize<5.0) oscWindowSize=5.0;
if (oscWindowSize>100.0) oscWindowSize=100.0;
}
if (ImGui::IsItemClicked(ImGuiMouseButton_Middle)) {
oscWindowSize=20.0;
}
ImGui::SameLine();
}
ImDrawList* dl=ImGui::GetWindowDrawList();