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

MIDI files are truncated #1

Closed
kode54 opened this issue Apr 11, 2018 · 8 comments
Closed

MIDI files are truncated #1

kode54 opened this issue Apr 11, 2018 · 8 comments

Comments

@kode54
Copy link

kode54 commented Apr 11, 2018

The RIFF file length fields report that the files are truncated. The file should be as long as the RIFF main body's length plus 8 (for the 'RIFF' and the length field). The last stream chunks of the files are also truncated.

I haven't checked the rest of the files, but it appears at least 370.riff is truncated by exactly 8 bytes, so I guess the ripper wasn't taking the RIFF header and length field into account when considering the value of the length field, which does not include those 8 bytes.

@Danjb1
Copy link
Owner

Danjb1 commented Apr 15, 2018

Thanks @kode54 for looking into this.

I'm using this page as a reference for the file format:
http://www.vgmpf.com/Wiki/index.php/MDS

I have written a simple program to parse the RIFF files, but trying to parse 370.riff using this structure gives me the following data:

header = RIFFD? MIDSfmt 
dwTimeFormat = 12
cbMaxBuffer = 384
dwFlags = 4096
numBlocks = 0

You refer to a length field, but where are you getting this from? Do you have a format specification I can look at?

@kode54
Copy link
Author

kode54 commented Apr 15, 2018

RIFF is a generic container format. The total file length, minus 8, is written immediately following the 'RIFF' and immediately before the field describing which format the file is, 'MIDS'.

@Danjb1
Copy link
Owner

Danjb1 commented Apr 18, 2018

Thanks again @kode54! By reducing the length field by 8 and renaming to .mids I am able to play the files through foobar using your MIDI player component. The mystery sound files? The game soundtrack, in MIDI format.

@Danjb1 Danjb1 closed this as completed Apr 18, 2018
@kode54
Copy link
Author

kode54 commented Apr 18, 2018

The lengths appeared to be correct, it's just that there's 8 extra bytes that whatever you used to extract them left off.

@Danjb1
Copy link
Owner

Danjb1 commented Apr 19, 2018

I used a tool called Watto's Game Extractor. Not sure how it does the extraction. I'll contact the author, but I think it's unlikely I'll get a response.

@wattostudios
Copy link

Thanks for contacting me Dan. Game Extractor was incorrectly calculating the length of the audio files as part of the scanner function, which I have now fixed and will include in the next release (3.07). I have sent you an email with a patched version which you can use in the interim to extract the files at their correct lengths.

@kode54
Copy link
Author

kode54 commented Apr 21, 2018

Yes, you can find an article on the format here:

https://en.wikipedia.org/wiki/Resource_Interchange_File_Format

It is a generic container format. "RIFF" is the header signature, the four bytes following it contain the length of the data following that field, and thus the total size of the file minus the 8 bytes that make up the signature and the length field.

The four bytes which follow the length are the type identifier, which is "MIDS" in this case, which I assume means a MIDI stream of some sort. It was used by a number of Windows games.

My midi_processing library documents the RIFF MIDS format in its parser. It also documents an unrelated MIDI container format, the RIFF RMID format, which is basically just a standard MIDI file in the data chunk of a RIFF container, for the purpose of supporting RIFF INFO or possibly RIFF 'id3 ' tagging.

https://github.com/kode54/midi_processing

E: Edit further: I just overexplained in a reply, before I realized I had my email client configured differently on this machine than my desktop. It's set to show newest posts at the top, so I was replying to your oldest message again. Oops.

@Danjb1
Copy link
Owner

Danjb1 commented Apr 22, 2018

Thanks @wattostudios for the fix, I have re-extracted the audio files and they work fine now!

And thanks @kode54 for the extra info 😁

Danjb1 pushed a commit that referenced this issue Jun 18, 2023
feat: create cmake skeleton for open-rival target
feat: add external libraries in cmake
feat: include directories instead of specific headers

Signed-off-by: Ricardo Benitez <benitezc.ricardo@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants