misc fixes and new effects
- fix 8-bit samples - 0C effect - E3 effect
This commit is contained in:
parent
ccd5acf1e4
commit
c0f7f12c89
|
@ -621,13 +621,19 @@ void DivEngine::renderSamples() {
|
||||||
s->rendLength=(double)s->length/samplePitches[s->pitch];
|
s->rendLength=(double)s->length/samplePitches[s->pitch];
|
||||||
s->rendData=new short[s->rendLength];
|
s->rendData=new short[s->rendLength];
|
||||||
int k=0;
|
int k=0;
|
||||||
float mult=(float)(s->vol+100)/100.0f;
|
printf("Volume: %d\n",s->vol);
|
||||||
|
float mult=(float)(s->vol+100)/150.0f;
|
||||||
for (double j=0; j<s->length; j+=samplePitches[s->pitch]) {
|
for (double j=0; j<s->length; j+=samplePitches[s->pitch]) {
|
||||||
if (k>=s->rendLength) {
|
if (k>=s->rendLength) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
float next=(float)s->data[(unsigned int)j]*mult;
|
if (s->depth==8) {
|
||||||
s->rendData[k++]=fmin(fmax(next,-32768),32767);
|
float next=(float)(s->data[(unsigned int)j]-0x80)*mult;
|
||||||
|
s->rendData[k++]=fmin(fmax(next,-128),127);
|
||||||
|
} else {
|
||||||
|
float next=(float)s->data[(unsigned int)j]*mult;
|
||||||
|
s->rendData[k++]=fmin(fmax(next,-32768),32767);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ struct DivChannelState {
|
||||||
std::vector<DivDelayedCommand> delayed;
|
std::vector<DivDelayedCommand> delayed;
|
||||||
int note, pitch, portaSpeed, portaNote;
|
int note, pitch, portaSpeed, portaNote;
|
||||||
int volume, volSpeed, cut, rowDelay, volMax;
|
int volume, volSpeed, cut, rowDelay, volMax;
|
||||||
int vibratoDepth, vibratoRate, vibratoPos;
|
int vibratoDepth, vibratoRate, vibratoPos, vibratoDir;
|
||||||
int tremoloDepth, tremoloRate, tremoloPos;
|
int tremoloDepth, tremoloRate, tremoloPos;
|
||||||
unsigned char arp, arpStage;
|
unsigned char arp, arpStage;
|
||||||
bool doNote, legato;
|
bool doNote, legato;
|
||||||
|
@ -26,6 +26,7 @@ struct DivChannelState {
|
||||||
vibratoDepth(0),
|
vibratoDepth(0),
|
||||||
vibratoRate(0),
|
vibratoRate(0),
|
||||||
vibratoPos(0),
|
vibratoPos(0),
|
||||||
|
vibratoDir(0),
|
||||||
tremoloDepth(0),
|
tremoloDepth(0),
|
||||||
tremoloRate(0),
|
tremoloRate(0),
|
||||||
tremoloPos(0),
|
tremoloPos(0),
|
||||||
|
|
|
@ -9,7 +9,11 @@ void DivPlatformGenesis::acquire(int& l, int& r) {
|
||||||
if (dacMode && dacSample!=-1) {
|
if (dacMode && dacSample!=-1) {
|
||||||
if (--dacPeriod<1) {
|
if (--dacPeriod<1) {
|
||||||
DivSample* s=parent->song.sample[dacSample];
|
DivSample* s=parent->song.sample[dacSample];
|
||||||
writes.emplace(0x2a,((unsigned short)s->rendData[dacPos++]+0x8000)>>8);
|
if (s->depth==8) {
|
||||||
|
writes.emplace(0x2a,(unsigned char)s->rendData[dacPos++]+0x80);
|
||||||
|
} else {
|
||||||
|
writes.emplace(0x2a,((unsigned short)s->rendData[dacPos++]+0x8000)>>8);
|
||||||
|
}
|
||||||
if (dacPos>=s->rendLength) {
|
if (dacPos>=s->rendLength) {
|
||||||
dacSample=-1;
|
dacSample=-1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,6 +214,9 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
||||||
case 0x00: // arpeggio
|
case 0x00: // arpeggio
|
||||||
chan[i].arp=effectVal;
|
chan[i].arp=effectVal;
|
||||||
break;
|
break;
|
||||||
|
case 0x0c: // retrigger
|
||||||
|
chan[i].rowDelay=effectVal+1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 0xe1: // portamento up
|
case 0xe1: // portamento up
|
||||||
chan[i].portaNote=chan[i].note+(effectVal&15);
|
chan[i].portaNote=chan[i].note+(effectVal&15);
|
||||||
|
@ -223,6 +226,9 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
||||||
chan[i].portaNote=chan[i].note-(effectVal&15);
|
chan[i].portaNote=chan[i].note-(effectVal&15);
|
||||||
chan[i].portaSpeed=(effectVal>>4)*4;
|
chan[i].portaSpeed=(effectVal>>4)*4;
|
||||||
break;
|
break;
|
||||||
|
case 0xe3: // vibrato direction
|
||||||
|
chan[i].vibratoDir=effectVal;
|
||||||
|
break;
|
||||||
case 0xe5: // pitch
|
case 0xe5: // pitch
|
||||||
chan[i].pitch=effectVal-0x80;
|
chan[i].pitch=effectVal-0x80;
|
||||||
dispatch->dispatch(DivCommand(DIV_CMD_PITCH,i,chan[i].pitch+((chan[i].vibratoDepth*vibTable[chan[i].vibratoPos])>>2)));
|
dispatch->dispatch(DivCommand(DIV_CMD_PITCH,i,chan[i].pitch+((chan[i].vibratoDepth*vibTable[chan[i].vibratoPos])>>2)));
|
||||||
|
@ -313,6 +319,7 @@ void DivEngine::nextRow() {
|
||||||
printf("| %.2x:%s | \x1b[1;33m%3d%s\x1b[m\n",curOrder,pb1,curRow,pb3);
|
printf("| %.2x:%s | \x1b[1;33m%3d%s\x1b[m\n",curOrder,pb1,curRow,pb3);
|
||||||
|
|
||||||
for (int i=0; i<chans; i++) {
|
for (int i=0; i<chans; i++) {
|
||||||
|
chan[i].rowDelay=0;
|
||||||
processRow(i,false);
|
processRow(i,false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -361,7 +368,18 @@ void DivEngine::nextTick() {
|
||||||
if (chan[i].vibratoDepth>0) {
|
if (chan[i].vibratoDepth>0) {
|
||||||
chan[i].vibratoPos+=chan[i].vibratoRate;
|
chan[i].vibratoPos+=chan[i].vibratoRate;
|
||||||
if (chan[i].vibratoPos>=64) chan[i].vibratoPos-=64;
|
if (chan[i].vibratoPos>=64) chan[i].vibratoPos-=64;
|
||||||
dispatch->dispatch(DivCommand(DIV_CMD_PITCH,i,chan[i].pitch+((chan[i].vibratoDepth*vibTable[chan[i].vibratoPos])>>4)));
|
switch (chan[i].vibratoDir) {
|
||||||
|
case 1: // up
|
||||||
|
dispatch->dispatch(DivCommand(DIV_CMD_PITCH,i,chan[i].pitch+(MAX(0,chan[i].vibratoDepth*vibTable[chan[i].vibratoPos])>>4)));
|
||||||
|
break;
|
||||||
|
case 2: // down
|
||||||
|
dispatch->dispatch(DivCommand(DIV_CMD_PITCH,i,chan[i].pitch+(MIN(0,chan[i].vibratoDepth*vibTable[chan[i].vibratoPos])>>4)));
|
||||||
|
break;
|
||||||
|
default: // both
|
||||||
|
dispatch->dispatch(DivCommand(DIV_CMD_PITCH,i,chan[i].pitch+((chan[i].vibratoDepth*vibTable[chan[i].vibratoPos])>>4)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (chan[i].portaSpeed>0) {
|
if (chan[i].portaSpeed>0) {
|
||||||
if (dispatch->dispatch(DivCommand(DIV_CMD_NOTE_PORTA,i,chan[i].portaSpeed,chan[i].portaNote))==2) {
|
if (dispatch->dispatch(DivCommand(DIV_CMD_NOTE_PORTA,i,chan[i].portaSpeed,chan[i].portaNote))==2) {
|
||||||
|
|
Loading…
Reference in a new issue