void cleaner(int sig) { outputStats(statfile); fprintf(stderr, "\nGot Ctrl+C closing...\n"); fflush(stdout); exit(0); }
static void doItemOverlap(struct chromAnn* inCa, FILE *outFh, FILE *dropFh) /* Do individual item overlap process of chromAnn object given the criteria, * and if so output */ { struct chromAnnRef *overlappingRecs = NULL; struct chromAnnRef **overlappingRecsPtr = NULL; /* used to indicate if recs should be collected */ if (mergeOutput || idOutput || statsOutput) overlappingRecsPtr = &overlappingRecs; boolean overlaps = selectIsOverlapped(selectOpts, inCa, &criteria, overlappingRecsPtr); if (overlappingRecsPtr != NULL) slSort(overlappingRecsPtr, chromAnnRefLocCmp); if (((nonOverlapping) ? !overlaps : overlaps) || outputAll) { if (mergeOutput) outputMerge(inCa, outFh, overlappingRecs); else if (idOutput) outputIds(inCa, outFh, overlappingRecs); else if (statsOutput) outputStats(inCa, outFh, overlappingRecs); else inCa->recWrite(inCa, outFh, '\n'); } else if (dropFh != NULL) { if (idOutput) fprintf(dropFh, "%s\n", getPrintId(inCa)); else inCa->recWrite(inCa, dropFh, '\n'); } slFreeList(&overlappingRecs); }
void MailDirImport::runTest() { done = false; timer.start(); qDebug() << " Synchronising resource."; currentInstance.synchronize(); while (!done) { QTest::qWait(WAIT_TIME); } outputStats(QStringLiteral("import")); }
int resynthesize(Options& opts) { readCoefOptions(opts); auto index = util::parse<unsigned>(opts.input); auto corpus = get_corpus(opts); assert(index < corpus.size()); std::vector<PhonemeInstance> input = corpus.input(index); INFO("Input file: " << alphabet_test.file_data_of(input[0]).file); INFO("Total duration: " << get_total_duration(input)); INFO("Original cost: " << concat_cost(input, crf, crf.lambda, input)); std::vector<int> path; traverse_automaton<MinPathFindFunctions, CRF, 1>(input, crf, crf.lambda, &path); std::vector<PhonemeInstance> output = crf.alphabet().to_phonemes(path); SynthPrinter sp(crf.alphabet(), labels_all); if(opts.has_opt("verbose")) sp.print_synth(path, input); sp.print_textgrid(path, input, labels_synth, opts.text_grid); CRF::Stats stats; INFO("Resynth. cost: " << concat_cost(output, crf, crf.lambda, input, &stats)); //INFO("Second best cost: " << costs[1]); auto baselineCost = concat_cost(output, baseline_crf, baseline_crf.lambda, input); INFO("Baseline cost: " << baselineCost); outputStats(crf.lambda, stats, opts); outputPath(opts, output, input); auto sws = SpeechWaveSynthesis(output, input, crf.alphabet()); Wave outputSignal = sws.get_resynthesis(opts); outputSignal.write(opts.get_opt<std::string>("output", "resynth.wav")); auto sws2 = SpeechWaveSynthesis(input, input, alphabet_test); auto concatenation = sws2.get_concatenation(); concatenation.write(opts.get_opt<std::string>("original", "original.wav")); if(opts.has_opt("verbose")) { Comparisons cmp; cmp.fill(concatenation, outputSignal); INFO("LogSpectrum = " << cmp.LogSpectrum); INFO("LogSpectrumCritical = " << cmp.LogSpectrumCritical); INFO("SegSNR = " << cmp.SegSNR); INFO("MFCC = " << cmp.MFCC); INFO("WSS = " << cmp.WSS); outputComparisons(opts, cmp, baselineCost); } return 0; }
// clean up void loopBackRelease() { // tell running collector thread to end... shouldStop = 1; WaitForSingleObject(m_hThread, INFINITE); CloseHandle(m_hThread); m_hThread = NULL; pAudioClient->Stop(); AvRevertMmThreadCharacteristics(hTask); pAudioCaptureClient->Release(); pAudioClient->Release(); m_pMMDevice->Release(); // thread is done, we are exiting... pBufLocalCurrentEndLocation = 0; outputStats(); }
int baseline(const Options& opts) { readCoefOptions(opts); auto index = opts.get_opt<unsigned>("input", 0); auto corpus = get_corpus(opts); std::vector<PhonemeInstance> input = corpus.input(index); INFO("Input file: " << alphabet_test.file_data_of(input[0]).file); INFO("Total duration: " << get_total_duration(input)); std::vector<int> path; traverse_automaton<MinPathFindFunctions>(input, baseline_crf, baseline_crf.lambda, &path); std::vector<PhonemeInstance> output = baseline_crf.alphabet().to_phonemes(path); Wave outputSignal = SpeechWaveSynthesis(output, input, baseline_crf.alphabet()) .get_resynthesis_td(); outputSignal.write(opts.get_opt<std::string>("output", "baseline.wav")); auto sws2 = SpeechWaveSynthesis(input, input, alphabet_test); auto concatenation = sws2.get_concatenation(); concatenation.write(opts.get_opt<std::string>("original", "original.wav")); CRF::Stats stats; INFO("Baseline cost in original: " << concat_cost(output, crf, crf.lambda, input, &stats)); auto baselineCost = concat_cost(output, baseline_crf, baseline_crf.lambda, input); INFO("Baseline cost:" << baselineCost); outputStats(crf.lambda, stats, opts); outputPath(opts, output, input); if(opts.has_opt("verbose")) { auto sws = SpeechWaveSynthesis(input, input, alphabet_test); auto concatenation = sws.get_concatenation(); Comparisons cmp; cmp.fill(concatenation, outputSignal); INFO("LogSpectrum = " << cmp.LogSpectrum); INFO("LogSpectrumCritical = " << cmp.LogSpectrumCritical); INFO("SegSNR = " << cmp.SegSNR); INFO("MFCC = " << cmp.MFCC); INFO("WSS = " << cmp.WSS); outputComparisons(opts, cmp, baselineCost); } return 0; }
double simulatedAnnealing(char *key, char *ciphertext, char *plaintext, int messageLen) { int count, iter; float annealStep; char newKey[26], oldKey[26]; double prob, delta, maxScore, score, bestScore; // Copy over key so we don't screw up our master copy. Decipher ciphertext using key and score it strcpy(oldKey,key); decipher(oldKey, ciphertext, plaintext, messageLen); maxScore = scoreText(plaintext,messageLen); bestScore = maxScore; iter = 0; // For each step, find our best key for (annealStep = ANNEALING_TEMP; annealStep >= 0; annealStep -= ANNEALING_STEP_SIZE) { for (count = 0; count < MAX_ITERATIONS; count++) { strcpy(newKey, oldKey); alterKey(newKey); decipher(newKey, ciphertext, plaintext, messageLen); score = scoreText(plaintext, messageLen); // our difference between our current maxScore and step score delta = score - maxScore; // We did work in the positive direction (hopefully...) if (delta >= 0) { maxScore = score; strcpy(oldKey, newKey); } else if (annealStep > 0) { // the work we did is a side-grade prob = exp(delta / annealStep); if (prob > 1.0 * rand() / RAND_MAX) { maxScore = score; strcpy(oldKey, newKey); } } // This is our best score so far if (maxScore > bestScore){ bestScore = maxScore; strcpy(key, oldKey); outputStats(iter, bestScore, key); } iter++; } } return bestScore; }
int main(int argc, char *argv[]) { float *u = new float[N]; float *v = new float[N]; float alpha = 2.3; double time4=0; initializeVectors(u,v); TICK(); axpyGPU(u,v,alpha,N); TOCK(time4); outputStats(time4); delete [] u; delete [] v; }
int main(int argc, char **argv) { int opt; static struct option longopts[] = { {"help", no_argument, 0, 'h'}, {"test", no_argument, 0, 't'}, {"simple", no_argument, 0, 's'}, {"bare", no_argument, 0, 'b'}, {"verbose", no_argument, 0, 'v'}, {"logfile", no_argument, 0, 'l'}, {"Id", required_argument, 0, 'A'}, {"Ib", required_argument, 0, 'B'}, {"Dd", required_argument, 0, 'C'}, {"Db", required_argument, 0, 'D'}, {0, 0, 0, 0} }; int longindex; // global simulator options bareMachineMode = true; quietMode = true; // local simulator options bool qtSpimLogMode = false; unsigned iCacheLogDepth = 6; unsigned iCacheLogBlksize = 2; unsigned dCacheLogDepth = 6; unsigned dCacheLogBlksize = 2; while ((opt = getopt_long_only(argc, argv, "", longopts, &longindex)) != -1) { switch (opt) { case 'h' : printHelp(); return 0; case 't' : bareMachineMode = false; instructionExecTest(); testCache(); return 0; case 's' : bareMachineMode = false; break; case 'b' : bareMachineMode = true; break; case 'q' : quietMode = false; break; case 'l' : qtSpimLogMode = true; break; case 'A': // Id iCacheLogDepth = atoi(optarg); break; case 'B': // Ib iCacheLogBlksize = atoi(optarg); break; case 'C': // Dd dCacheLogDepth = atoi(optarg); break; case 'D': // Db dCacheLogBlksize = atoi(optarg); break; default : printf("usage error\n"); exit(0); } } assert(argc > 1 && "need to specify input file"); char* infile = argv[optind]; M.initCache(iCacheLogDepth, iCacheLogBlksize, dCacheLogDepth, dCacheLogBlksize); if (qtSpimLogMode) M.readSpimLogFile(infile); else M.readElfFile(infile); if (bareMachineMode) runBareMachine(); else runSimpleMachine(); outputStats(); return 0; }
void * key_thread(void * args) { struct key_thread_args* key_args = (struct key_thread_args*)args; char *char_ptr, buf1[32], buf2[32], *keys, *saved; int i, delay = 10000; char* logfilename = key_args->logfilename; char* statfilename = key_args->statfilename; logfile = fopen(logfilename, "w"); statfile = fopen(statfilename, "w"); signal(SIGINT, cleaner); signal(SIGTERM, cleaner); initLogs(); /* setup Xwindows */ disp = XOpenDisplay(NULL); if (disp == NULL) { fprintf(stderr, "Cannot open display\n"); exit(1); } XSynchronize(disp, TRUE); /* setup buffers */ saved = buf1; keys = buf2; XQueryKeymap(disp, saved); while (1) { /* find changed keys */ XQueryKeymap(disp, keys); for (i = 0; i < 32*8; i++) { /* if the key data is different that the default we saved before */ int kbit = BIT(keys, i); int sbit = BIT(saved, i); if(kbit > 0) kbit = 1; if(sbit > 0) sbit = 1; if (BIT(keys, i) != BIT(saved, i)) { register char* str; str = (char*) KeyCodeToStr(i); int j = lettertoi(str); if(j >= 0 && j < 26) { if (!sbit && kbit) { StrTimer(str, "start"); } if (sbit && !kbit) { StrTimer(str, "end"); out(str, logs[j]->time, logs[j]->numpressed); } } fflush(stdout); /* in case user is writing to a pipe */ } } char_ptr = saved; saved = keys; keys = char_ptr; if(key_args->exit) { outputStats(); fclose(statfile); fclose(logfile); return; } } }