tildearrow / furnace

a multi-system chiptune tracker compatible with DefleMask modules
GNU General Public License v2.0
2.24k stars 199 forks source link

Furnace randomly generates garbage 0x94 ss commands when exporting AY-3-8910 to a VGM file #2072

Closed Kyuchumimo closed 3 weeks ago

Kyuchumimo commented 1 month ago

https://github.com/tildearrow/furnace/blob/dcf904c99fe0dbc2ce32e66b8a6e60eaf642a417/src/engine/vgmOps.cpp

This occurs specifically with the AY-3-8910 sound chip and its variants or using muti-chip (e.g. AY-3-8910 + Konami SCC).

The 0x94 command is part of a VGM function called DAC Stream Control Write.

Stop Stream:
  0x94 ss
      ss = Stream ID
            Note: 0xFF stops all streams

It makes no sense that this command exists, as I have never worked with PCM audio. Of the 5 commands (0x90-0x95) that belong to the DAC Stream Control Write category only 0x94 is present, which ends up doing nothing and taking up space making the final VGM files heavier.

lunathir commented 1 month ago

Did you try disabling direct stream mode if possible?

Kyuchumimo commented 1 month ago

I have already unchecked that box and it still exports those commands.

tildearrow commented 3 weeks ago

Please try with latest artifact (when it is done building) or Git master.

Kyuchumimo commented 3 weeks ago

There is a considerable improvement, but it is not fixed yet.

OLD VGM export: image

NEW VGM export: image

Here is a Python script for you to check it yourself:

print("Furnace VGM export test")

import re

# Opens the file in binary mode
with open('infile.vgm', 'rb') as file:
    # Reads the contents of the file
    content = file.read()

# Define the regex pattern to search for \x94 followed by a byte in the range \x00 to \x61
pattern = re.compile(b'\x94[\x00-\x61]')

# Search for all matches in the content.
matches = pattern.finditer(content)

# Prints the matches found together with their offsets.
found = False
for match in matches:
    offset = match.start()  # Gets the offset of the match
    print(f'DAC Stream Control Write command: cmd={match.group()[0]:02X}, ss={match.group()[1]:02X} @ offset: 0x{offset:X}')
    found = True

if not found:
    print('No matches were found.')
tildearrow commented 3 weeks ago

The 0x94 commands are for AY PCM, which isn't supported in VGM export.

Kyuchumimo commented 3 weeks ago

Yes, I know, so these commands should not exist in the first place (in the context of the AY-3-8910 audio chip), right?

tildearrow commented 3 weeks ago

Yeah, they shouldn't. I am disabling these now.

Kyuchumimo commented 3 weeks ago

Yay! it's working as it should imagen

commit reference: https://github.com/tildearrow/furnace/commit/bcdad3c53879e9fc0efc1d68ff44e35cfa5238c7