HearthSim / python-fsb5

Library and tool to extract audio from FSB5 (FMOD Sample Bank) files
https://hearthsim.info
MIT License
138 stars 39 forks source link

ValueError: 16 is not a valid SoundFormat #21

Open PiSaucer opened 1 year ago

PiSaucer commented 1 year ago

I am unable to convert FSB version 5 files.

Command:

python3 extract.py file.fsb

Error Message:

Traceback (most recent call last):
  File "C:\python-fsb5_win64\extract.py", line 131, in <module>
    main()
  File "C:\python-fsb5_win64\extract.py", line 127, in main
    exit(app.run(sys.argv[1:]))
  File "C:\python-fsb5_win64\extract.py", line 121, in run
    self.handle_file(f)
  File "C:\python-fsb5_win64\extract.py", line 99, in handle_file
    fsb, ext = self.load_fsb(data)
  File "C:\python-fsb5_win64\extract.py", line 55, in load_fsb
    fsb = fsb5.load(data)
  File "C:\python-fsb5_win64\fsb5\__init__.py", line 230, in load
    return FSB5(data)
  File "C:\python-fsb5_win64\fsb5\__init__.py", line 124, in __init__
    self.header = self.header._replace(mode=SoundFormat(self.header.mode), size=buf.tell())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\enum.py", line 384, in __call__
    return cls.__new__(cls, value)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\enum.py", line 702, in __new__
    raise ve_exc
ValueError: 16 is not a valid SoundFormat
lyrinka commented 4 months ago

I'm having the exact same issue and had to hard code 16 as a dummy format to suppress the exception.

16 is FADPCM format, it's not new but haven't found a lot of support in external tools. I'm not sure whether this library is still maintained but I see some other in progress work for reference: https://github.com/SamboyCoding/Fmod5Sharp/issues/7

Update: I found a working implementation in vgmstream https://github.com/vgmstream/vgmstream/blob/master/src/coding/fadpcm_decoder.c#L17