Skip to content

Commit

Permalink
detect whether opened sample is a bank
Browse files Browse the repository at this point in the history
and disable sample bank search code
also make the mono label not part of the sample name
  • Loading branch information
Eknous-P committed Jan 11, 2025
1 parent 061c939 commit 48f6076
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/engine/fileOpsSample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ std::vector<DivSample*> DivEngine::sampleFromFile(const char* path) {
samples[c]=new DivSample;
if (isNotMono) {
if (c==sampleChans) {
samples[c]->name=stripPath+"_mono";
samples[c]->name=stripPath;
} else {
if (sampleChans==2) {
samples[c]->name=stripPath+("_L\00_R"+3*c);
Expand Down
31 changes: 22 additions & 9 deletions src/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5350,6 +5350,18 @@ bool FurnaceGUI::loop() {
for (DivSample* s: samples) { // ask which samples to load!
pendingSamples.push_back(std::make_pair(s,false));
}
const char* ext=strrchr(i.c_str(),'.');
String extS;
for (; *ext; ext++) {
char i=*ext;
if (i>='A' && i<='Z') {
i+='a'-'A';
}
extS+=i;
}
isPendingSampleBank=(extS == ".pps" || extS == ".ppc" || extS == ".pvi" ||
extS == ".pdx" || extS == ".pzi" || extS == ".p86" ||
extS == ".p");
displayPendingSamples=true;
replacePendingSample=false;
}
Expand Down Expand Up @@ -6648,11 +6660,9 @@ bool FurnaceGUI::loop() {
bool quitPlease=false;

ImGui::AlignTextToFramePadding();
if (/*settings.polySamples*/1) { // TODO: detect whether loaded samples are from a multichannel sample
ImGui::Text(_("this sample has multiple channels! select which ones to load:"));
} else {
ImGui::Text(_("this is a sample bank! select which ones to load:"));
}
ImGui::Text("%s %s",
isPendingSampleBank?_("this is a sample bank!"):_("this sample has multiple channels!"),
replacePendingSample?_("select which ones to replace with:"):_("select which ones to load:"));
ImGui::SameLine();
if (ImGui::Button(_("All"))) {
for (std::pair<DivSample*,bool>& i: pendingSamples) {
Expand All @@ -6676,11 +6686,13 @@ bool FurnaceGUI::loop() {
if (ImGui::BeginTable("PendingSamplesList",1,ImGuiTableFlags_ScrollY,ImVec2(0.0f,sizeY))) {
// whats this search query thing? i dont see any search inputs
// looking at the git blame for here... incomplete backport?
if (sampleBankSearchQuery.empty()) {
// disabling for now...
// if (sampleBankSearchQuery.empty()) {
for (size_t i=0; i<pendingSamples.size(); i++) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
String id=fmt::sprintf("%d: %s",(int)i,pendingSamples[i].first->name);
if (i==pendingSamples.size()-1) id+=" (mono)";
if (pendingInsSingle) {
if (ImGui::Selectable(id.c_str())) {
pendingSamples[i].second=true;
Expand All @@ -6701,7 +6713,7 @@ bool FurnaceGUI::loop() {
}
if (pendingSamples[i].second) anySelected=true;
}
} else { // display search results
/* } else { // display search results
if (reissueSearch) {
String lowerCase=sampleBankSearchQuery;
Expand Down Expand Up @@ -6753,7 +6765,7 @@ bool FurnaceGUI::loop() {
}
}
}
}
}*/
ImGui::EndTable();
}

Expand Down Expand Up @@ -6788,7 +6800,7 @@ bool FurnaceGUI::loop() {
counter++;
}

curSample=(int)e->song.sample.size()-1;
if (!replacePendingSample) curSample=(int)e->song.sample.size()-1;
pendingSamples.clear();
}

Expand Down Expand Up @@ -8270,6 +8282,7 @@ FurnaceGUI::FurnaceGUI():
displayEditString(false),
displayPendingSamples(false),
replacePendingSample(false),
isPendingSampleBank(false),
displayExportingROM(false),
changeCoarse(false),
mobileEdit(false),
Expand Down
4 changes: 2 additions & 2 deletions src/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ class FurnaceGUI {
int sampleTexW, sampleTexH;
bool updateSampleTex;

String workingDir, fileName, clipboard, warnString, errorString, lastError, curFileName, nextFile, sysSearchQuery, newSongQuery, paletteQuery, sampleBankSearchQuery;
String workingDir, fileName, clipboard, warnString, errorString, lastError, curFileName, nextFile, sysSearchQuery, newSongQuery, paletteQuery /*, sampleBankSearchQuery*/;
String workingDirSong, workingDirIns, workingDirWave, workingDirSample, workingDirAudioExport;
String workingDirVGMExport, workingDirROMExport;
String workingDirFont, workingDirColors, workingDirKeybinds;
Expand Down Expand Up @@ -1648,7 +1648,7 @@ class FurnaceGUI {
bool displayNew, displayExport, displayPalette, fullScreen, preserveChanPos, sysDupCloneChannels, sysDupEnd, noteInputPoly, notifyWaveChange;
bool wantScrollListIns, wantScrollListWave, wantScrollListSample;
bool displayPendingIns, pendingInsSingle, displayPendingRawSample, snesFilterHex, modTableHex, displayEditString;
bool displayPendingSamples, replacePendingSample;
bool displayPendingSamples, replacePendingSample, isPendingSampleBank;
bool displayExportingROM;
bool changeCoarse;
bool mobileEdit;
Expand Down

0 comments on commit 48f6076

Please sign in to comment.