factoring metronomes, wait for haptic to begin
authorThomas Pietrzak <thomas.pietrzak@gmail.com>
Thu, 2 Jun 2011 20:43:56 +0000 (20:43 +0000)
committerThomas Pietrzak <thomas.pietrzak@gmail.com>
Thu, 2 Jun 2011 20:43:56 +0000 (20:43 +0000)
git-svn-id: svn+ssh://thomaspietrzak.com/var/svn/rep@21 47cf9a05-e0a8-4ed5-9e9b-101a649bc004

Haptic Metronome/Haptic Metronome.suo
Haptic Metronome/Haptic Metronome/Haptic Metronome.vcxproj
include/Metronome.hpp
include/MetronomeAudio.hpp
include/MetronomeHaptic.hpp
src/Metronome.cpp
src/MetronomeAudio.cpp
src/MetronomeHaptic.cpp
src/PaintGame.cpp
src/main.cpp

index 6080ca3c055c7efe7d3269a9482a23664743a295..7cdbd582c1e81d6883193690ad1663301977c76d 100644 (file)
Binary files a/Haptic Metronome/Haptic Metronome.suo and b/Haptic Metronome/Haptic Metronome.suo differ
index 1ec5140a4bfeff3a52bbbb9d78bebf08d56fea5d..861b312a091cb412d4652af767db707e891c1ba3 100644 (file)
@@ -50,9 +50,9 @@
   </PropertyGroup>\r
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
     <ClCompile>\r
-      <WarningLevel>Level4</WarningLevel>\r
+      <WarningLevel>Level3</WarningLevel>\r
       <Optimization>Disabled</Optimization>\r
-      <PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions);WIN32;FULLSCREEN</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions);WIN32</PreprocessorDefinitions>\r
       <DisableSpecificWarnings>4996</DisableSpecificWarnings>\r
     </ClCompile>\r
     <Link>\r
@@ -68,7 +68,7 @@
       <Optimization>MaxSpeed</Optimization>\r
       <FunctionLevelLinking>true</FunctionLevelLinking>\r
       <IntrinsicFunctions>true</IntrinsicFunctions>\r
-      <PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions);WIN32</PreprocessorDefinitions>\r
+      <PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions);WIN32;FULLSCREEN</PreprocessorDefinitions>\r
     </ClCompile>\r
     <Link>\r
       <GenerateDebugInformation>false</GenerateDebugInformation>\r
index cbcd7b5cfa44b207b18136c83af5bb86277b64ed..1a92832d10fa3c0bfdfb8aa11e965c3b94e996d5 100644 (file)
@@ -7,9 +7,13 @@
 class Metronome\r
 {\r
        public:\r
-               Metronome(const Track *track, Uint32 nbbeats=4, Uint32 tempo=0, bool activated=false);\r
+               Metronome(const Track &track, Uint32 nbbeats=4, Uint32 tempo=0, bool activated=false);\r
                virtual ~Metronome(){}\r
 \r
+               virtual void init(){}\r
+\r
+               virtual void checkAt(Uint32 timestamp)=0;\r
+\r
                virtual void setActive(bool activated) { _activated = activated; }\r
                virtual void setTempo(Uint32 tempo) { _tempo = tempo; }\r
                virtual void setNbBeats(Uint32 nbbeats) {_nbbeats = nbbeats; }\r
@@ -20,7 +24,13 @@ class Metronome
                Uint32 _nbbeats;\r
                Uint32 _tempo;\r
                bool _activated;\r
-               const Track *_track;\r
+               unsigned char _currentbeat;\r
+               const list<Pair<Uint32, Uint32> > *_bips;
+               const map<Uint32, Pair<Uint32, Uint32> > *_tempos;
+               const map<Uint32, Pair<Uint32, Uint32> > *_timesignatures;
+               list<Pair<Uint32, Uint32> >::const_iterator _iBips;
+               map<Uint32, Pair<Uint32, Uint32> >::const_iterator _iTempos;
+               map<Uint32, Pair<Uint32, Uint32> >::const_iterator _iTimesignature;
 };\r
 \r
 #endif\r
index 7134ffc165d9659f24c26ece43a07126457b9741..b2771862706cec694f5a9767e4acaabdf385d74f 100644 (file)
 class MetronomeAudio : public Metronome\r
 {      \r
        public:\r
-               MetronomeAudio(const Track *track, Uint32 nbbeats=4, Uint32 tempo=0, bool activated=true);\r
+               MetronomeAudio(const Track &track, Uint32 nbbeats=4, Uint32 tempo=0, bool activated=true);\r
 \r
                ~MetronomeAudio();\r
 \r
+               void checkAt(Uint32 timestamp);\r
+\r
                void run();\r
 \r
        private:\r
index a8a7a98fe2b6a0c5923d2fa2cc8629eb620e4400..e402770a3bc983fbfd4abf034a17a4ec5c8d560f 100644 (file)
 class MetronomeHaptic : public Metronome\r
 {      \r
        public:\r
-               MetronomeHaptic(const Track *track, Uint32 nbbeats=4, Uint32 tempo=0, bool activated=true);\r
+               MetronomeHaptic(const Track &track, Uint32 nbbeats=4, Uint32 tempo=0, bool activated=true);\r
 \r
                ~MetronomeHaptic();\r
 \r
+               void init();\r
+\r
                void setTempo(Uint32 tempo);\r
                void setNbBeats(Uint32 nbbeats);\r
 \r
+               void checkAt(Uint32 timestamp);\r
+\r
                void run();\r
 \r
        private:\r
@@ -30,4 +34,4 @@ class MetronomeHaptic : public Metronome
                Serial *_comport;\r
 };\r
 \r
-#endif
\ No newline at end of file
+#endif\r
index 5d8396ea04d73594f061ba0aa81bb58724b62f53..52d9622204ec55cba60694d4b3d32133f20882ad 100644 (file)
@@ -1,6 +1,10 @@
 #include "Metronome.hpp"\r
 \r
-Metronome::Metronome(const Track *track, Uint32 nbbeats, Uint32 tempo, bool activated)\r
-:_track(track), _nbbeats(nbbeats), _tempo(tempo), _activated(activated)\r
-{\r
+Metronome::Metronome(const Track &track, Uint32 nbbeats, Uint32 tempo, bool activated)\r
+:_nbbeats(nbbeats), _tempo(tempo), _activated(activated), _currentbeat(0), 
+       _bips(track.getBips()), _tempos(track.getTempos()), _timesignatures(track.getTimeSignatures())
+{
+       _iBips = _bips->begin();
+       _iTempos = _tempos->begin();
+       _iTimesignature = _timesignatures->begin();\r
 }\r
index 4ab0fda5114942113f3e145853f07f56225f4004..b785bbd1b54209474a233453143e978dbb92cbe1 100644 (file)
@@ -2,13 +2,12 @@
 
 #include "Mixer.hpp"
 
-extern Uint32 start;
-
 #define BIPLENGTH 10
 
+extern Uint32 start;
 extern FILE*logfile;
 
-MetronomeAudio::MetronomeAudio(const Track *track, Uint32 nbbeats, Uint32 tempo, bool activated)
+MetronomeAudio::MetronomeAudio(const Track &track, Uint32 nbbeats, Uint32 tempo, bool activated)
 :Metronome(track, nbbeats, tempo, activated), thread(NULL)
 {
        Mixer::getInstance()->addSound("bip","bip10.wav");
@@ -26,52 +25,45 @@ void MetronomeAudio::run()
        thread = SDL_CreateThread(&MetronomeAudio::thread_func, this);
 }
 
+void MetronomeAudio::checkAt(Uint32 timestamp)
+{
+       while (_iBips != _bips->end() && timestamp >= BIPTIMESTAMP(*_iBips))
+       {
+               if (_currentbeat == 0)
+                       Mixer::getInstance()->playSound("bip");
+               else
+                       Mixer::getInstance()->playSound("bip2");
+               if (logfile)
+                       fprintf(logfile, "BIP;%d;%d;%d\n", BIPTICK(*_iBips), BIPTIMESTAMP(*_iBips), timestamp);
+               SDL_Log("BipA %d at %d\n",  BIPTIMESTAMP(*_iBips), timestamp);
+
+               _currentbeat = (_currentbeat + 1) % _nbbeats;
+               _iBips++;
+       }
+
+       // on avance tant que les tempos sont dépassées
+       while (_iTimesignature != _timesignatures->end() && (*_iTimesignature).second.getX() < timestamp)
+       {
+               //time signature change
+               SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Time signature change at %d : tick=%d at %d for %d beats\n", 
+                       timestamp, 
+                       (*_iTimesignature).first, 
+                       (*_iTimesignature).second.getX(), 
+                       (*_iTimesignature).second.getY());
+               _nbbeats = (*_iTimesignature).second.getY();
+               _iTimesignature++;
+       }
+}
+
 int MetronomeAudio::thread_func(void *obj)
 {
        MetronomeAudio *thismetronome = static_cast<MetronomeAudio *>(obj);
 
        SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
 
-       const list<Pair<Uint32, Uint32> > *bips = thismetronome->_track->getBips();
-       //const map<Uint32, Pair<float, Uint32> > *tempo = thismetronome->_track->getTempos();
-    const map<Uint32, Pair<Uint32, Uint32> > *timesignatures = thismetronome->_track->getTimeSignatures();
-       static list<Pair<Uint32, Uint32> >::const_iterator cBips = bips->begin();
-       //static map<Uint32, Pair<float, Uint32> >::const_iterator cTempo = tempo->begin();
-       static map<Uint32, Pair<Uint32, Uint32> >::const_iterator cTimesignature = timesignatures->begin();
-
-       int currentbeat = 0;
-       Uint32 currenttime = 0;
-       float lag = 0.0;
-
        while(thismetronome->_activated)
        {
-               Uint32 currenttime = SDL_GetTicks() - start;
-
-               while (cBips != bips->end() && currenttime >= BIPTIMESTAMP(*cBips))
-               {
-                       if (currentbeat == 0)
-                               Mixer::getInstance()->playSound("bip");
-                       else
-                               Mixer::getInstance()->playSound("bip2");
-                       if (logfile)
-                               fprintf(logfile, "BIP;%d;%d;%d\n", BIPTICK(*cBips), BIPTIMESTAMP(*cBips), currenttime);
-
-                       currentbeat = (currentbeat + 1) % thismetronome->_nbbeats;
-                       cBips++;
-               }
-
-               // on avance tant que les tempos sont dépassées
-               while (cTimesignature != timesignatures->end() && (*cTimesignature).second.getX() < currenttime)
-               {
-                       //tempo change
-                       SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Time signature change at %d : tick=%d at %d for %d beats\n", 
-                               currenttime, 
-                               (*cTimesignature).first, 
-                               (*cTimesignature).second.getX(), 
-                               (*cTimesignature).second.getY());
-                       thismetronome->_nbbeats = (*cTimesignature).second.getY();
-                       cTimesignature++;
-               }
+               thismetronome->checkAt(SDL_GetTicks() - start);
 
                SDL_Delay(5);
        }
index 70290ef9cb29a9a6af954f5fb0ac8e2db4118033..164716972b05617c3bada2fc19c9664dad85b182 100644 (file)
@@ -2,18 +2,20 @@
 
 #include "Mixer.hpp"
 
+#include <SDL/SDL_mutex.h>
+
 #ifdef WIN32
        #include "SerialWindows.hpp"
 #else
        #include "SerialLinux.hpp"
 #endif
-extern Uint32 start;
 
 #define BEFOREDELAY 2000
 
+extern Uint32 start;
 extern FILE *logfile;
 
-MetronomeHaptic::MetronomeHaptic(const Track *track, Uint32 nbbeats, Uint32 tempo, bool activated)
+MetronomeHaptic::MetronomeHaptic(const Track &track, Uint32 nbbeats, Uint32 tempo, bool activated)
 :Metronome(track, nbbeats, tempo, activated), thread(NULL)
 {
        try
@@ -28,10 +30,10 @@ MetronomeHaptic::MetronomeHaptic(const Track *track, Uint32 nbbeats, Uint32 temp
        unsigned char buffer1[3];\r
        buffer1[0] = 'N'; buffer1[1] = 0x00; buffer1[2] = 0x01;\r
        unsigned char buffer2[6];\r
-       buffer2[0] = 0x01;                                      //pattern\r
-       buffer2[1] = 0; buffer2[2] = 100;       //duration\r
-       buffer2[3] = 0; buffer2[4] = 250;       //frequency\r
-       buffer2[5] = 255;                                       //amplitude\r
+       buffer2[0] = 0x01;                                              //pattern\r
+       buffer2[1] = 0; buffer2[2] = 50;        //duration\r
+       buffer2[3] = 0; buffer2[4] = 250;               //frequency\r
+       buffer2[5] = 255;                                               //amplitude\r
 \r
        //Tacton 1\r
        _comport->WriteData(buffer1, 3);
@@ -76,141 +78,72 @@ void MetronomeHaptic::run()
        thread = SDL_CreateThread(&MetronomeHaptic::thread_func, this);
 }
 
-int MetronomeHaptic::thread_func(void *obj)
+void MetronomeHaptic::init()
 {
-       MetronomeHaptic *thismetronome = static_cast<MetronomeHaptic *>(obj);
-
-       SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
-
-       const list<Pair<Uint32, Uint32> > *bips = thismetronome->_track->getBips();
-       //const map<Uint32, Pair<float, Uint32> > *tempo = thismetronome->_track->getTempos();
-    const map<Uint32, Pair<Uint32, Uint32> > *timesignatures = thismetronome->_track->getTimeSignatures();
-       static list<Pair<Uint32, Uint32> >::const_iterator cBips = bips->begin();
-       //static map<Uint32, Pair<float, Uint32> >::const_iterator cTempo = tempo->begin();
-       static map<Uint32, Pair<Uint32, Uint32> >::const_iterator cTimesignature = timesignatures->begin();
+       checkAt(BEFOREDELAY);
+}
 
-       bool written = thismetronome->_comport->WriteData("S", 1);
+void MetronomeHaptic::checkAt(Uint32 timestamp)
+{
        unsigned char outBuffer[6];
        outBuffer[0] = 'P';
-       unsigned char currentbeat = 0;
-
-       while(thismetronome->_activated)
+       
+       //send first beeps in advance
+       while (_iBips != _bips->end() && timestamp >= BIPTIMESTAMP(*_iBips))
        {
-               Uint32 currenttime = SDL_GetTicks() - start;
-
-               while (cBips != bips->end() && currenttime >= BIPTIMESTAMP(*cBips))
-               {
-/*                     char outBuffer[5];\r
-                       outBuffer[0] = 'N';*/\r
-                       outBuffer[1] = currentbeat % 4;\r
-                       outBuffer[2] = (BIPTIMESTAMP(*cBips) & 0xff000000) >> 24;\r
-                       outBuffer[3] = (BIPTIMESTAMP(*cBips) & 0x00ff0000) >> 16;\r
-                       outBuffer[4] = (BIPTIMESTAMP(*cBips) & 0x0000ff00) >> 8;\r
-                       outBuffer[5] = BIPTIMESTAMP(*cBips) & 0x000000ff;\r
-\r
-                       bool written = thismetronome->_comport->WriteData(outBuffer, 6);\r
-/*                     char INBUFFER[128];\r
-                       memset(INBUFFER, 0, 128);
-                       int nbread = thismetronome->_comport->ReadData(INBUFFER, 128);
-                       stringstream s;
-                       s << nbread << " read:\n" << INBUFFER << endl;
-                       OutputDebugString(s.str().c_str());*/\r
-
-                       if (logfile)
-                               fprintf(logfile, "BIP;%d;%d;%d\n", BIPTICK(*cBips), BIPTIMESTAMP(*cBips), currenttime);
-
-                       currentbeat = (currentbeat + 1) % thismetronome->_nbbeats;
-                       cBips++;
-               }
-
-               // on avance tant que les tempos sont dépassées
-               while (cTimesignature != timesignatures->end() && currenttime >= TIMESTAMP(*cTimesignature))
-               {
-/*                     char outBuffer[5];\r
-                       outBuffer[0] = 'B';\r
-                       outBuffer[1] = (TIMESTAMP(*cTimesignature) & 0xff000000) >> 24;\r
-                       outBuffer[2] = (TIMESTAMP(*cTimesignature) & 0x00ff0000) >> 16;\r
-                       outBuffer[3] = (TIMESTAMP(*cTimesignature) & 0x0000ff00) >> 8;\r
-                       outBuffer[4] = TIMESTAMP(*cTimesignature) & 0x000000ff;\r
-       \r
-                       bool written = thismetronome->_comport->WriteData(outBuffer, 5);\r
-       */                      
-                       //time signature change
-                       SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Time signature change at %d : tick=%d at %d for %d beats\n", 
-                               currenttime, 
-                               (*cTimesignature).first, 
-                               (*cTimesignature).second.getX(), 
-                               (*cTimesignature).second.getY());
-                       thismetronome->_nbbeats = (*cTimesignature).second.getY();
-                       cTimesignature++;
-               }
+               outBuffer[1] = _currentbeat % 4;\r
+               outBuffer[2] = (BIPTIMESTAMP(*_iBips) & 0xff000000) >> 24;\r
+               outBuffer[3] = (BIPTIMESTAMP(*_iBips) & 0x00ff0000) >> 16;\r
+               outBuffer[4] = (BIPTIMESTAMP(*_iBips) & 0x0000ff00) >> 8;\r
+               outBuffer[5] = BIPTIMESTAMP(*_iBips) & 0x000000ff;\r
+               bool written = _comport->WriteData(outBuffer, 6);\r
+
+               if (logfile)
+                       fprintf(logfile, "BIP;%d;%d;%d\n", BIPTICK(*_iBips), BIPTIMESTAMP(*_iBips), 0);
+               SDL_Log("BipH %d at %d\n", timestamp, BIPTIMESTAMP(*_iBips));
+
+               _currentbeat = (_currentbeat + 1) % _nbbeats;
+               _iBips++;
+       }
 
-               SDL_Delay(5);
+       // on avance tant que les tempos sont dépassées
+       while (_iTimesignature != _timesignatures->end() && BEFOREDELAY >= TIMESTAMP(*_iTimesignature))
+       {
+               //time signature change
+               SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Time signature change at %d : tick=%d at %d for %d beats\n",  
+                       timestamp, 
+                       (*_iTimesignature).first, 
+                       (*_iTimesignature).second.getX(), 
+                       (*_iTimesignature).second.getY());
+               _nbbeats = (*_iTimesignature).second.getY();
+               _iTimesignature++;
        }
-       return 0;
 }
 
-/*
 int MetronomeHaptic::thread_func(void *obj)
 {
        MetronomeHaptic *thismetronome = static_cast<MetronomeHaptic *>(obj);
 
-       SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
+//     SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
 
-       const map<Uint32, Pair<float, Uint32> > *tempo = thismetronome->_track->getTempos();
-    const map<Uint32, Pair<float, Uint32> > *timesignatures = thismetronome->_track->getTimeSignatures();
-       static map<Uint32, Pair<float, Uint32> >::const_iterator cTempo = tempo->begin();
-       static map<Uint32, Pair<float, Uint32> >::const_iterator cTimesignature = timesignatures->begin();
-               
-#ifdef WIN32
-    struct { int tv_sec, tv_usec; } now, start;
-       DWORD t = timeGetTime ();
-    start.tv_sec = t / 1000;
-    start.tv_usec = (t % 1000) * 1000;
-#else
-    struct timeval now, start;
-     gettimeofday(&start, NULL);
-#endif
-       float currenttime = 0;
+       unsigned char outBuffer[6];
+       outBuffer[0] = 'P';
+       
+       bool written = thismetronome->_comport->WriteData("S", 1);
 
        while(thismetronome->_activated)
        {
-#ifdef WIN32
-               t = timeGetTime ();
-               now.tv_sec = t / 1000;
-               now.tv_usec = (t % 1000) * 1000;
-#else
-               gettimeofday(&now, NULL);
-#endif
-       float currenttime = (now.tv_sec - start.tv_sec) * 1000.0f + (now.tv_usec - start.tv_usec) / 1000.0f;
-
-               // on avance tant que les tempos sont dépassées
-               while (cTempo != tempo->end() && currenttime > (*cTempo).second.getX())
-               {
-                       //tempo change
-                       stringstream s;
-                       s << "Tempo change at " << currenttime << " : tick=" << (*cTempo).first << " at " << (*cTempo).second.getX() << " for " << (60000000/(*cTempo).second.getY()) << " bpm" << endl;
-                       OutputDebugString(s.str().c_str());
-
-                       thismetronome->setTempo((*cTempo).second.getY());
-
-                       cTempo++;
-               }
-
-               // on avance tant que les tempos sont dépassées
-               while (cTimesignature != timesignatures->end() && (*cTimesignature).second.getX() < currenttime)
-               {
-                       //time signature change
-                       stringstream s;
-                       s << "Time signature change at " << currenttime << " : tick=" << (*cTimesignature).first << " at " << (*cTimesignature).second.getX() << " for " << (*cTimesignature).second.getY() << " beats " << endl;
-                       OutputDebugString(s.str().c_str());
-
-                       thismetronome->setNbBeats((*cTimesignature).second.getY());
-
-                       cTimesignature++;
-               }
+               // TEST
+               char INBUFFER[128];\r
+               memset(INBUFFER, 0, 128);
+               int nbread = thismetronome->_comport->ReadData(INBUFFER, 128);
+               if (nbread > 0)
+                       SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "%d read: %s\n", nbread, INBUFFER);
+               //\r
+\r
+               thismetronome->checkAt(SDL_GetTicks() - start + BEFOREDELAY);\r
+\r
                SDL_Delay(5);
        }
        return 0;
 }
-*/
\ No newline at end of file
index c94205b8b6308a3d34be9dd9bc5dc2b39d65517e..9886a89cede7c12f906865ce28936909cef0ba4c 100644 (file)
@@ -188,6 +188,10 @@ void init()
   glEnable(GL_LIGHT0);
 //  SDL_EnableKeyRepeat(10, 100);
 
+#ifdef FULLSCREEN
+       SDL_ShowCursor( SDL_DISABLE );
+#endif
+
        fromKeyboard.setTimestamp(-1);
        fromKeyboard.setEndTimestamp(-1);
 }
@@ -619,17 +623,18 @@ void loop(const Track &tr, const String &songname)
 
        init();
        SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Create Metronome\n");
-//     Metronome *m = new MetronomeAudio(&tr);
-       Metronome *m;
+       Metronome *m = NULL, *m2 = NULL;
        try
        {
-               m = new MetronomeHaptic(&tr);
+               //m = new MetronomeHaptic(tr);
+               m2 = new MetronomeAudio(tr);
        }
        catch (char *error)
        {
 //             cout << error << endl;
                SDL_LogError(SDL_LOG_CATEGORY_ERROR, "%s\n", error);
                m = NULL;
+               m2 = NULL;
        }
 
        bool quitProgram = false;
@@ -647,23 +652,23 @@ void loop(const Track &tr, const String &songname)
        if (gametype == REGULAR)
                Mixer::getInstance()->loadMusic(songname + "/tout.ogg");
 
-//must be done before paint and metronomes
-       start = SDL_GetTicks();
-/*#ifdef WIN32
-    DWORD t = timeGetTime ();
-    start.tv_sec = t / 1000;
-    start.tv_usec = (t % 1000) * 1000;
-#else
-     gettimeofday(&start, NULL);
-#endif*/
-
        SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "LET'S ROCK!\n");
        //m->setActive(true);
 
+       if (m)
+               m->init();
+       if (m2)
+               m2->init();
+       SDL_Delay(1000);
        if (gametype == REGULAR)
                Mixer::getInstance()->playMusic();
+       //must be done before paint and metronomes
+       start = SDL_GetTicks();
        if (m)
                m->run();
+       if (m2)
+               m2->run();
+
 /*     Mixer::getInstance()->playSound("guitar");
        if (rhythm)
                Mixer::getInstance()->playSound("rhythm");
@@ -701,4 +706,5 @@ void loop(const Track &tr, const String &songname)
   }
 
   delete m;
+  delete m2;
 }
\ No newline at end of file
index a72c74e6ede71afde35b4d681fd6425a0737ad33..1ee3801d1b2dd4f81f0352664207a0787cce0226 100644 (file)
@@ -40,6 +40,7 @@ void handleStrokeOff()
 
 int main(int argc, char *argv[])
 {
+       srand(time((time_t *)(NULL)));
        if (argc < 2)
        {
                cout << "Usage : " << argv[0] << "songname [logname] [tempo] [duration] [beatsize]" << endl;
@@ -130,5 +131,7 @@ int main(int argc, char *argv[])
        if (logfile)
                fclose(logfile);
 
+       SDL_ShowCursor( SDL_ENABLE );
+
        return 1;
 }