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;
}
Exemple #2
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;
}
  virtual status_t Import(SDL_RWops *rw)
  {
    fEvs = CreateMIDIEventList(rw, &fDivision);
    if (!fEvs) {
      return B_BAD_MIDI_DATA;
    }
    fTotal = 0;
    for (MIDIEvent *x = fEvs; x; x = x->next) fTotal++;
    fPos = fTotal;

    sort_events();
    return B_OK;
  }
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;
}