bool MIDINote::updateFromMIDIMessage(uint8_t* msg, int msgLength) { uint8_t channelMessage = msg[0] & 0xF0; if ( channelMessage == 0x80 ) { this->setKeydown(false); envelopePhase = RELEASE_PHASE; envelopePhasePosition = 0; return true; } else if ( channelMessage == 0x90 ) { pitch = msg[1]; channel = channelMessage & 0x0F; velocity = msg[2]; envelopePhase = 0; frequency = computeFrequency(); generatorPhase = 0; envelopePhasePosition = 0; envelopeFactor = 0; active = true; if ( velocity == 0 ) { this->setKeydown(false); envelopePhase = RELEASE_PHASE; } else { setKeydown(true); } return true; } return false; }
void RollingFileAppender::setDatePattern(const QString& datePattern) { setDatePatternString(datePattern); computeFrequency(); computeRollOverTime(); }
void DailyRollingFileAppender::activateOptions() { QMutexLocker locker(&mObjectGuard); computeFrequency(); if (!mActiveDatePattern.isEmpty()) { rollOver(); FileAppender::activateOptions(); } }
int main(int argc, char **argv) { if (argc < 2) { printf("\nInput file needed. Exiting...\n"); return 0; } FILE *input = fopen(argv[1], "r"); char pt, c; int i = 0, numChars, shifts[3] = {0}; float charCount[26] = {0}; table *alphabet = NULL; alphabet = readInFile(alphabet, "letterFrequencies.txt"); numChars = countFrequency(input, charCount); computeFrequency(numChars, charCount); printf("\nFREQUENCY ANALYSIS ATTACK ON THE SHIFT CIPHER" "\n--------------------------------------"); table *inputFrequencies = NULL; int a = 0; while (a < 26) { inputFrequencies = loadTable(inputFrequencies, a+97, charCount[a], 0); a++; } pickTopShifts(inputFrequencies, shifts); table *temp = inputFrequencies; printf("\nTESTING TOP 3 SHIFT POSSIBILITIES\n"); for (i = 0; i < 3; i++) { rewind(input); printf("\nDecryption %d/3; Shift :%d\t", i+1, shifts[i]-4); while((c = getc(input)) != EOF){ pt = decrypt(c, shifts[i]-4); putchar(pt); } } printf("\n"); fclose(input); return 0; }