faster sample format conversion

don't render in all formats when converting
This commit is contained in:
tildearrow 2024-04-04 14:22:19 -05:00
parent 80fdc706d1
commit 0ddbc56b94
4 changed files with 8 additions and 7 deletions

View file

@ -52,9 +52,9 @@ class DivWorkPool;
#define EXTERN_BUSY_BEGIN_SOFT e->softLocked=true; e->isBusy.lock(); #define EXTERN_BUSY_BEGIN_SOFT e->softLocked=true; e->isBusy.lock();
#define EXTERN_BUSY_END e->isBusy.unlock(); e->softLocked=false; #define EXTERN_BUSY_END e->isBusy.unlock(); e->softLocked=false;
//#define DIV_UNSTABLE #define DIV_UNSTABLE
#define DIV_VERSION "0.6.2" #define DIV_VERSION "dev197"
#define DIV_ENGINE_VERSION 197 #define DIV_ENGINE_VERSION 197
// for imports // for imports
#define DIV_VERSION_MOD 0xff01 #define DIV_VERSION_MOD 0xff01

View file

@ -807,8 +807,8 @@ bool DivSample::insert(unsigned int pos, unsigned int length) {
return false; return false;
} }
void DivSample::convert(DivSampleDepth newDepth) { void DivSample::convert(DivSampleDepth newDepth, unsigned int formatMask) {
render(); render(formatMask|(1U<<newDepth));
depth=newDepth; depth=newDepth;
switch (depth) { switch (depth) {
case DIV_SAMPLE_DEPTH_1BIT: case DIV_SAMPLE_DEPTH_1BIT:
@ -845,7 +845,7 @@ void DivSample::convert(DivSampleDepth newDepth) {
default: default:
break; break;
} }
render(); render(formatMask|(1U<<newDepth));
} }
#define RESAMPLE_BEGIN \ #define RESAMPLE_BEGIN \
@ -1309,6 +1309,7 @@ void DivSample::render(unsigned int formatMask) {
if (!initInternal(DIV_SAMPLE_DEPTH_1BIT_DPCM,samples)) return; if (!initInternal(DIV_SAMPLE_DEPTH_1BIT_DPCM,samples)) return;
int accum=63; int accum=63;
int next=63; int next=63;
for (unsigned int i=0; (i<samples && (i>>3)<lengthDPCM); i++) { for (unsigned int i=0; (i<samples && (i>>3)<lengthDPCM); i++) {
next=((unsigned short)(data16[i]^0x8000))>>9; next=((unsigned short)(data16[i]^0x8000))>>9;
if (next>accum) { if (next>accum) {

View file

@ -288,7 +288,7 @@ struct DivSample {
* @warning do not attempt to do this outside of a synchronized block! * @warning do not attempt to do this outside of a synchronized block!
* @param newDepth the new depth. * @param newDepth the new depth.
*/ */
void convert(DivSampleDepth newDepth); void convert(DivSampleDepth newDepth, unsigned int formatMask=0xffffffff);
/** /**
* initialize the rest of sample formats for this sample. * initialize the rest of sample formats for this sample.

View file

@ -498,7 +498,7 @@ void FurnaceGUI::drawSampleEdit() {
if (ImGui::Selectable(sampleDepths[i])) { if (ImGui::Selectable(sampleDepths[i])) {
sample->prepareUndo(true); sample->prepareUndo(true);
e->lockEngine([this,sample,i]() { e->lockEngine([this,sample,i]() {
sample->convert((DivSampleDepth)i); sample->convert((DivSampleDepth)i,e->getSampleFormatMask());
e->renderSamples(curSample); e->renderSamples(curSample);
}); });
updateSampleTex=true; updateSampleTex=true;