diff options
| -rwxr-xr-x | ofAsterisk/Makefile | 2 | ||||
| -rw-r--r-- | ofAsterisk/addons.make | 1 | ||||
| -rwxr-xr-x | ofAsterisk/config.make | 56 | ||||
| -rwxr-xr-x | ofAsterisk/ofAsterisk.cbp | 78 | ||||
| -rwxr-xr-x | ofAsterisk/ofAsterisk.workspace | 9 | ||||
| -rwxr-xr-x | ofAsterisk/src/Asterisk.cpp | 86 | ||||
| -rwxr-xr-x | ofAsterisk/src/Asterisk.h | 64 | ||||
| -rwxr-xr-x | ofAsterisk/src/main.cpp | 16 | ||||
| -rwxr-xr-x | ofAsterisk/src/testApp.cpp | 69 | ||||
| -rwxr-xr-x | ofAsterisk/src/testApp.h | 25 | ||||
| -rwxr-xr-x | vfg/src/Asterisk.cpp | 22 | ||||
| -rwxr-xr-x | vfg/src/Asterisk.h | 2 | ||||
| -rwxr-xr-x | vfg/src/music.cpp | 53 | ||||
| -rwxr-xr-x | vfg/src/music.h | 18 | ||||
| -rwxr-xr-x | vfg/src/testApp.cpp | 25 | ||||
| -rwxr-xr-x | vfg/src/testApp.h | 1 | ||||
| -rw-r--r-- | vfg/vfg.layout | 10 | ||||
| -rwxr-xr-x | vpn/10.10.10.1 | 14 | ||||
| -rwxr-xr-x | vpn/10.10.10.1~ | 14 | ||||
| -rwxr-xr-x | vpn/notes.txt | 6 |
20 files changed, 498 insertions, 73 deletions
diff --git a/ofAsterisk/Makefile b/ofAsterisk/Makefile new file mode 100755 index 0000000..2d83a77 --- /dev/null +++ b/ofAsterisk/Makefile @@ -0,0 +1,2 @@ +include config.make +include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/Makefile.examples diff --git a/ofAsterisk/addons.make b/ofAsterisk/addons.make new file mode 100644 index 0000000..17bb504 --- /dev/null +++ b/ofAsterisk/addons.make @@ -0,0 +1 @@ +ofxNetwork diff --git a/ofAsterisk/config.make b/ofAsterisk/config.make new file mode 100755 index 0000000..307c8ef --- /dev/null +++ b/ofAsterisk/config.make @@ -0,0 +1,56 @@ +# add custom variables to this file + +# OF_ROOT allows to move projects outside apps/* just set this variable to the +# absoulte path to the OF root folder + +OF_ROOT = ../../openFrameworks + + +# USER_CFLAGS allows to pass custom flags to the compiler +# for example search paths like: +# USER_CFLAGS = -I src/objects + +USER_CFLAGS = + + +# USER_LDFLAGS allows to pass custom flags to the linker +# for example libraries like: +# USER_LDFLAGS = libs/libawesomelib.a + +USER_LDFLAGS = + + +EXCLUDE_FROM_SOURCE="bin,.xcodeproj,obj" + +# change this to add different compiler optimizations to your project + +USER_COMPILER_OPTIMIZATION = -march=native -mtune=native -Os + + +# android specific, in case you want to use different optimizations +USER_LIBS_ARM = +USER_LIBS_ARM7 = +USER_LIBS_NEON = + +# android optimizations + +ANDROID_COMPILER_OPTIMIZATION = -Os + +NDK_PLATFORM = android-8 + +# uncomment this for custom application name (if the folder name is different than the application name) +#APPNAME = folderName + +# uncomment this for custom package name, must be the same as the java package that contains OFActivity +#PKGNAME = cc.openframeworks.$(APPNAME) + + + + + +# linux arm flags + +LINUX_ARM7_COMPILER_OPTIMIZATIONS = -march=armv7-a -mtune=cortex-a8 -finline-functions -funroll-all-loops -O3 -funsafe-math-optimizations -mfpu=neon -ftree-vectorize -mfloat-abi=hard -mfpu=vfp + + + diff --git a/ofAsterisk/ofAsterisk.cbp b/ofAsterisk/ofAsterisk.cbp new file mode 100755 index 0000000..fe155a0 --- /dev/null +++ b/ofAsterisk/ofAsterisk.cbp @@ -0,0 +1,78 @@ +<?xml version="1.0"?> +<CodeBlocks_project_file> + <FileVersion major="1" minor="6" /> + <Project> + <Option title="ofAsterisk" /> + <Option makefile_is_custom="1" /> + <Option pch_mode="2" /> + <Option compiler="gcc" /> + <Option virtualFolders="addons/;src/;build config/;" /> + <Build> + <Target title="Debug"> + <Option output="bin/$(PROJECT_NAME)_debug" prefix_auto="1" extension_auto="1" /> + <Option working_dir="bin" /> + <Option object_output="obj/Debug/" /> + <Option external_deps="../../../openFrameworks/libs/openFrameworksCompiled/lib/linux64/libopenFrameworksDebug.a;" /> + <Option type="1" /> + <Option compiler="gcc" /> + <Option projectLinkerOptionsRelation="2" /> + </Target> + <Target title="Release"> + <Option output="bin/$(PROJECT_NAME)" prefix_auto="1" extension_auto="1" /> + <Option working_dir="bin" /> + <Option object_output="obj/Release/" /> + <Option external_deps="../../../openFrameworks/libs/openFrameworksCompiled/lib/linux64/libopenFrameworks.a;" /> + <Option type="1" /> + <Option compiler="gcc" /> + <Option projectLinkerOptionsRelation="2" /> + </Target> + </Build> + <Unit filename="config.make"> + <Option virtualFolder="build config" /> + </Unit> + <Unit filename="src/main.cpp"> + <Option virtualFolder="src/" /> + </Unit> + <Unit filename="src/testApp.cpp"> + <Option virtualFolder="src/" /> + </Unit> + <Unit filename="src/testApp.h"> + <Option virtualFolder="src/" /> + </Unit> + <Extensions> + <code_completion /> + <envvars /> + <debugger /> + </Extensions> + <Unit filename="../../../openFrameworks/addons/ofxNetwork/src/ofxNetworkUtils.h"> + <Option virtualFolder="addons/ofxNetwork/src" /> + </Unit> + <Unit filename="../../../openFrameworks/addons/ofxNetwork/src/ofxTCPServer.cpp"> + <Option virtualFolder="addons/ofxNetwork/src" /> + </Unit> + <Unit filename="../../../openFrameworks/addons/ofxNetwork/src/ofxUDPManager.cpp"> + <Option virtualFolder="addons/ofxNetwork/src" /> + </Unit> + <Unit filename="../../../openFrameworks/addons/ofxNetwork/src/ofxTCPServer.h"> + <Option virtualFolder="addons/ofxNetwork/src" /> + </Unit> + <Unit filename="../../../openFrameworks/addons/ofxNetwork/src/ofxTCPManager.h"> + <Option virtualFolder="addons/ofxNetwork/src" /> + </Unit> + <Unit filename="../../../openFrameworks/addons/ofxNetwork/src/ofxNetwork.h"> + <Option virtualFolder="addons/ofxNetwork/src" /> + </Unit> + <Unit filename="../../../openFrameworks/addons/ofxNetwork/src/ofxTCPClient.cpp"> + <Option virtualFolder="addons/ofxNetwork/src" /> + </Unit> + <Unit filename="../../../openFrameworks/addons/ofxNetwork/src/ofxTCPManager.cpp"> + <Option virtualFolder="addons/ofxNetwork/src" /> + </Unit> + <Unit filename="../../../openFrameworks/addons/ofxNetwork/src/ofxTCPClient.h"> + <Option virtualFolder="addons/ofxNetwork/src" /> + </Unit> + <Unit filename="../../../openFrameworks/addons/ofxNetwork/src/ofxUDPManager.h"> + <Option virtualFolder="addons/ofxNetwork/src" /> + </Unit> + </Project> +</CodeBlocks_project_file> diff --git a/ofAsterisk/ofAsterisk.workspace b/ofAsterisk/ofAsterisk.workspace new file mode 100755 index 0000000..f55c1f7 --- /dev/null +++ b/ofAsterisk/ofAsterisk.workspace @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_workspace_file> + <Workspace title="ofAsterisk"> + <Project filename="ofAsterisk.cbp" active="1"> + <Depends filename="../../../openFrameworks/libs/openFrameworksCompiled/project/linux64/libopenFrameworks.cbp" /> + </Project> + <Project filename="../../../openFrameworks/libs/openFrameworksCompiled/project/linux64/libopenFrameworks.cbp" /> + </Workspace> +</CodeBlocks_workspace_file> diff --git a/ofAsterisk/src/Asterisk.cpp b/ofAsterisk/src/Asterisk.cpp new file mode 100755 index 0000000..ae85269 --- /dev/null +++ b/ofAsterisk/src/Asterisk.cpp @@ -0,0 +1,86 @@ +#include "Asterisk.h"
+
+
+//there is no notification that there is someone in the queue
+//but there is a status message you can check periodically...
+
+Asterisk::Asterisk()
+{
+ udpConnection.Create();
+ udpConnection.Bind(5000);
+ udpConnection.SetNonBlocking(true);
+ cmd("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"database put GAME passcode 1234\"'");
+ state=WAITING;
+ printf("Asterisk: created socket and connected to server\n");
+}
+
+void Asterisk::startGame(){
+ if (state!=PLAYING) {
+ cmd("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"devstate change Custom:GAME NOT_INUSE\"'");
+ printf("Asterisk: attempting to dequeue\n");
+ state=STARTING;
+ }
+}
+void Asterisk::endGame(string score){
+ if (state==PLAYING) {
+ cmd("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"database put GAME statuscode "+score+"\"'");
+ string emsg="ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"hangup request "+playerCode+"\"'";
+ printf("%s\n",emsg.c_str());
+ cmd(emsg);
+ printf("Asterisk: hanging up %s\n",playerCode.c_str());
+ state=WAITING;
+ }
+}
+void Asterisk::cmd(string s) {
+ file = popen(s.c_str(), "r");
+ int filenum=fileno(file);
+ //fcntl(filenum, F_SETFL, O_NONBLOCK); //doesn't seem to work, still pauses
+ //pclose(file); //discard the pipe THIS IS BLOCKING
+}
+
+int Asterisk::update(){
+ //how to capture stdin response from popen
+ /*
+ if (state==WAITING||state==STARTING) {
+ char buf[100];
+ ssize_t r = read(filenum, buf, 100);
+ //if (r == -1 && errno == EAGAIN)
+ //no data yet
+ //else
+ if (r > 0)
+ //received data
+ printf("%s\n",buf);
+ pclose(file);
+ state=IDLE;
+ ///else
+ //pipe closed
+ }
+ */
+ //check messages and pipes, returns new keypresses
+ char udpMessage[10000];
+ udpConnection.Receive(udpMessage,10000);
+ string msg=udpMessage;
+ if(msg!=""){
+ printf("Asterisk: %s\n",msg.c_str());
+ if (msg.length()>3) {
+ //printf("status msg: %s\n",msg.c_str());
+ if (msg.substr(0,5)=="Local") {
+ state=PLAYING;
+ playerCode=msg.substr(0,msg.length()-1);
+ printf("Asterisk: game started: code %s\n",playerCode.c_str());
+ return 1000;
+ }
+ return 0;
+ }
+ else {
+ return ofToInt(msg);
+ }
+ }
+ else return 0;
+}
+
+Asterisk::~Asterisk()
+{
+ pclose(file);
+ //dtor
+}
diff --git a/ofAsterisk/src/Asterisk.h b/ofAsterisk/src/Asterisk.h new file mode 100755 index 0000000..c9ce864 --- /dev/null +++ b/ofAsterisk/src/Asterisk.h @@ -0,0 +1,64 @@ +#ifndef ASTERISK_H
+#define ASTERISK_H
+
+#include "ofMain.h"
+#include "ofxNetwork.h"
+
+#define IDLE 0
+#define WAITING 1
+#define STARTING 2
+#define PLAYING 3
+
+// http://stackoverflow.com/questions/1735781/non-blocking-pipe-using-popen
+
+/*
+
+Commands for game to control PBX
+
+Game ready
+
+ssh 10.10.10.1 'sudo /usr/sbin/asterisk -rx "devstate change Custom:GAME NOT_INUSE"'
+
+change daily access 4 digit code
+
+ssh 10.10.10.1 'sudo /usr/sbin/asterisk -rx "database put GAME passcode 1234"'
+
+
+
+Set status code for current game
+
+ssh 10.10.10.1 'sudo /usr/sbin/asterisk -rx "database put GAME statuscode 1234"'
+
+Gameover Hangup Call
+
+ssh 10.10.10.1 'sudo /usr/sbin/asterisk -rx "hangup request Local/9999@default-00000039;2"
+
+Local/9999@default-00000039;2 is a channel identifier and will be send to game when AGI script connects to game controller. The channel ID is unique for each call
+
+
+can we have a message that someone has joined the queue?
+can we have a message if someone hangs up?
+*/
+
+class Asterisk
+{
+ public:
+ Asterisk();
+ virtual ~Asterisk();
+ void startGame();
+ void endGame(string score);
+ int update();
+ void cmd(string s);
+
+ int state;
+
+ protected:
+ private:
+ int startTime;
+ FILE *file;
+ int filenum;
+ ofxUDPManager udpConnection;
+ string playerCode;
+};
+
+#endif // ASTERISK_H
diff --git a/ofAsterisk/src/main.cpp b/ofAsterisk/src/main.cpp new file mode 100755 index 0000000..6042c32 --- /dev/null +++ b/ofAsterisk/src/main.cpp @@ -0,0 +1,16 @@ +#include "ofMain.h" +#include "testApp.h" +#include "ofAppGlutWindow.h" + +//======================================================================== +int main( ){ + + ofAppGlutWindow window; + ofSetupOpenGL(&window, 100,100, OF_WINDOW); // <-------- setup the GL context + + // this kicks off the running of my app + // can be OF_WINDOW or OF_FULLSCREEN + // pass in width and height too: + ofRunApp( new testApp()); + +} diff --git a/ofAsterisk/src/testApp.cpp b/ofAsterisk/src/testApp.cpp new file mode 100755 index 0000000..a69a084 --- /dev/null +++ b/ofAsterisk/src/testApp.cpp @@ -0,0 +1,69 @@ +#include "testApp.h" + +//-------------------------------------------------------------- +void testApp::setup(){ + +} + +//-------------------------------------------------------------- +void testApp::update(){ + int ret=game.update(); +} + +//-------------------------------------------------------------- +void testApp::draw(){ + +} + +//-------------------------------------------------------------- +void testApp::keyPressed(int key){ + switch (key) { + case 's': + game.startGame(); + break; + case 'e': + game.endGame("GOOD"); + break; + } + +} + +//-------------------------------------------------------------- +void testApp::keyReleased(int key){ + +} + +//-------------------------------------------------------------- +void testApp::mouseMoved(int x, int y ){ + +} + +//-------------------------------------------------------------- +void testApp::mouseDragged(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void testApp::mousePressed(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void testApp::mouseReleased(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void testApp::windowResized(int w, int h){ + +} + +//-------------------------------------------------------------- +void testApp::gotMessage(ofMessage msg){ + +} + +//-------------------------------------------------------------- +void testApp::dragEvent(ofDragInfo dragInfo){ + +}
\ No newline at end of file diff --git a/ofAsterisk/src/testApp.h b/ofAsterisk/src/testApp.h new file mode 100755 index 0000000..84c984c --- /dev/null +++ b/ofAsterisk/src/testApp.h @@ -0,0 +1,25 @@ +#pragma once + +#include "ofMain.h" +#include "Asterisk.h" + +class testApp : public ofBaseApp{ + + public: + void setup(); + void update(); + void draw(); + + void keyPressed (int key); + void keyReleased(int key); + void mouseMoved(int x, int y ); + void mouseDragged(int x, int y, int button); + void mousePressed(int x, int y, int button); + void mouseReleased(int x, int y, int button); + void windowResized(int w, int h); + void dragEvent(ofDragInfo dragInfo); + void gotMessage(ofMessage msg); + + Asterisk game; + +}; diff --git a/vfg/src/Asterisk.cpp b/vfg/src/Asterisk.cpp index 5392ade..ae85269 100755 --- a/vfg/src/Asterisk.cpp +++ b/vfg/src/Asterisk.cpp @@ -2,6 +2,7 @@ //there is no notification that there is someone in the queue
+//but there is a status message you can check periodically...
Asterisk::Asterisk()
{
@@ -10,13 +11,25 @@ Asterisk::Asterisk() udpConnection.SetNonBlocking(true);
cmd("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"database put GAME passcode 1234\"'");
state=WAITING;
+ printf("Asterisk: created socket and connected to server\n");
}
void Asterisk::startGame(){
- //if (state=IDLE) {
+ if (state!=PLAYING) {
cmd("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"devstate change Custom:GAME NOT_INUSE\"'");
+ printf("Asterisk: attempting to dequeue\n");
state=STARTING;
- //}
+ }
+}
+void Asterisk::endGame(string score){
+ if (state==PLAYING) {
+ cmd("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"database put GAME statuscode "+score+"\"'");
+ string emsg="ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"hangup request "+playerCode+"\"'";
+ printf("%s\n",emsg.c_str());
+ cmd(emsg);
+ printf("Asterisk: hanging up %s\n",playerCode.c_str());
+ state=WAITING;
+ }
}
void Asterisk::cmd(string s) {
file = popen(s.c_str(), "r");
@@ -26,6 +39,7 @@ void Asterisk::cmd(string s) { }
int Asterisk::update(){
+ //how to capture stdin response from popen
/*
if (state==WAITING||state==STARTING) {
char buf[100];
@@ -47,16 +61,18 @@ int Asterisk::update(){ udpConnection.Receive(udpMessage,10000);
string msg=udpMessage;
if(msg!=""){
+ printf("Asterisk: %s\n",msg.c_str());
if (msg.length()>3) {
//printf("status msg: %s\n",msg.c_str());
if (msg.substr(0,5)=="Local") {
state=PLAYING;
+ playerCode=msg.substr(0,msg.length()-1);
+ printf("Asterisk: game started: code %s\n",playerCode.c_str());
return 1000;
}
return 0;
}
else {
- //printf("cmd: %s\n",msg.c_str());
return ofToInt(msg);
}
}
diff --git a/vfg/src/Asterisk.h b/vfg/src/Asterisk.h index b3c5fd5..c9ce864 100755 --- a/vfg/src/Asterisk.h +++ b/vfg/src/Asterisk.h @@ -46,6 +46,7 @@ class Asterisk Asterisk();
virtual ~Asterisk();
void startGame();
+ void endGame(string score);
int update();
void cmd(string s);
@@ -57,6 +58,7 @@ class Asterisk FILE *file;
int filenum;
ofxUDPManager udpConnection;
+ string playerCode;
};
#endif // ASTERISK_H
diff --git a/vfg/src/music.cpp b/vfg/src/music.cpp index 32f9d3e..d3d7807 100755 --- a/vfg/src/music.cpp +++ b/vfg/src/music.cpp @@ -124,6 +124,12 @@ void musicscore::parseMidi(string filename){ iter1--;
printf("processed %s: length %f, %i notes in %f seconds\n",filename.c_str(),((float)(iter1->first+iter1->second->duration)*.001f),notes.size(),ofGetElapsedTimef()-wt);
}
+void musicscore::printNotes() {
+ map<int,note*>::iterator iter;
+ for (iter = notes.begin(); iter != notes.end(); iter++) {
+ printf("%i: %i, %i for %i\n",iter->first,iter->second->num,iter->second->velocity,iter->second->duration);
+ }
+}
void musicscore::makeFlakes(int threshStart,int threshEnd,levelscore *levels){
flakes.clear();
//decimate notes to generate flakes that can be interacted with
@@ -147,10 +153,12 @@ void musicscore::makeFlakes(int threshStart,int threshEnd,levelscore *levels){ missedFlake=flakes.end(); missedNote=-1;
}
-void musicscore::setTimeframe(int millis) {timeframe=millis;} -void musicscore::setNowpoint(float pct) {nowpoint=pct;}
+void musicscore::setTimeframe(int millis) {
+ timeframe=millis;
+ nowpoint=timeframe*0.33f;
+}
void musicscore::drawNotes(levelscore *levels) {
- int scoreStart=ofGetElapsedTimeMillis()-startTime-((1.0f-nowpoint)*timeframe);
+ int scoreStart=ofGetElapsedTimeMillis()-startTime-nowpoint;
int scoreEnd=scoreStart+timeframe;
//note drawing 46h - 52h
int numnotes=16;
@@ -167,12 +175,16 @@ void musicscore::drawNotes(levelscore *levels) { ofSetColor(ofColor::fromHsb(((float)thisnote*255)/numnotes,200,100),(((float)(thisstart*heightStep))/ofGetHeight()*128)+32);
ofRect(thisnote*widthStep,ofGetHeight()-(thisstart*heightStep),widthStep,-(thislength*heightStep));
}
+ //visualise keyThreshold
+ ofSetColor(255,0,0,70);
+ ofRect(0,ofGetHeight()-(nowpoint*heightStep),ofGetWidth(),keyThresh*heightStep);
}
void musicscore::drawFlakes(levelscore *levels,float scale) {
ofEnableAlphaBlending();
- int scoreStart=ofGetElapsedTimeMillis()-startTime-((1.0f-nowpoint)*timeframe);
- int scoreEnd=scoreStart+timeframe;
+ int now=ofGetElapsedTimeMillis()-startTime;
+ int screenStart=now-nowpoint;
+ int screenEnd=screenStart+timeframe;
//note drawing 46h - 52h
int numnotes=16;
int firstnote=70;
@@ -180,9 +192,9 @@ void musicscore::drawFlakes(levelscore *levels,float scale) { float heightStep=((float)ofGetHeight())/timeframe;
map<int,flake*>::iterator iter;
//draw flakes
- for (iter = flakes.lower_bound(scoreStart); iter != flakes.upper_bound(scoreEnd); iter++) {
+ for (iter = flakes.lower_bound(screenStart); iter != flakes.upper_bound(screenEnd); iter++) {
int thisnote=iter->second->num-firstnote;
- int thisstart=iter->first-scoreStart;
+ int thisstart=iter->first-screenStart;
int thislength=iter->second->duration;
//if (iter->second->activated) ofSetColor(255,255,255);
@@ -195,21 +207,24 @@ void musicscore::drawFlakes(levelscore *levels,float scale) { //todo - make all drawing resolution independent
}
- //check for unactivated flakes within this segment: is there a more efficient way? - //need to know when a flake has just been missed -
+ //check for unactivated flakes within this level: is there a more efficient way? + //need to know when a flake has just been missed
+ //this seems to mess up a little bit when switching levels + //also: when the window for hitting flakes gets too big, it messes up
missedFlakes=0;
missedLast=false; map<int,flake*>::iterator missed=flakes.end();
- int scoreTime=ofGetElapsedTimeMillis()-startTime;
- for (iter = flakes.lower_bound(levels->getLowerBound(levels->getLevel(scoreStart))); iter != flakes.lower_bound(scoreStart); iter++){
+ int lvlstart=levels->getLowerBound(levels->getLevel(now));
+ int window=max(lvlstart,now-keyThresh);
+ for (iter = flakes.lower_bound(lvlstart); iter != flakes.lower_bound(window); iter++){
if (!iter->second->activated) {
missedFlakes++; missed=iter;
}
missedLast=!iter->second->activated;
}
- //at this point missed points to the latest unactivated flake in the level if there is one + //at this point missed points to the latest unactivated flake in the level if there is one or else flakes.end()
+ if ((missed!=flakes.end())&&(missedFlake!=missed)) { missedFlake=missed; missedNote=notemap(missed->second->num); @@ -218,10 +233,10 @@ void musicscore::drawFlakes(levelscore *levels,float scale) { ofDisableAlphaBlending();
}
-void musicscore::playerControl(int key,int threshold){
+void musicscore::playerControl(int key){
map<int,flake*>::iterator iter;
- int scoreTime=ofGetElapsedTimeMillis()-startTime;
- for (iter = flakes.lower_bound(scoreTime-threshold); iter != flakes.upper_bound(scoreTime+threshold); iter++) {
+ int now=ofGetElapsedTimeMillis()-startTime;
+ for (iter = flakes.lower_bound(now-keyThresh); iter != flakes.upper_bound(now); iter++) {
if (key==notemap(iter->second->num)) {
iter->second->activate();
hitNote=key;
@@ -236,11 +251,9 @@ song::song(string backfile,string melfile,string musfile,string lyricfile,string lyrics.load(lyricfile);
levels.load(levelfile);
isPlaying=false;
- keyThresh=500; - notes.setNowpoint(0.8f);
}
void song::setTimeframe(int millis) {notes.setTimeframe(millis);}
-void song::setKeythresh(int millis) {keyThresh=millis;}
+void song::setKeyThresh(int millis) {notes.keyThresh=millis;}
void song::setFlakeThresh(int tS,int tE) {
fThreshStart=tS;
fThreshEnd=tE;
@@ -304,7 +317,7 @@ void song::draw(float scale){ ofDrawBitmapString(ofToString((float)songTime/1000.0f,1)+" "+ofToString(levels.getLevel(songTime))+" "+ofToString(notes.missedFlakes)+" of "+ofToString(levels.getLives(songTime)),10,(ofGetHeight()*gridY[1])-3);
}
void song::playerControl(int key){
- notes.playerControl(key,keyThresh);
+ notes.playerControl(key);
} int song::missedNote(){
return notes.missedNote;
diff --git a/vfg/src/music.h b/vfg/src/music.h index a1eddc4..3a9f299 100755 --- a/vfg/src/music.h +++ b/vfg/src/music.h @@ -156,18 +156,18 @@ class musicscore: public score { public:
musicscore();
void parseMidi(string filename);
- void setTimeframe(int millis); - void setNowpoint(float pct);
+ void setTimeframe(int millis);
void drawNotes(levelscore *levels);
void drawFlakes(levelscore *levels,float scale);
- void playerControl(int key,int threshold);
+ void playerControl(int key);
void makeFlakes(int threshStart,int threshEnd,levelscore *levels);
-
+ void printNotes();
int missedFlakes; int missedNote;
int hitNote;
bool missedLast;
bool perfect;
+ int keyThresh;
private:
map<int,note*> notes;
@@ -175,7 +175,7 @@ class musicscore: public score { map<int,flake*>::iterator missedFlake;
int timeframe; float nowpoint;
-
+
vector<Puppet> snowflakes;
};
@@ -188,7 +188,7 @@ class song { void preRoll(long preroll);
void setTimeframe(int millis);
void setFlakeThresh(int tS,int tE);
- void setKeythresh(int millis);
+ void setKeyThresh(int millis);
void drawNotes();
void draw(float scale); int missedNote();
@@ -197,16 +197,18 @@ class song { void playerControl(int key);
int getLevel(long time);
int getCurrentTime();
+
+ musicscore notes;
private:
ofSoundPlayer backing;
ofSoundPlayer melody;
lyricscore lyrics;
- musicscore notes;
+
levelscore levels;
long startTime;
bool isPreroll;
- int fThreshStart,fThreshEnd,keyThresh;
+ int fThreshStart,fThreshEnd;
};
//---------------------------------------------------------------------------------------------------------------------------------------------
/*
diff --git a/vfg/src/testApp.cpp b/vfg/src/testApp.cpp index d1cb41c..53cfa95 100755 --- a/vfg/src/testApp.cpp +++ b/vfg/src/testApp.cpp @@ -3,14 +3,16 @@ //-------------------------------------------------------------- void testApp::setup(){ - songs.push_back(new song("WeWishYouAMerryChistmas_v.2.1/VODA_MUS_WEWISHU_Backing_v.2.1.mp3","WeWishYouAMerryChistmas_v.2.1/VODA_MUS_WEWISHU_Lead_v.2.1.mp3","VODA_MUS_WEWISHU_Midi_v.2.1.xml","Lyrics_WeWishYou.2.1.xml","Levels_WeWishYou.2.1.xml")); + //songs.push_back(new song("WeWishYouAMerryChistmas_v.2.1/VODA_MUS_WEWISHU_Backing_v.2.1.mp3","WeWishYouAMerryChistmas_v.2.1/VODA_MUS_WEWISHU_Lead_v.2.1.mp3","VODA_MUS_WEWISHU_Midi_v.2.1.xml","Lyrics_WeWishYou.2.1.xml","Levels_WeWishYou.2.1.xml")); + songs.push_back(new song("DeckTheHalls_v.4.0/VODA_MUS_DeckTheHalls-Backing_v.4.0.mp3","DeckTheHalls_v.4.0/VODA_MUS_DeckTheHalls-Lead_v.4.0.mp3","VODA_MIDI_DeckTheHalls-v.4.0.xml","Lyrics_DeckTheHalls.4.0.xml","Levels_DeckTheHalls.4.0.xml")); songs.push_back(new song("DingDong.v.2.2/VODA_MUS_DingDong_Backing_v.2.2.mp3","DingDong.v.2.2/VODA_MUS_DingDong_Melody_v.2.2.mp3","VODA_MIDI_DingDong_v.2.2.xml","Lyrics_DingDong.2.2.xml","Levels_DingDong.2.2.xml")); songs.push_back(new song("JingleBells_v.4.0/VODA_MUS_JingleBells_Backing_v.4.0.mp3","JingleBells_v.4.0/VODA_MUS_JingleBells_Melody_v.4.0.mp3","VODA_MUS_JingleBells_MIDI_v.4.0.xml","Lyrics_JingleBells.4.0.xml","Levels_JingleBells.4.0.xml")); - songs.push_back(new song("DeckTheHalls_v.4.0/VODA_MUS_DeckTheHalls-Backing_v.4.0.mp3","DeckTheHalls_v.4.0/VODA_MUS_DeckTheHalls-Lead_v.4.0.mp3","VODA_MIDI_DeckTheHalls-v.4.0.xml","Lyrics_DeckTheHalls.4.0.xml","Levels_DeckTheHalls.4.0.xml")); ofSetBackgroundAuto(false); ofBackground(0,0,0); - + + //printf("we wish you a merry xmas:\n"); + //songs[0]->notes.printNotes(); for (int i=0;i<3;i++) penguins.push_back(Animal()); penguins[0].load("Penguin-Blue.xml"); @@ -54,7 +56,8 @@ void testApp::setup(){ vignette.loadImage("Vignette.png"); - showFPS=false; + showFPS=true; + showVis=true; currentsong=0; nextsong=0; @@ -91,8 +94,10 @@ void testApp::update(){ currentsong=nextsong; songs[currentsong]->setTimeframe(3000); songs[currentsong]->setFlakeThresh(1000,100); + songs[currentsong]->setKeyThresh(1000); songs[currentsong]->preRoll(750); tags[0]->play(); + nextsong=(nextsong+1)%songs.size(); } else if (ret>48&&ret<52) { songs[currentsong]->playerControl(ret-48); @@ -133,7 +138,7 @@ void testApp::draw(){ if (songs[currentsong]->isPlaying) { ofSetColor(255,255,255); - songs[currentsong]->drawNotes(); + if (showVis) songs[currentsong]->drawNotes(); int missed=songs[currentsong]->missedNote(); if (missed>-1) (*playanimal)[missed].playNow("Shudder"); int hit=songs[currentsong]->hitNote(); @@ -167,14 +172,15 @@ void testApp::draw(){ void testApp::keyPressed(int key){ switch (key) { case ' ': - nextsong=(nextsong+1)%songs.size(); if (!songs[currentsong]->isPlaying) { currentlevel=0; currentsong=nextsong; - songs[currentsong]->setTimeframe(3000); - songs[currentsong]->setFlakeThresh(1000,100); + songs[currentsong]->setTimeframe(5000); + songs[currentsong]->setFlakeThresh(2000,500); + songs[currentsong]->setKeyThresh(1500); songs[currentsong]->preRoll(750); tags[0]->play(); + nextsong=(nextsong+1)%songs.size(); } break; case '1': @@ -189,6 +195,9 @@ void testApp::keyPressed(int key){ case 'f': showFPS=!showFPS; break; + case 'v': + showVis=!showVis; + break; case 'r': //loadanimals("Raccoons"); playanimal =&raccoons; diff --git a/vfg/src/testApp.h b/vfg/src/testApp.h index 143885c..2d17cd0 100755 --- a/vfg/src/testApp.h +++ b/vfg/src/testApp.h @@ -104,6 +104,7 @@ class testApp : public ofBaseApp{ Asterisk game; bool showFPS; + bool showVis; int currentsong,nextsong; diff --git a/vfg/vfg.layout b/vfg/vfg.layout index 4f82781..59eb91b 100644 --- a/vfg/vfg.layout +++ b/vfg/vfg.layout @@ -16,22 +16,22 @@ <File name="src/Puppet.h" open="1" top="0" tabpos="4"> <Cursor position="312" topLine="0" /> </File> - <File name="src/Tag.h" open="1" top="1" tabpos="7"> + <File name="src/Tag.h" open="1" top="0" tabpos="7"> <Cursor position="551" topLine="0" /> </File> <File name="src/main.cpp" open="0" top="0" tabpos="1"> <Cursor position="219" topLine="0" /> </File> - <File name="src/music.cpp" open="0" top="0" tabpos="6"> - <Cursor position="8331" topLine="170" /> + <File name="src/music.cpp" open="1" top="1" tabpos="8"> + <Cursor position="7763" topLine="155" /> </File> <File name="src/music.h" open="0" top="0" tabpos="6"> <Cursor position="4738" topLine="125" /> </File> <File name="src/testApp.cpp" open="1" top="0" tabpos="6"> - <Cursor position="1108" topLine="5" /> + <Cursor position="3434" topLine="54" /> </File> <File name="src/testApp.h" open="1" top="0" tabpos="2"> - <Cursor position="2068" topLine="57" /> + <Cursor position="2068" topLine="40" /> </File> </CodeBlocks_layout_file> diff --git a/vpn/10.10.10.1 b/vpn/10.10.10.1 deleted file mode 100755 index 7ec52f7..0000000 --- a/vpn/10.10.10.1 +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/python - -import socket - -UDP_IP = "" -UDP_PORT = 5000 - -sock = socket.socket(socket.AF_INET, # Internet - socket.SOCK_DGRAM) # UDP -sock.bind((UDP_IP, UDP_PORT)) - -while True: - data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes - print "received message:", data
\ No newline at end of file diff --git a/vpn/10.10.10.1~ b/vpn/10.10.10.1~ deleted file mode 100755 index 7ec52f7..0000000 --- a/vpn/10.10.10.1~ +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/python - -import socket - -UDP_IP = "" -UDP_PORT = 5000 - -sock = socket.socket(socket.AF_INET, # Internet - socket.SOCK_DGRAM) # UDP -sock.bind((UDP_IP, UDP_PORT)) - -while True: - data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes - print "received message:", data
\ No newline at end of file diff --git a/vpn/notes.txt b/vpn/notes.txt index 9d3d298..f0df640 100755 --- a/vpn/notes.txt +++ b/vpn/notes.txt @@ -1,9 +1,13 @@ sudo openvpn --config server.conf
01-5548000
1800-804444
-ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx "database put GAME passcode 89889"'
+
+ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx "database put GAME passcode 1234"'
ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx "database put GAME ip 4.4.4.4"'
ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx "devstate change Custom:GAME NOT_INUSE"'
+ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx "database put GAME statuscode 1234"'
+ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx "hangup request Local/9999@default-00000039;2"
+
1 -download the source of asterisk from the server including the patch
2 -make && sudo make install
|
