#ifndef _TRACKSTATE_H
#define _TRACKSTATE_H

#include "midifile.h"
#include "midievent.h"

typedef struct {
  MIDITRACK *t;
  int tickpos;
  unsigned char *pos,*end;
  unsigned char status;
  midi_event_t next;  // done when next.time<0
} trackstate_t;

void init_trackstate(trackstate_t *track,MIDITRACK *t); // still needs rewind!
void free_trackstate_data(trackstate_t *track);

// returns first events tickpos   or -1
int track_rewind(trackstate_t *track);

// returns next(successor) tickpos, -2 on EOT, -1 on error
int track_next(trackstate_t *track);

#endif
