TDfps::TDfps (int nbmoy) : TDString ("") { lasttime = 0xffffffff; lt = NULL; setnbmoy (nbmoy); setcolor (Vector4(1.0,0.5,0.0,0.0)); // orange setwidth (20.0); // thick ! }
Revmodel::Revmodel() { // Tie the components to their buffers combL[0].setbuffer(bufcombL1,combtuningL1); combR[0].setbuffer(bufcombR1,combtuningR1); combL[1].setbuffer(bufcombL2,combtuningL2); combR[1].setbuffer(bufcombR2,combtuningR2); combL[2].setbuffer(bufcombL3,combtuningL3); combR[2].setbuffer(bufcombR3,combtuningR3); combL[3].setbuffer(bufcombL4,combtuningL4); combR[3].setbuffer(bufcombR4,combtuningR4); combL[4].setbuffer(bufcombL5,combtuningL5); combR[4].setbuffer(bufcombR5,combtuningR5); combL[5].setbuffer(bufcombL6,combtuningL6); combR[5].setbuffer(bufcombR6,combtuningR6); combL[6].setbuffer(bufcombL7,combtuningL7); combR[6].setbuffer(bufcombR7,combtuningR7); combL[7].setbuffer(bufcombL8,combtuningL8); combR[7].setbuffer(bufcombR8,combtuningR8); allpassL[0].setbuffer(bufallpassL1,allpasstuningL1); allpassR[0].setbuffer(bufallpassR1,allpasstuningR1); allpassL[1].setbuffer(bufallpassL2,allpasstuningL2); allpassR[1].setbuffer(bufallpassR2,allpasstuningR2); allpassL[2].setbuffer(bufallpassL3,allpasstuningL3); allpassR[2].setbuffer(bufallpassR3,allpasstuningR3); allpassL[3].setbuffer(bufallpassL4,allpasstuningL4); allpassR[3].setbuffer(bufallpassR4,allpasstuningR4); // Set default values allpassL[0].setfeedback(0.5f); allpassR[0].setfeedback(0.5f); allpassL[1].setfeedback(0.5f); allpassR[1].setfeedback(0.5f); allpassL[2].setfeedback(0.5f); allpassR[2].setfeedback(0.5f); allpassL[3].setfeedback(0.5f); allpassR[3].setfeedback(0.5f); param[0] = initialroom; param[1] = initialdamp; param[2] = initialwet; setroomsize(initialroom); setdamp(initialdamp); setwidth(initialwidth); setmode(initialmode); // Buffer will be full of rubbish - so we MUST mute them for (int i = 0; i < numcombs; i++) { combL[i].mute(); combR[i].mute(); } for (int i=0;i<numallpasses;i++) { allpassL[i].mute(); allpassR[i].mute(); } }
void Phaser::changepar(int npar, unsigned char value) { switch (npar) { case 0: setvolume(value); break; case 1: setpanning(value); break; case 2: lfo.Pfreq = value; lfo.updateparams(); break; case 3: lfo.Prandomness = value; lfo.updateparams(); break; case 4: lfo.PLFOtype = value; lfo.updateparams(); barber = (2 == value); break; case 5: lfo.Pstereo = value; lfo.updateparams(); break; case 6: setdepth(value); break; case 7: setfb(value); break; case 8: setstages(value); break; case 9: setlrcross(value); setoffset(value); break; case 10: Poutsub = (value > 1) ? 1 : value; break; case 11: setphase(value); setwidth(value); break; case 12: Phyper = min((int)value, 1); break; case 13: setdistortion(value); break; case 14: Panalog = value; break; } }
void Analog_Phaser::changepar (int npar, int value) { switch (npar) { case 0: setvolume (value); break; case 1: setdistortion (value); break; case 2: lfo.Pfreq = value; lfo.updateparams (); break; case 3: lfo.Prandomness = value; lfo.updateparams (); break; case 4: lfo.PLFOtype = value; lfo.updateparams (); barber = 0; if (value == 2) barber = 1; break; case 5: lfo.Pstereo = value; lfo.updateparams (); break; case 6: setwidth (value); break; case 7: setfb (value); break; case 8: setstages (value); break; case 9: setoffset (value); break; case 10: if (value > 1) value = 1; Poutsub = value; break; case 11: setdepth (value); break; case 12: if (value > 1) value = 1; Phyper = value; break; }; };
void RyanWah::changepar (int npar, int value) { switch (npar) { case 0: setvolume (value); break; case 1: Pq = value; q = (float) Pq; break; case 2: lfo.Pfreq = value; lfo.updateparams (); break; case 3: lfo.Prandomness = 0;//value; lfo.updateparams (); break; case 4: lfo.PLFOtype = value; lfo.updateparams (); break; case 5: lfo.Pstereo = value; lfo.updateparams (); break; case 6: setwidth (value); break; case 7: setampsns (value); break; case 8: Pampsnsinv = value; setampsns (Pampsns); break; case 9: Pampsmooth = value; setampsns (Pampsns); break; case 10: Plp = value; lpmix = ((float) Plp)/32.0f; reinitfilter (); break; case 11: Pbp = value; bpmix = ((float) Pbp)/32.0f; reinitfilter (); break; case 12: Php = value; hpmix = ((float) Php)/32.0f; reinitfilter (); break; case 13: Pstages = (value - 1); filterl->setstages(Pstages); filterr->setstages(Pstages); cleanup(); break; case 14: Prange = value; if(Pamode) maxfreq = ((float) Prange)/(fSAMPLE_RATE/6.0f); else maxfreq = ((float) Prange); break; case 15: Pminfreq = value; if (Pamode) minfreq = ((float) Pminfreq)/(fSAMPLE_RATE/6.0f); else minfreq = (float) value; break; case 16: variq = value; break; case 17: Pmode=value; if((Pmode==1) || (Pmode==3)) Pqm = 1; else Pqm = 0; filterl->setmode(Pqm); filterr->setmode(Pqm); if((Pmode==2) || (Pmode==3)) Pamode = 1; else Pamode = 0; if(Pamode) { minfreq = ((float) Pminfreq)/(fSAMPLE_RATE/6.0f); maxfreq = ((float) Prange)/(fSAMPLE_RATE/6.0f); } else { minfreq = (float) Pminfreq; maxfreq = (float) Prange; } break; case 18: Ppreset = value; break; }; };
main (int argc, char **argv) { AFfilehandle file; AFframecount count, frameCount; int channelCount, sampleFormat, sampleWidth; float frameSize; void *buffer; double sampleRate; ALport outport; ALconfig outportconfig; if (argc < 2) usage(); file = afOpenFile(argv[1], "r", NULL); if (file == AF_NULL_FILEHANDLE) { fprintf(stderr, "Could not open file %s.\n", argv[1]); exit(EXIT_FAILURE); } frameCount = afGetFrameCount(file, AF_DEFAULT_TRACK); frameSize = afGetVirtualFrameSize(file, AF_DEFAULT_TRACK, 1); channelCount = afGetVirtualChannels(file, AF_DEFAULT_TRACK); sampleRate = afGetRate(file, AF_DEFAULT_TRACK); afGetVirtualSampleFormat(file, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth); if (sampleFormat == AF_SAMPFMT_UNSIGNED) { afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, sampleWidth); } printf("frame count: %lld\n", frameCount); printf("frame size: %d bytes\n", (int) frameSize); printf("channel count: %d\n", channelCount); printf("sample rate: %.2f Hz\n", sampleRate); buffer = malloc(BUFFERED_FRAME_COUNT * frameSize); outportconfig = alNewConfig(); setwidth(outportconfig, sampleWidth); setsampleformat(outportconfig, sampleFormat); alSetChannels(outportconfig, channelCount); count = afReadFrames(file, AF_DEFAULT_TRACK, buffer, BUFFERED_FRAME_COUNT); outport = alOpenPort("irixread", "w", outportconfig); setrate(outport, sampleRate); do { printf("count = %lld\n", count); alWriteFrames(outport, buffer, count); count = afReadFrames(file, AF_DEFAULT_TRACK, buffer, BUFFERED_FRAME_COUNT); } while (count > 0); waitport(outport); alClosePort(outport); alFreeConfig(outportconfig); afCloseFile(file); }
int main(int argc, char **argv) { static bstate states[N]; static bstate out_states[3 * N]; int num_outstates = 0; int j; int k; int x, y; double sum_p = 0.0; double sum_squared_p = 0.0; int num_legal_final_states; int height; int width; int num_iterations = 100; if (argc < 5) { fprintf(stderr, "Usage: estimate_legal_stratified <height> <width> <num_samples> <seed>\n"); return 1; } height = atoi(argv[1]); width = atoi(argv[2]); num_iterations = atoi(argv[3]); gg_srand(atoi(argv[4])); setwidth(height); for (j = 0; j < num_iterations; j++) { double p = 1.0; for (k = 0; k < N; k++) memcpy(states[k], *startstate(), sizeof(bstate)); for (y = 0; y < width; y++) for (x = 0; x < height; x++) { num_outstates = 0; for (k = 0; k < N; k++) { bstate expanded_states[3]; int num_expanded_states; int m; num_expanded_states = expandstate(states[k], x, expanded_states); for (m = 0; m < num_expanded_states; m++) { memcpy(out_states[num_outstates++], expanded_states[m], sizeof(bstate)); } } p *= (double) num_outstates / (3 * N); for (k = 0; k < N; k++) memcpy(states[k], out_states[random_choice(num_outstates)], sizeof(bstate)); } num_legal_final_states = 0; for (k = 0; k < num_outstates; k++) num_legal_final_states += finalstate(out_states[k]); p *= (double) num_legal_final_states / num_outstates; sum_p += p; sum_squared_p += p * p; if ((j + 1) % 10 == 0) { double std = sqrt(sum_squared_p - sum_p * sum_p / (j + 1)) / j; printf("%d %10.8lg %lg %lg\n", j + 1, sum_p / (j + 1), std, std * sqrt(j)); } } printf("Estimated legal probability: %10.8lg\n", sum_p / num_iterations); printf("Standard deviation: %lg\n", sqrt(sum_squared_p - sum_p * sum_p / num_iterations) / num_iterations); printf("Standard deviation per sample: %lg\n", sqrt((sum_squared_p - sum_p * sum_p / num_iterations) / num_iterations)); return 0; }
int main(int argc, char **argv) { int k; int j; long double size = 0.0; long double sum_size = 0.0; long double sum_squared_size = 0.0; int width; int height; struct queue_item *Qin = Q1; struct queue_item *Qout = Q2; struct queue_item *tmp; int x, y; int num_iterations = 10000; if (argc < 5) { fprintf(stderr, "Usage: estimate_legal_stratified <height> <width> <num_samples> <seed>\n"); return 1; } height = atoi(argv[1]); width = atoi(argv[2]); num_iterations = atoi(argv[3]); gg_srand(atoi(argv[4])); setwidth(height); for (j = 0; j < num_iterations; j++) { for (k = 0; k < MAX_NUMBER_OF_STRATA; k++) Qin[k].weight = -1.0; memcpy(Qin[0].node, *startstate(), sizeof(bstate)); Qin[0].weight = 1.0; for (y = 0; y < width; y++) for (x = 0; x < height; x++) { for (k = 0; k <= height; k++) Qout[k].weight = -1.0; for (k = 0; k <= height; k++) { bstate expanded_states[3]; int num_expanded_states; int m; if (Qin[k].weight == -1.0) continue; num_expanded_states = expandstate(Qin[k].node, x, expanded_states); for (m = 0; m < num_expanded_states; m++) { int next_stratum = stratify(expanded_states[m]); if (Qout[next_stratum].weight == -1.0) { memcpy(Qout[next_stratum].node, expanded_states[m], sizeof(bstate)); Qout[next_stratum].weight = Qin[k].weight / 3.0; } else { Qout[next_stratum].weight += Qin[k].weight / 3.0; if (gg_drand() * Qout[next_stratum].weight < Qin[k].weight / 3.0) memcpy(Qout[next_stratum].node, expanded_states[m], sizeof(bstate)); } } } tmp = Qin; Qin = Qout; Qout = tmp; } size = 0; for (k = 0; k <= height; k++) if (Qin[k].weight != -1.0 && finalstate(Qin[k].node)) size += Qin[k].weight; sum_size += size; sum_squared_size += size * size; if ((j + 1) % 1000 == 0) { double std = sqrt(sum_squared_size - sum_size * sum_size / (j + 1)) / j; printf("%d %10.8Lg %lg %lg\n", j + 1, sum_size / (j + 1), std, std * sqrt(j)); } } printf("Estimated legal probability: %10.8Lg\n", sum_size / num_iterations); printf("Standard deviation: %lg\n", sqrt(sum_squared_size - sum_size * sum_size / num_iterations) / num_iterations); printf("Standard deviation per sample: %lg\n", sqrt((sum_squared_size - sum_size * sum_size / num_iterations) / num_iterations)); return 0; }
int main(int argc, char *argv[]) { int incpus,ncpus,cpuid,modidx,width,y,x,nextx,tsizelen; uint64_t msize,modulus,nin; char c,*tsizearg,inbase[64]; uint64_t skipunder, nnewillcnt, newstates[3]; int i,nnew,noutfiles; statebuf *mb; statecnt sn; jtset *jts; goin *gin; goout *go; assert(sizeof(uint64_t)==8); if (argc!=9 && argc!=10) { printf("usage: %s width modulo_index y x incpus ncpus cpuid maxtreesize[kKmMgG] [lastfile]\n",argv[0]); exit(1); } setwidth(width = atoi(argv[1])); modidx = atoi(argv[2]); if (modidx < 0 || modidx >= NMODULI) { printf ("modulo_index %d not in range [0,%d)\n", modidx, NMODULI); exit(1); } modulus = -(uint64_t)modulusdeltas[modidx]; y = atoi(argv[3]); x = atoi(argv[4]); nextx = (x+1) % width; incpus = atoi(argv[5]); ncpus = atoi(argv[6]); if (ncpus < 1 || ncpus > MAXCPUS) { printf ("#cpus %d not in range [0,%d]\n", ncpus, MAXCPUS); exit(1); } cpuid = atoi(argv[7]); if (cpuid < 0 || cpuid >= ncpus) { printf("cpuid %d not in range [0,%d]\n", ncpus, ncpus-1); exit(1); } tsizelen = strlen(tsizearg = argv[8]); if (!isdigit(c = tsizearg[tsizelen-1])) tsizearg[tsizelen-1] = '\0'; msize = atol(tsizearg); if (c == 'k' || c == 'K') msize *= 1000LL; if (c == 'm' || c == 'M') msize *= 1000000LL; if (c == 'g' || c == 'G') msize *= 1000000000LL; if (msize < 1000000LL) { printf("memsize %jd too small for comfort.\n", (intmax_t)msize); exit(1); } if (argc > 9) { assert(sscanf(argv[9],"%d.%lo", &noutfiles, &skipunder) == 2); noutfiles++; printf("skipping %d output files and states up to %jo\n", noutfiles, (uintmax_t)skipunder); skipunder++; } else { noutfiles = 0; skipunder = 0L; } sprintf(inbase,"%d.%d/yx.%02d.%02d",width,modidx,y,x); gin = openstreams(inbase, incpus, ncpus, cpuid, modulus, skipunder); go = goinit(width, modidx, modulus, y+!nextx, nextx, ncpus, cpuid); nnewillcnt = nin = 0LL; jts = jtalloc(msize, modulus, LOCBITS); if (nstreams(gin)) { for (; (mb = minstream(gin))->state != FINALSTATE; nin++,deletemin(gin)) { sn.cnt = mb->cnt; // printf("expanding %jo\n", (uintmax_t)mb->state); nnew = expandstate(mb->state, x, newstates); for (i=0; i<nnew; i++) { sn.state = newstates[i]; //printf("inserting %jo\n", (uintmax_t)sn.state); jtinsert(jts, &sn); } if (nnew < 3) // nnew == 2 modadd(modulus, &nnewillcnt, mb->cnt); if (jtfull(jts)) dumpstates(go, jts, noutfiles++, mb->state); } } dumpstates(go, jts, noutfiles++, FINALSTATE); jtfree(jts); printf("(%d,%d) size %ju xsize %ju mod ",y,x,(uintmax_t)nin,(uintmax_t)totalread(gin)); if (modulus) printf("%ju",(uintmax_t)modulus); else printf("18446744073709551616"); printf("\nnewillegal %ju ", (uintmax_t)nnewillcnt); printf( "needy %ju ", (uintmax_t)needywritten(go)); printf( "legal %ju ", (uintmax_t)legalwritten(go)); printf("at (%d,%d)\n",y+(nextx==0),nextx); assert(cpuid != 0 || skipunder != 0L || nin > 0); // crash if cpu0 processes no states return 0; }
int main(int c, char *v[], char *e[]) { register int rflag = ttyflg; int rsflag = 1; /* local restricted flag */ register unsigned char *flagc = flagadr; struct namnod *n; init_sigval(); mypid = getpid(); mypgid = getpgid(mypid); mysid = getsid(mypid); /* * initialize storage allocation */ if (stakbot == 0) { addblok((unsigned)0); } /* * If the first character of the last path element of v[0] is "-" * (ex. -sh, or /bin/-sh), this is a login shell */ if (*simple(v[0]) == '-') { signal(SIGXCPU, SIG_DFL); signal(SIGXFSZ, SIG_DFL); /* * As the previous comment states, this is a login shell. * Therefore, we set the login_shell flag to explicitly * indicate this condition. */ login_shell = TRUE; } stdsigs(); /* * set names from userenv */ setup_env(); /* * Do locale processing. */ setlocale(LC_CTYPE, ""); /* * 'rsflag' is zero if SHELL variable is * set in environment and * the simple file part of the value. * is rsh */ if (n = findnam("SHELL")) { if (eq("rsh", simple(n->namval))) rsflag = 0; } /* * a shell is also restricted if the simple name of argv(0) is * rsh or -rsh in its simple name */ #ifndef RES if (c > 0 && (eq("rsh", simple(*v)) || eq("-rsh", simple(*v)))) rflag = 0; #endif if (eq("jsh", simple(*v)) || eq("-jsh", simple(*v))) flags |= monitorflg; hcreate(); set_dotpath(); /* * look for options * dolc is $# */ dolc = options(c, (unsigned char **)v); if (dolc < 2) { flags |= stdflg; { while (*flagc) flagc++; *flagc++ = STDFLG; *flagc = 0; } } if ((flags & stdflg) == 0) dolc--; if ((flags & privflg) == 0) { register uid_t euid; register gid_t egid; register uid_t ruid; register gid_t rgid; /* * Determine all of the user's id #'s for this process and * then decide if this shell is being entered as a result * of a fork/exec. * If the effective uid/gid do NOT match and the euid/egid * is < 100 and the egid is NOT 1, reset the uid and gid to * the user originally calling this process. */ euid = geteuid(); ruid = getuid(); egid = getegid(); rgid = getgid(); if ((euid != ruid) && (euid < 100)) setuid(ruid); /* reset the uid to the orig user */ if ((egid != rgid) && ((egid < 100) && (egid != 1))) setgid(rgid); /* reset the gid to the orig user */ } dolv = (unsigned char **)v + c - dolc; dolc--; /* * return here for shell file execution * but not for parenthesis subshells */ if (setjmp(subshell)) { freejobs(); flags |= subsh; } /* * number of positional parameters */ replace(&cmdadr, dolv[0]); /* cmdadr is $0 */ /* * set pidname '$$' */ assnum(&pidadr, (long)mypid); /* * set up temp file names */ settmp(); /* * default internal field separators * Do not allow importing of IFS from parent shell. * setup_env() may have set anything from parent shell to IFS. * Always set the default ifs to IFS. */ assign(&ifsnod, sptbnl); dfault(&timeoutnod, "0"); timeoutnod.namflg |= N_RDONLY; dfault(&mchknod, MAILCHECK); mailchk = stoi(mchknod.namval); /* initialize OPTIND for getopt */ n = lookup("OPTIND"); assign(n, "1"); /* * make sure that option parsing starts * at first character */ getopt_sp = 1; /* initialize multibyte information */ setwidth(); if ((beenhere++) == FALSE) /* ? profile */ { if ((login_shell == TRUE) && (flags & privflg) == 0) { /* system profile */ #ifndef RES if ((input = pathopen(nullstr, sysprofile)) >= 0) exfile(rflag); /* file exists */ #endif /* user profile */ if ((input = pathopen(homenod.namval, profile)) >= 0) { exfile(rflag); flags &= ~ttyflg; } } if (rsflag == 0 || rflag == 0) { if ((flags & rshflg) == 0) { while (*flagc) flagc++; *flagc++ = 'r'; *flagc = '\0'; } flags |= rshflg; } /* * open input file if specified */ if (comdiv) { estabf(comdiv); input = -1; } else { if (flags & stdflg) { input = 0; } else { /* * If the command file specified by 'cmdadr' * doesn't exist, chkopen() will fail calling * exitsh(). If this is a login shell and * the $HOME/.profile file does not exist, the * above statement "flags &= ~ttyflg" does not * get executed and this makes exitsh() call * longjmp() instead of exiting. longjmp() will * return to the location specified by the last * active jmpbuffer, which is the one set up in * the function exfile() called after the system * profile file is executed (see lines above). * This would cause an infinite loop, because * chkopen() will continue to fail and exitsh() * to call longjmp(). To make exitsh() exit instead * of calling longjmp(), we then set the flag forcexit * at this stage. */ flags |= forcexit; input = chkopen(cmdadr, 0); flags &= ~forcexit; } #ifdef ACCT if (input != 0) preacct(cmdadr); #endif comdiv--; } } #ifdef pdp11 else *execargs = (char *)dolv; /* for `ps' cmd */ #endif exfile(0); done(0); /*NOTREACHED*/ return 0; }