0000:0000 | 52 49 46 46 80 53 00 00 52 4D 49 44 64 61 74 61 | RIFF.S..RMIDdata
0000:0010 | 74 53 00 00 4D 54 68 64 00 00 00 06 00 01 00 2D | tS..MThd.......
//Timidity++ 2.15.0
if(memcmp(magic, "MThd", 4) == 0)
{
readmidi_read_init();
err = read_smf_file(tf);
}
else if(memcmp(magic, "RCM-", 4) == 0 || memcmp(magic, "COME", 4) == 0)
{
readmidi_read_init();
err = read_rcp_file(tf, magic, fn);
}
else if (strncmp(magic, "RIFF", 4) == 0) {
if (tf_read(magic, 1, 4, tf) == 4 &&
tf_read(magic, 1, 4, tf) == 4 &&
strncmp(magic, "RMID", 4) == 0 &&
tf_read(magic, 1, 4, tf) == 4 &&
strncmp(magic, "data", 4) == 0 &&
tf_read(magic, 1, 4, tf) == 4) {
goto retry_read;
} else {
err = 1;
ctl->cmsg(CMSG_WARNING, VERB_NORMAL,
"%s: Not a MIDI file!", current_filename);
}
}
else if(memcmp(magic, "melo", 4) == 0)
{
readmidi_read_init();
err = read_mfi_file(tf);
}
//VLC 3.0.17.4
/* Skip RIFF MIDI header if present */
if (!memcmp (peek, "RIFF", 4) && !memcmp (peek + 8, "RMID", 4))
{
uint32_t riff_len = GetDWLE (peek + 4);
msg_Dbg (demux, "detected RIFF MIDI file %"PRIu32" bytes", riff_len);//I had to remove the parentheses from '%"PRIu32" bytes' because otherwise it is not sent, forum error.
if ((vlc_stream_Read (stream, NULL, 12) < 12))
return VLC_EGENERIC;
/* Look for the RIFF data chunk */
for (;
{
char chnk_hdr[8];
uint32_t chnk_len;
if ((riff_len < 8)
|| (vlc_stream_Read (stream, chnk_hdr, 8) < 8))
return VLC_EGENERIC;
riff_len -= 8;
chnk_len = GetDWLE (chnk_hdr + 4);
if (riff_len < chnk_len)
return VLC_EGENERIC;
riff_len -= chnk_len;
if (!memcmp (chnk_hdr, "data", 4))
break; /* found! */
if (vlc_stream_Read (stream, NULL, chnk_len) < (ssize_t)chnk_len)
return VLC_EGENERIC;
}
/* Read real SMF header. Assume RIFF data chunk length is proper. */
if (vlc_stream_Peek (stream, &peek, 14) < 14)
return VLC_EGENERIC;
}
static int read_riff(void)
{
/* skip file length */
read_byte();
read_byte();
read_byte();
read_byte();
/* check file type ("RMID" = RIFF MIDI) */
if (read_id() != MAKE_ID('R', 'M', 'I', 'D')) {
invalid_format:
errormsg("%s: invalid file format", file_name);
return 0;
}
/* search for "data" chunk */
for (;
{
int id = read_id();
int len = read_32_le();
if (feof(file)) {
data_not_found:
errormsg("%s: data chunk not found", file_name);
return 0;
}
if (id == MAKE_ID('d', 'a', 't', 'a'))
break;
if (len < 0)
goto data_not_found;
skip((len + 1) & ~1);
}
/* the "data" chunk must contain data in SMF format */
if (read_id() != MAKE_ID('M', 'T', 'h', 'd'))
goto invalid_format;
return read_smf();
}
I've posted a question here long time ago about this matter.
RIFF MIDI files are bundles of Standard MIDI files with an optional DLS Soundfont. The file extension is usually RMI.
The open source Drumstick project has support for reading RIFF MIDI files since v2.4.0
RIFF "RMID" files contain exactly one SMF file in the "data" chunk. But the file might contain other chunks; Microsoft suggests that "INFO" makes sense.
You have to search for the "data" chunk. The Timidity code assumes that the "data" chunk is the first chunk; I do not know if this is correct.
<RMID-form> RIFF( 'RMID'
data( <MIDI-data> )
)
<MIDI-data> a Standard MIDI File, as defined in The Complete MIDI 1.0 Detailed Specification
I found this, which curiously before was in this same place.
https://web.archive.org/web/20110610135604/http://www.midi.org/about-midi/rp29spec(rmid).pdf
In my post I've asked if this file could be published here again, perhaps with a prominent "deprecated" marking on it. But nobody answered to that request.
The link you posted is available from the LOC page, in the Sustainability factors / Documentation section. But I feel that being an official MIDI.org document, the RP-029 should be also available here.