GUI: prevent resampling under 100Hz
This commit is contained in:
parent
cfb47d8b06
commit
7d9df63a39
|
@ -1189,6 +1189,7 @@ bool DivSample::resampleSinc(double sRate, double tRate) {
|
|||
|
||||
bool DivSample::resample(double sRate, double tRate, int filter) {
|
||||
if (depth!=DIV_SAMPLE_DEPTH_8BIT && depth!=DIV_SAMPLE_DEPTH_16BIT) return false;
|
||||
if (tRate<100) return false;
|
||||
switch (filter) {
|
||||
case DIV_RESAMPLE_NONE:
|
||||
return resampleNone(sRate,tRate);
|
||||
|
|
|
@ -1110,7 +1110,7 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
}
|
||||
if (ImGui::BeginPopupContextItem("SResampleOpt",ImGuiPopupFlags_MouseButtonLeft)) {
|
||||
if (ImGui::InputDouble("Rate##SRRate",&resampleTarget,1.0,50.0,"%g")) {
|
||||
if (resampleTarget<1) resampleTarget=1;
|
||||
if (resampleTarget<100) resampleTarget=100;
|
||||
if (resampleTarget>96000) resampleTarget=96000;
|
||||
}
|
||||
double factor=resampleTarget/(double)targetRate;
|
||||
|
@ -1118,16 +1118,18 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
if (ImGui::InputScalar("Length##SRLen",ImGuiDataType_U32,&targetLength, &_ONE, &_SIXTEEN)) {
|
||||
if (targetLength<1) targetLength=1;
|
||||
resampleTarget=targetRate*targetLength/(double)sample->samples;
|
||||
if (resampleTarget<1) resampleTarget=1;
|
||||
if (resampleTarget<100) resampleTarget=100;
|
||||
if (resampleTarget>96000) resampleTarget=96000;
|
||||
}
|
||||
if (ImGui::InputDouble(_("Factor"),&factor,0.125,0.5,"%g")) {
|
||||
resampleTarget=(double)targetRate*factor;
|
||||
if (resampleTarget<1) resampleTarget=1;
|
||||
if (resampleTarget<100) resampleTarget=100;
|
||||
if (resampleTarget>96000) resampleTarget=96000;
|
||||
}
|
||||
if (ImGui::Button("0.5x")) {
|
||||
resampleTarget*=0.5;
|
||||
if (resampleTarget<100) resampleTarget=100;
|
||||
if (resampleTarget>96000) resampleTarget=96000;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("==")) {
|
||||
|
@ -1136,13 +1138,15 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
ImGui::SameLine();
|
||||
if (ImGui::Button("2.0x")) {
|
||||
resampleTarget*=2.0;
|
||||
if (resampleTarget<100) resampleTarget=100;
|
||||
if (resampleTarget>96000) resampleTarget=96000;
|
||||
}
|
||||
ImGui::Combo(_("Filter"),&resampleStrat,LocalizedComboGetter,resampleStrats,6);
|
||||
if (ImGui::Button(_("Resample"))) {
|
||||
sample->prepareUndo(true);
|
||||
e->lockEngine([this,sample,targetRate]() {
|
||||
if (!sample->resample(targetRate,resampleTarget,resampleStrat)) {
|
||||
showError(_("couldn't resample! make sure your sample is 8 or 16-bit."));
|
||||
showError(_("couldn't resample! make sure your sample is 8 or 16-bit and that the target rate is at least 100Hz."));
|
||||
}
|
||||
e->renderSamples(curSample);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue