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);
}
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);
// SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
- thismetronome->_tactonPlayer.start();
+ if (thismetronome->_tactonPlayer)
+ thismetronome->_tactonPlayer->start();
while(thismetronome->_activated)
{
#include <cmath>
#include <cstdio>
#include <sys/types.h>
+#include <direct.h>
-#include <dirent.h>
+//#include <dirent.h>
using namespace std;
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)