Example #1
0
static void InsertNextSignature_PEQ(struct PEventQueue *peq){
  if (g_signature==NULL) {

    peq->TreatMe=PlayerNextSignature_Block;
    peq->block = PC_GetPlayBlock(1);
    
    if (peq->block == NULL)
      ReturnPEQelement(peq);
    
    else {
      
      PC_InsertElement_a( // need to use the "_a" version so that the block has a chance to update first. (there should be an "_aa" version for the block. Now fx/etc. can be called before signature block change)
                         peq,
                         1,
                         0
                          );
    }
    
  } else {

    peq->TreatMe=PlayerNextSignature;
    
    PC_InsertElement2(
                     peq,
                     0,
                     &g_signature->l.p
                     );

  }
}
Example #2
0
static void PE_ChangePitchToEnd(struct PEventQueue *peq,int doit){
	STime btime=PC_TimeToRelBlockStart(pc->end_time);

	if(btime>=peq->time2){
		ReturnPEQelement(peq);
		return;
	}

        const struct Notes *note = peq->note;

        float prev_pitch = peq->pitch!=NULL ? peq->pitch->note : note->note;
        int logtype      = peq->pitch!=NULL ? peq->pitch->logtype : note->pitch_first_logtype;
        
        float next_pitch = note->pitch_end;
        if(next_pitch<=1) // not supposed to happen though.
          next_pitch = 1;

        float x;

	STime ntime=PEQ_CalcNextPitchEvent(
                                           peq,
                                           peq->time1,
                                           btime,
                                           peq->time2,
                                           prev_pitch,
                                           &x,
                                           next_pitch,
                                           logtype
                                           );

	if(ntime>peq->time2){
		ReturnPEQelement(peq);
		return;
	}

//	Pdebug("Player vel->end, Pitch: %d, ntime: %d, btime: %d, time1: %d, time2: %d\n",x,ntime,btime,peq->time1,peq->time2);
	if(doit){
		SendPitchChange(x,peq);
	}

	PC_InsertElement(peq,0,ntime);

	return;

}
Example #3
0
void InitPEQendnote(
	const struct Blocks *block,
	const struct Tracks *track,
	const struct Notes *note,
	int playlistaddpos
){
	NInt tracknum=track->l.num;
	struct PEventQueue *peq=GetPEQelement();
	int orgplaylistaddpos=playlistaddpos;

	peq->TreatMe=PE_StopNote;
	peq->block=block;
	peq->track=track;
	peq->note=note;

	if(
		note->noend==1 &&
		note->end.line==block->num_lines-1 &&
		note->end.counter==MAX_UINT32-1 &&
		note->end.dividor==MAX_UINT32
	){
		if(PC_isPlayingBlock()) playlistaddpos=0;

		for(;;){
			playlistaddpos++;
			const struct Blocks *block=PC_GetPlayBlock(playlistaddpos);
			if(block==NULL){
				ReturnPEQelement(peq);
				return;
			}
			track=ListFindElement1_r0(&block->tracks->l,tracknum);
			if(track!=NULL){
				if(track->notes!=NULL){
					if(track->stops!=NULL){
						PC_InsertElement2(peq,playlistaddpos,PlaceMin(&track->stops->l.p,&track->notes->l.p));
						break;
					}else{
						PC_InsertElement2(peq,playlistaddpos,&track->notes->l.p);
						break;
					}
				}else{
					if(track->stops!=NULL){
						PC_InsertElement2(peq,playlistaddpos,&track->stops->l.p);
						break;
					}
				}
			}
		}
	}else{
		PC_InsertElement2(peq,playlistaddpos,&note->end);
	}

//A small hack here.
	peq->playpos=orgplaylistaddpos;
}
Example #4
0
static void PE_ChangePitchToEnd(struct PEventQueue *peq,int doit){
	float x;

	STime btime=PC_TimeToRelBlockStart(pc->end_time);

	if(btime>=peq->time2){
		ReturnPEQelement(peq);
		return;
	}

        float next_pitch = FindNextPitch(peq);
        if(next_pitch<=0.0f){
          ReturnPEQelement(peq);
          return;
	}

	STime ntime=PEQ_CalcNextPitchEvent(
                                     peq,
                                     peq->time1,
                                     btime,
                                     peq->time2,
                                     peq->pitch->note,
                                     &x,
                                     next_pitch
	);

	if(ntime>peq->time2){
		ReturnPEQelement(peq);
		return;
	}

//	Pdebug("Player vel->end, Pitch: %d, ntime: %d, btime: %d, time1: %d, time2: %d\n",x,ntime,btime,peq->time1,peq->time2);
	if(doit){
		SendPitchChange(x,peq);
	}

	PC_InsertElement(peq,0,ntime);

	return;

}
Example #5
0
static void PlayerFirstLine(struct PEventQueue *peq,int doit){

#ifdef WITH_PD
  int64_t next_time = ATOMIC_GET(pc->seqtime) + peq->block->times[1].time;

  RT_PD_set_line(peq->l.time, next_time, 0);

  //printf("FirstLine: %d, time: %d, nextrealline: %d, nexttime: %d, addplaypos: %d, pc->seqtime: %d\n",(int)0,(int)peq->l.time,(int)peq->realline,(int)next_time,(int)0,(int)pc->seqtime);
  //fflush(stdout);
#endif

  ReturnPEQelement(peq);
}
Example #6
0
void PE_HandleFirstFX(struct PEventQueue *peq,int doit){
	int x;
	STime ntime,btime;
	struct FXNodeLines *next;

//	Pdebug("fx, start: %d\n",peq->fxnodeline->val);
	if(doit){
          fxhandle(peq->fxnodeline->val,peq,0,FX_start);
	}

	btime=PC_TimeToRelBlockStart(pc->end_time);

	peq->TreatMe=PE_HandleFX;

	if(btime>=peq->time2){
		next=NextFXNodeLine(peq->nextfxnodeline);

		if(next==NULL){
//			Pdebug("fx, slutt: %d\n",peq->nextfxnodeline->val);
			if(doit){
                          fxhandle(peq->nextfxnodeline->val,peq,0,FX_end);
			}
			ReturnPEQelement(peq);
		}else{
			peq->fxnodeline=peq->nextfxnodeline;
			peq->nextfxnodeline=next;
			peq->time1=peq->time2;
			peq->time2=Place2STime(peq->block,&next->l.p);
			PE_HandleFX(peq,doit);
		}
		return;
	}

	ntime=PEQ_CalcNextEvent(
		peq->time1,
		btime,
		peq->time2,
		peq->fxnodeline->val,
		&x,
		peq->nextfxnodeline->val
	);

	if(ntime>peq->time2) ntime=peq->time2;

	PC_InsertElement(peq,0,ntime);

	return;
}
Example #7
0
static void PEQ_FindNextNoteAddPlayPos(struct PEventQueue *peq){
  const struct Blocks *block;
  struct Tracks *track;
  struct Notes *note;
  int playlistaddpos=0;

  if (PC_GetNextNoteAfterCurrentBlock(peq->track->l.num, &playlistaddpos, &note, &track, &block) == false) {
    ReturnPEQelement(peq);
    return;
  }

  peq->block=block;
  peq->track=track;
  peq->note=note;

  PC_InsertElement2_a(peq,playlistaddpos,&note->l.p);

  InitPEQendnote(block,track,note,playlistaddpos);
  InitPEQvelocities(block,track,note,playlistaddpos);
  InitPEQpitches(block,track,note,playlistaddpos);

}
Example #8
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;
}
Example #9
0
void PlayerNewLine(struct PEventQueue *peq,int doit){
	int addplaypos=0;
	int line=peq->line;
        //int time = peq->l.time;

#ifdef WITH_PD
        int org_line = peq->line;
        bool inserted_pd_line = false;
        int64_t org_time = peq->l.time;
#endif

	line++;

	if(pc->playtype==PLAYRANGE){
          RError("When did this happen?"); // PLAYRANGE has never been implemented
	}else{
		if(line>=peq->block->num_lines){
		        const struct Blocks *nextblock=PC_GetPlayBlock(1);
			if(nextblock==NULL){
				ReturnPEQelement(peq);
				return;
			}else{

                          struct PEventQueue *peq2=GetPEQelement();
                          peq2->TreatMe=PlayerFirstLine;
                          peq2->block=nextblock;
                          PC_InsertElement_a_latencycompencated(
                                                                peq2,
                                                                1,
                                                                nextblock->times[0].time
                                                                );
#ifdef WITH_PD
                          //printf("org_time: %f. next_time: %f\n",org_time/48000.0,peq2->l.time/48000.0);
                          RT_PD_set_line(org_time, peq2->l.time, org_line);
                          inserted_pd_line=true;
#endif

                          line=1;
                          peq->block=nextblock;
                          addplaypos=1;
			}
		}
	}

	peq->line=line;

        PC_InsertElement_latencycompencated(
                                            peq,
                                            addplaypos,
                                            peq->block->times[line].time
                                            );

#ifdef WITH_PD
        if(inserted_pd_line==false)
          RT_PD_set_line(org_time, peq->l.time, org_line);
#endif

	//printf("NewLine: %d (n: %d), time: %d, nextrealline: %d, nexttime: %d, addplaypos: %d, pc->seqtime: %d\n",org_line, (int)line,(int)time,(int)peq->realline,(int)peq->l.time,(int)addplaypos,(int)pc->seqtime);
        //fflush(stdout);

	return;
}