Logo Search packages:      
Sourcecode: aubio version File versions  Download package

sint_t aubio_midi_player_callback ( void *  data,
uint_t  usec 
)

aubio_midi_player_callback

Definition at line 195 of file midi_player.c.

References _aubio_midi_player_t::current_file, _aubio_midi_player_t::deltatime, _aubio_midi_player_t::ntracks, _aubio_midi_player_t::playlist, _aubio_midi_player_t::status, _aubio_midi_player_t::ticks_passed, _aubio_midi_player_t::track, and _aubio_midi_player_t::usec_passed.

{
  sint_t i;
  uint_t ticks;
  uint_t delta_ticks;
  sint_t status = AUBIO_MIDI_PLAYER_DONE;
  aubio_midi_player_t* player;
  //aubio_synth_t* synth;
  player  = (aubio_midi_player_t*) data;
  //synth = player->synth;

  /* Load the next file if necessary */
  while (player->current_file == NULL) {

    if (player->playlist == NULL) {
      return 0;
    }

    aubio_midi_player_reset(player);

    player->current_file = aubio_list_get(player->playlist);
    player->playlist = aubio_list_next(player->playlist);

    //AUBIO_DBG( "%s: %d: Loading midifile %s", __FILE__, __LINE__, player->current_file);
    AUBIO_DBG("Loading midifile %s\n", player->current_file);

    if (aubio_midi_player_load(player, player->current_file) == AUBIO_OK) {

      player->ticks_passed = 0;
      player->usec_passed = 0;

      for (i = 0; i < player->ntracks; i++) {
        if (player->track[i] != NULL) {
          aubio_track_reset(player->track[i]);
        }
      }

    } else {
      player->current_file = NULL;
    }
  }

  delta_ticks = (uint_t) ((lsmp_t)(usec - player->usec_passed) / player->deltatime);
  ticks = player->ticks_passed + delta_ticks;

  for (i = 0; i < player->ntracks; i++) {
    if (!aubio_track_eot(player->track[i])) {
      status = AUBIO_MIDI_PLAYER_PLAYING;
      if (aubio_track_send_events(player->track[i], /*synth,*/ player, ticks) != AUBIO_OK) {
        /* */
      }
    }
  }

  player->status       = status;
  player->ticks_passed = ticks;
  player->usec_passed  = usec;

  if (player->status == AUBIO_MIDI_PLAYER_DONE) {
    player->current_file = NULL; 
  }

  return 1;
}


Generated by  Doxygen 1.6.0   Back to index