Exemplo n.º 1
0
static double get_num_beats(const struct SeqTrack *seqtrack, const struct SeqBlock *seqblock, LPB_Iterator *iterator, int audioframes_to_add, const char *from_where, bool *curr_num_beats_is_valid){
  struct Blocks *block = seqblock->block;

  double time = seqtrack->start_time - seqblock->time;

#if DEBUG_BUGS
  R_ASSERT_NON_RELEASE(time > -(RADIUM_BLOCKSIZE*ATOMIC_DOUBLE_GET(block->reltempo)));
#endif
  
  if (time < 0) // Happens when switching between two seqblocks at a non-audio block alignment (i.e. delta time > 0). To avoid this minor inaccuracy, it seems necessary to break the use of constant 64 frame audio block sizes, so it's probably not worth it.
    time = 0;
  
  double time_to_add = (double)audioframes_to_add * ATOMIC_DOUBLE_GET(block->reltempo);

#if DEBUG_BUGS
  printf("Get num_beats. from_where: %s, time: %f, time_to_add: %f, pc->start_time_f: %f, stime2place: %f\n",
         from_where,
         time,
         time_to_add,
         ATOMIC_DOUBLE_GET(seqtrack->start_time_f),
         STime2Place_f(block, time+time_to_add)
         );
#endif

  if (time+time_to_add > getBlockSTimeLength(block)) // can happen when switching block
    *curr_num_beats_is_valid = false;
  
  return
    iterator->num_beats_played_so_far +
    scale_double(STime2Place_f(block, time+time_to_add),
                 iterator->place1_f, iterator->place2_f,
                 0.0, iterator->num_beats_between_place1_and_place2
                 );
}
Exemplo n.º 2
0
Place STime2Place(
                  const struct Blocks *block,
                  STime time
                  )
{
  Place place;
  Place *firstplace = PlaceGetFirstPos();
  Place lastplace;
  PlaceSetLastPos(block, &lastplace);

  if (time < 0) {
    return *firstplace;
  }

  if (time >= getBlockSTimeLength(block)){
    PlaceTilLimit(&place,&lastplace);
    return place;
  }

  double place_f = STime2Place_f(block,time);

  Double2Placement(place_f, &place);
    
  if (PlaceGreaterOrEqual(&place, &lastplace))
    PlaceTilLimit(&place,&lastplace);

  else if (PlaceLessThan(&place,firstplace))
    place = *firstplace;
  
  //if (place.line==64)
  //  abort();

  return place;
}