Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

main XML conf modifications

  • Loading branch information...
commit b08904e08498d3d9e6208fc9f9c1c3fa00cc7bd9 1 parent 98c034f
@vincent authored
View
50 app.js
@@ -2,7 +2,8 @@
var nconf = require('nconf');
nconf.file({ file: 'config.json' })
.defaults({
- sets_directory: __dirname + '/sets'
+ sets_directory: __dirname + '/sets',
+ reactivisionxml: false
});
var all_icons = {
@@ -109,8 +110,15 @@ function context(req){
// all sets
var user_sets_html = sets_list_html(user_sets, active_set);
+
+ var plateform = os.platform();
return {
+ platform: {
+ is_windows: plateform == "windows",
+ is_linux: plateform == "linux",
+ is_macos: plateform == "darwin"
+ },
config: nconf.load(),
user_sets: user_sets,
user_sets_html: user_sets_html.join(''),
@@ -288,34 +296,58 @@ app.get('/action', function(req, res){
});
}
+
+ // activate
+ if (req.param('activate', false)){
+ if (req.param('set', false)){
+ // reactivisionxml
+
+ var filepath = nconf.get('reactivisionxml');
+
+ fs.readFile(filepath, 'utf8', function(err, contents){
+ var reacParser = new R.ReacTIVisionConfigFileParser();
+ reacParser.run(contents);
+ reacParser.modify('MIDI', { config: nconf.get('sets_directory') + '/' + req.param('set') });
+
+ contents = reacParser.newContents();
+
+ fs.writeFile(filepath, contents, 'utf8', function(err){
+ res.end();
+ });
+ });
+ }
+ }
// stop
if (req.param('stop', false)){
if (os.platform() == 'windows'){
- exec('TASKKILL /F /IM reactvision.exe');
+ console.log(exec('TASKKILL /F /IM reactvision.exe'));
} else {
- exec('killall -9 reactvision &');
+ console.log(exec('killall -9 reactvision &'));
}
+ res.end();
}
// start
if (req.param('stop', false)){
if (os.platform() == 'windows'){
- exec('reactvision.exe');
+ console.log(exec('reactvision.exe'));
} else {
- exec('reactvision &');
+ console.log(exec('reactvision &'));
}
+ res.end();
}
// restart
if (req.param('restart', false)){
if (os.platform() == 'windows'){
- exec('TASKKILL /F /IM reactvision.exe');
- exec('reactvision.exe');
+ console.log(exec('TASKKILL /F /IM reactvision.exe'));
+ console.log(exec('reactvision.exe'));
} else {
- exec('killall -9 reactvision &');
- exec('reactvision &');
+ console.log(exec('killall -9 reactvision &'));
+ console.log(exec('reactvision &'));
}
+ res.end();
}
// other possible actions ..
View
3  config.json
@@ -1,3 +1,4 @@
{
- "sets_directory": "/Users/vincent/Workspace/reactnode/sets"
+ "sets_directory": "/Users/vincent/Workspace/reactnode/sets",
+ "reactivisionxml": "/Users/vincent/Downloads/reacTIVision-1.4/reacTIVision.app/Contents/Resources/reacTIVision.xml"
}
View
85 node_modules/reactvision.js
@@ -4,6 +4,8 @@ var ce = require('cloneextends');
var E_START = 0;
var E_MIDI = 1;
var E_MAP = 2;
+var E_REACTIVISION = 3;
+var E_OTHER = 4;
/**************************************************************************/
if (!Object['values']){
@@ -29,7 +31,6 @@ MidiConfigFileParser.prototype = {
var config = config;
var parse_state = E_START;
var result = {};
- var currentMap = {};
this.parser = sax.parser(false);
@@ -90,7 +91,87 @@ MidiConfigFileParser.prototype = {
}
};
+/**************************************************************************/
+
+//Constructor
+function ReacTIVisionConfigFileParser() { }
+
+//properties and methods
+ReacTIVisionConfigFileParser.prototype = {
+ struct: {},
+
+ run: function(string){
+
+ var self = this;
+ var parse_state = E_START;
+ var result = {};
+
+ self.parser = sax.parser(false);
+
+ self.parser.onopentag = function (node) {
+ switch (parse_state) {
+ case E_START:
+ if (node.name == 'REACTIVISION') {
+ parse_state = E_REACTIVISION;
+ }
+ break;
+
+ case E_REACTIVISION:
+ parse_state = E_OTHER;
+ break;
+
+ case E_OTHER:
+ self.struct[node.name] = node;
+ break;
+ }
+ };
+
+ // parse !
+ self.parser.write(string).close();
+ },
+
+ modify: function(nodeName, attributes){
+ var self = this;
+ // node already exists
+ if (self.struct[nodeName]) {
+ Object.keys(self.struct[nodeName].attributes).forEach(function(key){
+ if (attributes[key]) {
+ self.struct[nodeName].attributes[key] = attributes[key];
+ }
+ });
+ }
+ // new node
+ else {
+ self.struct[nodeName] = {
+ name: nodeName,
+ attributes: attributes
+ };
+ }
+ },
+
+ newContents: function(){
+ var self = this;
+ var result = '<reactivision> \n';
+
+ Object.keys(self.struct).forEach(function(nodeName){
+ var attributes = '';
+
+ Object.keys(self.struct[nodeName].attributes).forEach(function(attrKey){
+ attributes += attrKey + '="' + self.struct[nodeName].attributes[attrKey] + '" ';
+ });
+
+ result += ' <' + nodeName.toLowerCase() + ' ' + attributes + ' /> \n';
+ });
+
+ result += '</reactivision>';
+ return result;
+ }
+
+};
+
+
//node.js module export
module.exports = {
- MidiConfigFileParser: MidiConfigFileParser
+ MidiConfigFileParser: MidiConfigFileParser,
+ ReacTIVisionConfigFileParser: ReacTIVisionConfigFileParser
};
View
19 public/tests/reacTIVision.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<reactivision>
+ <!--
+these are all the possible configuration tagsand their default values.
+you only need to specify parameters you want to change from their default setting.
+please note that the active tags need to be placed outside of this commented area.
+
+<tuio host="127.0.0.1" port="3333" />
+<midi config="midi_demo.xml" />
+<camera config="camera.xml" />
+<finger size="12" sensitivity="100" />
+<fiducial engine="amoeba" tree="small.trees" />
+<image display="dest" equalize="false" gradient="32" />
+<calibration file="default.grid" invert="xa" />
+-->
+ <finger size="0" sensitivity="75" />
+ <image display="dest" equalize="false" gradient="32" />
+ <calibration file="default.grid" invert=" " />
+</reactivision>
View
5 sets/demo.xml
@@ -26,18 +26,19 @@
<midi device="1">
<map fiducial="2" type="vfader" control="9" min="0.1" max="0.9"/>
- <map fiducial="2" type="hfader" control="9" min="0.1" max="0.9"/>
<map fiducial="2" type="note" note="9" />
<map fiducial="3" type="vfader" control="9" min="0.1" max="0.9"/>
<map fiducial="3" type="knob" control="9" min="0.1" max="0.9"/>
<map fiducial="3" type="note" note="9" />
+ <map fiducial="6" type="vfader" control="9" min="0.1" max="0.9"/>
+ <map fiducial="6" type="hfader" control="9" min="0.1" max="0.9"/>
<map fiducial="6" type="knob" control="9" min="0.1" max="0.9"/>
<map fiducial="7" type="vfader" control="9" min="0.1" max="0.9"/>
<map fiducial="7" type="knob" control="9" min="0.1" max="0.9"/>
<map fiducial="8" type="vfader" control="9" min="0.1" max="0.9"/>
<map fiducial="8" type="knob" control="9" min="0.1" max="0.9"/>
- <map fiducial="9" type="vfader" control="9" min="0.1" max="0.9"/>
<map fiducial="9" type="knob" control="9" min="0.1" max="0.9"/>
+ <map fiducial="10" type="vfader" control="9" min="0.1" max="0.9"/>
<map fiducial="10" type="knob" control="9" min="0.1" max="0.9"/>
</midi>
View
45 sets/plopdemo.xml
@@ -0,0 +1,45 @@
+
+<?xml version="1.0" encoding="UTF-8" ?>
+
+ <!--
+ reacTIVision MIDI mapping configuration file
+ using MIDI each dimension needs to be mapped to an individual control number.
+ possible dimensions are: x-position, y-position and rotation angle
+ additionaly the fiducial presence can be mapped to note on/off events.
+
+ each mapping tag contains at least the following attributes:
+ fiducial: the ID number of the fiducial tag
+ type: the control type
+ hfader=xpos, vfader=ypos, knob=angle, note=presence
+ control: the control number (for the hfader, vfader & knob types)
+ note: the note number (for the note type)
+
+ optional attributes:
+ channel: the MIDI channel (defaults to 0)
+ min: minimum range (defaults to 0)
+ max: maximum range (defaults to 1)
+
+ the min/max attribute allow the selection of a subregion in the desired dimension.
+ for example min=0.1 and max 0.9 will ignore 10% on each side of the image
+ for the knob type max=1 will map to a full rotation from 0 to 127 in MIDI values.
+ -->
+
+ <midi device="1">
+ <map fiducial="2" type="vfader" control="9" min="0.1" max="0.9"/>
+ <map fiducial="2" type="hfader" control="9" min="0.1" max="0.9"/>
+ <map fiducial="2" type="note" note="9" />
+ <map fiducial="3" type="vfader" control="9" min="0.1" max="0.9"/>
+ <map fiducial="3" type="knob" control="9" min="0.1" max="0.9"/>
+ <map fiducial="3" type="note" note="9" />
+ <map fiducial="6" type="vfader" control="9" min="0.1" max="0.9"/>
+ <map fiducial="6" type="hfader" control="9" min="0.1" max="0.9"/>
+ <map fiducial="6" type="knob" control="9" min="0.1" max="0.9"/>
+ <map fiducial="7" type="vfader" control="9" min="0.1" max="0.9"/>
+ <map fiducial="7" type="knob" control="9" min="0.1" max="0.9"/>
+ <map fiducial="8" type="vfader" control="9" min="0.1" max="0.9"/>
+ <map fiducial="8" type="knob" control="9" min="0.1" max="0.9"/>
+ <map fiducial="9" type="knob" control="9" min="0.1" max="0.9"/>
+ <map fiducial="10" type="vfader" control="9" min="0.1" max="0.9"/>
+ <map fiducial="10" type="knob" control="9" min="0.1" max="0.9"/>
+
+ </midi>
View
23 views/config.html
@@ -1,12 +1,31 @@
-<div class="span9">
+<div class="span9" style="margin-left: 26%;">
<form class="form-horizontal" method="post">
<fieldset>
<legend>Configuration panel</legend>
<div class="control-group">
<label class="control-label" for="input01">Sets directory</label>
<div class="controls">
- <input type="text" class="input-xlarge" id="input01" name="config.sets_directory" value="{config.sets_directory}">
<p class="help-block">Where are your patterns XML files ?</p>
+ <input type="text" class="input-xlarge" id="input01" name="config.sets_directory" value="{config.sets_directory}">
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="input01">ReacTIVision</label>
+ <div class="controls">
+ <p class="help-block">Where is <i>reacTIVision.xml</i> ?</p>
+ <input type="text" class="input-xlarge" id="input02" name="config.reactivisionxml" value="{config.reactivisionxml}" ondrop="console.log(event);">
+ {if platform.is_windows}
+ <input type="hidden" name="config.platform" value="windows" />
+ <p class="help-block">Usually, it resides beside the <em>reacTIVision.exe</em> program</p>
+ {/if}
+ {if platform.is_macos}
+ <input type="hidden" name="config.platform" value="macos" />
+ <p class="help-block">Usually, it resides on <em>.../reacTIVision.app/Contents/Resources/reacTIVision.xml</em></p>
+ {/if}
+ {if platform.is_linux}
+ <input type="hidden" name="config.platform" value="linux" />
+ <p class="help-block">Usually, it resides beside the reacTIVision program</em></p>
+ {/if}
</div>
</div>
<div class="form-actions">
View
27 views/edit.html
@@ -1,18 +1,25 @@
-<div class="span9">
+<div class="span9" style="margin-left: 26%;">
<form id="editform" action="/edit?set={active_set}" method="get">
<input type="hidden" name="active_set" id="active_set" value="{active_set}"/>
+ <div class="controls clearfix page-header" style="margin-top:0px;">
+
+ <h1>{active_set}</h1>
+ <br/>
+
+ <div style="float:left; width: 160px;">
+ <a href="/action?activate=1&set={active_set}" class="btn btn-primary btn-success"><i class="icon-white icon-ok-circle"></i> Make it active</a>
+ </div>
+
+ <div style="float:left; width: 120px;">
+ <button type="submit" class="btn btn-primary btn-danger"><i class="icon-white icon-ban-circle"></i> Delete</button>
+ </div>
+
+ </div>
+
{if set_fiducials}
- <ul class="thumbnails">
- <li class="span3">
- <!--
- <a href="#" class="thumbnail" title="fiducial {fid.id}">
- <img src="/assets/img/add_item.png" alt="fiducial {fid.id}" width="237" height="235">
- {for i in fid.icons}<i class="icon-{i}"></i>{/for}
- </a>
- -->
- </li>
+ <ul class="thumbnails">
{for fid in set_fiducials}
<li class="span3" id="fiducial_{fid.id}">
<span class="number">{fid.id}</span>
View
4 views/index.html
@@ -1,6 +1,6 @@
-<div class="span9">
+<div class="span9" style="margin-left: 26%;">
- <div class="hero-unit">
+ <div class="hero-unit well">
<h1>ReacTVision sets</h1>
<p>This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><br/><a class="btn btn-primary btn-large">Create a new set &raquo;</a></p>
View
5 views/layout.html
@@ -150,6 +150,7 @@
<li class="active"><a href="/">Home</a></li>
<li><a href="/config">Configuration</a></li>
</ul>
+
<!--
<button style="float:right;" class="btn zoom-minus" href="#"><i class="icon-zoom-in"></i> -</button>
@@ -175,8 +176,8 @@
</div>
<div class="container-fluid">
- <div class="row-fluid">
- <div class="span3">
+ <div class="row-fluid fixed-top">
+ <div class="span3" style="position: fixed;">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Your sets<br/><em style="font-size:8px; letter-spacing: .8px">in {config.sets_directory}</em></li>
Please sign in to comment.
Something went wrong with that request. Please try again.