Example #1
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;
}
Example #2
0
bool isSTimeInBlock(const struct Blocks *block,STime time){
  STime block_length = getBlockSTimeLength(block);
  if(time > block_length)
    return false;
  else
    return true;
}
Example #3
0
// Called from main thread
static void GE_fill_in_shared_variables(SharedVariables *sv){

  struct Tracker_Windows *window = root->song->tracker_windows;
  struct WBlocks *wblock = window->wblock;
  struct Blocks *block = wblock->block;

  sv->top_realline  = wblock->top_realline;
  sv->num_reallines = wblock->num_reallines;
  sv->curr_realline = wblock->curr_realline;
  sv->fontheight    = window->fontheight;
  
  sv->reltempo       = block->reltempo;
  sv->block_duration = getBlockSTimeLength(block);

  sv->scrollbar_height          = get_scrollbar_y2(window,wblock) - get_scrollbar_y1(window,wblock);
  sv->scrollbar_scroller_height = get_scrollbar_scroller_height(window,wblock);

  sv->block          = block;

  sv->times          = block->times;

  {
    radium::ScopedMutex locker(&vector_mutex);
    VECTOR_push_back(&g_times_storage, sv->times);
  }
  
  sv->realline_places = (Place*)V_malloc(sv->num_reallines * sizeof(Place));
  for(int i=0;i<sv->num_reallines;i++){
    sv->realline_places[i] = wblock->reallines[i]->l.p;
  }
}
Example #4
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
                 );
}
Example #5
0
double STime2Place_f(
                  const struct Blocks *block,
                  double time
                  )
{

  if (time < 0)
    return 0.0;

  if (time >= getBlockSTimeLength(block))
    return block->num_lines;

  
#if 0
  int line1=0;
  int line2=1;
  for(;;){
    if (time >= block->times[line1].time && time < block->times[line2].time)
      break;

    line1++;
    line2++;    
  }
#else
  int line1,line2;
  int line=1;
  while(block->times[line].time < time) // could be optimized by binary search, but binary search is a horror to get right, and it's not that important here.
    line++;

  line2 = line;
  line1 = line-1;
#endif

  
  return STime2Place2(block->times,
                      time,
                      NUM_STIME2PLACE2_TRIES,
                      line1,
                      line2,
                      block->times[line1].time,
                      block->times[line2].time
                      );
}
Example #6
0
static void print_lpb_iterator_status(const struct Blocks *block, LPB_Iterator *iterator){
#if !defined(RELEASE)
  printf("\n\nplace: %f -> %f (%d)\nlpb_value: %d\n",iterator->place1_f,iterator->place2_f,block==NULL?-1:(int)getBlockSTimeLength(block),iterator->lpb_value);
  printf("num_beats_so_far: %f", iterator->num_beats_played_so_far);
  printf("num_beats_between: %f\n\n",iterator->num_beats_between_place1_and_place2);
  //printf("beat_position: %f\n\n",RT_LPB_get_beat_position());
#endif
}