Beispiel #1
0
int fluid_player_reset(fluid_player_t* player)
{
	int i;

	for (i = 0; i < MAX_NUMBER_OF_TRACKS; i++) {
		if (player->track[i] != NULL) {
			delete_fluid_track(player->track[i]);
			player->track[i] = NULL;
		}
	}
/*	player->current_file = NULL; */
/*	player->status = FLUID_PLAYER_READY; */
/*	player->loop = 1; */
	player->ntracks = 0;
	player->division = 0;
	player->send_program_change = 1;
	player->miditempo = 480000;
	player->deltatime = 4.0;
	return 0;
}
Beispiel #2
0
/*
 * fluid_midi_file_read_track
 */
int
fluid_midi_file_read_track(fluid_midi_file *mf, fluid_player_t *player, int num)
{
    fluid_track_t *track;
    unsigned char id[5], length[5];
    int found_track = 0;
    int skip;

    if (fluid_midi_file_read(mf, id, 4) != FLUID_OK) {
        return FLUID_FAILED;
    }
    id[4] = '\0';
    mf->dtime = 0;

    while (!found_track) {

        if (fluid_isasciistring((char *) id) == 0) {
            FLUID_LOG(FLUID_ERR,
                    "An non-ascii track header found, corrupt file");
            return FLUID_FAILED;

        } else if (strcmp((char *) id, "MTrk") == 0) {

            found_track = 1;

            if (fluid_midi_file_read_tracklen(mf) != FLUID_OK) {
                return FLUID_FAILED;
            }

            track = new_fluid_track(num);
            if (track == NULL) {
                FLUID_LOG(FLUID_ERR, "Out of memory");
                return FLUID_FAILED;
            }

            while (!fluid_midi_file_eot(mf)) {
                if (fluid_midi_file_read_event(mf, track, num) != FLUID_OK) {
                    delete_fluid_track(track);
                    return FLUID_FAILED;
                }
            }

            /* Skip remaining track data, if any */
            if (mf->trackpos < mf->tracklen)
                fluid_midi_file_skip(mf, mf->tracklen - mf->trackpos);

            fluid_player_add_track(player, track);

        } else {
            found_track = 0;
            if (fluid_midi_file_read(mf, length, 4) != FLUID_OK) {
                return FLUID_FAILED;
            }
            skip = fluid_getlength(length);
            /* fseek(mf->fp, skip, SEEK_CUR); */
            if (fluid_midi_file_skip(mf, skip) != FLUID_OK) {
                return FLUID_FAILED;
            }
        }
    }
    if (fluid_midi_file_eof(mf)) {
        FLUID_LOG(FLUID_ERR, "Unexpected end of file");
        return FLUID_FAILED;
    }
    return FLUID_OK;
}