|
@@ -21,9 +21,10 @@ public:
|
|
|
std::vector<Bar> bars;
|
|
|
|
|
|
Loop()
|
|
|
- : bpm(60), stopNext(false), enabled(false),
|
|
|
- currentBarIndex(0), currentBeatIndex(0), lastBeatTime(0),
|
|
|
- loopThread(&Loop::loop, this)
|
|
|
+ : loopThread(&Loop::loop, this),
|
|
|
+ bpm(60), stopNext(false), enabled(false),
|
|
|
+ currentBarIndex(0), currentBeatIndex(0),
|
|
|
+ lastBeatTime(0), bars(1)
|
|
|
{
|
|
|
}
|
|
|
|
|
@@ -76,15 +77,23 @@ private:
|
|
|
|
|
|
void beat()
|
|
|
{
|
|
|
- std::cout << "\a" << lastBeatTime.count() << std::endl;
|
|
|
+ // std::cout << "\a" << lastBeatTime.count() << std::endl;
|
|
|
if(bars.size() > 0) {
|
|
|
if(currentBarIndex >= bars.size()) {
|
|
|
currentBarIndex = 0;
|
|
|
}
|
|
|
-
|
|
|
- std::cout << "trigger bar#" << currentBarIndex << std::endl;
|
|
|
+ if(currentBeatIndex >= bars[currentBarIndex].beatsCount) {
|
|
|
+ currentBeatIndex = 0;
|
|
|
+ currentBarIndex++;
|
|
|
+ if(currentBarIndex >= bars.size()) {
|
|
|
+ currentBarIndex = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ std::cout << "trigger bar#" << currentBarIndex << " beat#" << currentBeatIndex << std::endl;
|
|
|
+ bars[currentBarIndex].beats[currentBeatIndex].trigger();
|
|
|
|
|
|
- currentBarIndex++;
|
|
|
+ currentBeatIndex++;
|
|
|
}
|
|
|
|
|
|
lastBeatTime = getMillisecondsSinceEpoch();
|