Commit 309701f1 authored by Dan Wilcox's avatar Dan Wilcox
Browse files

added osc /autostop message, updated readme

parent 898d0f8e
......@@ -118,6 +118,7 @@ Usage: LanguageIdentifier [OPTIONS]
Options:
-h,--help Print this help message and exit
-s,--senders TEXT ... OSC sender addr:port host pairs, ex. "192.168.0.100:5555" or multicast "239.200.200.200:6666", default "localhost:9999"
-p,--port INT OSC receiver port, default 9898
-c,--confidence FLOAT:FLOAT bounded to [0 - 1]
min confidence, default 0.75
-t,--threshold FLOAT:INT bounded to [0 - 100]
......@@ -127,6 +128,8 @@ Options:
--inputname TEXT audio input device name, can do partial match, ex. "Microphone"
--inputchan INT audio input device channel, default 1
-r,--samplerate INT audio input device samplerate, can be 441000 or a multiple of 16000, default 48000
--nolisten do not listen on start
--autostop stop listening automatically after detection
-v,--verbose verbose printing
--version print version and exit
```
......@@ -137,6 +140,17 @@ For example, to send OSC to multiple addresses use the `-s` option:
% bin/LanguageIdentifier -s localhost:9999 localhost:6666 192.168.0.101:7777
```
#### OSC spec
LanguageIdentifier listens on port 9898 by default and responds to the following OSC messages:
* **/listen**: start listening
* **/listen _state_**: start/stop listening
- state: bool, 0 - stop, 1 - start
* **/autostop**: enable listening auto stop after detection
* **/autostop _state_**: enable/disable listening auto stop after detection
- state: bool, 0 - keep listening, 1 - stop on detection
#### macOS
For macOS, the application binary can be invoked from within the .app bundle to pass commandline arguments:
......
......@@ -311,13 +311,23 @@ void ofApp::audioIn(ofSoundBuffer & input) {
//--------------------------------------------------------------
void ofApp::keyPressed(int key) {
if(key == 'l') {
if(listening) {
stopListening();
}
else {
startListening();
}
switch(key) {
case 'l':
if(listening) {
stopListening();
}
else {
startListening();
}
break;
case 'a':
if(autostop) {
enableAutostop();
}
else {
disableAutostop();
}
break;
}
}
......@@ -399,10 +409,31 @@ void ofApp::stopListening() {
ofLogVerbose(PACKAGE) << "listening " << listening;
}
//--------------------------------------------------------------
void ofApp::enableAutostop() {
if(!autostop) {
ofLogVerbose(PACKAGE) << "autostop " << autostop;
}
autostop = true;
}
//--------------------------------------------------------------
void ofApp::disableAutostop() {
if(autostop) {
ofLogVerbose(PACKAGE) << "autostop " << autostop;
}
autostop = false;
}
//--------------------------------------------------------------
void ofApp::oscReceived(const ofxOscMessage &message) {
if(message.getAddress() == "/listen") {
if(message.getNumArgs() > 0) {
if(message.getNumArgs() == 0) {
if(!listening) {
startListening();
}
}
else if(message.getNumArgs() == 1) {
if(message.getArgAsBool(0)) {
startListening();
}
......@@ -411,4 +442,17 @@ void ofApp::oscReceived(const ofxOscMessage &message) {
}
}
}
else if(message.getAddress() == "/autostop") {
if(message.getNumArgs() == 0) {
enableAutostop();
}
else if(message.getNumArgs() == 1) {
if(message.getArgAsBool(0)) {
enableAutostop();
}
else {
disableAutostop();
}
}
}
}
......@@ -56,6 +56,12 @@ class ofApp : public ofBaseApp {
/// stop listening
void stopListening();
/// enable listening auto stop after detection
void enableAutostop();
/// disable listening auto stop after detection
void disableAutostop();
/// osc receiver callback
void oscReceived(const ofxOscMessage &message);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment