コード例 #1
0
HMISong::HMISong (FILE *file, const uint8_t *musiccache, int len)
: MIDIStreamer(), MusHeader(0), Tracks(0)
{
	if (len < 0x100)
	{ // Way too small to be HMI.
		return;
	}
	MusHeader = new uint8_t[len];
	SongLen = len;
	NumTracks = 0;
	if (file != NULL)
	{
		if (fread(MusHeader, 1, len, file) != (size_t)len)
			return;
	}
	else
	{
		memcpy(MusHeader, musiccache, len);
	}

	// Do some validation of the MIDI file
	if (memcmp(MusHeader, HMI_SONG_MAGIC, sizeof(HMI_SONG_MAGIC)) == 0)
	{
		SetupForHMI(len);
	}
	else if (memcmp(MusHeader, HMP_SONG_MAGIC, sizeof(HMP_SONG_MAGIC)) == 0)
	{
		SetupForHMP(len);
	}
}
コード例 #2
0
HMISong::HMISong (FileReader &reader, EMidiDevice type)
: MIDIStreamer(type), MusHeader(0), Tracks(0)
{
#ifdef _WIN32
	if (ExitEvent == NULL)
	{
		return;
	}
#endif
    int len = reader.GetLength();
	if (len < 0x100)
	{ // Way too small to be HMI.
		return;
	}
	MusHeader = new BYTE[len];
	SongLen = len;
	NumTracks = 0;
    if (reader.Read(MusHeader, len) != len)
        return;

	// Do some validation of the MIDI file
	if (memcmp(MusHeader, HMI_SONG_MAGIC, sizeof(HMI_SONG_MAGIC)) == 0)
	{
		SetupForHMI(len);
	}
	else if (((DWORD *)MusHeader)[0] == MAKE_ID('H','M','I','M') &&
			 ((DWORD *)MusHeader)[1] == MAKE_ID('I','D','I','P'))
	{
		SetupForHMP(len);
	}
}
コード例 #3
0
HMISong::HMISong (FILE *file, BYTE *musiccache, int len, EMidiDevice type)
: MIDIStreamer(type), MusHeader(0), Tracks(0)
{
#ifdef _WIN32
	if (ExitEvent == NULL)
	{
		return;
	}
#endif
	if (len < 0x100)
	{ // Way too small to be HMI.
		return;
	}
	MusHeader = new BYTE[len];
	SongLen = len;
	NumTracks = 0;
	if (file != NULL)
	{
		if (fread(MusHeader, 1, len, file) != (size_t)len)
			return;
	}
	else
	{
		memcpy(MusHeader, musiccache, len);
	}

	// Do some validation of the MIDI file
	if (memcmp(MusHeader, HMI_SONG_MAGIC, sizeof(HMI_SONG_MAGIC)) == 0)
	{
		SetupForHMI(len);
	}
	else if (((DWORD *)MusHeader)[0] == MAKE_ID('H','M','I','M') &&
			 ((DWORD *)MusHeader)[1] == MAKE_ID('I','D','I','P'))
	{
		SetupForHMP(len);
	}
}
コード例 #4
0
ファイル: midisource_hmi.cpp プロジェクト: Blzut3/gzdoom
HMISong::HMISong (FileReader &reader)
{
    int len = (int)reader.GetLength();
	if (len < 0x100)
	{ // Way too small to be HMI.
		return;
	}
	MusHeader = new uint8_t[len];
	SongLen = len;
	NumTracks = 0;
	if (reader.Read(MusHeader, len) != len)
		return;

	// Do some validation of the MIDI file
	if (memcmp(MusHeader, HMI_SONG_MAGIC, sizeof(HMI_SONG_MAGIC)) == 0)
	{
		SetupForHMI(len);
	}
	else if (((uint32_t *)MusHeader)[0] == MAKE_ID('H','M','I','M') &&
			 ((uint32_t *)MusHeader)[1] == MAKE_ID('I','D','I','P'))
	{
		SetupForHMP(len);
	}
}