GUI: add oscilloscope window size setting
and also remember last zoom/winSize value
This commit is contained in:
parent
2119675b10
commit
fc0a51ed56
|
@ -2973,6 +2973,9 @@ bool DivEngine::init() {
|
||||||
oscBuf[0]=new float[32768];
|
oscBuf[0]=new float[32768];
|
||||||
oscBuf[1]=new float[32768];
|
oscBuf[1]=new float[32768];
|
||||||
|
|
||||||
|
memset(oscBuf[0],0,32768*sizeof(float));
|
||||||
|
memset(oscBuf[1],0,32768*sizeof(float));
|
||||||
|
|
||||||
initDispatch();
|
initDispatch();
|
||||||
renderSamples();
|
renderSamples();
|
||||||
reset();
|
reset();
|
||||||
|
|
|
@ -3927,6 +3927,9 @@ bool FurnaceGUI::init() {
|
||||||
if (orderEditMode<0) orderEditMode=0;
|
if (orderEditMode<0) orderEditMode=0;
|
||||||
if (orderEditMode>3) orderEditMode=3;
|
if (orderEditMode>3) orderEditMode=3;
|
||||||
|
|
||||||
|
oscZoom=e->getConfFloat("oscZoom",0.5f);
|
||||||
|
oscWindowSize=e->getConfFloat("oscWindowSize",20.0f);
|
||||||
|
|
||||||
pianoOctaves=e->getConfInt("pianoOctaves",pianoOctaves);
|
pianoOctaves=e->getConfInt("pianoOctaves",pianoOctaves);
|
||||||
pianoOctavesEdit=e->getConfInt("pianoOctavesEdit",pianoOctavesEdit);
|
pianoOctavesEdit=e->getConfInt("pianoOctavesEdit",pianoOctavesEdit);
|
||||||
pianoOptions=e->getConfBool("pianoOptions",pianoOptions);
|
pianoOptions=e->getConfBool("pianoOptions",pianoOptions);
|
||||||
|
@ -4137,6 +4140,10 @@ bool FurnaceGUI::finish() {
|
||||||
e->setConf("followPattern",followPattern);
|
e->setConf("followPattern",followPattern);
|
||||||
e->setConf("orderEditMode",orderEditMode);
|
e->setConf("orderEditMode",orderEditMode);
|
||||||
|
|
||||||
|
// commit oscilloscope state
|
||||||
|
e->setConf("oscZoom",oscZoom);
|
||||||
|
e->setConf("oscWindowSize",oscWindowSize);
|
||||||
|
|
||||||
// commit piano state
|
// commit piano state
|
||||||
e->setConf("pianoOctaves",pianoOctaves);
|
e->setConf("pianoOctaves",pianoOctaves);
|
||||||
e->setConf("pianoOctavesEdit",pianoOctavesEdit);
|
e->setConf("pianoOctavesEdit",pianoOctavesEdit);
|
||||||
|
@ -4422,6 +4429,7 @@ FurnaceGUI::FurnaceGUI():
|
||||||
openSampleFilterOpt(false),
|
openSampleFilterOpt(false),
|
||||||
oscTotal(0),
|
oscTotal(0),
|
||||||
oscZoom(0.5f),
|
oscZoom(0.5f),
|
||||||
|
oscWindowSize(20.0f),
|
||||||
oscZoomSlider(false),
|
oscZoomSlider(false),
|
||||||
chanOscCols(3),
|
chanOscCols(3),
|
||||||
chanOscWindowSize(20.0f),
|
chanOscWindowSize(20.0f),
|
||||||
|
|
|
@ -1240,6 +1240,7 @@ class FurnaceGUI {
|
||||||
int oscTotal;
|
int oscTotal;
|
||||||
float oscValues[512];
|
float oscValues[512];
|
||||||
float oscZoom;
|
float oscZoom;
|
||||||
|
float oscWindowSize;
|
||||||
bool oscZoomSlider;
|
bool oscZoomSlider;
|
||||||
|
|
||||||
// per-channel oscilloscope
|
// per-channel oscilloscope
|
||||||
|
|
|
@ -21,9 +21,6 @@
|
||||||
#include "imgui_internal.h"
|
#include "imgui_internal.h"
|
||||||
#include <imgui.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() {
|
void FurnaceGUI::readOsc() {
|
||||||
int writePos=e->oscWritePos;
|
int writePos=e->oscWritePos;
|
||||||
int readPos=e->oscReadPos;
|
int readPos=e->oscReadPos;
|
||||||
|
@ -47,8 +44,11 @@ void FurnaceGUI::readOsc() {
|
||||||
total=oscTotal+(bias>>6);
|
total=oscTotal+(bias>>6);
|
||||||
if (total>avail) total=avail;
|
if (total>avail) total=avail;
|
||||||
//printf("total: %d. avail: %d bias: %d\n",total,avail,bias);
|
//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++) {
|
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;
|
oscValues[i]=(e->oscBuf[0][pos]+e->oscBuf[1][pos])*0.5f;
|
||||||
if (oscValues[i]>0.001f || oscValues[i]<-0.001f) {
|
if (oscValues[i]>0.001f || oscValues[i]<-0.001f) {
|
||||||
WAKE_UP;
|
WAKE_UP;
|
||||||
|
@ -97,6 +97,14 @@ void FurnaceGUI::drawOsc() {
|
||||||
if (oscZoom>2.0) oscZoom=2.0;
|
if (oscZoom>2.0) oscZoom=2.0;
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
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();
|
ImDrawList* dl=ImGui::GetWindowDrawList();
|
||||||
|
|
Loading…
Reference in a new issue