Prepare to add hasSamplePtrHeader and hasSampleInstHeader in dispatch (WIP)
for refresh sample memory when loop/end pointer and instrument parameter changed. Also, this PR has minor code style fixes and add warning in MultiPCM sample map usage.
This commit is contained in:
parent
4ed40d37d6
commit
bd8d9a56a0
|
@ -989,6 +989,20 @@ class DivDispatch {
|
|||
*/
|
||||
virtual size_t getSampleMemUsage(int index=0);
|
||||
|
||||
/**
|
||||
* check whether chip has sample pointer header in sample memory.
|
||||
* @param index the memory index.
|
||||
* @return whether it did.
|
||||
*/
|
||||
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 hasSampleInstHeader(int index=0);
|
||||
|
||||
/**
|
||||
* check whether sample has been loaded in memory.
|
||||
* @param index index.
|
||||
|
|
|
@ -2648,6 +2648,15 @@ int DivEngine::addInstrument(int refChan, DivInstrumentType fallbackType) {
|
|||
song.insLen=insCount+1;
|
||||
checkAssetDir(song.insDir,song.ins.size());
|
||||
saveLock.unlock();
|
||||
bool hasSampleInst=false;
|
||||
for (int s=0; s<song.systemLen; s++) {
|
||||
if (disCont[s].dispatch->hasSampleInstHeader()) {
|
||||
hasSampleInst=true;
|
||||
}
|
||||
}
|
||||
if (hasSampleInst) {
|
||||
renderSamplesP();
|
||||
}
|
||||
BUSY_END;
|
||||
return insCount;
|
||||
}
|
||||
|
@ -2665,6 +2674,15 @@ int DivEngine::addInstrumentPtr(DivInstrument* which) {
|
|||
checkAssetDir(song.waveDir,song.wave.size());
|
||||
checkAssetDir(song.sampleDir,song.sample.size());
|
||||
saveLock.unlock();
|
||||
bool hasSampleInst=false;
|
||||
for (int s=0; s<song.systemLen; s++) {
|
||||
if (disCont[s].dispatch->hasSampleInstHeader()) {
|
||||
hasSampleInst=true;
|
||||
}
|
||||
}
|
||||
if (hasSampleInst) {
|
||||
renderSamplesP();
|
||||
}
|
||||
BUSY_END;
|
||||
return song.insLen;
|
||||
}
|
||||
|
@ -2700,6 +2718,15 @@ void DivEngine::delInstrumentUnsafe(int index) {
|
|||
}
|
||||
removeAsset(song.insDir,index);
|
||||
checkAssetDir(song.insDir,song.ins.size());
|
||||
bool hasSampleInst=false;
|
||||
for (int s=0; s<song.systemLen; s++) {
|
||||
if (disCont[s].dispatch->hasSampleInstHeader()) {
|
||||
hasSampleInst=true;
|
||||
}
|
||||
}
|
||||
if (hasSampleInst) {
|
||||
renderSamplesP();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -213,6 +213,14 @@ size_t DivDispatch::getSampleMemUsage(int index) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool DivDispatch::hasSamplePtrHeader(int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DivDispatch::hasSampleInstHeader(int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const DivMemoryComposition* DivDispatch::getMemCompo(int index) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -3244,6 +3244,14 @@ size_t DivPlatformOPL::getSampleMemUsage(int index) {
|
|||
(index==0 && adpcmChan>=0)?adpcmBMemLen:0;
|
||||
}
|
||||
|
||||
bool DivPlatformOPL::hasSamplePtrHeader(int index) {
|
||||
return (index==0 && pcmChanOffs>=0);
|
||||
}
|
||||
|
||||
bool DivPlatformOPL::hasSampleInstHeader(int index) {
|
||||
return (index==0 && pcmChanOffs>=0);
|
||||
}
|
||||
|
||||
bool DivPlatformOPL::isSampleLoaded(int index, int sample) {
|
||||
if (index!=0) return false;
|
||||
if (sample<0 || sample>32767) return false;
|
||||
|
|
|
@ -218,6 +218,8 @@ class DivPlatformOPL: public DivDispatch {
|
|||
const void* getSampleMem(int index);
|
||||
size_t getSampleMemCapacity(int index);
|
||||
size_t getSampleMemUsage(int index);
|
||||
bool hasSamplePtrHeader(int index=0);
|
||||
bool hasSampleInstHeader(int index=0);
|
||||
bool isSampleLoaded(int index, int sample);
|
||||
const DivMemoryComposition* getMemCompo(int index);
|
||||
void renderSamples(int chipID);
|
||||
|
|
|
@ -964,6 +964,10 @@ size_t DivPlatformSNES::getSampleMemUsage(int index) {
|
|||
return index == 0 ? sampleMemLen : 0;
|
||||
}
|
||||
|
||||
bool DivPlatformSNES::hasSamplePtrHeader(int index) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DivPlatformSNES::isSampleLoaded(int index, int sample) {
|
||||
if (index!=0) return false;
|
||||
if (sample<0 || sample>32767) return false;
|
||||
|
|
|
@ -127,6 +127,7 @@ class DivPlatformSNES: public DivDispatch {
|
|||
const void* getSampleMem(int index=0);
|
||||
size_t getSampleMemCapacity(int index=0);
|
||||
size_t getSampleMemUsage(int index=0);
|
||||
bool hasSamplePtrHeader(int index=0);
|
||||
bool isSampleLoaded(int index, int sample);
|
||||
const DivMemoryComposition* getMemCompo(int index);
|
||||
void renderSamples(int chipID);
|
||||
|
|
|
@ -1861,7 +1861,13 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
|
|||
int sampleCountBefore=e->song.sampleLen;
|
||||
std::vector<DivInstrument*> instruments=e->instrumentFromFile(path,false);
|
||||
if (!instruments.empty()) {
|
||||
if (e->song.sampleLen!=sampleCountBefore) {
|
||||
int hasSampleInst=false;
|
||||
for (int s=0; s<e->song.systemLen; s++) {
|
||||
if (e->getDispatch(s)->hasSampleInstHeader()) {
|
||||
hasSampleInst=true;
|
||||
}
|
||||
}
|
||||
if ((e->song.sampleLen!=sampleCountBefore) || hasSampleInst) {
|
||||
e->renderSamplesP();
|
||||
}
|
||||
if (curFileDialog==GUI_FILE_INS_OPEN_REPLACE) {
|
||||
|
@ -3928,7 +3934,13 @@ bool FurnaceGUI::loop() {
|
|||
DivWavetable* droppedWave=NULL;
|
||||
//DivSample* droppedSample=NULL;
|
||||
if (!instruments.empty()) {
|
||||
if (e->song.sampleLen!=sampleCountBefore) {
|
||||
bool hasSampleInst=false;
|
||||
for (int s=0; s<e->song.systemLen; s++) {
|
||||
if (e->getDispatch(s)->hasSampleInstHeader()) {
|
||||
hasSampleInst=true;
|
||||
}
|
||||
}
|
||||
if ((e->song.sampleLen!=sampleCountBefore) || hasSampleInst) {
|
||||
e->renderSamplesP();
|
||||
}
|
||||
if (!e->getWarnings().empty()) {
|
||||
|
@ -5521,7 +5533,13 @@ bool FurnaceGUI::loop() {
|
|||
instruments.push_back(j);
|
||||
}
|
||||
}
|
||||
if (e->song.sampleLen!=sampleCountBefore) {
|
||||
bool hasSampleInst=false;
|
||||
for (int s=0; s<e->song.systemLen; s++) {
|
||||
if (e->getDispatch(s)->hasSampleInstHeader()) {
|
||||
hasSampleInst=true;
|
||||
}
|
||||
}
|
||||
if ((e->song.sampleLen!=sampleCountBefore) || hasSampleInst) {
|
||||
e->renderSamplesP();
|
||||
}
|
||||
if (warn) {
|
||||
|
@ -5561,7 +5579,13 @@ bool FurnaceGUI::loop() {
|
|||
int sampleCountBefore=e->song.sampleLen;
|
||||
std::vector<DivInstrument*> instruments=e->instrumentFromFile(copyOfName.c_str(),true,settings.readInsNames);
|
||||
if (!instruments.empty()) {
|
||||
if (e->song.sampleLen!=sampleCountBefore) {
|
||||
bool hasSampleInst=false;
|
||||
for (int s=0; s<e->song.systemLen; s++) {
|
||||
if (e->getDispatch(s)->hasSampleInstHeader()) {
|
||||
hasSampleInst=true;
|
||||
}
|
||||
}
|
||||
if ((e->song.sampleLen!=sampleCountBefore) || hasSampleInst) {
|
||||
e->renderSamplesP();
|
||||
}
|
||||
if (!e->getWarnings().empty()) {
|
||||
|
|
|
@ -1982,6 +1982,22 @@ 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 hasSampleInst=false; \
|
||||
for (int s=0; s<e->song.systemLen; s++) { \
|
||||
if (e->getDispatch(s)->hasSampleInstHeader()) { \
|
||||
hasSampleInst=true; \
|
||||
} \
|
||||
} \
|
||||
if (hasSampleInst) { \
|
||||
e->renderSamplesP(curSample); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define PARAMETER MARK_MODIFIED; e->notifyInsChange(curIns); updateFMPreview=true;
|
||||
|
||||
String genericGuide(float value) {
|
||||
|
@ -3512,6 +3528,9 @@ void FurnaceGUI::insTabSample(DivInstrument* ins) {
|
|||
// Note map
|
||||
ImGui::BeginDisabled(ins->amiga.useWave);
|
||||
P(ImGui::Checkbox(_("Use sample map"),&ins->amiga.useNoteMap));
|
||||
if ((ins->type==DIV_INS_MULTIPCM) && ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip(_("Only for OPL4 PCM."));
|
||||
}
|
||||
if (ins->amiga.useNoteMap) {
|
||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left) && ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows)) sampleMapFocused=false;
|
||||
if (curWindowLast!=GUI_WINDOW_INS_EDIT) sampleMapFocused=false;
|
||||
|
@ -7885,17 +7904,17 @@ void FurnaceGUI::drawInsEdit() {
|
|||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
P(CWVSliderScalar("##Attack Rate",sliderSize,ImGuiDataType_U8,&ins->multipcm.ar,&_ZERO,&_FIFTEEN)); rightClickable
|
||||
PH(CWVSliderScalar("##Attack Rate",sliderSize,ImGuiDataType_U8,&ins->multipcm.ar,&_ZERO,&_FIFTEEN)); rightClickable
|
||||
ImGui::TableNextColumn();
|
||||
P(CWVSliderScalar("##Decay 1 Rate",sliderSize,ImGuiDataType_U8,&ins->multipcm.d1r,&_ZERO,&_FIFTEEN)); rightClickable
|
||||
PH(CWVSliderScalar("##Decay 1 Rate",sliderSize,ImGuiDataType_U8,&ins->multipcm.d1r,&_ZERO,&_FIFTEEN)); rightClickable
|
||||
ImGui::TableNextColumn();
|
||||
P(CWVSliderScalar("##Decay Level",sliderSize,ImGuiDataType_U8,&ins->multipcm.dl,&_ZERO,&_FIFTEEN)); rightClickable
|
||||
PH(CWVSliderScalar("##Decay Level",sliderSize,ImGuiDataType_U8,&ins->multipcm.dl,&_ZERO,&_FIFTEEN)); rightClickable
|
||||
ImGui::TableNextColumn();
|
||||
P(CWVSliderScalar("##Decay 2 Rate",sliderSize,ImGuiDataType_U8,&ins->multipcm.d2r,&_ZERO,&_FIFTEEN)); rightClickable
|
||||
PH(CWVSliderScalar("##Decay 2 Rate",sliderSize,ImGuiDataType_U8,&ins->multipcm.d2r,&_ZERO,&_FIFTEEN)); rightClickable
|
||||
ImGui::TableNextColumn();
|
||||
P(CWVSliderScalar("##Release Rate",sliderSize,ImGuiDataType_U8,&ins->multipcm.rr,&_ZERO,&_FIFTEEN)); rightClickable
|
||||
PH(CWVSliderScalar("##Release Rate",sliderSize,ImGuiDataType_U8,&ins->multipcm.rr,&_ZERO,&_FIFTEEN)); rightClickable
|
||||
ImGui::TableNextColumn();
|
||||
P(CWVSliderScalar("##Rate Correction",sliderSize,ImGuiDataType_U8,&ins->multipcm.rc,&_ZERO,&_FIFTEEN)); rightClickable
|
||||
PH(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();
|
||||
|
@ -7905,11 +7924,11 @@ void FurnaceGUI::drawInsEdit() {
|
|||
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.0);
|
||||
ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch,0.0);
|
||||
ImGui::TableNextColumn();
|
||||
P(CWSliderScalar(_("LFO Rate"),ImGuiDataType_U8,&ins->multipcm.lfo,&_ZERO,&_SEVEN)); rightClickable
|
||||
PH(CWSliderScalar(_("LFO Rate"),ImGuiDataType_U8,&ins->multipcm.lfo,&_ZERO,&_SEVEN)); rightClickable
|
||||
ImGui::TableNextColumn();
|
||||
P(CWSliderScalar(_("PM Depth"),ImGuiDataType_U8,&ins->multipcm.vib,&_ZERO,&_SEVEN)); rightClickable
|
||||
PH(CWSliderScalar(_("PM Depth"),ImGuiDataType_U8,&ins->multipcm.vib,&_ZERO,&_SEVEN)); rightClickable
|
||||
ImGui::TableNextColumn();
|
||||
P(CWSliderScalar(_("AM Depth"),ImGuiDataType_U8,&ins->multipcm.am,&_ZERO,&_SEVEN)); rightClickable
|
||||
PH(CWSliderScalar(_("AM Depth"),ImGuiDataType_U8,&ins->multipcm.am,&_ZERO,&_SEVEN)); rightClickable
|
||||
ImGui::EndTable();
|
||||
}
|
||||
P(ImGui::Checkbox(_("Damp"),&ins->multipcm.damp));
|
||||
|
|
|
@ -60,6 +60,18 @@ const double timeMultipliers[13]={
|
|||
_x+=_text; \
|
||||
}
|
||||
|
||||
// with sample pointer header in sample memory
|
||||
#define REFRESH_SAMPLE \
|
||||
bool hasSamplePtr=false; \
|
||||
for (int s=0; s<e->song.systemLen; s++) { \
|
||||
if (e->getDispatch(s)->hasSamplePtrHeader()) { \
|
||||
hasSamplePtr=true; \
|
||||
} \
|
||||
} \
|
||||
if (hasSamplePtr) { \
|
||||
e->renderSamplesP(curSample); \
|
||||
}
|
||||
|
||||
#define MAX_RATE(_name,_x) \
|
||||
if (e->isPreviewingSample()) { \
|
||||
if ((int)e->getSamplePreviewRate()>(int)(_x)) { \
|
||||
|
@ -638,9 +650,7 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
sample->loopEnd=sample->samples;*/
|
||||
}
|
||||
updateSampleTex=true;
|
||||
if (e->getSampleFormatMask()&(1U<<DIV_SAMPLE_DEPTH_BRR)) {
|
||||
e->renderSamplesP(curSample);
|
||||
}
|
||||
REFRESH_SAMPLE
|
||||
}
|
||||
popWarningColor();
|
||||
if (ImGui::IsItemHovered() && (!warnLoop.empty() || sample->depth==DIV_SAMPLE_DEPTH_BRR)) {
|
||||
|
@ -877,9 +887,7 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
sample->loopStart=sample->loopEnd;
|
||||
}
|
||||
updateSampleTex=true;
|
||||
if (e->getSampleFormatMask()&(1U<<DIV_SAMPLE_DEPTH_BRR)) {
|
||||
e->renderSamplesP(curSample);
|
||||
}
|
||||
REFRESH_SAMPLE
|
||||
}
|
||||
if (ImGui::IsItemActive()) {
|
||||
keepLoopAlive=true;
|
||||
|
@ -920,9 +928,7 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
sample->loopEnd=sample->samples;
|
||||
}
|
||||
updateSampleTex=true;
|
||||
if (e->getSampleFormatMask()&(1U<<DIV_SAMPLE_DEPTH_BRR)) {
|
||||
e->renderSamplesP(curSample);
|
||||
}
|
||||
REFRESH_SAMPLE
|
||||
}
|
||||
if (ImGui::IsItemActive()) {
|
||||
keepLoopAlive=true;
|
||||
|
|
Loading…
Reference in a new issue