{"action":"created","issue":{"url":"https://api.github.com/repos/rserota/wad/issues/33","labels_url":"https://api.github.com/repos/rserota/wad/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/rserota/wad/issues/33/comments","events_url":"https://api.github.com/repos/rserota/wad/issues/33/events","html_url":"https://github.com/rserota/wad/issues/33","id":58290720,"number":33,"title":"External effects on mic input?","user":{"login":"jenius","id":556932,"avatar_url":"https://avatars.githubusercontent.com/u/556932?v=3","gravatar_id":"","url":"https://api.github.com/users/jenius","html_url":"https://github.com/jenius","followers_url":"https://api.github.com/users/jenius/followers","following_url":"https://api.github.com/users/jenius/following{/other_user}","gists_url":"https://api.github.com/users/jenius/gists{/gist_id}","starred_url":"https://api.github.com/users/jenius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenius/subscriptions","organizations_url":"https://api.github.com/users/jenius/orgs","repos_url":"https://api.github.com/users/jenius/repos","events_url":"https://api.github.com/users/jenius/events{/privacy}","received_events_url":"https://api.github.com/users/jenius/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-02-19T23:59:20Z","updated_at":"2015-02-20T23:40:29Z","closed_at":null,"body":"Hey sorry, so many issues! You've been so helpful in working them out so far though, really appreciate it. So I'm trying to add an external effect to the mic through Tuna. I followed the instructions for how to make it happen in the readme with the `constructExternalFx` and `setUpExternalFxOnPlay` methods, and noticed nothing was happening when I passed the arguments for it through to the `play` function.\r\n\r\nBrowsing quickly though the code, I saw that while [constructExternalFx is being called](https://github.com/rserota/wad/blob/master/src/wad.js#L580), `setUpExternalFxOnPlay` is not anywhere and never goes off. I tried adding this to the same section of code above, and the function does run in that case, but the external effects are not actually applied.\r\n\r\nHere's some sample code to work with:\r\n\r\n```js\r\nvar Wad = require('wad');\r\nvar Tuna = require('tuna');\r\n\r\nWad.prototype.constructExternalFx = function(arg, ctx) {\r\n  console.log('constructExternalFx called');\r\n  this.tuna = new Tuna(ctx);\r\n  this.chorus = arg.chorus;\r\n}\r\n\r\nWad.prototype.setUpExternalFxOnPlay = function(arg, context) {\r\n  console.log('setUpExternalFxOnPlay called');\r\n  if (arg.chorus) {\r\n    var chorus = new this.tuna.Chorus({\r\n      rate: arg.chorus.rate || this.chorus.rate,\r\n      feedback: arg.chorus.feedback || this.chorus.feedback,\r\n      delay: arg.chorus.delay || this.chorus.delay,\r\n      bypass: arg.chorus.bypass || this.chorus.bypass\r\n    });\r\n\r\n    chorus.input.connect = chorus.connect.bind(chorus);\r\n    this.nodes.push(chorus.input);\r\n  }\r\n}\r\n\r\nvar voice = new Wad({ source: 'mic' });\r\n\r\nvoice.play({\r\n  chorus: {\r\n      rate: 1.5,\r\n      feedback: 0.2,\r\n      delay: 0.0045,\r\n      bypass: 0\r\n    }\r\n});\r\n```\r\n\r\nEdit: Also just tried adding these params to the `Wad` constructor -- no error but still no effects."},"comment":{"url":"https://api.github.com/repos/rserota/wad/issues/comments/75339850","html_url":"https://github.com/rserota/wad/issues/33#issuecomment-75339850","issue_url":"https://api.github.com/repos/rserota/wad/issues/33","id":75339850,"user":{"login":"rserota","id":5151127,"avatar_url":"https://avatars.githubusercontent.com/u/5151127?v=3","gravatar_id":"","url":"https://api.github.com/users/rserota","html_url":"https://github.com/rserota","followers_url":"https://api.github.com/users/rserota/followers","following_url":"https://api.github.com/users/rserota/following{/other_user}","gists_url":"https://api.github.com/users/rserota/gists{/gist_id}","starred_url":"https://api.github.com/users/rserota/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rserota/subscriptions","organizations_url":"https://api.github.com/users/rserota/orgs","repos_url":"https://api.github.com/users/rserota/repos","events_url":"https://api.github.com/users/rserota/events{/privacy}","received_events_url":"https://api.github.com/users/rserota/received_events","type":"User","site_admin":false},"created_at":"2015-02-20T23:40:29Z","updated_at":"2015-02-20T23:40:29Z","body":"While you're digging, here are some things to think about.  I'm not sure how much of this is directly related to the problem you're having right now, but it should give you some background info that will help you debug your application. \r\n\r\nTo get all the nodes in `voice` hooked up, they're all pushed into `voice.nodes`. After granting your browser access to your mic (or after calling play with new args), this array should have a mediaStreamSource, a gainNode, and a pannerNode, in addition to the other nodes you've added (filters, tuna chorus, etc). You can inspect this array to make sure it has the nodes you expect it to have.\r\n\r\nAfter they've been pushed, the `plugEmIn` function will try to daisy-chain them together, like so:\r\n    `nodes[0].connect(nodes[1])`\r\n    `nodes[1].connect(nodes[2])`\r\netc etc\r\n\r\nHowever, some types of nodes (e.g. reverb and delay) have a custom interface. If `plugEmIn` sees that `nodes[i].interface === 'custom'`, then it will try to connect them like so:\r\n    `nodes[0].output.connect(nodes[1].input)`\r\n    `nodes[1].output.connect(nodes[2].input)`\r\netc etc\r\n\r\nTuna nodes are a little weird because they have an input, but no output, so they don't behave like native nodes or custom nodes. The workaround is binding `chorus.connect` to `chorus.input.connect`, so that we can pretend our tuna nodes are native nodes. That does work, but it's probably one of the shakier parts of this process. \r\n"}}