remove hasSampleInsHeader()

- it is only used by MultiPCM
- an alternative approach is in place
This commit is contained in:
tildearrow 2025-09-14 14:21:31 -05:00
parent c1b7a06a37
commit 3a06e7b963
7 changed files with 21 additions and 92 deletions

View file

@ -1008,13 +1008,6 @@ class DivDispatch {
*/
virtual bool hasSamplePtrHeader(int index=0);
/**
* check whether chip has sample instrument header in sample memory.
* @param index the memory index.
* @return whether it did.
*/
virtual bool hasSampleInsHeader(int index=0);
/**
* check whether sample has been loaded in memory.
* @param index index.

View file

@ -2681,6 +2681,9 @@ void DivEngine::loadTempIns(DivInstrument* which) {
tempIns=new DivInstrument;
}
*tempIns=*which;
for (int i=0; i<song.systemLen; i++) {
disCont[i].dispatch->notifyInsAddition(i);
}
BUSY_END;
}
@ -2706,15 +2709,6 @@ void DivEngine::delInstrumentUnsafe(int index) {
}
removeAsset(song.insDir,index);
checkAssetDir(song.insDir,song.ins.size());
bool hasSampleIns=false;
for (int s=0; s<song.systemLen; s++) {
if (disCont[s].dispatch->hasSampleInsHeader()) {
hasSampleIns=true;
}
}
if (hasSampleIns) {
renderSamplesP();
}
}
}

View file

@ -221,10 +221,6 @@ bool DivDispatch::hasSamplePtrHeader(int index) {
return false;
}
bool DivDispatch::hasSampleInsHeader(int index) {
return false;
}
size_t DivDispatch::getSampleMemOffset(int index) {
return 0;
}

View file

@ -566,10 +566,6 @@ bool DivPlatformMultiPCM::hasSamplePtrHeader(int index) {
return (index==0);
}
bool DivPlatformMultiPCM::hasSampleInsHeader(int index) {
return (index==0);
}
bool DivPlatformMultiPCM::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>32767) return false;

View file

@ -130,7 +130,6 @@ class DivPlatformMultiPCM: public DivDispatch {
size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index);
bool hasSamplePtrHeader(int index=0);
bool hasSampleInsHeader(int index=0);
bool isSampleLoaded(int index, int sample);
const DivMemoryComposition* getMemCompo(int index);
void renderSamples(int chipID);

View file

@ -1861,13 +1861,7 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
int sampleCountBefore=e->song.sampleLen;
std::vector<DivInstrument*> instruments=e->instrumentFromFile(path,false);
if (!instruments.empty()) {
int hasSampleIns=false;
for (int s=0; s<e->song.systemLen; s++) {
if (e->getDispatch(s)->hasSampleInsHeader()) {
hasSampleIns=true;
}
}
if ((e->song.sampleLen!=sampleCountBefore) || hasSampleIns) {
if (e->song.sampleLen!=sampleCountBefore) {
e->renderSamplesP();
}
if (curFileDialog==GUI_FILE_INS_OPEN_REPLACE) {
@ -1876,6 +1870,7 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
}
if (prevIns>=0 && prevIns<=(int)e->song.ins.size()) {
*e->song.ins[prevIns]=*instruments[0];
e->notifyInsChange(prevIns);
}
} else {
e->loadTempIns(instruments[0]);
@ -3934,13 +3929,7 @@ bool FurnaceGUI::loop() {
DivWavetable* droppedWave=NULL;
//DivSample* droppedSample=NULL;
if (!instruments.empty()) {
bool hasSampleIns=false;
for (int s=0; s<e->song.systemLen; s++) {
if (e->getDispatch(s)->hasSampleInsHeader()) {
hasSampleIns=true;
}
}
if ((e->song.sampleLen!=sampleCountBefore) || hasSampleIns) {
if (e->song.sampleLen!=sampleCountBefore) {
e->renderSamplesP();
}
if (!e->getWarnings().empty()) {
@ -5062,6 +5051,7 @@ bool FurnaceGUI::loop() {
if (prevInsData!=NULL) {
if (prevIns>=0 && prevIns<(int)e->song.ins.size()) {
*e->song.ins[prevIns]=*prevInsData;
e->notifyInsChange(prevIns);
}
}
} else {
@ -5533,13 +5523,7 @@ bool FurnaceGUI::loop() {
instruments.push_back(j);
}
}
bool hasSampleIns=false;
for (int s=0; s<e->song.systemLen; s++) {
if (e->getDispatch(s)->hasSampleInsHeader()) {
hasSampleIns=true;
}
}
if ((e->song.sampleLen!=sampleCountBefore) || hasSampleIns) {
if (e->song.sampleLen!=sampleCountBefore) {
e->renderSamplesP();
}
if (warn) {
@ -5579,13 +5563,7 @@ bool FurnaceGUI::loop() {
int sampleCountBefore=e->song.sampleLen;
std::vector<DivInstrument*> instruments=e->instrumentFromFile(copyOfName.c_str(),true,settings.readInsNames);
if (!instruments.empty()) {
bool hasSampleIns=false;
for (int s=0; s<e->song.systemLen; s++) {
if (e->getDispatch(s)->hasSampleInsHeader()) {
hasSampleIns=true;
}
}
if ((e->song.sampleLen!=sampleCountBefore) || hasSampleIns) {
if (e->song.sampleLen!=sampleCountBefore) {
e->renderSamplesP();
}
if (!e->getWarnings().empty()) {
@ -5603,6 +5581,7 @@ bool FurnaceGUI::loop() {
// reset macro zoom
memset(e->song.ins[curIns]->temp.vZoom,-1,sizeof(e->song.ins[curIns]->temp.vZoom));
MARK_MODIFIED;
e->notifyInsChange(curIns);
} else {
showError(_("...but you haven't selected an instrument!"));
}
@ -6816,6 +6795,7 @@ bool FurnaceGUI::loop() {
*e->song.ins[curIns]=*i.first;
// reset macro zoom
memset(e->song.ins[curIns]->temp.vZoom,-1,sizeof(e->song.ins[curIns]->temp.vZoom));
e->notifyInsChange(curIns);
} else {
showError(_("...but you haven't selected an instrument!"));
}

View file

@ -1982,35 +1982,8 @@ void FurnaceGUI::drawGBEnv(unsigned char vol, unsigned char len, unsigned char s
updateFMPreview=true; \
}
// with instrument header in sample memory
#define PH(x) if (x) { \
MARK_MODIFIED; \
e->notifyInsChange(curIns); \
updateFMPreview=true; \
bool hasSampleIns=false; \
for (int s=0; s<e->song.systemLen; s++) { \
if (e->getDispatch(s)->hasSampleInsHeader()) { \
hasSampleIns=true; \
} \
} \
if (hasSampleIns) { \
e->renderSamplesP(curSample); \
} \
}
#define PARAMETER MARK_MODIFIED; e->notifyInsChange(curIns); updateFMPreview=true;
#define REFRESH_INSTRUMENTS \
bool hasSampleIns=false; \
for (int s=0; s<e->song.systemLen; s++) { \
if (e->getDispatch(s)->hasSampleInsHeader()) { \
hasSampleIns=true; \
} \
} \
if (hasSampleIns) { \
e->renderSamplesP(curSample); \
}
String genericGuide(float value) {
return fmt::sprintf("%d",(int)value);
}
@ -3505,7 +3478,6 @@ void FurnaceGUI::insTabSample(DivInstrument* ins) {
id=fmt::sprintf("%d: %s",i,e->song.sample[i]->name);
if (ImGui::Selectable(id.c_str(),ins->amiga.initSample==i)) { PARAMETER
ins->amiga.initSample=i;
REFRESH_INSTRUMENTS
}
}
ImGui::EndCombo();
@ -6780,7 +6752,6 @@ void FurnaceGUI::drawInsEdit() {
// reset macro zoom
memset(ins->temp.vZoom,-1,sizeof(ins->temp.vZoom));
REFRESH_INSTRUMENTS
}
}
ImGui::EndCombo();
@ -7917,17 +7888,17 @@ void FurnaceGUI::drawInsEdit() {
ImGui::TableNextRow();
ImGui::TableNextColumn();
PH(CWVSliderScalar("##Attack Rate",sliderSize,ImGuiDataType_U8,&ins->multipcm.ar,&_ZERO,&_FIFTEEN)); rightClickable
P(CWVSliderScalar("##Attack Rate",sliderSize,ImGuiDataType_U8,&ins->multipcm.ar,&_ZERO,&_FIFTEEN)); rightClickable
ImGui::TableNextColumn();
PH(CWVSliderScalar("##Decay 1 Rate",sliderSize,ImGuiDataType_U8,&ins->multipcm.d1r,&_ZERO,&_FIFTEEN)); rightClickable
P(CWVSliderScalar("##Decay 1 Rate",sliderSize,ImGuiDataType_U8,&ins->multipcm.d1r,&_ZERO,&_FIFTEEN)); rightClickable
ImGui::TableNextColumn();
PH(CWVSliderScalar("##Decay Level",sliderSize,ImGuiDataType_U8,&ins->multipcm.dl,&_ZERO,&_FIFTEEN)); rightClickable
P(CWVSliderScalar("##Decay Level",sliderSize,ImGuiDataType_U8,&ins->multipcm.dl,&_ZERO,&_FIFTEEN)); rightClickable
ImGui::TableNextColumn();
PH(CWVSliderScalar("##Decay 2 Rate",sliderSize,ImGuiDataType_U8,&ins->multipcm.d2r,&_ZERO,&_FIFTEEN)); rightClickable
P(CWVSliderScalar("##Decay 2 Rate",sliderSize,ImGuiDataType_U8,&ins->multipcm.d2r,&_ZERO,&_FIFTEEN)); rightClickable
ImGui::TableNextColumn();
PH(CWVSliderScalar("##Release Rate",sliderSize,ImGuiDataType_U8,&ins->multipcm.rr,&_ZERO,&_FIFTEEN)); rightClickable
P(CWVSliderScalar("##Release Rate",sliderSize,ImGuiDataType_U8,&ins->multipcm.rr,&_ZERO,&_FIFTEEN)); rightClickable
ImGui::TableNextColumn();
PH(CWVSliderScalar("##Rate Correction",sliderSize,ImGuiDataType_U8,&ins->multipcm.rc,&_ZERO,&_FIFTEEN)); rightClickable
P(CWVSliderScalar("##Rate Correction",sliderSize,ImGuiDataType_U8,&ins->multipcm.rc,&_ZERO,&_FIFTEEN)); rightClickable
ImGui::TableNextColumn();
drawFMEnv(0,ins->multipcm.ar,ins->multipcm.d1r,ins->multipcm.d2r,ins->multipcm.rr,ins->multipcm.dl,0,0,0,127,15,15,ImVec2(ImGui::GetContentRegionAvail().x,sliderSize.y),ins->type);
ImGui::EndTable();
@ -7937,11 +7908,11 @@ void FurnaceGUI::drawInsEdit() {
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.0);
ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch,0.0);
ImGui::TableNextColumn();
PH(CWSliderScalar(_("LFO Rate"),ImGuiDataType_U8,&ins->multipcm.lfo,&_ZERO,&_SEVEN)); rightClickable
P(CWSliderScalar(_("LFO Rate"),ImGuiDataType_U8,&ins->multipcm.lfo,&_ZERO,&_SEVEN)); rightClickable
ImGui::TableNextColumn();
PH(CWSliderScalar(_("PM Depth"),ImGuiDataType_U8,&ins->multipcm.vib,&_ZERO,&_SEVEN)); rightClickable
P(CWSliderScalar(_("PM Depth"),ImGuiDataType_U8,&ins->multipcm.vib,&_ZERO,&_SEVEN)); rightClickable
ImGui::TableNextColumn();
PH(CWSliderScalar(_("AM Depth"),ImGuiDataType_U8,&ins->multipcm.am,&_ZERO,&_SEVEN)); rightClickable
P(CWSliderScalar(_("AM Depth"),ImGuiDataType_U8,&ins->multipcm.am,&_ZERO,&_SEVEN)); rightClickable
ImGui::EndTable();
}
P(ImGui::Checkbox(_("Damp"),&ins->multipcm.damp));