remove dirent.h, couple of tweaks
authorThomas Pietrzak <thomas.pietrzak@gmail.com>
Wed, 7 Mar 2012 10:44:22 +0000 (10:44 +0000)
committerThomas Pietrzak <thomas.pietrzak@gmail.com>
Wed, 7 Mar 2012 10:44:22 +0000 (10:44 +0000)
git-svn-id: svn+ssh://thomaspietrzak.com/var/svn/rep@54 47cf9a05-e0a8-4ed5-9e9b-101a649bc004

Haptic Metronome/Haptic Metronome.suo
include/MetronomeHaptic.hpp
src/MetronomeHaptic.cpp
src/Tools.cpp
src/main.cpp

index 57a05efe38d0732fe8572609b0448e5dc2963944..27c6e50df569776d9549471af352448acb37eec3 100644 (file)
Binary files a/Haptic Metronome/Haptic Metronome.suo and b/Haptic Metronome/Haptic Metronome.suo differ
index 35bc78fd1aa51300c9710d97b2d4cea1baddd820..8ae11c87e684af41c61e79419e44df83f7f11fb6 100644 (file)
@@ -30,7 +30,7 @@ class MetronomeHaptic : public Metronome
        private:\r
                static int thread_func(void *unused);\r
                SDL_Thread *thread;\r
-               TactonPlayer _tactonPlayer;\r
+               TactonPlayer *_tactonPlayer;\r
 };\r
 \r
 #endif\r
index 2093a6ad56bca0b7b39d3bfc1c1660fe2bc3ad3e..e942d6ac1cb55956760ed081c434034f1157f2d0 100644 (file)
@@ -10,15 +10,30 @@ extern Uint32 start;
 extern FILE *logfile;
 
 MetronomeHaptic::MetronomeHaptic(const Track &track, Uint32 nbbeats, Uint32 tempo, bool activated)
-:Metronome(track, nbbeats, tempo, activated), thread(NULL), _tactonPlayer("COM3")
+:Metronome(track, nbbeats, tempo, activated), thread(NULL)
 {
+       try\r
+       {\r
+               _tactonPlayer = new TactonPlayer("COM4");\r
+       }\r
+       catch (...)\r
+       {\r
+               SDL_Log("Wristband not found");\r
+               _tactonPlayer = NULL;\r
+       }\r
+
        //load the tactons
-       _tactonPlayer.registFile("bips.txt");\r
+       if (_tactonPlayer)
+               _tactonPlayer->registFile("bips.txt");\r
 }
 
 MetronomeHaptic::~MetronomeHaptic()
 {
-       _tactonPlayer.stop();
+       if (_tactonPlayer)
+       {
+               _tactonPlayer->stop();
+               delete _tactonPlayer;
+       }
        _activated = false;
        SDL_WaitThread(thread, NULL);
 }
@@ -45,10 +60,12 @@ void MetronomeHaptic::init()
 
 void MetronomeHaptic::checkAt(Uint32 timestamp)
 {
+       if (!_tactonPlayer)
+               return;
        //send first beeps in advance
        while (_iBips != _bips->end() && timestamp >= BIPTIMESTAMP(*_iBips))
        {
-               _tactonPlayer.schedule(_currentbeat % 4, BIPTIMESTAMP(*_iBips));\r
+               _tactonPlayer->schedule(_currentbeat % 4, BIPTIMESTAMP(*_iBips));\r
 
                if (logfile)
                        fprintf(logfile, "BIP;%d;%d;%d\n", BIPTICK(*_iBips), BIPTIMESTAMP(*_iBips), 0);
@@ -78,7 +95,8 @@ int MetronomeHaptic::thread_func(void *obj)
 
 //     SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
        
-       thismetronome->_tactonPlayer.start();
+       if (thismetronome->_tactonPlayer)
+               thismetronome->_tactonPlayer->start();
 
        while(thismetronome->_activated)
        {
index bb23adc1aa5d3881900c0ebb318ff366338cf9cc..e735657105064221adc485420237ab682a8364e4 100644 (file)
@@ -25,8 +25,9 @@
 #include <cmath>
 #include <cstdio>
 #include <sys/types.h>
+#include <direct.h>
 
-#include <dirent.h>
+//#include <dirent.h>
 
 using namespace std;
 
@@ -43,13 +44,14 @@ bool fileExists(const String &f)
 
 bool dirExists(const String &d)
 {
-  DIR *dir;
+  return _chdir(d.c_str()) == 0;
+/*  DIR *dir;
   if ((dir = opendir(d.c_str())) != NULL)
   {
     closedir(dir);
     return true;
   }
-  return false;
+  return false;*/
 }
 
 Vector2D<int> rotatePoint(const Vector2D<int> pos, const Vector2D<int> center, const double &angle)
index 1ee3801d1b2dd4f81f0352664207a0787cce0226..5357327f1d5953a4bcd09f5579660853545c685c 100644 (file)
@@ -115,7 +115,7 @@ int main(int argc, char *argv[])
                }
                catch(...)
                {
-                       SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Unable to load the song fil\n");
+                       SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Unable to load the song file\n");
                        exit(0);
                }