{"action":"created","comment":{"url":"https://api.github.com/repos/processing/p5.js-sound/pulls/comments/121289575","pull_request_review_id":43327044,"id":121289575,"diff_hunk":"@@ -467,9 +467,7 @@ define(function (require) {\n    *                               Defaults to 0.8.\n    */\n   p5.FFT.prototype.smooth = function(s) {\n-    if (s) {\n-      this.smoothing = s;\n-    }\n+    this.smoothing = s;\n     this.analyser.smoothingTimeConstant = s;","path":"src/fft.js","position":8,"original_position":8,"commit_id":"0402cdb90ef4ff6d9c89ce05624a88afc0c72757","original_commit_id":"0402cdb90ef4ff6d9c89ce05624a88afc0c72757","user":{"login":"therewasaguy","id":504124,"avatar_url":"https://avatars1.githubusercontent.com/u/504124?v=3","gravatar_id":"","url":"https://api.github.com/users/therewasaguy","html_url":"https://github.com/therewasaguy","followers_url":"https://api.github.com/users/therewasaguy/followers","following_url":"https://api.github.com/users/therewasaguy/following{/other_user}","gists_url":"https://api.github.com/users/therewasaguy/gists{/gist_id}","starred_url":"https://api.github.com/users/therewasaguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/therewasaguy/subscriptions","organizations_url":"https://api.github.com/users/therewasaguy/orgs","repos_url":"https://api.github.com/users/therewasaguy/repos","events_url":"https://api.github.com/users/therewasaguy/events{/privacy}","received_events_url":"https://api.github.com/users/therewasaguy/received_events","type":"User","site_admin":false},"body":"@TheBrenny ah, sorry, it was confusing that I used `this.fft` in the example above when I should have used `this.analyser`. I'll try to clarify...\r\n\r\nFirst of all, your comment is spot on that 0 is falsey and so your update is definitely an improvement. Anything beyond that is nice to have, let me know if you want to give it a shot.\r\n\r\nI'm thinking, what if somebody calls `fft.smooth('some string');` ? Then in the smoothing function we'd see this go through successfully...\r\n\r\n```this.smoothing = 'some string'```\r\n\r\n...but this throw an error\r\n\r\n`this.analyser.smoothingTimeConstant = 'some string'`\r\n\r\nSame thing would happen if smoothing is above 1, or below 0.\r\n\r\nSo I am suggesting to take `this.smoothing` out of [the smooth() method](https://github.com/TheBrenny/p5.js-sound/blob/6de0770487c0dac22f085a4c81de7088122ec207/src/fft.js#L471), and instead define the property as a \"getter\" in the constructor. Something like this:\r\n\r\n```\r\np5.FFT = function(smoothing, bins) {\r\n    var SMOOTHING = smoothing || 0.8;\r\n\r\n    ...\r\n    this.analyser.smoothingTimeConstant = SMOOTHING;\r\n\r\n    ...\r\n    Object.defineProperty(this, 'smoothing', {\r\n      get: function() {\r\n        return this.analyser.smoothingTimeConstant;\r\n      }\r\n      set: function(s) {\r\n         this.analyser.smoothingTimeConstant = s;\r\n      }\r\n    });\r\n}\r\n```\r\n\r\nIf we create an instance called fft, and set `fft.smoothing = 0`, that calls the setter, which does the same thing `fft.smooth(0)` would do. If we `console.log(fft.smoothing)` that will call the getter, returning `this.analyser.smoothingTimeConstant` in real time.\r\n\r\nWe haven't used getters and setters in p5.sound much, but seems like a useful place to incorporate them.","created_at":"2017-06-11T19:31:23Z","updated_at":"2017-06-11T19:31:23Z","html_url":"https://github.com/processing/p5.js-sound/pull/176#discussion_r121289575","pull_request_url":"https://api.github.com/repos/processing/p5.js-sound/pulls/176","_links":{"self":{"href":"https://api.github.com/repos/processing/p5.js-sound/pulls/comments/121289575"},"html":{"href":"https://github.com/processing/p5.js-sound/pull/176#discussion_r121289575"},"pull_request":{"href":"https://api.github.com/repos/processing/p5.js-sound/pulls/176"}}},"pull_request":{"url":"https://api.github.com/repos/processing/p5.js-sound/pulls/176","id":125016268,"html_url":"https://github.com/processing/p5.js-sound/pull/176","diff_url":"https://github.com/processing/p5.js-sound/pull/176.diff","patch_url":"https://github.com/processing/p5.js-sound/pull/176.patch","issue_url":"https://api.github.com/repos/processing/p5.js-sound/issues/176","number":176,"state":"open","locked":false,"title":"Updated smooth function","user":{"login":"TheBrenny","id":1498923,"avatar_url":"https://avatars0.githubusercontent.com/u/1498923?v=3","gravatar_id":"","url":"https://api.github.com/users/TheBrenny","html_url":"https://github.com/TheBrenny","followers_url":"https://api.github.com/users/TheBrenny/followers","following_url":"https://api.github.com/users/TheBrenny/following{/other_user}","gists_url":"https://api.github.com/users/TheBrenny/gists{/gist_id}","starred_url":"https://api.github.com/users/TheBrenny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheBrenny/subscriptions","organizations_url":"https://api.github.com/users/TheBrenny/orgs","repos_url":"https://api.github.com/users/TheBrenny/repos","events_url":"https://api.github.com/users/TheBrenny/events{/privacy}","received_events_url":"https://api.github.com/users/TheBrenny/received_events","type":"User","site_admin":false},"body":"Calling \r\n\r\n```javascript\r\nvar fft = new p5.FFT();\r\nfft.smooth(0);\r\nconsole.log(fft.smoothing);\r\nconsole.log(fft.analyser.smoothingTimeConstant);\r\n```\r\n\r\nwould yeild different results. This is because the smoothing time constant would get updated always, and `fft.smoothing` wouldn't because of the way that 0 is falsey (`0 == false`).","created_at":"2017-06-11T07:09:37Z","updated_at":"2017-06-11T19:31:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5fb6aea67de381c918f310568763892ffdf8042d","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/processing/p5.js-sound/pulls/176/commits","review_comments_url":"https://api.github.com/repos/processing/p5.js-sound/pulls/176/comments","review_comment_url":"https://api.github.com/repos/processing/p5.js-sound/pulls/comments{/number}","comments_url":"https://api.github.com/repos/processing/p5.js-sound/issues/176/comments","statuses_url":"https://api.github.com/repos/processing/p5.js-sound/statuses/0402cdb90ef4ff6d9c89ce05624a88afc0c72757","head":{"label":"TheBrenny:patch-2","ref":"patch-2","sha":"0402cdb90ef4ff6d9c89ce05624a88afc0c72757","user":{"login":"TheBrenny","id":1498923,"avatar_url":"https://avatars0.githubusercontent.com/u/1498923?v=3","gravatar_id":"","url":"https://api.github.com/users/TheBrenny","html_url":"https://github.com/TheBrenny","followers_url":"https://api.github.com/users/TheBrenny/followers","following_url":"https://api.github.com/users/TheBrenny/following{/other_user}","gists_url":"https://api.github.com/users/TheBrenny/gists{/gist_id}","starred_url":"https://api.github.com/users/TheBrenny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheBrenny/subscriptions","organizations_url":"https://api.github.com/users/TheBrenny/orgs","repos_url":"https://api.github.com/users/TheBrenny/repos","events_url":"https://api.github.com/users/TheBrenny/events{/privacy}","received_events_url":"https://api.github.com/users/TheBrenny/received_events","type":"User","site_admin":false},"repo":{"id":93986999,"name":"p5.js-sound","full_name":"TheBrenny/p5.js-sound","owner":{"login":"TheBrenny","id":1498923,"avatar_url":"https://avatars0.githubusercontent.com/u/1498923?v=3","gravatar_id":"","url":"https://api.github.com/users/TheBrenny","html_url":"https://github.com/TheBrenny","followers_url":"https://api.github.com/users/TheBrenny/followers","following_url":"https://api.github.com/users/TheBrenny/following{/other_user}","gists_url":"https://api.github.com/users/TheBrenny/gists{/gist_id}","starred_url":"https://api.github.com/users/TheBrenny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheBrenny/subscriptions","organizations_url":"https://api.github.com/users/TheBrenny/orgs","repos_url":"https://api.github.com/users/TheBrenny/repos","events_url":"https://api.github.com/users/TheBrenny/events{/privacy}","received_events_url":"https://api.github.com/users/TheBrenny/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/TheBrenny/p5.js-sound","description":"p5.sound brings the Processing approach to Web Audio and p5.js. Demos:","fork":true,"url":"https://api.github.com/repos/TheBrenny/p5.js-sound","forks_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/forks","keys_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/teams","hooks_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/hooks","issue_events_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/issues/events{/number}","events_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/events","assignees_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/assignees{/user}","branches_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/branches{/branch}","tags_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/tags","blobs_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/git/refs{/sha}","trees_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/statuses/{sha}","languages_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/languages","stargazers_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/stargazers","contributors_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/contributors","subscribers_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/subscribers","subscription_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/subscription","commits_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/commits{/sha}","git_commits_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/git/commits{/sha}","comments_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/comments{/number}","issue_comment_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/issues/comments{/number}","contents_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/contents/{+path}","compare_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/merges","archive_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/downloads","issues_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/issues{/number}","pulls_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/pulls{/number}","milestones_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/milestones{/number}","notifications_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/labels{/name}","releases_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/releases{/id}","deployments_url":"https://api.github.com/repos/TheBrenny/p5.js-sound/deployments","created_at":"2017-06-11T06:49:26Z","updated_at":"2017-06-11T06:49:27Z","pushed_at":"2017-06-11T07:07:47Z","git_url":"git://github.com/TheBrenny/p5.js-sound.git","ssh_url":"git@github.com:TheBrenny/p5.js-sound.git","clone_url":"https://github.com/TheBrenny/p5.js-sound.git","svn_url":"https://github.com/TheBrenny/p5.js-sound","homepage":"http://p5js.org/reference/#/libraries/p5.sound","size":13120,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"processing:master","ref":"master","sha":"cede0fdc8fc7ea60d5cc052b65ffc7056cb49baf","user":{"login":"processing","id":1617169,"avatar_url":"https://avatars1.githubusercontent.com/u/1617169?v=3","gravatar_id":"","url":"https://api.github.com/users/processing","html_url":"https://github.com/processing","followers_url":"https://api.github.com/users/processing/followers","following_url":"https://api.github.com/users/processing/following{/other_user}","gists_url":"https://api.github.com/users/processing/gists{/gist_id}","starred_url":"https://api.github.com/users/processing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/processing/subscriptions","organizations_url":"https://api.github.com/users/processing/orgs","repos_url":"https://api.github.com/users/processing/repos","events_url":"https://api.github.com/users/processing/events{/privacy}","received_events_url":"https://api.github.com/users/processing/received_events","type":"Organization","site_admin":false},"repo":{"id":21714677,"name":"p5.js-sound","full_name":"processing/p5.js-sound","owner":{"login":"processing","id":1617169,"avatar_url":"https://avatars1.githubusercontent.com/u/1617169?v=3","gravatar_id":"","url":"https://api.github.com/users/processing","html_url":"https://github.com/processing","followers_url":"https://api.github.com/users/processing/followers","following_url":"https://api.github.com/users/processing/following{/other_user}","gists_url":"https://api.github.com/users/processing/gists{/gist_id}","starred_url":"https://api.github.com/users/processing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/processing/subscriptions","organizations_url":"https://api.github.com/users/processing/orgs","repos_url":"https://api.github.com/users/processing/repos","events_url":"https://api.github.com/users/processing/events{/privacy}","received_events_url":"https://api.github.com/users/processing/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/processing/p5.js-sound","description":"p5.sound brings the Processing approach to Web Audio and p5.js. Demos:","fork":false,"url":"https://api.github.com/repos/processing/p5.js-sound","forks_url":"https://api.github.com/repos/processing/p5.js-sound/forks","keys_url":"https://api.github.com/repos/processing/p5.js-sound/keys{/key_id}","collaborators_url":"https://api.github.com/repos/processing/p5.js-sound/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/processing/p5.js-sound/teams","hooks_url":"https://api.github.com/repos/processing/p5.js-sound/hooks","issue_events_url":"https://api.github.com/repos/processing/p5.js-sound/issues/events{/number}","events_url":"https://api.github.com/repos/processing/p5.js-sound/events","assignees_url":"https://api.github.com/repos/processing/p5.js-sound/assignees{/user}","branches_url":"https://api.github.com/repos/processing/p5.js-sound/branches{/branch}","tags_url":"https://api.github.com/repos/processing/p5.js-sound/tags","blobs_url":"https://api.github.com/repos/processing/p5.js-sound/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/processing/p5.js-sound/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/processing/p5.js-sound/git/refs{/sha}","trees_url":"https://api.github.com/repos/processing/p5.js-sound/git/trees{/sha}","statuses_url":"https://api.github.com/repos/processing/p5.js-sound/statuses/{sha}","languages_url":"https://api.github.com/repos/processing/p5.js-sound/languages","stargazers_url":"https://api.github.com/repos/processing/p5.js-sound/stargazers","contributors_url":"https://api.github.com/repos/processing/p5.js-sound/contributors","subscribers_url":"https://api.github.com/repos/processing/p5.js-sound/subscribers","subscription_url":"https://api.github.com/repos/processing/p5.js-sound/subscription","commits_url":"https://api.github.com/repos/processing/p5.js-sound/commits{/sha}","git_commits_url":"https://api.github.com/repos/processing/p5.js-sound/git/commits{/sha}","comments_url":"https://api.github.com/repos/processing/p5.js-sound/comments{/number}","issue_comment_url":"https://api.github.com/repos/processing/p5.js-sound/issues/comments{/number}","contents_url":"https://api.github.com/repos/processing/p5.js-sound/contents/{+path}","compare_url":"https://api.github.com/repos/processing/p5.js-sound/compare/{base}...{head}","merges_url":"https://api.github.com/repos/processing/p5.js-sound/merges","archive_url":"https://api.github.com/repos/processing/p5.js-sound/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/processing/p5.js-sound/downloads","issues_url":"https://api.github.com/repos/processing/p5.js-sound/issues{/number}","pulls_url":"https://api.github.com/repos/processing/p5.js-sound/pulls{/number}","milestones_url":"https://api.github.com/repos/processing/p5.js-sound/milestones{/number}","notifications_url":"https://api.github.com/repos/processing/p5.js-sound/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/processing/p5.js-sound/labels{/name}","releases_url":"https://api.github.com/repos/processing/p5.js-sound/releases{/id}","deployments_url":"https://api.github.com/repos/processing/p5.js-sound/deployments","created_at":"2014-07-11T00:04:58Z","updated_at":"2017-06-11T14:40:42Z","pushed_at":"2017-06-11T14:19:48Z","git_url":"git://github.com/processing/p5.js-sound.git","ssh_url":"git@github.com:processing/p5.js-sound.git","clone_url":"https://github.com/processing/p5.js-sound.git","svn_url":"https://github.com/processing/p5.js-sound","homepage":"http://p5js.org/reference/#/libraries/p5.sound","size":13141,"stargazers_count":229,"watchers_count":229,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":134,"mirror_url":null,"open_issues_count":59,"forks":134,"open_issues":59,"watchers":229,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/processing/p5.js-sound/pulls/176"},"html":{"href":"https://github.com/processing/p5.js-sound/pull/176"},"issue":{"href":"https://api.github.com/repos/processing/p5.js-sound/issues/176"},"comments":{"href":"https://api.github.com/repos/processing/p5.js-sound/issues/176/comments"},"review_comments":{"href":"https://api.github.com/repos/processing/p5.js-sound/pulls/176/comments"},"review_comment":{"href":"https://api.github.com/repos/processing/p5.js-sound/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/processing/p5.js-sound/pulls/176/commits"},"statuses":{"href":"https://api.github.com/repos/processing/p5.js-sound/statuses/0402cdb90ef4ff6d9c89ce05624a88afc0c72757"}}}}
{"actor":{"display_login":"therewasaguy"}}