Skip to content

Commit

Permalink
add example
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbloomer committed May 28, 2013
1 parent 26bfbce commit fec05c3
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 15 deletions.
32 changes: 21 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,38 @@ Tadaa defaults to 'aplay' (available for Linux systems) but the player can be co

Tada can play a sound, depending the value you are monitoring.

var tadaa = require('tadaa');
var audioPlayer = 'mplayer' // player used to play sounds, defaults to aplay
var interval = 60000; // time in ms for which the value function is called
var tadaa = require('../lib/tadaa');

var audioPlayer = 'aplay' // player used to play sounds, defaults to aplay
var interval = 10000; // time in ms for which the value function is called
var up = 'up.wav'; // sound to play when value goes up
var down = 'down.wav'; // sound to play when value goes down

var fnup = function(currentValue, newValue) {
return newValue > currentValue;
};

var fndown = function(currentValue, newValue) {
return newValue < currentValue;
};

// Function to call to get the value
var getValue = function(callback){
// ...my clever value logic...
callback(null, Math.random() * 100); }
var getValue = function(options, callback){
// ...insert your clever value logic...
var number = Math.random() * 100;
console.log(number);
callback(null, number);
}
var getValueOptions = { a : 1, b : 2 }; // Data to pass to the function.

tadaa.start(interval, [{fn: fnup, sound:up}, {fn: fndown, sound:down}], getValue, getValueOptions, audioPlayer};
// Data to pass to the function.
var getValueOptions = { a : 1, b : 2 };

tadaa.start(
interval,
[{fn: fnup, sound:up}, {fn: fndown, sound:down}],
getValue,
getValueOptions,
audioPlayer);

## Tadaa logic functions included in the box
- up
Expand Down
Binary file added example/down.wav
Binary file not shown.
32 changes: 32 additions & 0 deletions example/random_number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var tadaa = require('../lib/tadaa');

var audioPlayer = 'aplay' // player used to play sounds, defaults to aplay
var interval = 10000; // time in ms for which the value function is called
var up = 'up.wav'; // sound to play when value goes up
var down = 'down.wav'; // sound to play when value goes down

var fnup = function(currentValue, newValue) {
return newValue > currentValue;
};

var fndown = function(currentValue, newValue) {
return newValue < currentValue;
};

// Function to call to get the value
var getValue = function(options, callback){
// ...insert your clever value logic...
var number = Math.random() * 100;
console.log(number);
callback(null, number);
}

// Data to pass to the function.
var getValueOptions = { a : 1, b : 2 };

tadaa.start(
interval,
[{fn: fnup, sound:up}, {fn: fndown, sound:down}],
getValue,
getValueOptions,
audioPlayer);
Binary file added example/up.wav
Binary file not shown.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
"dependencies": {
"buddha": "1.0.x",
"commander": "0.5.x",
"pivotal": "0.1.x"
},
"dependencies" : {
"pivotal": "0.1.x",
"async" : "x.x.x"
},
"devDependencies" : {
Expand All @@ -30,5 +28,5 @@
"main": "./lib/tadaa",
"bin": { "tadaa": "./bin/tadaa" },
"scripts": { "test": "mocha test/*_test.js --reporter spec" },
"engines": { "node": ">= 0.4.12 < 0.9.0" }
"engines": { "node": ">= 0.4.12 < 0.11.0" }
}

0 comments on commit fec05c3

Please sign in to comment.