libertyernie / LoopingAudioConverter

A converter frontend for loopable audio formats
181 stars 17 forks source link

(Feature Request) MSF support. #22

Closed AyanamiRei1 closed 5 years ago

AyanamiRei1 commented 5 years ago

MSF is a format that's used by the PS3 with several games like Skyrim and Under Night in Birth Exe Late for example LoopingAudioConverter can already convert from this format but not into it and that's what I would like to be added into this fantastic program mainly because a converter did exist at one point and trying to find a link to the thing is almost next to impossible.

If needed I can provide a sample.

Thanks.

libertyernie commented 5 years ago

I haven't found any programs that can create MSFs except for clayson's MSF Converter, and I wouldn't be able to redistribute that anyway even if I could find a download link.

Here's the code used to decode MSF files in vgmstream (which is what I'm using): https://github.com/losnoco/vgmstream/blob/master/src/meta/msf.c

It would be hard for me to write code to create MSF files since I don't have a PS3 to test with. MSF supports a bunch of codecs - I wonder if any game would support any codec, though? I know Smash Bros. Brawl uses ADPCM for all its music but if you give it a PCM16 BRSTM it works fine.

AyanamiRei1 commented 5 years ago

Looking inside a few MSF files that I have I can see loads of mentions of LAME inside it. image which I'm guessing it's just encoded using LAME here's a sample if that helps.

stage_Sonic.zip

libertyernie commented 5 years ago

Yeah, from looking at the vgmstream code, that one uses MP3 as the codec. The codec is specified by the bytes from 4-8 and the options are:

I imagine it wouldn't be too hard to write an MSF converter, at least one that uses PCM16 - the files will be bigger than necessary but it ought to work. Maybe I'll try at some point.

AyanamiRei1 commented 5 years ago

Ooh please do thanks a lot.

libertyernie commented 5 years ago

I see there's a set of flags (at 0x17) in the MSF header. If the 0x40 byte is set, according to vgmstream's source code, that means it's VBR (variable bitrate.) I don't have a good way of detecting CBR vs. VBR from an existing MP3 file, and I wonder why the PS3 even cares - vgmstream doesn't use that particular flag at all.

Since I'm a little skittish about releasing an app that's making guesses about how to build an MSF with MP3 data, I think I might just put the PCM16 (uncompressed) MSF builder in the next version. And maybe the MP3 MSF builder can be a separate app that prompts the user for the appropriate header values.

EDIT: On second thought, it's probably impossible to make a VBR MP3 loop properly. So maybe I just need to enforce re-encoding with a constant bit rate.

AyanamiRei1 commented 5 years ago

Can I build the PCM MSF converter? I'd like to see if it works with a few games

Thanks.

libertyernie commented 5 years ago

I just pushed the changeset that includes the PCM conversion. You should be able to use Visual Studio 2017 to build it (the free version works fine.) If that doesn't work, let me know and I'll post a beta version or something.

AyanamiRei1 commented 5 years ago

I just pushed the changeset that includes the PCM conversion. You should be able to use Visual Studio 2017 to build it (the free version works fine.) If that doesn't work, let me know and I'll post a beta version or something.

I'm having a bit of trouble building it.

image

libertyernie commented 5 years ago

I just pushed another commit that might fix it.

Do you get any other errors besides those four?

AyanamiRei1 commented 5 years ago

image

AyanamiRei1 commented 5 years ago

Well I got it to build and I can confirm the MSF converter works with games that normally use the MP3 MSF type like UNIST for example.

I figured out how I got it to build it's because I had an older version before the MSF exporter part was added in and I guess that had the missing files

libertyernie commented 5 years ago

Nice! I think I'll hold off on adding MP3 support unless there's a case that really needs it. I figured PCM might be fine - Super Smash Bros. Brawl is the same way. The files are huge but they play fine.