Esempio n. 1
0
NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc)
{
    NativeMidiSong *newsong;
    MIDIEvent       *evntlist = NULL;

    newsong=malloc(sizeof(NativeMidiSong));
    if (!newsong) {
        return NULL;
    }
    memset(newsong,0,sizeof(NativeMidiSong));

    /* Attempt to load the midi file */
    evntlist = CreateMIDIEventList(src, &newsong->ppqn);
    if (!evntlist)
    {
        free(newsong);
        return NULL;
    }

    MIDItoStream(newsong, evntlist);

    FreeMIDIEventList(evntlist);

    if (freesrc) {
        SDL_RWclose(src);
    }
    return newsong;
}
NativeMidiSong *native_midi_loadsong(const char *midifile)
{
	NativeMidiSong *newsong;
	MIDIEvent		*evntlist = NULL;
	SDL_RWops	*rw;

	newsong=malloc(sizeof(NativeMidiSong));
	if (!newsong)
		return NULL;
	memset(newsong,0,sizeof(NativeMidiSong));

	/* Attempt to load the midi file */
	rw = SDL_RWFromFile(midifile, "rb");
	if (rw) {
		evntlist = CreateMIDIEventList(rw, &newsong->ppqn);
		SDL_RWclose(rw);
		if (!evntlist)
		{
			free(newsong);
			return NULL;
		}
	}

	MIDItoStream(newsong, evntlist);

	FreeMIDIEventList(evntlist);

	return newsong;
}
Esempio n. 3
0
NativeMidiSong *native_midi_loadsong(char *midifile)
{
	NativeMidiSong *newsong;
	MIDIEvent		*evntlist = NULL;
	
	newsong=malloc(sizeof(NativeMidiSong));
	if (!newsong)
		return NULL;
	memset(newsong,0,sizeof(NativeMidiSong));
	
	/* Attempt to load the midi file */
	evntlist = CreateMIDIEventList(midifile, &newsong->ppqn);
	if (!evntlist)
	{
		free(newsong);
		return NULL;
	}
	
	MIDItoStream(newsong, evntlist);
	
	FreeMIDIEventList(evntlist);
	
	return newsong;
}