Skip to content

Commit bd2cf29

Browse files
committed
WIP MoonSound/OPL4
1 parent 9cbdc1a commit bd2cf29

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/main/msx/audio/OPL4AudioWave.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ wmsx.OPL4AudioWave = function(opl4) {
299299
keyOn[cha] = on;
300300
// Define ADSR phase
301301
if (on) {
302-
setEnvStep(cha, DAMP_START);
302+
setEnvStep(cha, ATTACK);
303303

304304
// console.log("Note:", cha, waveNumber[cha], octave[cha], fNum[cha], phaseInc[cha].toString(16));
305305
} else
@@ -587,8 +587,8 @@ wmsx.OPL4AudioWave = function(opl4) {
587587
evc: envStepLevelIncClock,
588588
evi: wmsx.Util.storeInt8BitArrayToStringBase64(envStepLevelInc),
589589
evn: wmsx.Util.storeInt8BitArrayToStringBase64(envStepNext),
590-
evl: wmsx.Util.storeInt8BitArrayToStringBase64(envStepNextAtLevel),
591-
eve: wmsx.Util.storeInt8BitArrayToStringBase64(envLevel),
590+
evl: wmsx.Util.storeInt16BitArrayToStringBase64(envStepNextAtLevel),
591+
eve: wmsx.Util.storeInt16BitArrayToStringBase64(envLevel),
592592

593593
kso: wmsx.Util.storeInt8BitArrayToStringBase64(rcOffset)
594594
}
@@ -626,8 +626,8 @@ wmsx.OPL4AudioWave = function(opl4) {
626626
envStepLevelIncClock = s.evc;
627627
envStepLevelInc = wmsx.Util.restoreStringBase64ToSignedInt8BitArray(s.evi, envStepLevelInc);
628628
envStepNext = wmsx.Util.restoreStringBase64ToInt8BitArray(s.evn, envStepNext);
629-
envStepNextAtLevel = wmsx.Util.restoreStringBase64ToInt8BitArray(s.evl, envStepNextAtLevel);
630-
envLevel = wmsx.Util.restoreStringBase64ToInt8BitArray(s.eve, envLevel);
629+
envStepNextAtLevel = wmsx.Util.restoreStringBase64ToInt16BitArray(s.evl, envStepNextAtLevel);
630+
envLevel = wmsx.Util.restoreStringBase64ToInt16BitArray(s.eve, envLevel);
631631
rcOffset = wmsx.Util.restoreStringBase64ToInt8BitArray(s.kso, rcOffset);
632632
};
633633

src/main/msx/audio/OPL4WaveTables.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ wmsx.OPL4WaveTables = function() {
88
tab[0] = 0;
99
tab[256] = 256;
1010
for (var i = 1; i < 256; ++i)
11-
tab[i] = 256 - Math.floor((Math.log(((256 - i)/256) + 0.0188) / 4 + 0.995) * 256);
11+
tab[i] = -Math.floor((Math.log(((256 - i)/256) + 0.00001) / 12) * 256);
12+
// tab[i] = -Math.floor((Math.log(((256 - i)/256) + 0.0025) / 6) * 256);
13+
// tab[i] = 256 - Math.floor((Math.log(((256 - i)/256) + 0.0188) / 4 + 0.995) * 256);
1214
return tab;
1315
};
1416

@@ -44,7 +46,7 @@ wmsx.OPL4WaveTables = function() {
4446
var tab = new Array(76);
4547
for (var i = 0; i < 64; ++i) {
4648
var dur = this.RATE_ATTACK_DURATIONS[i];
47-
tab[i] = dur >= 0 ? Math.max(1, Math.round(dur / 1000 * 49780 / 256)) : 0; // Valid Durations are at least 1 clock. 0 = infinite
49+
tab[i] = dur >= 0 ? Math.max(1, Math.round(dur / 2.2 / 1000 * 49780 / 256)) : 0; // Valid Durations are at least 1 clock. 0 = infinite
4850
}
4951
// Repeat last value for exceeding rates (> 63), possible when Rate = 15 and KSR offset > 3, as (Rate x 4 + KSROffset) can be > 63!
5052
for (i = 64; i < 60 + 16; ++i)

0 commit comments

Comments
 (0)