PCFOP * read_instr(struct PCFState * st, const char * line, uint32_t iptr) { char buf[LINE_MAX], *bitr; buf[0] = '\0'; bitr = buf; assert(line[0] == '('); line++; while((line[0] != ' ') && (line[0] != ')')) { bitr[0] = line[0]; line++; bitr++; } bitr[0] = '\0'; if(strcmp(buf, "LABEL") == 0) return read_label(line, st, iptr); else if(strcmp(buf, "INITBASE") == 0) return read_initbase(line); else if(strcmp(buf, "CONST") == 0) return read_const(line); else if(strcmp(buf, "GATE") == 0) return read_gate(line); else if(strcmp(buf, "BITS") == 0) return read_bits(line); else if(strcmp(buf, "MKPTR") == 0) return read_mkptr(line); else if(strcmp(buf, "COPY") == 0) return read_copy(line); else if(strcmp(buf, "COPY-INDIR") == 0) return read_copy_indir(line); else if(strcmp(buf, "INDIR-COPY") == 0) return read_indir_copy(line); else if(strcmp(buf, "CALL") == 0) return read_call(line); else if(strcmp(buf, "RET") == 0) return read_ret(line); else if(strcmp(buf, "BRANCH") == 0) return read_branch(line); else if(strcmp(buf, "CLEAR") == 0) return read_clear(line); else if(strcmp(buf, "JOIN") == 0) return read_join(line); else if(strcmp(buf, "ADD") == 0) return read_add(line); else if(strcmp(buf, "MUL") == 0) return read_mul(line); assert(0); }
static void pr_key_index (avatar_s *avatar, ki_t key_index) { key_s key; datagate_s gate; int rc; if (!key_index) return; rc = read_key(avatar, key_index, &key); if (rc) { format(" %u BAD KEY!!!\n", key_index); return; } if (key.k_node) { format(" %u->%llx %s %s " "slot=%d\n", key_index, key.k_id, gate_type(key.k_type), gate_pass(key.k_type), key.k_node); } else { rc = read_gate(key.k_id, &gate); if (rc) { format(" %u->%llx %s %s Gate Broken\n", key_index, key.k_id, gate_type(key.k_type), gate_pass(key.k_type)); } else { format(" %u->%llx %s %s ->%s\n", key_index, gate.gt_id, gate_type(gate.gt_type), gate_pass(gate.gt_type), gate.gt_avatar->av_name); pr_datagate( &gate); } } }
int grains(int *ibufposition,int bufno,int *crosbuf,int *inithole,int *grainstart,int *is_first_grain, int *gapcnt,int *holecnt,int *obufpos,int *graincnt,int chans,int *grainadjusted, double samptotime,double **env,double **envstep,double *envel_val,int winsize,dataptr dz) { int exit_status; register int ibufpos, abs_ipos; int in_grain, m; double gate, ngate; double thistime; float *obuf = dz->sampbuf[2]; float *b = dz->sampbuf[bufno]; int has_snd_output = FALSE; int samps_read_before_thisbuf = dz->total_samps_read - dz->ssampsread; if(dz->outfiletype==SNDFILE_OUT && dz->process != GRAIN_ALIGN) has_snd_output = TRUE; for(ibufpos = 0,abs_ipos = samps_read_before_thisbuf; ibufpos < dz->ssampsread; ibufpos+=chans,abs_ipos+=chans) { if(dz->ptr[GR_GATEVALS]!=NULL && (exit_status = read_gate(abs_ipos,chans,dz))<0) return(exit_status); gate = dz->param[GR_GATE] * F_MAXSAMP; ngate = dz->param[GR_NGATE] * F_MAXSAMP; if(dz->iparam[GR_WSIZE_SAMPS] > 0) { /* envelope tracking */ if((exit_status = adjust_gate(&gate,&ngate,abs_ipos,winsize,env,envstep,envel_val,dz))<0) return(exit_status); } in_grain = FALSE; for(m=0;m<chans;m++) { if(b[ibufpos+m]>gate || b[ibufpos+m]<ngate) in_grain = TRUE; } if(in_grain) { if(*inithole) { *grainstart = ibufpos; *inithole = 0; } if(*holecnt) { if(*holecnt >= dz->iparam[GR_MINHOLE]) { thistime = get_grainstart_time(ibufpos,*grainstart,abs_ipos,*crosbuf,samptotime,dz); if((exit_status = read_values_from_all_existing_brktables(thistime,dz))<0) return(exit_status); if((exit_status = do_the_grain(ibufpos,graincnt,bufno,*gapcnt,obufpos,*grainstart, *crosbuf,chans,grainadjusted,samptotime,is_first_grain,dz))<0) return(exit_status); if(exit_status!=CONTINUE) { *ibufposition = ibufpos; return(FINISHED); /* grsync ran out of sync-times */ } *grainstart = ibufpos; *gapcnt = 0; *crosbuf = 0; } } *holecnt = 0; } else { if(*inithole) { if(has_snd_output) { for(m=0;m<chans;m++) obuf[(*obufpos)++] = b[ibufpos+m]; if(*obufpos >= dz->buflen) { if((exit_status = write_samps(obuf,dz->buflen,dz))<0) return(exit_status); *obufpos = 0; } } continue; } *holecnt += chans; } *gapcnt += chans; } *ibufposition = ibufpos; if(*crosbuf==TRUE) { /* If crosbuf STILL set */ if(dz->ssampsread == dz->buflen) { /* Reached end of buffer while doing crosbuf grain */ if(dz->process == GRAIN_COUNT && dz->itemcnt == GRAIN_ASSESS) { if(dz->vflag[0] == 0) { fprintf(stdout,"WARNING: Encountered grain too large for buffer: counting grains so far\n"); dz->vflag[0] = 1; } } else fprintf(stdout,"WARNING: Encountered grain too large for buffer: writing file so far\n"); fflush(stdout); } return(FINISHED); /* Else reached end of file while doing crosbuf grain */ } if(dz->samps_left) /* UNLESS we've reached end of src */ *crosbuf = TRUE; /* mark crossing into next buffer */ return(CONTINUE); }