void InitPEQpitches( const struct Blocks *block, const struct Tracks *track, struct Notes *note, int playlistaddpos ){ if(track->patch==NULL) return; struct Pitches *pitch=note->pitches; if(pitch==NULL && note->pitch_end==0.0) return; struct PEventQueue *peq=GetPEQelement(); peq->block=block; peq->track=track; peq->note=note; peq->pitch=pitch; peq->time1=Place2STime(block,¬e->l.p); if (pitch==NULL) { peq->nextpitch = NULL; peq->time2=Place2STime(block,¬e->end); peq->TreatMe=PE_ChangePitchToEnd; } else { pitch->doit = pitch->chance==0x100 || pitch->chance > rnd(0x100); peq->nextpitch = pitch; peq->time2=Place2STime(block,&pitch->l.p); peq->TreatMe=PE_ChangePitch; } int x; PC_InsertElement( peq,playlistaddpos, PEQ_CalcNextEvent( peq->time1, peq->time1, peq->time2, 1, &x, 20000000, note->pitch_first_logtype ) ); }
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; }
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; }
static void InitPEQfxs( const struct Blocks *block, const struct Tracks *track, struct FXs *fxs ){ struct PEventQueue *peq=GetPEQelement(); peq->TreatMe=PE_HandleFirstFX; peq->block=block; peq->track=track; peq->fxs=fxs; peq->fxnodeline=fxs->fxnodelines; peq->nextfxnodeline=NextFXNodeLine(peq->fxnodeline); peq->time1=Place2STime(block,&peq->fxnodeline->l.p); peq->time2=Place2STime(block,&peq->nextfxnodeline->l.p); PC_InsertElement(peq,0,peq->time1); }
void InitPEQpitches( const struct Blocks *block, const struct Tracks *track, const struct Notes *note, int playlistaddpos ){ struct PEventQueue *peq; struct Pitches *pitch=note->pitches; if(track->patch==NULL) return; if(pitch==NULL) return; peq=GetPEQelement(); peq->block=block; peq->track=track; peq->note=note; peq->pitch=pitch; peq->time1=Place2STime(block,¬e->l.p); peq->nextpitch = pitch; peq->time2=Place2STime(block,&pitch->l.p); peq->TreatMe=PE_ChangePitch; int x; PC_InsertElement( peq,playlistaddpos, PEQ_CalcNextEvent( peq->time1, peq->time1, peq->time2, 1, &x, 20000000 ) ); }
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; }
static void PE_ChangePitch(struct PEventQueue *peq,int doit){ float x; STime ntime,btime; struct Pitches *next; btime=PC_TimeToRelBlockStart(pc->end_time); if(btime>=peq->time2){ next=NextPitch(peq->nextpitch); peq->time1=peq->time2; peq->pitch=peq->nextpitch; if(next==NULL){ peq->time2=Place2STime(peq->block,&peq->note->end); peq->TreatMe=PE_ChangePitchToEnd; PE_ChangePitchToEnd(peq,doit); }else{ peq->nextpitch=next; peq->time2=Place2STime(peq->block,&next->l.p); PE_ChangePitch(peq,doit); } return; } float pitch1,pitch2; if(peq->pitch==peq->nextpitch){ pitch1=peq->note->note; pitch2=peq->pitch->note; }else{ pitch1=peq->pitch->note; pitch2=peq->nextpitch->note; } ntime=PEQ_CalcNextPitchEvent( peq, peq->time1, btime, peq->time2, pitch1, &x, pitch2 ); if(btime==ntime){ Pdebug("Samme, stopper, x: %d\n",x); return; } if(ntime>peq->time2) ntime=peq->time2; // Pdebug("Player vel->vel, 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; }