Fabian Peter Hammerle vor 10 Jahren
Ursprung
Commit
d414b57589
3 geänderte Dateien mit 18 neuen und 8 gelöschten Zeilen
  1. 1 1
      Beat.h
  2. 1 0
      CMakeLists.txt
  3. 16 7
      Loop.h

+ 1 - 1
Beat.h

@@ -2,9 +2,9 @@
 
 class Beat
 {
+public:
     void trigger() 
     {
-        std::cout << "\atick" << std::endl;
     }
 };
 

+ 1 - 0
CMakeLists.txt

@@ -1,5 +1,6 @@
 cmake_minimum_required (VERSION 2.8.0)
 project (launchpad-sequencer)
+
 include_directories("${CMAKE_SOURCE_DIR}")
 add_definitions(-pthread)
 add_definitions(-std=c++11)

+ 16 - 7
Loop.h

@@ -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();