Skip to content

Commit e2ee7e0

Browse files
committed
Increased PSG max volume from 0.25 to 0.30
1 parent 89a9e41 commit e2ee7e0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/main/msx/audio/PSGAudio.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ wmsx.PSGAudio = function(secondary) {
9191
var sampleC = amplitudeC === 0 || (toneC && !currentSampleC) || (noiseC && !currentSampleN) ? 0 : amplitudeC;
9292
var sampleP = 0;
9393
if (currentSampleP) {
94-
sampleP = CHANNEL_MAX_VOLUME;
94+
sampleP = PULSE_CHANNEL_VOLUME;
9595
if (!pulseSignal && audioSocket.getBUSCycles() - pulseSignalOnClock >= MIN_PULSE_ON_CLOCKS) currentSampleP = 0;
9696
}
9797
sampleResult[0] = sampleA * volPanL[0] + sampleB * volPanL[1] + sampleC * volPanL[2] + sampleP * volPanL[3];
@@ -103,7 +103,7 @@ wmsx.PSGAudio = function(secondary) {
103103
(amplitudeB === 0 || (toneB && !currentSampleB) || (noiseB && !currentSampleN) ? 0 : amplitudeB) +
104104
(amplitudeC === 0 || (toneC && !currentSampleC) || (noiseC && !currentSampleN) ? 0 : amplitudeC);
105105
if (currentSampleP) {
106-
mSampleResult += CHANNEL_MAX_VOLUME;
106+
mSampleResult += PULSE_CHANNEL_VOLUME;
107107
if (!pulseSignal && audioSocket.getBUSCycles() - pulseSignalOnClock >= MIN_PULSE_ON_CLOCKS) currentSampleP = 0;
108108
}
109109
return mSampleResult;
@@ -236,6 +236,13 @@ wmsx.PSGAudio = function(secondary) {
236236
volumeCurve[v] = Math.pow(2, -(15 - v) / 2) * CHANNEL_MAX_VOLUME;
237237
}
238238

239+
// OLD, more smooth curve, apparently wrong (different from real HW)
240+
// function createVolumeCurve() {
241+
// for (var v = 0; v < 16; v++)
242+
// volumeCurve[v] = (Math.pow(CHANNEL_VOLUME_CURVE_POWER, v / 15) - 1) / (CHANNEL_VOLUME_CURVE_POWER - 1) * CHANNEL_MAX_VOLUME;
243+
// }
244+
// var CHANNEL_VOLUME_CURVE_POWER = 30;
245+
239246

240247
var periodA = 0;
241248
var periodACount = 0;
@@ -283,14 +290,16 @@ wmsx.PSGAudio = function(secondary) {
283290
var sampleResult = [ 0, 0 ];
284291

285292
var volumeCurve = new Array(16);
293+
this.volumeCurve = volumeCurve;
286294

287295
var volPanL = new Array(4);
288296
var volPanR = new Array(4);
289297

290298
var audioSignal;
291299
var audioSocket;
292300

293-
var CHANNEL_MAX_VOLUME = 0.25;
301+
var CHANNEL_MAX_VOLUME = 0.30;
302+
var PULSE_CHANNEL_VOLUME = 0.25;
294303

295304
var MIN_PULSE_ON_CLOCKS = 160;
296305

0 commit comments

Comments
 (0)