resample to size

This commit is contained in:
Eknous-P 2025-08-17 18:05:37 +04:00 committed by tildearrow
parent 70d0be5bfe
commit fa56ea10bc
2 changed files with 15 additions and 9 deletions

1
.gitignore vendored
View file

@ -24,6 +24,7 @@ android/.gradle/
android/app/build/
android/app/.cxx/
.vs/
.idea/
CMakeSettings.json
CMakePresets.json
extern/imgui_patched/examples/

View file

@ -30,6 +30,7 @@
#include "guiConst.h"
#include "sampleUtil.h"
#include "util.h"
#include "intConst.h"
#define SWAP_COLOR_ARGB(x) \
x=(x&0xff00ff00)|((x&0xff)<<16)|((x&0xff0000)>>16);
@ -1108,12 +1109,22 @@ void FurnaceGUI::drawSampleEdit() {
ImGui::OpenPopup("SResampleOpt");
}
if (ImGui::BeginPopupContextItem("SResampleOpt",ImGuiPopupFlags_MouseButtonLeft)) {
ImGui::Text(_("Rate"));
if (ImGui::InputDouble("##SRRate",&resampleTarget,1.0,50.0,"%g")) {
if (ImGui::InputDouble("Rate##SRRate",&resampleTarget,1.0,50.0,"%g")) {
if (resampleTarget<0) resampleTarget=0;
if (resampleTarget>96000) resampleTarget=96000;
}
double factor=resampleTarget/(double)targetRate;
unsigned int targetLength=sample->samples*factor;
if (ImGui::InputScalar("Length##SRLen",ImGuiDataType_U32,&targetLength, &_ONE, &_SIXTEEN)) {
resampleTarget=targetRate/((double)sample->samples/targetLength);
if (resampleTarget<0) resampleTarget=0;
if (resampleTarget>96000) resampleTarget=96000;
}
if (ImGui::InputDouble(_("Factor"),&factor,0.125,0.5,"%g")) {
resampleTarget=(double)targetRate*factor;
if (resampleTarget<0) resampleTarget=0;
if (resampleTarget>96000) resampleTarget=96000;
}
ImGui::SameLine();
if (ImGui::Button("0.5x")) {
resampleTarget*=0.5;
}
@ -1125,12 +1136,6 @@ void FurnaceGUI::drawSampleEdit() {
if (ImGui::Button("2.0x")) {
resampleTarget*=2.0;
}
double factor=resampleTarget/(double)targetRate;
if (ImGui::InputDouble(_("Factor"),&factor,0.125,0.5,"%g")) {
resampleTarget=(double)targetRate*factor;
if (resampleTarget<0) resampleTarget=0;
if (resampleTarget>96000) resampleTarget=96000;
}
ImGui::Combo(_("Filter"),&resampleStrat,LocalizedComboGetter,resampleStrats,6);
if (ImGui::Button(_("Resample"))) {
sample->prepareUndo(true);