Adjustments to audio parsing
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -323,10 +323,11 @@ abstract class WLParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- THE FIX: Accurate Historical Chunk Indices ---
|
// In Wolf3D v1.4 (Shareware and Retail), Music ALWAYS starts at chunk 261.
|
||||||
// WL1 (Shareware) has exactly 234 sound effects before the music.
|
// Chunks 0-86: PC Sounds
|
||||||
// WL6 (Retail) has exactly 261 sound effects before the music.
|
// Chunks 87-173: AdLib Sounds
|
||||||
int musicStartIndex = (version == GameVersion.shareware) ? 234 : 261;
|
// Chunks 174-260: Digitized Sounds
|
||||||
|
int musicStartIndex = 261;
|
||||||
|
|
||||||
List<AdLibSound> adLib = allAudioChunks
|
List<AdLibSound> adLib = allAudioChunks
|
||||||
.take(musicStartIndex)
|
.take(musicStartIndex)
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ class Opl2Emulator {
|
|||||||
int channelIdx = reg - 0xB0;
|
int channelIdx = reg - 0xB0;
|
||||||
Opl2Channel channel = channels[channelIdx];
|
Opl2Channel channel = channels[channelIdx];
|
||||||
|
|
||||||
|
// Track the previous key state to prevent constant phase resetting
|
||||||
|
bool wasKeyOn = channel.keyOn;
|
||||||
|
|
||||||
// Extract the bits using bitwise masks
|
// Extract the bits using bitwise masks
|
||||||
channel.keyOn = (data & 0x20) != 0; // Bit 5
|
channel.keyOn = (data & 0x20) != 0; // Bit 5
|
||||||
channel.block = (data & 0x1C) >> 2; // Bits 2-4
|
channel.block = (data & 0x1C) >> 2; // Bits 2-4
|
||||||
@@ -65,8 +68,8 @@ class Opl2Emulator {
|
|||||||
channel.fNum = (channel.fNum & 0xFF) | fNumHigh;
|
channel.fNum = (channel.fNum & 0xFF) | fNumHigh;
|
||||||
channel.updateFrequency();
|
channel.updateFrequency();
|
||||||
|
|
||||||
// When a new note is struck, we reset the phase counter to 0
|
// ONLY reset the phase if the note was just struck
|
||||||
if (channel.keyOn) {
|
if (!wasKeyOn && channel.keyOn) {
|
||||||
channel.phase = 0.0;
|
channel.phase = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user