本文整理汇总了C++中SigTimer::getPeriodCount方法的典型用法代码示例。如果您正苦于以下问题:C++ SigTimer::getPeriodCount方法的具体用法?C++ SigTimer::getPeriodCount怎么用?C++ SigTimer::getPeriodCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SigTimer
的用法示例。
在下文中一共展示了SigTimer::getPeriodCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mainloopalgorithms
void mainloopalgorithms(void) {
// 1. check to see if we are in a new measure and update the
// metronome accordingly. If in 4/4, then the metronome will
// be guarenteed to be between 0 and 3.99999 after the following
// code is run. The update will make sure that the metronome remains
// synced exactly in time with the absolute beat. (Useful for
// polyphony, not really necessary in monophonic cases).
if (metronome.expired() >= meter) {
metronome.update(meter);
}
// 2. Determine the current beat of the meter.
// We will want to play automated chords on beats one and three.
beatfraction = metronome.getPeriodCount();
beat = (int)beatfraction + 1;
beatfraction -= beat - 1;
// 3. Process the incoming MIDI note messages (if any), keeping track
// of the last note, and whether it is currently on or off.
while (synth.getNoteCount() > 0) {
notemessage = synth.extractNote();
if (notemessage.getP2() != 0) {
note = notemessage.getP1();
notestates[note] = 1;
} else {
notestates[notemessage.getP1()] = 0;
}
}
// 4. Determine the position in time in the current beat.
// There are two beat-parts which are called states:
// state == 0: we are at the start of the beat and may need to
// choose a new chord.
// state == 1: we are past the maximum wait time for a chord decision
// Also, check to see if the state has changed from 0 to 1 or 1 to 0.
oldstate = state;
state = beatfraction < maxwait ? 0 : 1;
stateChange = (state != oldstate);
// 5. Check to see if a chord needs to be played.
if (stateChange && state == 0) {
playMetronome(beat);
if (chordBeat(beat, meter)) {
notescan = 1;
} else {
playChord(currentnote, OFF);
}
}
if (notescan && notestates[note]) { // if note played in beat window
currentnote = note;
playChord(currentnote, ON);
notescan = 0;
} else if (notescan && state == 1) { // if too late for a new note
playChord(currentnote, ON);
notescan = 0;
}
}