mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-30 16:33:01 +00:00
VGM export: improve volumes
This commit is contained in:
parent
6c5f9886fb
commit
17cb32fe9e
1 changed files with 72 additions and 7 deletions
|
@ -883,16 +883,20 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHIP_VOL(_id,_mult) { \
|
#define CHIP_VOL(_id,_mult) { \
|
||||||
double _vol=fabs((float)song.systemVol[i])*4.0*_mult; \
|
double _vol=fabs((float)song.systemVol[i])*256.0*_mult; \
|
||||||
if (_vol<0.0) _vol=0.0; \
|
if (_vol<0.0) _vol=0.0; \
|
||||||
if (_vol>32767.0) _vol=32767.0; \
|
if (_vol>32767.0) _vol=32767.0; \
|
||||||
|
chipVolSum+=(unsigned int)(_vol/_mult); \
|
||||||
|
chipAccounting++; \
|
||||||
chipVol.push_back((_id)|(0x80000000)|(((unsigned int)_vol)<<16)); \
|
chipVol.push_back((_id)|(0x80000000)|(((unsigned int)_vol)<<16)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHIP_VOL_SECOND(_id,_mult) { \
|
#define CHIP_VOL_SECOND(_id,_mult) { \
|
||||||
double _vol=fabs((float)song.systemVol[i])*4.0*_mult; \
|
double _vol=fabs((float)song.systemVol[i])*256.0*_mult; \
|
||||||
if (_vol<0.0) _vol=0.0; \
|
if (_vol<0.0) _vol=0.0; \
|
||||||
if (_vol>32767.0) _vol=32767.0; \
|
if (_vol>32767.0) _vol=32767.0; \
|
||||||
|
chipVolSum+=(unsigned int)(_vol/_mult); \
|
||||||
|
chipAccounting++; \
|
||||||
chipVol.push_back((_id)|(0x80000100)|(((unsigned int)_vol)<<16)); \
|
chipVol.push_back((_id)|(0x80000100)|(((unsigned int)_vol)<<16)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -977,6 +981,8 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
int hasLynx=0;
|
int hasLynx=0;
|
||||||
|
|
||||||
int howManyChips=0;
|
int howManyChips=0;
|
||||||
|
int chipVolSum=0;
|
||||||
|
int chipAccounting=0;
|
||||||
|
|
||||||
int loopPos=-1;
|
int loopPos=-1;
|
||||||
int loopTick=-1;
|
int loopTick=-1;
|
||||||
|
@ -1040,7 +1046,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_SMS:
|
case DIV_SYSTEM_SMS:
|
||||||
if (!hasSN) {
|
if (!hasSN) {
|
||||||
hasSN=disCont[i].dispatch->chipClock;
|
hasSN=disCont[i].dispatch->chipClock;
|
||||||
CHIP_VOL(0,1.0);
|
CHIP_VOL(0,2.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
switch (song.systemFlags[i].getInt("chipType",0)) {
|
switch (song.systemFlags[i].getInt("chipType",0)) {
|
||||||
case 1: // real SN
|
case 1: // real SN
|
||||||
|
@ -1059,7 +1065,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
} else if (!(hasSN&0x40000000)) {
|
} else if (!(hasSN&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
CHIP_VOL_SECOND(0,1.0);
|
CHIP_VOL_SECOND(0,2.0);
|
||||||
hasSN|=0x40000000;
|
hasSN|=0x40000000;
|
||||||
howManyChips++;
|
howManyChips++;
|
||||||
}
|
}
|
||||||
|
@ -1067,9 +1073,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_GB:
|
case DIV_SYSTEM_GB:
|
||||||
if (!hasGB) {
|
if (!hasGB) {
|
||||||
hasGB=disCont[i].dispatch->chipClock;
|
hasGB=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(19,0.75);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
} else if (!(hasGB&0x40000000)) {
|
} else if (!(hasGB&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(19,0.75);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
hasGB|=0x40000000;
|
hasGB|=0x40000000;
|
||||||
howManyChips++;
|
howManyChips++;
|
||||||
|
@ -1078,10 +1086,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_PCE:
|
case DIV_SYSTEM_PCE:
|
||||||
if (!hasPCE) {
|
if (!hasPCE) {
|
||||||
hasPCE=disCont[i].dispatch->chipClock;
|
hasPCE=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(27,0.98);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writePCESamples=true;
|
writePCESamples=true;
|
||||||
} else if (!(hasPCE&0x40000000)) {
|
} else if (!(hasPCE&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL(27,0.98);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
hasPCE|=0x40000000;
|
hasPCE|=0x40000000;
|
||||||
howManyChips++;
|
howManyChips++;
|
||||||
|
@ -1090,10 +1100,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_NES:
|
case DIV_SYSTEM_NES:
|
||||||
if (!hasNES) {
|
if (!hasNES) {
|
||||||
hasNES=disCont[i].dispatch->chipClock;
|
hasNES=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(20,1.7);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeNESSamples=true;
|
writeNESSamples=true;
|
||||||
} else if (!(hasNES&0x40000000)) {
|
} else if (!(hasNES&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(20,1.7);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
hasNES|=0x40000000;
|
hasNES|=0x40000000;
|
||||||
howManyChips++;
|
howManyChips++;
|
||||||
|
@ -1103,10 +1115,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_SEGAPCM_COMPAT:
|
case DIV_SYSTEM_SEGAPCM_COMPAT:
|
||||||
if (!hasSegaPCM) {
|
if (!hasSegaPCM) {
|
||||||
hasSegaPCM=4000000;
|
hasSegaPCM=4000000;
|
||||||
|
CHIP_VOL(4,0.67);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeSegaPCM=1;
|
writeSegaPCM=1;
|
||||||
} else if (!(hasSegaPCM&0x40000000)) {
|
} else if (!(hasSegaPCM&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(4,0.67);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeSegaPCM=2;
|
writeSegaPCM=2;
|
||||||
hasSegaPCM|=0x40000000;
|
hasSegaPCM|=0x40000000;
|
||||||
|
@ -1116,10 +1130,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_X1_010:
|
case DIV_SYSTEM_X1_010:
|
||||||
if (!hasX1) {
|
if (!hasX1) {
|
||||||
hasX1=disCont[i].dispatch->chipClock;
|
hasX1=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(38,0.5);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeX1010[0]=disCont[i].dispatch;
|
writeX1010[0]=disCont[i].dispatch;
|
||||||
} else if (!(hasX1&0x40000000)) {
|
} else if (!(hasX1&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(38,0.5);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeX1010[1]=disCont[i].dispatch;
|
writeX1010[1]=disCont[i].dispatch;
|
||||||
hasX1|=0x40000000;
|
hasX1|=0x40000000;
|
||||||
|
@ -1134,10 +1150,14 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_YM2610B_EXT:
|
case DIV_SYSTEM_YM2610B_EXT:
|
||||||
if (!hasOPNB) {
|
if (!hasOPNB) {
|
||||||
hasOPNB=disCont[i].dispatch->chipClock;
|
hasOPNB=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(8,1.0);
|
||||||
|
CHIP_VOL(0x88,1.25);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeADPCM_OPNB[0]=disCont[i].dispatch;
|
writeADPCM_OPNB[0]=disCont[i].dispatch;
|
||||||
} else if (!(hasOPNB&0x40000000)) {
|
} else if (!(hasOPNB&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(8,1.0);
|
||||||
|
CHIP_VOL_SECOND(0x88,1.25);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeADPCM_OPNB[1]=disCont[i].dispatch;
|
writeADPCM_OPNB[1]=disCont[i].dispatch;
|
||||||
hasOPNB|=0x40000000;
|
hasOPNB|=0x40000000;
|
||||||
|
@ -1182,9 +1202,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
if (hasStereo && song.systemFlags[i].getBool("stereo",false)) {
|
if (hasStereo && song.systemFlags[i].getBool("stereo",false)) {
|
||||||
ayFlags|=0x80;
|
ayFlags|=0x80;
|
||||||
}
|
}
|
||||||
|
CHIP_VOL(18,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
} else if (!(hasAY&0x40000000)) {
|
} else if (!(hasAY&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(18,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
hasAY|=0x40000000;
|
hasAY|=0x40000000;
|
||||||
howManyChips++;
|
howManyChips++;
|
||||||
|
@ -1194,9 +1216,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_SAA1099:
|
case DIV_SYSTEM_SAA1099:
|
||||||
if (!hasSAA) {
|
if (!hasSAA) {
|
||||||
hasSAA=disCont[i].dispatch->chipClock;
|
hasSAA=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(35,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
} else if (!(hasSAA&0x40000000)) {
|
} else if (!(hasSAA&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(35,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
hasSAA|=0x40000000;
|
hasSAA|=0x40000000;
|
||||||
howManyChips++;
|
howManyChips++;
|
||||||
|
@ -1208,10 +1232,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_YM2612_DUALPCM_EXT:
|
case DIV_SYSTEM_YM2612_DUALPCM_EXT:
|
||||||
if (!hasOPN2) {
|
if (!hasOPN2) {
|
||||||
hasOPN2=disCont[i].dispatch->chipClock;
|
hasOPN2=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(2,0.8);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeDACSamples=true;
|
writeDACSamples=true;
|
||||||
} else if (!(hasOPN2&0x40000000)) {
|
} else if (!(hasOPN2&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(2,0.8);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
hasOPN2|=0x40000000;
|
hasOPN2|=0x40000000;
|
||||||
howManyChips++;
|
howManyChips++;
|
||||||
|
@ -1220,9 +1246,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_YM2151:
|
case DIV_SYSTEM_YM2151:
|
||||||
if (!hasOPM) {
|
if (!hasOPM) {
|
||||||
hasOPM=disCont[i].dispatch->chipClock;
|
hasOPM=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(3,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
} else if (!(hasOPM&0x40000000)) {
|
} else if (!(hasOPM&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(3,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
hasOPM|=0x40000000;
|
hasOPM|=0x40000000;
|
||||||
howManyChips++;
|
howManyChips++;
|
||||||
|
@ -1233,10 +1261,14 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
if (!hasOPN) {
|
if (!hasOPN) {
|
||||||
hasOPN=disCont[i].dispatch->chipClock;
|
hasOPN=disCont[i].dispatch->chipClock;
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
|
CHIP_VOL(6,1.0);
|
||||||
|
CHIP_VOL(0x86,1.7);
|
||||||
writeDACSamples=true;
|
writeDACSamples=true;
|
||||||
} else if (!(hasOPN&0x40000000)) {
|
} else if (!(hasOPN&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
|
CHIP_VOL_SECOND(6,1.0);
|
||||||
|
CHIP_VOL_SECOND(0x86,1.7);
|
||||||
hasOPN|=0x40000000;
|
hasOPN|=0x40000000;
|
||||||
howManyChips++;
|
howManyChips++;
|
||||||
}
|
}
|
||||||
|
@ -1245,10 +1277,14 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_YM2608_EXT:
|
case DIV_SYSTEM_YM2608_EXT:
|
||||||
if (!hasOPNA) {
|
if (!hasOPNA) {
|
||||||
hasOPNA=disCont[i].dispatch->chipClock;
|
hasOPNA=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(7,1.0);
|
||||||
|
CHIP_VOL(0x87,1.3);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeADPCM_OPNA[0]=disCont[i].dispatch;
|
writeADPCM_OPNA[0]=disCont[i].dispatch;
|
||||||
} else if (!(hasOPNA&0x40000000)) {
|
} else if (!(hasOPNA&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(7,1.0);
|
||||||
|
CHIP_VOL_SECOND(0x87,1.3);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeADPCM_OPNA[1]=disCont[i].dispatch;
|
writeADPCM_OPNA[1]=disCont[i].dispatch;
|
||||||
hasOPNA|=0x40000000;
|
hasOPNA|=0x40000000;
|
||||||
|
@ -1260,9 +1296,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_VRC7:
|
case DIV_SYSTEM_VRC7:
|
||||||
if (!hasOPLL) {
|
if (!hasOPLL) {
|
||||||
hasOPLL=disCont[i].dispatch->chipClock;
|
hasOPLL=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(1,1.6);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
} else if (!(hasOPLL&0x40000000)) {
|
} else if (!(hasOPLL&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(1,1.6);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
hasOPLL|=0x40000000;
|
hasOPLL|=0x40000000;
|
||||||
howManyChips++;
|
howManyChips++;
|
||||||
|
@ -1285,9 +1323,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_POKEY:
|
case DIV_SYSTEM_POKEY:
|
||||||
if (!hasPOKEY) {
|
if (!hasPOKEY) {
|
||||||
hasPOKEY=disCont[i].dispatch->chipClock;
|
hasPOKEY=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(30,0.8);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
} else if (!(hasPOKEY&0x40000000)) {
|
} else if (!(hasPOKEY&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(30,0.8);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
hasPOKEY|=0x40000000;
|
hasPOKEY|=0x40000000;
|
||||||
howManyChips++;
|
howManyChips++;
|
||||||
|
@ -1310,10 +1350,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
// However I think it it not necessary because old VGM players will still
|
// However I think it it not necessary because old VGM players will still
|
||||||
// not be able to handle the 64kb sample bank trick
|
// not be able to handle the 64kb sample bank trick
|
||||||
hasQSound=disCont[i].dispatch->chipClock;
|
hasQSound=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(31,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeQSound[0]=disCont[i].dispatch;
|
writeQSound[0]=disCont[i].dispatch;
|
||||||
} else if (!(hasQSound&0x40000000)) {
|
} else if (!(hasQSound&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(31,1.0);
|
||||||
willExport[i]=false;
|
willExport[i]=false;
|
||||||
writeQSound[1]=disCont[i].dispatch;
|
writeQSound[1]=disCont[i].dispatch;
|
||||||
addWarning("dual QSound is not supported by the VGM format");
|
addWarning("dual QSound is not supported by the VGM format");
|
||||||
|
@ -1322,6 +1364,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_SWAN:
|
case DIV_SYSTEM_SWAN:
|
||||||
if (!hasSwan) {
|
if (!hasSwan) {
|
||||||
hasSwan=disCont[i].dispatch->chipClock;
|
hasSwan=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(33,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
// funny enough, VGM doesn't have support for WSC's sound DMA by design
|
// funny enough, VGM doesn't have support for WSC's sound DMA by design
|
||||||
// so DAC stream it goes
|
// so DAC stream it goes
|
||||||
|
@ -1329,6 +1372,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
writeDACSamples=true;
|
writeDACSamples=true;
|
||||||
} else if (!(hasSwan&0x40000000)) {
|
} else if (!(hasSwan&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(33,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
hasSwan|=0x40000000;
|
hasSwan|=0x40000000;
|
||||||
howManyChips++;
|
howManyChips++;
|
||||||
|
@ -1337,9 +1381,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_VBOY:
|
case DIV_SYSTEM_VBOY:
|
||||||
if (!hasVSU) {
|
if (!hasVSU) {
|
||||||
hasVSU=disCont[i].dispatch->chipClock;
|
hasVSU=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(34,0.72);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
} else if (!(hasVSU&0x40000000)) {
|
} else if (!(hasVSU&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(34,0.72);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
hasVSU|=0x40000000;
|
hasVSU|=0x40000000;
|
||||||
howManyChips++;
|
howManyChips++;
|
||||||
|
@ -1349,9 +1395,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_OPL_DRUMS:
|
case DIV_SYSTEM_OPL_DRUMS:
|
||||||
if (!hasOPL) {
|
if (!hasOPL) {
|
||||||
hasOPL=disCont[i].dispatch->chipClock;
|
hasOPL=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(9,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
} else if (!(hasOPL&0x40000000)) {
|
} else if (!(hasOPL&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(9,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
hasOPL|=0x40000000;
|
hasOPL|=0x40000000;
|
||||||
howManyChips++;
|
howManyChips++;
|
||||||
|
@ -1361,10 +1409,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_Y8950_DRUMS:
|
case DIV_SYSTEM_Y8950_DRUMS:
|
||||||
if (!hasY8950) {
|
if (!hasY8950) {
|
||||||
hasY8950=disCont[i].dispatch->chipClock;
|
hasY8950=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(11,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeADPCM_Y8950[0]=disCont[i].dispatch;
|
writeADPCM_Y8950[0]=disCont[i].dispatch;
|
||||||
} else if (!(hasY8950&0x40000000)) {
|
} else if (!(hasY8950&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(11,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeADPCM_Y8950[1]=disCont[i].dispatch;
|
writeADPCM_Y8950[1]=disCont[i].dispatch;
|
||||||
hasY8950|=0x40000000;
|
hasY8950|=0x40000000;
|
||||||
|
@ -1375,9 +1425,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_OPL2_DRUMS:
|
case DIV_SYSTEM_OPL2_DRUMS:
|
||||||
if (!hasOPL2) {
|
if (!hasOPL2) {
|
||||||
hasOPL2=disCont[i].dispatch->chipClock;
|
hasOPL2=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(10,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
} else if (!(hasOPL2&0x40000000)) {
|
} else if (!(hasOPL2&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(10,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
hasOPL2|=0x40000000;
|
hasOPL2|=0x40000000;
|
||||||
howManyChips++;
|
howManyChips++;
|
||||||
|
@ -1387,9 +1439,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_OPL3_DRUMS:
|
case DIV_SYSTEM_OPL3_DRUMS:
|
||||||
if (!hasOPL3) {
|
if (!hasOPL3) {
|
||||||
hasOPL3=disCont[i].dispatch->chipClock;
|
hasOPL3=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(12,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
} else if (!(hasOPL3&0x40000000)) {
|
} else if (!(hasOPL3&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(12,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
hasOPL3|=0x40000000;
|
hasOPL3|=0x40000000;
|
||||||
howManyChips++;
|
howManyChips++;
|
||||||
|
@ -1402,9 +1456,11 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
if (song.system[i]==DIV_SYSTEM_SCC_PLUS) {
|
if (song.system[i]==DIV_SYSTEM_SCC_PLUS) {
|
||||||
hasK051649|=0x80000000;
|
hasK051649|=0x80000000;
|
||||||
}
|
}
|
||||||
|
CHIP_VOL(25,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
} else if (!(hasK051649&0x40000000)) {
|
} else if (!(hasK051649&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(25,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
hasK051649|=0x40000000;
|
hasK051649|=0x40000000;
|
||||||
if (song.system[i]==DIV_SYSTEM_SCC_PLUS) {
|
if (song.system[i]==DIV_SYSTEM_SCC_PLUS) {
|
||||||
|
@ -1416,10 +1472,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_YMZ280B:
|
case DIV_SYSTEM_YMZ280B:
|
||||||
if (!hasZ280) {
|
if (!hasZ280) {
|
||||||
hasZ280=disCont[i].dispatch->chipClock;
|
hasZ280=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(15,0.72);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeZ280[0]=disCont[i].dispatch;
|
writeZ280[0]=disCont[i].dispatch;
|
||||||
} else if (!(hasZ280&0x40000000)) {
|
} else if (!(hasZ280&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(15,0.72);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeZ280[1]=disCont[i].dispatch;
|
writeZ280[1]=disCont[i].dispatch;
|
||||||
hasZ280|=0x40000000;
|
hasZ280|=0x40000000;
|
||||||
|
@ -1435,11 +1493,13 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
if (!hasRFC1) {
|
if (!hasRFC1) {
|
||||||
hasRFC1=disCont[i].dispatch->chipClock;
|
hasRFC1=disCont[i].dispatch->chipClock;
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL(16,1.6);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeRF5C68[1]=disCont[i].dispatch;
|
writeRF5C68[1]=disCont[i].dispatch;
|
||||||
}
|
}
|
||||||
} else if (!hasRFC) {
|
} else if (!hasRFC) {
|
||||||
hasRFC=disCont[i].dispatch->chipClock;
|
hasRFC=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(5,1.6);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeRF5C68[0]=disCont[i].dispatch;
|
writeRF5C68[0]=disCont[i].dispatch;
|
||||||
}
|
}
|
||||||
|
@ -1447,10 +1507,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_MSM6295:
|
case DIV_SYSTEM_MSM6295:
|
||||||
if (!hasOKIM6295) {
|
if (!hasOKIM6295) {
|
||||||
hasOKIM6295=disCont[i].dispatch->chipClock;
|
hasOKIM6295=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(24,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeMSM6295[0]=disCont[i].dispatch;
|
writeMSM6295[0]=disCont[i].dispatch;
|
||||||
} else if (!(hasOKIM6295&0x40000000)) {
|
} else if (!(hasOKIM6295&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(24,1.0);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeMSM6295[1]=disCont[i].dispatch;
|
writeMSM6295[1]=disCont[i].dispatch;
|
||||||
hasOKIM6295|=0x40000000;
|
hasOKIM6295|=0x40000000;
|
||||||
|
@ -1460,10 +1522,12 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_GA20:
|
case DIV_SYSTEM_GA20:
|
||||||
if (!hasGA20) {
|
if (!hasGA20) {
|
||||||
hasGA20=disCont[i].dispatch->chipClock;
|
hasGA20=disCont[i].dispatch->chipClock;
|
||||||
|
CHIP_VOL(40,0.4);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeGA20[0]=disCont[i].dispatch;
|
writeGA20[0]=disCont[i].dispatch;
|
||||||
} else if (!(hasGA20&0x40000000)) {
|
} else if (!(hasGA20&0x40000000)) {
|
||||||
isSecond[i]=true;
|
isSecond[i]=true;
|
||||||
|
CHIP_VOL_SECOND(40,0.4);
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
writeGA20[1]=disCont[i].dispatch;
|
writeGA20[1]=disCont[i].dispatch;
|
||||||
hasGA20|=0x40000000;
|
hasGA20|=0x40000000;
|
||||||
|
@ -1473,7 +1537,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
case DIV_SYSTEM_T6W28:
|
case DIV_SYSTEM_T6W28:
|
||||||
if (!hasSN) {
|
if (!hasSN) {
|
||||||
hasSN=0xc0000000|disCont[i].dispatch->chipClock;
|
hasSN=0xc0000000|disCont[i].dispatch->chipClock;
|
||||||
CHIP_VOL(0,1.0);
|
CHIP_VOL(0,2.0);
|
||||||
snNoiseConfig=3;
|
snNoiseConfig=3;
|
||||||
snNoiseSize=15;
|
snNoiseSize=15;
|
||||||
willExport[i]=true;
|
willExport[i]=true;
|
||||||
|
@ -1548,8 +1612,9 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
w->writeC(0); // OPN
|
w->writeC(0); // OPN
|
||||||
w->writeC(0); // OPNA
|
w->writeC(0); // OPNA
|
||||||
}
|
}
|
||||||
if (version>=0x160) {
|
if (version>=0x160) { // global volume
|
||||||
int calcVolume=32.0*(log(song.masterVol)/log(2.0));
|
double abnormalVol=song.masterVol*(double)chipVolSum/(256.0*MAX(1,chipAccounting));
|
||||||
|
int calcVolume=32.0*(log(abnormalVol)/log(2.0));
|
||||||
if (calcVolume<-63) calcVolume=-63;
|
if (calcVolume<-63) calcVolume=-63;
|
||||||
if (calcVolume>192) calcVolume=192;
|
if (calcVolume>192) calcVolume=192;
|
||||||
w->writeC(calcVolume&0xff); // volume
|
w->writeC(calcVolume&0xff); // volume
|
||||||
|
|
Loading…
Reference in a new issue