-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.cpp
More file actions
62 lines (57 loc) · 1.94 KB
/
app.cpp
File metadata and controls
62 lines (57 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "app.h"
int soundy::app::run()
{
sColorTracker::Instance()->setLowH(sConfig::Instance()->lowH());
sColorTracker::Instance()->setHighH(sConfig::Instance()->highH());
sColorTracker::Instance()->setLowS(sConfig::Instance()->lowS());
sColorTracker::Instance()->setHighS(sConfig::Instance()->highS());
sColorTracker::Instance()->setLowV(sConfig::Instance()->lowV());
sColorTracker::Instance()->setHighV(sConfig::Instance()->highV());
soundy::GUI::mainWindow mainWin;
soundy::GUI::configWindow configWin;
bool play = false;
cv::Point p;
sAudio::Instance()->initSound();
cv::Mat frame_err;
frame_err = cv::imread("frame_err.png");
while(true){
p = sColorTracker::Instance()->ColorPos();
if(play)
sAudio::Instance()->playSound(p.y/60, p.y/60);
if(!sColorTracker::Instance()->frame().empty()) {
mainWin.show(sColorTracker::Instance()->frame(), p.x, p.y);
} else {
mainWin.show(frame_err);
}
if(sConfig::Instance()->configMode()) configWin.show();
int c = cv::waitKey(10);
if ((char)c == 27) break;
if ((char)c == 32){
play = !play;
if(!play) sAudio::Instance()->playSound(0, 0);
if(DEBUG && play) std::cout << "playing." << std::endl; // if debuging and play is set to true
if(DEBUG && !play) std::cout << "stop playing." << std::endl; // if debuging and play is set to false11
}
if ((char)c == 67 || (char)c == 99){
sConfig::Instance()->setConfigMode(!sConfig::Instance()->configMode());
}
}
return 0;
}
soundy::app::app()
{
if(!sConfig::Instance()->readConfig()) {
cv::namedWindow("error");
cv::Mat err_img(640, 480, CV_8UC3, cv::Scalar::all(255));
cv::putText(err_img, "Error reading configuration.",
cv::Point(240, 180), CV_FONT_HERSHEY_COMPLEX,
0.6, cv::Scalar::all(0), 1, 8);
cv::imshow("error", err_img);
}
_loadingError = true;
}
int main(int argc, char *argv[])
{
soundy::app application;
return application.run();
}