mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-27 06:53:01 +00:00
GUI: add note/fine to sample editor rate
also deprecate compat rate
This commit is contained in:
parent
515e7a5a1d
commit
2da7002fc8
3 changed files with 98 additions and 13 deletions
|
@ -5923,6 +5923,7 @@ FurnaceGUI::FurnaceGUI():
|
||||||
sampleSelStart(-1),
|
sampleSelStart(-1),
|
||||||
sampleSelEnd(-1),
|
sampleSelEnd(-1),
|
||||||
sampleInfo(true),
|
sampleInfo(true),
|
||||||
|
sampleCompatRate(false),
|
||||||
sampleDragActive(false),
|
sampleDragActive(false),
|
||||||
sampleDragMode(false),
|
sampleDragMode(false),
|
||||||
sampleDrag16(false),
|
sampleDrag16(false),
|
||||||
|
|
|
@ -1616,7 +1616,7 @@ class FurnaceGUI {
|
||||||
int resampleStrat;
|
int resampleStrat;
|
||||||
float amplifyVol;
|
float amplifyVol;
|
||||||
int sampleSelStart, sampleSelEnd;
|
int sampleSelStart, sampleSelEnd;
|
||||||
bool sampleInfo;
|
bool sampleInfo, sampleCompatRate;
|
||||||
bool sampleDragActive, sampleDragMode, sampleDrag16, sampleZoomAuto;
|
bool sampleDragActive, sampleDragMode, sampleDrag16, sampleZoomAuto;
|
||||||
void* sampleDragTarget;
|
void* sampleDragTarget;
|
||||||
ImVec2 sampleDragStart;
|
ImVec2 sampleDragStart;
|
||||||
|
|
|
@ -168,7 +168,20 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Text("Info");
|
ImGui::Text("Info");
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text("Rate");
|
pushToggleColors(!sampleCompatRate);
|
||||||
|
if (ImGui::Button("Rate")) {
|
||||||
|
sampleCompatRate=false;
|
||||||
|
}
|
||||||
|
popToggleColors();
|
||||||
|
ImGui::SameLine();
|
||||||
|
pushToggleColors(sampleCompatRate);
|
||||||
|
if (ImGui::Button("Compat Rate")) {
|
||||||
|
sampleCompatRate=true;
|
||||||
|
}
|
||||||
|
if (ImGui::IsItemHovered()) {
|
||||||
|
ImGui::SetTooltip("used in DefleMask-compatible sample mode (17xx), in where samples are mapped to an octave.");
|
||||||
|
}
|
||||||
|
popToggleColors();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
bool doLoop=(sample->isLoopable());
|
bool doLoop=(sample->isLoopable());
|
||||||
if (ImGui::Checkbox("Loop",&doLoop)) { MARK_MODIFIED
|
if (ImGui::Checkbox("Loop",&doLoop)) { MARK_MODIFIED
|
||||||
|
@ -243,21 +256,92 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
int targetRate=sampleCompatRate?sample->rate:sample->centerRate;
|
||||||
ImGui::Text("C-4 (Hz)");
|
int sampleNote=round(64.0+(128.0*12.0*log((double)targetRate/8363.0)/log(2.0)));
|
||||||
ImGui::SameLine();
|
int sampleNoteCoarse=60+(sampleNote>>7);
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
int sampleNoteFine=(sampleNote&127)-64;
|
||||||
if (ImGui::InputInt("##SampleCenter",&sample->centerRate,10,200)) { MARK_MODIFIED
|
|
||||||
if (sample->centerRate<100) sample->centerRate=100;
|
if (sampleNoteCoarse<0) {
|
||||||
if (sample->centerRate>65535) sample->centerRate=65535;
|
sampleNoteCoarse=0;
|
||||||
|
sampleNoteFine=-64;
|
||||||
|
}
|
||||||
|
if (sampleNoteCoarse>119) {
|
||||||
|
sampleNoteCoarse=119;
|
||||||
|
sampleNoteFine=63;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Text("Compat");
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("Hz");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||||
if (ImGui::InputInt("##SampleRate",&sample->rate,10,200)) { MARK_MODIFIED
|
if (ImGui::InputInt("##SampleRate",&targetRate,10,200)) { MARK_MODIFIED
|
||||||
if (sample->rate<100) sample->rate=100;
|
if (targetRate<100) targetRate=100;
|
||||||
if (sample->rate>96000) sample->rate=96000;
|
if (targetRate>192000) targetRate=192000;
|
||||||
|
|
||||||
|
if (sampleCompatRate) {
|
||||||
|
sample->rate=targetRate;
|
||||||
|
} else {
|
||||||
|
sample->centerRate=targetRate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Text("Note");
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||||
|
if (ImGui::BeginCombo("##SampleNote",noteNames[sampleNoteCoarse+60])) {
|
||||||
|
char temp[1024];
|
||||||
|
for (int i=0; i<120; i++) {
|
||||||
|
snprintf(temp,1023,"%s##_SRN%d",noteNames[i+60],i);
|
||||||
|
if (ImGui::Selectable(temp,i==sampleNoteCoarse)) {
|
||||||
|
sampleNoteCoarse=i;
|
||||||
|
|
||||||
|
sampleNote=((sampleNoteCoarse-60)<<7)+sampleNoteFine;
|
||||||
|
|
||||||
|
targetRate=8363.0*pow(2.0,(double)sampleNote/(128.0*12.0));
|
||||||
|
if (targetRate<100) targetRate=100;
|
||||||
|
if (targetRate>192000) targetRate=192000;
|
||||||
|
|
||||||
|
if (sampleCompatRate) {
|
||||||
|
sample->rate=targetRate;
|
||||||
|
} else {
|
||||||
|
sample->centerRate=targetRate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::EndCombo();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Text("Fine");
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||||
|
int prevFine=sampleNoteFine;
|
||||||
|
int prevSampleRate=targetRate;
|
||||||
|
if (ImGui::InputInt("##SampleFine",&sampleNoteFine,1,10)) { MARK_MODIFIED
|
||||||
|
if (sampleNoteFine>63) sampleNoteFine=63;
|
||||||
|
if (sampleNoteFine<-64) sampleNoteFine=-64;
|
||||||
|
|
||||||
|
sampleNote=((sampleNoteCoarse-60)<<7)+sampleNoteFine;
|
||||||
|
|
||||||
|
targetRate=round(8363.0*pow(2.0,(double)sampleNote/(128.0*12.0)));
|
||||||
|
|
||||||
|
if (targetRate==prevSampleRate) {
|
||||||
|
if (prevFine==sampleNoteFine) {
|
||||||
|
// do nothing
|
||||||
|
} else if (prevFine>sampleNoteFine) { // coarse incr/decr due to precision loss
|
||||||
|
targetRate--;
|
||||||
|
} else {
|
||||||
|
targetRate++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetRate<100) targetRate=100;
|
||||||
|
if (targetRate>192000) targetRate=192000;
|
||||||
|
|
||||||
|
if (sampleCompatRate) {
|
||||||
|
sample->rate=targetRate;
|
||||||
|
} else {
|
||||||
|
sample->centerRate=targetRate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
|
Loading…
Reference in a new issue