GUI: add oscilloscope window size setting
and also remember last zoom/winSize value
This commit is contained in:
parent
2119675b10
commit
fc0a51ed56
4 changed files with 24 additions and 4 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue