Beispiel #1
0
static void schedule_next_LPB(struct SeqTrack *seqtrack, const struct SeqBlock *seqblock, const struct LPBs *next_lpb){
  R_ASSERT_RETURN_IF_FALSE(next_lpb != NULL);
  R_ASSERT_RETURN_IF_FALSE(seqblock!=NULL);
  
  const int num_args = 1;
        
  union SuperType args[num_args];
  args[0].const_pointer = seqblock;

  LPB_Iterator *iterator = &seqtrack->lpb_iterator;
    
  iterator->next_lpb = next_lpb;

  int64_t time = get_seqblock_place_time(seqblock, next_lpb->l.p);
  
  SCHEDULER_add_event(seqtrack, time, RT_scheduled_LPB, &args[0], num_args, SCHEDULER_LPB_PRIORITY);
}
Beispiel #2
0
static void PE_StartNote(struct PEventQueue *peq,int doit){

	if(doit && peq->track->onoff==1 && peq->track->patch!=NULL){
          union SuperType args[2];
          args[0].const_pointer = peq->track;
          args[1].const_pointer = peq->note;

          //printf("__PE_StartNote. Scheduling start for %d at %d\n",peq->note->note,(int)peq->l.time);
          SCHEDULER_add_event(peq->l.time, scheduled_play_note, &args[0], 2, SCHEDULER_NOTE_ON_PRIORITY);

          //RT_PATCH_play_note(peq->track->patch,note->note,note->velocity,peq->track, peq->l.time);
	}

	PEQ_FindNextNote(peq);

	return;
}
static void RT_schedule_reallines_in_block2(struct SeqTrack *seqtrack, struct SeqBlock *seqblock, struct WBlocks *wblock, int realline){
  R_ASSERT_RETURN_IF_FALSE(seqblock->block != NULL);

  if(realline>=wblock->num_reallines)
    return;

  const int num_args = 4;
    
  union SuperType args[num_args];

  args[0].const_pointer = seqblock;
  args[1].pointer = wblock;
  args[2].int32_num = realline;
  args[3].int_num = ++seqblock->curr_scheduled_realline_counter;

  Place realline_place = wblock->reallines[realline]->l.p;
  int64_t time = get_seqblock_place_time(seqblock, realline_place);

  SCHEDULER_add_event(seqtrack, time, RT_scheduled_realline, &args[0], num_args, SCHEDULER_INIT_PRIORITY);
}
Beispiel #4
0
static void SendPitchChange(float x,struct PEventQueue *peq){
  if(peq->track->patch!=NULL && peq->track->onoff==1){

    union SuperType args[3];
    args[0].const_pointer = peq->track;
    args[1].const_pointer = peq->note;
    args[2].float_num = x;

    SCHEDULER_add_event(peq->l.time, scheduled_change_pitch, &args[0], 3, SCHEDULER_PITCH_PRIORITY);

    /*
      RT_PATCH_change_pitch(peq->track->patch,
      peq->note->note,
      x,
      peq->track,
      peq->l.time
      );
    */
  }
}
Beispiel #5
0
static void fxhandle(int x, struct PEventQueue *peq, int skip, FX_when when){
  struct FX *fx = peq->fxs->fx;
  struct Patch *patch = peq->track->patch;

  if (fx==NULL)
    return;
  
  if (patch != fx->patch) // This can happen if changing patch for a track while playing.
    return;
  
  if (peq->track->onoff==1)
    return;
  
  union SuperType args[4];
  args[0].pointer = fx;
  args[1].int_num = x;
  args[2].int_num = skip;
  args[3].int_num = when;
  
  SCHEDULER_add_event(peq->l.time, scheduled_fx_change, &args[0], 4, SCHEDULER_FX_PRIORITY);
}
Beispiel #6
0
void RT_schedule_Signature_newblock(struct SeqTrack *seqtrack,
                                    const struct SeqBlock *seqblock,
                                    const Place start_place)
{

  Signature_Iterator *iterator = &seqtrack->signature_iterator;
  memset(iterator, 0, sizeof(Signature_Iterator));
  iterator->signature_value = root->signature;
  //printf("   SIG Init %d/%d\n",iterator->signature_value.numerator, iterator->signature_value.denominator);
  
  const struct Blocks *block = seqblock->block;
    
  const struct Signatures *next_signature = block->signatures;

  if(next_signature==NULL)
    return;

  // spool forward to the 'signature' that is used by 'start_place'
  //
  while(PlaceGreaterThan(&start_place, &next_signature->l.p)){
    iterator->signature_value = next_signature->signature;
    //printf("   SIG Init %d/%d\n",iterator->signature_value.numerator, iterator->signature_value.denominator);
    next_signature = NextSignature(next_signature);
    if (next_signature==NULL)
      return;
  }

  iterator->next_signature = next_signature;
  
  {
    int num_args = 1;
    union SuperType args[num_args];
    args[0].const_pointer = seqblock;
    
    int64_t time = get_seqblock_place_time(seqblock, next_signature->l.p);
    
    SCHEDULER_add_event(seqtrack, time, RT_scheduled_Signature, &args[0], num_args, SCHEDULER_SIGNATURE_PRIORITY);
  }
}
Beispiel #7
0
static void PE_StopNote(struct PEventQueue *peq,int doit){

	if(doit && peq->track->onoff==1 && peq->track->patch!=NULL){
//		Pdebug("Stop note: %d, vel: %d\n",peq->note->note,peq->note->velocity_end);
          union SuperType args[3];
          args[0].const_pointer = peq->track;
          args[1].const_pointer = peq->note;

          //printf("__PE_StopNote. Scheduling stop for %d at %d\n",peq->note->note,(int)peq->l.time);
          SCHEDULER_add_event(peq->l.time, scheduled_stop_note, &args[0], 2, SCHEDULER_NOTE_OFF_PRIORITY);
          /*
          RT_PATCH_stop_note(peq->track->patch,
                             peq->note->note,
                             peq->note->velocity_end,
                             peq->track,
                             peq->l.time
                             );
          */
	}

	ReturnPEQelement(peq);
	return;
}
Beispiel #8
0
static void RT_schedule_pitch(struct SeqTrack *seqtrack,
                              int64_t current_time,
                              const struct SeqBlock *seqblock,
                              const struct Tracks *track,
                              const struct Notes *note,
                              const struct Pitches *pitch1,
                              bool first_val_has_been_sent
                              )
{

  if(note->pitches==NULL && note->pitch_end == 0.0) // In case note is changed while playing
    return;

  const struct Pitches *pitch2 = pitch1==NULL ? note->pitches : NextPitch(pitch1);

  Place p1 = pitch1==NULL ? note->l.p : pitch1->l.p;
  Place p2 = pitch2==NULL ? note->end : pitch2->l.p;
  
  int64_t time1 = get_seqblock_place_time(seqblock, p1);
  int64_t time2 = get_seqblock_place_time(seqblock, p2);

  if (pitch2==NULL)
    time2--; // Can not send out pitch at the same time as note_end, since note_end events has higher priority than pitch events.
#if !defined(RELEASE)
  else
    R_ASSERT(time2 >= time1);
#endif
    
  if (time2 < time1)
    return;

  int logtype1 = pitch1==NULL ? note->pitch_first_logtype : pitch1->logtype;

  if (logtype1 == LOGTYPE_HOLD){

    if (current_time == time1) {
      
      RT_scheduled_hold_pitch_do(seqtrack, current_time, seqblock, track, note, pitch1, !first_val_has_been_sent);
                                    
    } else {
        
      const int num_args = 4;
    
      union SuperType args[num_args];
      args[0].const_pointer = seqblock;
      args[1].const_pointer = track;
      args[2].const_pointer = note;
      args[3].const_pointer = pitch1;
      
      SCHEDULER_add_event(seqtrack, time1, RT_scheduled_hold_pitch, &args[0], num_args, SCHEDULER_PITCH_PRIORITY);
    }
      
  } else {

    //int64_t time = R_MIN(time2, time1 + RADIUM_BLOCKSIZE);

    bool doit;

    if (pitch1==NULL)
      doit = true;
    else
      doit = pitch1->chance==0x100 || pitch1->chance > rnd(0x100);

    union SuperType args[g_num_pitches_args];
    args[0].const_pointer = seqblock;
    args[1].const_pointer = track;
    args[2].const_pointer = note;
    args[3].const_pointer = pitch1;
    args[4].int_num       = time1;
    args[5].int_num       = time2;
    args[6].bool_num      = doit;

#if DO_DEBUG
    float val1 = pitch1==NULL ? note->note      : pitch1->note;
    float val2 = pitch2==NULL ? note->pitch_end : pitch2->note;
    
    printf(" Scheduling Pitch. %f -> %f, %d -> %d\n", val1, val2, (int)time1, (int)time2);
#endif
  
    SCHEDULER_add_event(seqtrack, time1, RT_scheduled_glide_pitch, &args[0], g_num_pitches_args, SCHEDULER_PITCH_PRIORITY);

  }
}