Merge branch 'master' of https://github.com/tildearrow/furnace into es5506_alt

* 'master' of https://github.com/tildearrow/furnace:
  GUI: improve unified data view
  GUI: sample editor preview in selection
  finally
  Revert "fudge and bread"
  Revert "fire!"
  Revert "temporarily kill MSVC"
  Revert "MSVC: ughh, f**k you, you d**khead."
  MSVC: ughh, f**k you, you d**khead.
  temporarily kill MSVC
  fire!

# Conflicts:
#	src/engine/engine.h
#	src/engine/playback.cpp
This commit is contained in:
cam900 2022-05-30 08:13:27 +09:00
commit 4f6f13e938
11 changed files with 217 additions and 74 deletions

View file

@ -1477,8 +1477,10 @@ int DivEngine::getEffectiveSampleRate(int rate) {
return rate;
}
void DivEngine::previewSample(int sample, int note) {
void DivEngine::previewSample(int sample, int note, int pStart, int pEnd) {
BUSY_BEGIN;
sPreview.pBegin=pStart;
sPreview.pEnd=pEnd;
if (sample<0 || sample>=(int)song.sample.size()) {
sPreview.sample=-1;
sPreview.pos=0;
@ -1495,7 +1497,7 @@ void DivEngine::previewSample(int sample, int note) {
if (rate<100) rate=100;
blip_set_rates(samp_bb,rate,got.rate);
samp_prevSample=0;
sPreview.pos=0;
sPreview.pos=(sPreview.pBegin>=0)?sPreview.pBegin:0;
sPreview.sample=sample;
sPreview.wave=-1;
sPreview.dir=false;

View file

@ -340,11 +340,14 @@ class DivEngine {
int wave;
unsigned int pos;
bool dir;
int pBegin, pEnd;
SamplePreview():
sample(-1),
wave(-1),
pos(0),
dir(false) {}
dir(false),
pBegin(-1),
pEnd(-1) {}
} sPreview;
short vibTable[64];
@ -527,7 +530,7 @@ class DivEngine {
void syncReset();
// trigger sample preview
void previewSample(int sample, int note=-1);
void previewSample(int sample, int note=-1, int pStart=-1, int pEnd=-1);
void stopSamplePreview();
// trigger wave preview

View file

@ -1173,8 +1173,12 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
if (sPreview.sample>=0 && sPreview.sample<(int)song.sample.size()) {
DivSample* s=song.sample[sPreview.sample];
const bool pBeginVaild=sPreview.pBegin>=0 && sPreview.pBegin<s->samples;
const bool pEndVaild=sPreview.pEnd>=0 && sPreview.pEnd<s->samples;
const int loopStart=pBeginVaild?sPreview.pBegin:s->loopStart;
const int loopEnd=pEndVaild?sPreview.pEnd:(int)s->loopEnd;
for (size_t i=0; i<prevtotal; i++) {
if (sPreview.pos>=s->samples) {
if (sPreview.pos>=s->samples || (sPreview.pEnd>=0 && (int)sPreview.pos>=sPreview.pEnd)) {
samp_temp=0;
} else {
samp_temp=s->data16[sPreview.pos];
@ -1188,19 +1192,19 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
samp_prevSample=samp_temp;
if (sPreview.dir) {
if (s->isLoopable() && ((int)sPreview.pos)<s->loopStart) {
if ((s->isLoopable() && sPreview.pos<s->loopEnd) && ((int)sPreview.pos)<loopStart) {
switch (s->loopMode) {
case DIV_SAMPLE_LOOPMODE_FORWARD:
sPreview.dir=false;
sPreview.pos=s->loopStart+1;
sPreview.pos=loopStart+1;
break;
case DIV_SAMPLE_LOOPMODE_BACKWARD:
sPreview.dir=true;
sPreview.pos=s->loopEnd-1;
sPreview.pos=loopEnd-1;
break;
case DIV_SAMPLE_LOOPMODE_PINGPONG:
sPreview.dir=false;
sPreview.pos=s->loopStart+1;
sPreview.pos=loopStart+1;
break;
case DIV_SAMPLE_LOOPMODE_ONESHOT:
default:
@ -1208,19 +1212,19 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
}
}
} else {
if (s->isLoopable() && sPreview.pos>=s->loopEnd) {
if ((s->isLoopable() && (int)sPreview.pos>=s->loopStart) && ((int)sPreview.pos)>=loopEnd) {
switch (s->loopMode) {
case DIV_SAMPLE_LOOPMODE_FORWARD:
sPreview.dir=false;
sPreview.pos=s->loopStart;
sPreview.pos=loopStart;
break;
case DIV_SAMPLE_LOOPMODE_BACKWARD:
sPreview.dir=true;
sPreview.pos=s->loopEnd-1;
sPreview.pos=loopEnd-1;
break;
case DIV_SAMPLE_LOOPMODE_PINGPONG:
sPreview.dir=true;
sPreview.pos=s->loopEnd-1;
sPreview.pos=loopEnd-1;
break;
case DIV_SAMPLE_LOOPMODE_ONESHOT:
default:
@ -1231,19 +1235,19 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
}
if (sPreview.dir) {
if (s->isLoopable() && ((int)sPreview.pos)<s->loopStart) {
if ((s->isLoopable() && sPreview.pos<s->loopEnd) && ((int)sPreview.pos)<loopStart) {
switch (s->loopMode) {
case DIV_SAMPLE_LOOPMODE_FORWARD:
sPreview.dir=false;
sPreview.pos=s->loopStart+1;
sPreview.pos=loopStart+1;
break;
case DIV_SAMPLE_LOOPMODE_BACKWARD:
sPreview.dir=true;
sPreview.pos=s->loopEnd-1;
sPreview.pos=loopEnd-1;
break;
case DIV_SAMPLE_LOOPMODE_PINGPONG:
sPreview.dir=false;
sPreview.pos=s->loopStart+1;
sPreview.pos=loopStart+1;
break;
case DIV_SAMPLE_LOOPMODE_ONESHOT:
default:
@ -1256,19 +1260,19 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
sPreview.sample=-1;
}
} else {
if (s->isLoopable() && sPreview.pos>=s->loopEnd) {
if ((s->isLoopable() && (int)sPreview.pos>=s->loopStart) && ((int)sPreview.pos)>=loopEnd) {
switch (s->loopMode) {
case DIV_SAMPLE_LOOPMODE_FORWARD:
sPreview.dir=false;
sPreview.pos=s->loopStart;
sPreview.pos=loopStart;
break;
case DIV_SAMPLE_LOOPMODE_BACKWARD:
sPreview.dir=true;
sPreview.pos=s->loopEnd-1;
sPreview.pos=loopEnd-1;
break;
case DIV_SAMPLE_LOOPMODE_PINGPONG:
sPreview.dir=true;
sPreview.pos=s->loopEnd-1;
sPreview.pos=loopEnd-1;
break;
case DIV_SAMPLE_LOOPMODE_ONESHOT:
default:

View file

@ -727,7 +727,7 @@ void DivSample::render() {
}
}
if (depth!=DIV_SAMPLE_DEPTH_YMZ_ADPCM) { // YMZ ADPCM
if (!initInternal(3,samples)) return;
if (!initInternal(DIV_SAMPLE_DEPTH_YMZ_ADPCM,samples)) return;
ymz_encode(data16,dataZ,(samples+7)&(~0x7));
}
if (depth!=DIV_SAMPLE_DEPTH_QSOUND_ADPCM) { // QSound ADPCM
@ -744,7 +744,7 @@ void DivSample::render() {
ymb_encode(data16,dataB,(samples+511)&(~0x1ff));
}
if (depth!=DIV_SAMPLE_DEPTH_8BIT) { // 8-bit PCM
if (!initInternal(8,samples)) return;
if (!initInternal(DIV_SAMPLE_DEPTH_8BIT,samples)) return;
for (unsigned int i=0; i<samples; i++) {
data8[i]=data16[i]>>8;
}