Merge remote-tracking branch 'origin/master' into newFilePicker
This commit is contained in:
commit
f9372ec53f
19 changed files with 224 additions and 67 deletions
|
|
@ -917,6 +917,11 @@ class DivDispatch {
|
|||
*/
|
||||
virtual void notifyWaveChange(int wave);
|
||||
|
||||
/**
|
||||
* notify sample change.
|
||||
*/
|
||||
virtual void notifySampleChange(int sample);
|
||||
|
||||
/**
|
||||
* notify addition of an instrument.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -283,6 +283,14 @@ void DivEngine::notifyWaveChange(int wave) {
|
|||
BUSY_END;
|
||||
}
|
||||
|
||||
void DivEngine::notifySampleChange(int sample) {
|
||||
BUSY_BEGIN;
|
||||
for (int i=0; i<song.systemLen; i++) {
|
||||
disCont[i].dispatch->notifySampleChange(sample);
|
||||
}
|
||||
BUSY_END;
|
||||
}
|
||||
|
||||
int DivEngine::loadSampleROM(String path, ssize_t expectedSize, unsigned char*& ret) {
|
||||
ret=NULL;
|
||||
if (path.empty()) {
|
||||
|
|
@ -595,10 +603,41 @@ void DivEngine::createNewFromDefaults() {
|
|||
BUSY_END;
|
||||
}
|
||||
|
||||
void DivEngine::copyChannel(int src, int dest) {
|
||||
logV("copying channel %d to %d",src,dest);
|
||||
if (src==dest) {
|
||||
logV("not copying because it's the same channel!");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i=0; i<DIV_MAX_PATTERNS; i++) {
|
||||
curOrders->ord[dest][i]=curOrders->ord[src][i];
|
||||
|
||||
DivPattern* srcPat=curPat[src].data[i];
|
||||
DivPattern* destPat=curPat[dest].data[i];
|
||||
if (srcPat==NULL) {
|
||||
if (destPat!=NULL) {
|
||||
delete destPat;
|
||||
curPat[dest].data[i]=NULL;
|
||||
}
|
||||
} else {
|
||||
curPat[src].data[i]->copyOn(curPat[dest].getPattern(i, true));
|
||||
}
|
||||
}
|
||||
|
||||
curPat[dest].effectCols=curPat[src].effectCols;
|
||||
|
||||
curSubSong->chanName[dest]=curSubSong->chanName[src];
|
||||
curSubSong->chanShortName[dest]=curSubSong->chanShortName[src];
|
||||
curSubSong->chanShow[dest]=curSubSong->chanShow[src];
|
||||
curSubSong->chanShowChanOsc[dest]=curSubSong->chanShowChanOsc[src];
|
||||
curSubSong->chanCollapse[dest]=curSubSong->chanCollapse[src];
|
||||
}
|
||||
|
||||
void DivEngine::swapChannels(int src, int dest) {
|
||||
logV("swapping channel %d with %d",src,dest);
|
||||
if (src==dest) {
|
||||
logV("not swapping channels because it's the same channel!",src,dest);
|
||||
logV("not swapping channels because it's the same channel!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -738,6 +777,16 @@ void DivEngine::checkAssetDir(std::vector<DivAssetDir>& dir, size_t entries) {
|
|||
delete[] inAssetDir;
|
||||
}
|
||||
|
||||
void DivEngine::copyChannelP(int src, int dest) {
|
||||
if (src<0 || src>=chans) return;
|
||||
if (dest<0 || dest>=chans) return;
|
||||
BUSY_BEGIN;
|
||||
saveLock.lock();
|
||||
copyChannel(src,dest);
|
||||
saveLock.unlock();
|
||||
BUSY_END;
|
||||
}
|
||||
|
||||
void DivEngine::swapChannelsP(int src, int dest) {
|
||||
if (src<0 || src>=chans) return;
|
||||
if (dest<0 || dest>=chans) return;
|
||||
|
|
|
|||
|
|
@ -649,6 +649,7 @@ class DivEngine {
|
|||
void exchangeWave(int one, int two);
|
||||
void exchangeSample(int one, int two);
|
||||
|
||||
void copyChannel(int src, int dest);
|
||||
void swapChannels(int src, int dest);
|
||||
void stompChannel(int ch);
|
||||
|
||||
|
|
@ -748,6 +749,8 @@ class DivEngine {
|
|||
void notifyInsChange(int ins);
|
||||
// notify wavetable change
|
||||
void notifyWaveChange(int wave);
|
||||
// notify sample change
|
||||
void notifySampleChange(int sample);
|
||||
|
||||
// dispatch a command
|
||||
int dispatchCmd(DivCommand c);
|
||||
|
|
@ -1260,6 +1263,9 @@ class DivEngine {
|
|||
// >=0: render specific sample
|
||||
void renderSamplesP(int whichSample=-1);
|
||||
|
||||
// public copy channel
|
||||
void copyChannelP(int src, int dest);
|
||||
|
||||
// public swap channels
|
||||
void swapChannelsP(int src, int dest);
|
||||
|
||||
|
|
|
|||
|
|
@ -402,13 +402,12 @@ std::vector<DivSample*> DivEngine::sampleFromFile(const char* path) {
|
|||
{
|
||||
// There's no documentation on libsndfile detune range, but the code
|
||||
// implies -50..50. Yet when loading a file you can get a >50 value.
|
||||
// disabled for now
|
||||
/*
|
||||
if(inst.detune > 50)
|
||||
inst.detune = inst.detune - 100;
|
||||
short pitch = ((0x3c-inst.basenote)*100) + inst.detune;
|
||||
sample->centerRate=si.samplerate*pow(2.0,pitch/(12.0 * 100.0));
|
||||
*/
|
||||
if (getConfInt("sampleImportInstDetune", 0)) {
|
||||
if(inst.detune > 50)
|
||||
inst.detune = inst.detune - 100;
|
||||
short pitch = ((0x3c-inst.basenote)*100) + inst.detune;
|
||||
sample->centerRate=si.samplerate*pow(2.0,pitch/(12.0 * 100.0));
|
||||
}
|
||||
if(inst.loop_count && inst.loops[0].mode >= SF_LOOP_FORWARD)
|
||||
{
|
||||
sample->loop=true;
|
||||
|
|
|
|||
|
|
@ -160,7 +160,11 @@ void DivDispatch::notifyInsChange(int ins) {
|
|||
|
||||
}
|
||||
|
||||
void DivDispatch::notifyWaveChange(int ins) {
|
||||
void DivDispatch::notifyWaveChange(int wave) {
|
||||
|
||||
}
|
||||
|
||||
void DivDispatch::notifySampleChange(int sample) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -516,6 +516,10 @@ void DivPlatformMultiPCM::notifyInsChange(int ins) {
|
|||
}
|
||||
}
|
||||
|
||||
void DivPlatformMultiPCM::notifySampleChange(int sample) {
|
||||
renderInstruments();
|
||||
}
|
||||
|
||||
void DivPlatformMultiPCM::notifyInsAddition(int sysID) {
|
||||
renderInstruments();
|
||||
}
|
||||
|
|
@ -654,8 +658,6 @@ void DivPlatformMultiPCM::renderSamples(int sysID) {
|
|||
memCompo=DivMemoryComposition();
|
||||
memCompo.name="Sample Memory";
|
||||
|
||||
renderInstruments();
|
||||
|
||||
size_t memPos=0x1800;
|
||||
int sampleCount=parent->song.sampleLen;
|
||||
if (sampleCount>512) {
|
||||
|
|
@ -709,6 +711,7 @@ void DivPlatformMultiPCM::renderSamples(int sysID) {
|
|||
pcmMemLen=memPos+256;
|
||||
memCompo.used=pcmMemLen;
|
||||
}
|
||||
renderInstruments();
|
||||
memCompo.capacity=getSampleMemCapacity(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ class DivPlatformMultiPCM: public DivDispatch {
|
|||
void toggleRegisterDump(bool enable);
|
||||
void setFlags(const DivConfig& flags);
|
||||
void notifyInsChange(int ins);
|
||||
void notifySampleChange(int sample);
|
||||
void notifyInsAddition(int sysID);
|
||||
void notifyInsDeletion(void* ins);
|
||||
int getPortaFloor(int ch);
|
||||
|
|
|
|||
|
|
@ -2993,6 +2993,12 @@ void DivPlatformOPL::notifyInsChange(int ins) {
|
|||
}
|
||||
}
|
||||
|
||||
void DivPlatformOPL::notifySampleChange(int sample) {
|
||||
if (pcmChanOffs>=0) {
|
||||
renderInstruments();
|
||||
}
|
||||
}
|
||||
|
||||
void DivPlatformOPL::notifyInsDeletion(void* ins) {
|
||||
for (int i=0; i<totalChans; i++) {
|
||||
chan[i].std.notifyInsDeletion((DivInstrument*)ins);
|
||||
|
|
@ -3264,6 +3270,58 @@ const DivMemoryComposition* DivPlatformOPL::getMemCompo(int index) {
|
|||
return &memCompo;
|
||||
}
|
||||
|
||||
// this is called on instrument change, reset and/or renderSamples().
|
||||
// I am not making this part of DivDispatch as this is the only chip with
|
||||
// instruments in ROM.
|
||||
void DivPlatformOPL::renderInstruments() {
|
||||
if (pcmChanOffs>=0) {
|
||||
const int maxSample=PCM_IN_RAM?128:512;
|
||||
int sampleCount=parent->song.sampleLen;
|
||||
if (sampleCount>maxSample) {
|
||||
sampleCount=maxSample;
|
||||
}
|
||||
// instrument table
|
||||
for (int i=0; i<sampleCount; i++) {
|
||||
DivSample* s=parent->song.sample[i];
|
||||
unsigned int insAddr=(i*12)+(PCM_IN_RAM?0x200000:0);
|
||||
unsigned char bitDepth;
|
||||
int endPos=CLAMP(s->isLoopable()?s->loopEnd:(s->samples+1),1,0x10000);
|
||||
int loop=s->isLoopable()?CLAMP(s->loopStart,0,endPos-2):(endPos-2);
|
||||
switch (s->depth) {
|
||||
case DIV_SAMPLE_DEPTH_8BIT:
|
||||
bitDepth=0;
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_12BIT:
|
||||
bitDepth=1;
|
||||
if (!s->isLoopable()) {
|
||||
endPos++;
|
||||
loop++;
|
||||
}
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_16BIT:
|
||||
bitDepth=2;
|
||||
break;
|
||||
default:
|
||||
bitDepth=0;
|
||||
break;
|
||||
}
|
||||
pcmMem[insAddr]=(bitDepth<<6)|((sampleOffPCM[i]>>16)&0x3f);
|
||||
pcmMem[1+insAddr]=(sampleOffPCM[i]>>8)&0xff;
|
||||
pcmMem[2+insAddr]=(sampleOffPCM[i])&0xff;
|
||||
pcmMem[3+insAddr]=(loop>>8)&0xff;
|
||||
pcmMem[4+insAddr]=(loop)&0xff;
|
||||
pcmMem[5+insAddr]=((~(endPos-1))>>8)&0xff;
|
||||
pcmMem[6+insAddr]=(~(endPos-1))&0xff;
|
||||
// on MultiPCM this consists of instrument params, but on OPL4 this is not used
|
||||
pcmMem[7+insAddr]=0; // LFO, VIB
|
||||
pcmMem[8+insAddr]=(0xf<<4)|(0xf<<0); // AR, D1R
|
||||
pcmMem[9+insAddr]=0; // DL, D2R
|
||||
pcmMem[10+insAddr]=(0xf<<4)|(0xf<<0); // RC, RR
|
||||
pcmMem[11+insAddr]=0; // AM
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DivPlatformOPL::renderSamples(int sysID) {
|
||||
if (adpcmChan<0 && pcmChanOffs<0) return;
|
||||
if (adpcmChan>=0 && adpcmBMem!=NULL) {
|
||||
|
|
@ -3349,45 +3407,7 @@ void DivPlatformOPL::renderSamples(int sysID) {
|
|||
}
|
||||
pcmMemLen=memPos+256;
|
||||
|
||||
// instrument table
|
||||
for (int i=0; i<sampleCount; i++) {
|
||||
DivSample* s=parent->song.sample[i];
|
||||
unsigned int insAddr=(i*12)+(PCM_IN_RAM?0x200000:0);
|
||||
unsigned char bitDepth;
|
||||
int endPos=CLAMP(s->isLoopable()?s->loopEnd:(s->samples+1),1,0x10000);
|
||||
int loop=s->isLoopable()?CLAMP(s->loopStart,0,endPos-2):(endPos-2);
|
||||
switch (s->depth) {
|
||||
case DIV_SAMPLE_DEPTH_8BIT:
|
||||
bitDepth=0;
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_12BIT:
|
||||
bitDepth=1;
|
||||
if (!s->isLoopable()) {
|
||||
endPos++;
|
||||
loop++;
|
||||
}
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_16BIT:
|
||||
bitDepth=2;
|
||||
break;
|
||||
default:
|
||||
bitDepth=0;
|
||||
break;
|
||||
}
|
||||
pcmMem[insAddr]=(bitDepth<<6)|((sampleOffPCM[i]>>16)&0x3f);
|
||||
pcmMem[1+insAddr]=(sampleOffPCM[i]>>8)&0xff;
|
||||
pcmMem[2+insAddr]=(sampleOffPCM[i])&0xff;
|
||||
pcmMem[3+insAddr]=(loop>>8)&0xff;
|
||||
pcmMem[4+insAddr]=(loop)&0xff;
|
||||
pcmMem[5+insAddr]=((~(endPos-1))>>8)&0xff;
|
||||
pcmMem[6+insAddr]=(~(endPos-1))&0xff;
|
||||
// on MultiPCM this consists of instrument params, but on OPL4 this is not used
|
||||
pcmMem[7+insAddr]=0; // LFO, VIB
|
||||
pcmMem[8+insAddr]=(0xf<<4)|(0xf<<0); // AR, D1R
|
||||
pcmMem[9+insAddr]=0; // DL, D2R
|
||||
pcmMem[10+insAddr]=(0xf<<4)|(0xf<<0); // RC, RR
|
||||
pcmMem[11+insAddr]=0; // AM
|
||||
}
|
||||
renderInstruments();
|
||||
if (PCM_IN_RAM) {
|
||||
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_RESERVED,"ROM data",0,0,0x200000));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,6 +186,8 @@ class DivPlatformOPL: public DivDispatch {
|
|||
void acquire_ymfm2(short** buf, size_t len);
|
||||
void acquire_ymfm1(short** buf, size_t len);
|
||||
|
||||
void renderInstruments();
|
||||
|
||||
public:
|
||||
void acquire(short** buf, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
|
|
@ -211,6 +213,7 @@ class DivPlatformOPL: public DivDispatch {
|
|||
void toggleRegisterDump(bool enable);
|
||||
void setFlags(const DivConfig& flags);
|
||||
void notifyInsChange(int ins);
|
||||
void notifySampleChange(int sample);
|
||||
void notifyInsDeletion(void* ins);
|
||||
int getPortaFloor(int ch);
|
||||
void poke(unsigned int addr, unsigned short val);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue