Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for HERAD Music System (HSQ, SDB, AGD) #39

Open
mrsinistar64 opened this issue Oct 8, 2016 · 4 comments
Open

Support for HERAD Music System (HSQ, SDB, AGD) #39

mrsinistar64 opened this issue Oct 8, 2016 · 4 comments
Assignees

Comments

@mrsinistar64
Copy link

@mrsinistar64 mrsinistar64 commented Oct 8, 2016

Recently, binarymaster and myself were able to reverse engineer HERAD, which is the music format that is used in Dune, KGB and MegaRace. You can read the documentation here.

The music notation is heavily based off of MIDI but does have some differences: for example, Pitch Bend events only have the MSB byte with the LSB byte being truncated. Note Off events are normal in Dune and KGB, but in MegaRace, they have been truncated as well, as the velocity byte is missing. Which leads me to our next problem.

Due to the fact that MegaRace uses a newer version of HERAD, there will need to be some sort of way for AdPlug to determine if the music file being loaded is a version 1 or version 2 song, since there is no value in the header to denote which version the song file is. I suggest analyzing the MIDI data to determine the file type.

As for instruments, the layout of the OPL register values is very similar to Ad Lib Inc.'s INS/BNK format, however, Cryo also implemented "macros" that control various OPL registers with MIDI commands, for example, HERAD can use either Note On Velocity or Aftertouch to control either the modulator output level, carrier output level or feedback. There's also macros for automated pitch bends, which are very useful for drums.

Dune's AdLib Gold files are very similar to their OPL2/Sound Blaster counterparts. The only difference is additional channels beyond OPL2's standard 9 channels and additional bytes in the header for the AdLib Gold surround module, which can be simply ignored.

For example files, here are links for the music files in Dune and MegaRace.

I've also attached the uncompressed drivers (drivers.zip) for Dune and MegaRace, so hopefully that will help with any unanswered questions that may come up.

I look forward to your response. I hope that with this information, AdPlug can finally have HERAD support. Thanks in advance!

@Malvineous

This comment has been minimized.

Copy link
Member

@Malvineous Malvineous commented Oct 8, 2016

There are no active AdPlug developers at present, but if anyone is willing to implement this I am more than happy to merge patches.

@mrsinistar64

This comment has been minimized.

Copy link
Author

@mrsinistar64 mrsinistar64 commented Oct 8, 2016

Thanks for the quick response. I'll see if I can find someone to help code a patch.

@binarymaster

This comment has been minimized.

Copy link
Member

@binarymaster binarymaster commented Oct 10, 2016

Useful hints for those who will code a player for this format:

  • M32 vs. others detection
    • There's 0 instruments in M32 file (instCount = FileSize - instOffset / 40)
    • M32 should not be supported by AdPlug
  • SDB vs. AGD detection
    • First track offset is 0x32 for SDB
    • First track offset is 0x52 for AGD
  • HERAD v1 vs. v2 detection
    • Loop through all instruments
    • If the first byte (inst.mode) is equal to 0, then it's version 1, break loop
    • If loop is finished and inst.mode == 0 not found, then it's version 2

Here's format reader implemented by me for MIDIPLEX:

https://github.com/stascorp/MIDIPLEX/blob/5af22fdec2e4f912edb233720aa572db34db36d2/Main.pas#L2348

@binarymaster binarymaster self-assigned this Mar 27, 2017
@binarymaster

This comment has been minimized.

Copy link
Member

@binarymaster binarymaster commented Apr 2, 2017

Work in progress now.

You can track the development in herad-dev branch.

binarymaster added a commit that referenced this issue Nov 18, 2017
binarymaster added a commit to adplug/winamp that referenced this issue Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.