fuzziqersoftware / resource_dasm

Classic Mac OS resource fork and application disassembler, with reverse-engineering tools for specific applications
MIT License
113 stars 12 forks source link

Suggestion: Rework the codebase into a .hsb/.rmf extractor #10

Open nehochupechatat opened 2 years ago

nehochupechatat commented 2 years ago

I suggest that someone (maybe fuzziqer) reworks this into something that can rip .rmf/.hsb files. It also uses snd/esnd/csnd, midi/emid/cmid/ecmi, SONG and INST. Documentation on hsb/rmf can be found in the miniBAE source code. ALIS is for duplicate patches.

fuzziqersoftware commented 2 years ago

Interesting idea. I haven't seen .rmf or .hsb files before; could you upload or link to some examples here? I can't promise I'll get to this soon, but will consider it.

nehochupechatat commented 2 years ago

rmf is basically beatnik's file format for music mixed with custom samples and it's a lot like mac soundmusicsys songs but with a different structure.

https://github.com/heyigor/miniBAE/tree/main/minibae/Content/rmf Here are some rmf songs (the bigger ones include custom samples, some use MPEG)

https://github.com/heyigor/miniBAE/tree/main/minibae/banks hsb banks

hsb and rmf files were used mainly on WebTV, web pages and old cellphones (T-Mobile Sidekick, Nokias)

nehochupechatat commented 2 years ago

Documentation on the ALIS format (basically duplicate patches - patch 5 will direct to patch 4 for example) Documentation is available in the source code (documentation folder)

nehochupechatat commented 2 years ago

Maybe you could also make the tool dump the instrument and alias info into a txt file so people could recreate these instruments in other synths. Maybe you could even implement this INST disassembler into resource_dasm!

fuzziqersoftware commented 2 years ago

I've implemented support for .rmf/.hsb/.bsn files; you can use the --index-format=hirf option with resource_dasm to extract the contents. The contents go through the same decoding steps as Mac OS resource forks, so everything gets decrypted and decompressed, snds become .wav files, etc. Curiously, the SONG resource format is different in RMF files and incompatible with the SONG format in resource forks; I implemented support for both formats.

I also added a decoder that turns INSTs into JSON files (as we currently do with SONGs), which hopefully will make them easier to use with other software. I'm not much of a musician and am not familiar with music authoring software so I just used the existing smssynth JSON format, which probably isn't compatible with any popular music software. It's at least human-readable, so you can manually set up the instruments. If there's a specific output format that would be more useful, I might be able to make resource_dasm export in that format.

Unfortunately, I think there's a bug in the ima4 decoder that corrupts certain stereo snds when decoding them. None of my ~700 test cases with Mac OS snd resources trigger this bug, so it might be specific to how Beatnik handles ima4 compression. Like the above, I can't promise I'll be able to fix this soon, but I've added it to the to-do list.

nehochupechatat commented 2 years ago

I see. Well, I built on linux mint and it says 'can't open file' for some reason. On raspbian (i use an x86 port) phosg's string test fails. Would you mind releasing a pre-compiled binary?

UPDATE: Solved the problem, thanks.

nehochupechatat commented 2 years ago

I tried running it and the ima adpcm sample it exports is really broken, not to mention it isn't even actually stereo for how beatnik handles ima adpcm, use X_IMA.c

http://onj3.andrelouis.com/phonetones/Software%20and%20Soundbanks/Soundbanks/Beatnik%20miniBAE/Danger%20Hiptop.hsb the hsb i used it with

nehochupechatat commented 2 years ago

It seems to export all samples as stereo and truncate them on other hsbs, even if they're actually mono I tried opening them as raw PCM, and it works but the problem is that the loop points are lost. Could you perhaps update it to export as mono?

fuzziqersoftware commented 2 years ago

I added a hack to treat most snds in HIRF archives as mono, and fixed the ALIS template so the text files are readable. The .hsb that you linked above seems to decode properly now. (I don't know what the sounds are supposed to sound like, but they sound reasonable / not corrupted to me.)

nehochupechatat commented 2 years ago

.Thanks a lot! The loop points don't seem to export correctly on this bank and the Hiptop bank though. http://onj3.andrelouis.com/phonetones/Software%20and%20Soundbanks/Soundbanks/Beatnik%20miniBAE/Sony%20Ericsson%20P800.hsb

Also what else would be nice would be adding ADSR, resonance, sample volume and other valumes into the json. It's also a part of the documentation

If you want to listen to beatnik stuff for reference use playBAE - a friend got it to compile https://github.com/zefie/miniBAE

To look at samples through .bsns - use Beatnik Editor (use wine for it) and activate expertconverter http://onj3.andrelouis.com/phonetones/Software%20and%20Soundbanks/Software/Beatnik%20Editor.zip

.bsn is basically a project file for hsb, so this will let you look at some sample loop points if there is a .bsn for that .hsb. And also ADSR values.

nehochupechatat commented 2 years ago

Another goal would be to dump RMF metadata with composer credits (an example file is tropicalist-full.rmf found in the source code) I think it's a part of the SONG documentation txt