Skip to content

Commit

Permalink
Merge pull request #40 from Awk34/output-gain
Browse files Browse the repository at this point in the history
Output gain
  • Loading branch information
Awk34 committed Mar 19, 2014
2 parents dd0bce7 + 19c8707 commit 0066ad6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 12 deletions.
33 changes: 26 additions & 7 deletions js/dot.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,8 @@ function Dot(definition, x, y) {

//events
var conn = null;
addListeners(this.centerElement, {
var callbackListeners = {
onHoldStart: function(e) {navigator.vibrate(HOLD_EFFECT_VIBRATE_TIME);},
onHoldDragStart: function(e) {conn = new Connection(selfDot);},
onHoldDragMove: function(e) {conn.endAt(e.mmX, e.mmY)},
onDragStart: function(e) {
//move to front
selfDot.svgElement.parentNode.appendChild(selfDot.svgElement);
Expand Down Expand Up @@ -235,11 +233,32 @@ function Dot(definition, x, y) {
updateArcsClipPath();
}
},
onHoldDragEnd: function(e) {
conn.finalize(document.elementFromPoint(e.clientX, e.clientY))
},
onTapEnd: function(e) {selfDot.toggle();}
});
};
if (definition.noOutput) {
callbackListeners.onHoldDragStart = function(e) {
//TODO: inform the user that this node does
// not have any outputs, and therefore
// cannot be the starting point of a
// connection.
}
//TODO: BUG: for some reason, the lack of the
// two following functions causes an error.
callbackListeners.onHoldDragMove = function(){};
callbackListeners.onHoldDragEnd = function(){};
} else {
//there's output. Allow this node to connect to others.
callbackListeners.onHoldDragStart = function(e) {
conn = new Connection(selfDot);
};
callbackListeners.onHoldDragMove = function(e) {
conn.endAt(e.mmX, e.mmY)
};
callbackListeners.onHoldDragEnd = function(e) {
conn.finalize(document.elementFromPoint(e.clientX, e.clientY))
};
}
addListeners(this.centerElement, callbackListeners);

function Arc(parent, start, end, definition) {
var selfArc = this;
Expand Down
1 change: 0 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
window.AudioContext = window.AudioContext || window.webkitAudioContext;
var context = new AudioContext();
context.destination.connections = [];

addListeners(helptext, {onTapEnd: function(){ helptext.classList.toggle('hidden'); }});
addListeners(help, {onTapEnd: function(){ helptext.classList.toggle('hidden'); }});
Expand Down
26 changes: 22 additions & 4 deletions js/nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,32 @@ var DOT_LIST = [
shortName: "Out",
className: "output",
canTakeInput: true,
noOutput: true,
create: function() {
var tmp = context.destination;
tmp.connections = [];
var tmp = context.createGain();
tmp.connect(context.destination);
return tmp;
},
//huehuehue
hue: 300,
parameters: []
parameters: [
{
name: "gain",
className: "gain",
scale: function(percent) {
return percent;
},
invScale: function(value) {
/*
* 'value' ranges from 0 to 1
* defaultValue: 1
* minValue: 0
* maxValue: 1
*/
return value;
},
hue: 0
}
]
},
{
name: "Oscillator",
Expand Down

0 comments on commit 0066ad6

Please sign in to comment.