{"action":"created","comment":{"url":"https://api.github.com/repos/LLK/scratch-audio/pulls/comments/195759444","pull_request_review_id":129192058,"id":195759444,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NTc1OTQ0NA==","diff_hunk":"@@ -0,0 +1,84 @@\n+const SoundPlayer = require('./GreenPlayer');\n+const EffectsChain = require('./EffectsChain');\n+\n+const ALL_TARGETS = '*';\n+\n+class SoundBank {\n+    constructor (audioEngine) {\n+        this.audioEngine = audioEngine;\n+\n+        this.soundPlayers = {};\n+        this.playerTargets = new Map();\n+        this.soundEffects = new Map();\n+    }\n+\n+    getSound (soundId) {\n+        if (!this.soundPlayers[soundId]) {\n+            this.soundPlayers[soundId] = new SoundPlayer(this.audioEngine, {\n+                id: soundId, buffer: this.audioEngine.audioBuffers[soundId]\n+            });\n+        }\n+\n+        return this.soundPlayers[soundId];\n+    }\n+\n+    getSoundEffects (sound) {\n+        if (!this.soundEffects.has(sound)) {\n+            this.soundEffects.set(sound, new EffectsChain(this.audioEngine));\n+        }\n+\n+        return this.soundEffects.get(sound);\n+    }\n+\n+\n+    playSound (target, soundId) {\n+        const effects = this.getSoundEffects(soundId);\n+        const player = this.getSoundPlayer(soundId);\n+\n+        this.playerTargets.set(soundId, target);\n+        effects.setFromTarget(target);\n+        effects.addSoundPlayer(player);\n+\n+        player.connect(effects);\n+        player.play();\n+\n+        return player.finished();\n+    }\n+\n+    setEffects (target) {\n+        this.playerTargets.forEach((playerTarget, key) => {\n+            if (playerTarget === target) {\n+                this.getSoundEffects(key).setFromTarget(target);\n+            }\n+        });\n+    }\n+\n+    stop (target, soundId) {\n+        if (this.playerTargets.get(soundId) === target) {\n+            this.soundPlayers[soundId].stop();","path":"src/SoundBank.js","position":58,"original_position":58,"commit_id":"43a4b9508fc1bc312fe0fa28893ddf9eacb8c579","original_commit_id":"43a4b9508fc1bc312fe0fa28893ddf9eacb8c579","user":{"login":"gnarf","id":549355,"node_id":"MDQ6VXNlcjU0OTM1NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/549355?v=4","gravatar_id":"","url":"https://api.github.com/users/gnarf","html_url":"https://github.com/gnarf","followers_url":"https://api.github.com/users/gnarf/followers","following_url":"https://api.github.com/users/gnarf/following{/other_user}","gists_url":"https://api.github.com/users/gnarf/gists{/gist_id}","starred_url":"https://api.github.com/users/gnarf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnarf/subscriptions","organizations_url":"https://api.github.com/users/gnarf/orgs","repos_url":"https://api.github.com/users/gnarf/repos","events_url":"https://api.github.com/users/gnarf/events{/privacy}","received_events_url":"https://api.github.com/users/gnarf/received_events","type":"User","site_admin":false},"body":"should probaby use `this.getSound(soundId)` here for future refactor possibilities.","created_at":"2018-06-15T14:32:52Z","updated_at":"2018-06-15T14:32:52Z","html_url":"https://github.com/LLK/scratch-audio/pull/92#discussion_r195759444","pull_request_url":"https://api.github.com/repos/LLK/scratch-audio/pulls/92","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/LLK/scratch-audio/pulls/comments/195759444"},"html":{"href":"https://github.com/LLK/scratch-audio/pull/92#discussion_r195759444"},"pull_request":{"href":"https://api.github.com/repos/LLK/scratch-audio/pulls/92"}}},"pull_request":{"url":"https://api.github.com/repos/LLK/scratch-audio/pulls/92","id":195193223,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk1MTkzMjIz","html_url":"https://github.com/LLK/scratch-audio/pull/92","diff_url":"https://github.com/LLK/scratch-audio/pull/92.diff","patch_url":"https://github.com/LLK/scratch-audio/pull/92.patch","issue_url":"https://api.github.com/repos/LLK/scratch-audio/issues/92","number":92,"state":"open","locked":false,"title":"[WIP] SoundBank","user":{"login":"gnarf","id":549355,"node_id":"MDQ6VXNlcjU0OTM1NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/549355?v=4","gravatar_id":"","url":"https://api.github.com/users/gnarf","html_url":"https://github.com/gnarf","followers_url":"https://api.github.com/users/gnarf/followers","following_url":"https://api.github.com/users/gnarf/following{/other_user}","gists_url":"https://api.github.com/users/gnarf/gists{/gist_id}","starred_url":"https://api.github.com/users/gnarf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnarf/subscriptions","organizations_url":"https://api.github.com/users/gnarf/orgs","repos_url":"https://api.github.com/users/gnarf/repos","events_url":"https://api.github.com/users/gnarf/events{/privacy}","received_events_url":"https://api.github.com/users/gnarf/received_events","type":"User","site_admin":false},"body":"(just up for ease of communication, this is purely a first draft right now)","created_at":"2018-06-15T14:30:04Z","updated_at":"2018-06-15T14:32:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"512c608e848e8b8265c328056bfe003e9648169a","assignee":null,"assignees":[],"requested_reviewers":[{"login":"mzgoddard","id":833298,"node_id":"MDQ6VXNlcjgzMzI5OA==","avatar_url":"https://avatars1.githubusercontent.com/u/833298?v=4","gravatar_id":"","url":"https://api.github.com/users/mzgoddard","html_url":"https://github.com/mzgoddard","followers_url":"https://api.github.com/users/mzgoddard/followers","following_url":"https://api.github.com/users/mzgoddard/following{/other_user}","gists_url":"https://api.github.com/users/mzgoddard/gists{/gist_id}","starred_url":"https://api.github.com/users/mzgoddard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzgoddard/subscriptions","organizations_url":"https://api.github.com/users/mzgoddard/orgs","repos_url":"https://api.github.com/users/mzgoddard/repos","events_url":"https://api.github.com/users/mzgoddard/events{/privacy}","received_events_url":"https://api.github.com/users/mzgoddard/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":530136391,"node_id":"MDU6TGFiZWw1MzAxMzYzOTE=","url":"https://api.github.com/repos/LLK/scratch-audio/labels/pr%20-%20needs%20work","name":"pr - needs work","color":"fc2929","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/LLK/scratch-audio/pulls/92/commits","review_comments_url":"https://api.github.com/repos/LLK/scratch-audio/pulls/92/comments","review_comment_url":"https://api.github.com/repos/LLK/scratch-audio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/LLK/scratch-audio/issues/92/comments","statuses_url":"https://api.github.com/repos/LLK/scratch-audio/statuses/43a4b9508fc1bc312fe0fa28893ddf9eacb8c579","head":{"label":"gnarf:soundbank-effectchain","ref":"soundbank-effectchain","sha":"43a4b9508fc1bc312fe0fa28893ddf9eacb8c579","user":{"login":"gnarf","id":549355,"node_id":"MDQ6VXNlcjU0OTM1NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/549355?v=4","gravatar_id":"","url":"https://api.github.com/users/gnarf","html_url":"https://github.com/gnarf","followers_url":"https://api.github.com/users/gnarf/followers","following_url":"https://api.github.com/users/gnarf/following{/other_user}","gists_url":"https://api.github.com/users/gnarf/gists{/gist_id}","starred_url":"https://api.github.com/users/gnarf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnarf/subscriptions","organizations_url":"https://api.github.com/users/gnarf/orgs","repos_url":"https://api.github.com/users/gnarf/repos","events_url":"https://api.github.com/users/gnarf/events{/privacy}","received_events_url":"https://api.github.com/users/gnarf/received_events","type":"User","site_admin":false},"repo":{"id":137497144,"node_id":"MDEwOlJlcG9zaXRvcnkxMzc0OTcxNDQ=","name":"scratch-audio","full_name":"gnarf/scratch-audio","owner":{"login":"gnarf","id":549355,"node_id":"MDQ6VXNlcjU0OTM1NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/549355?v=4","gravatar_id":"","url":"https://api.github.com/users/gnarf","html_url":"https://github.com/gnarf","followers_url":"https://api.github.com/users/gnarf/followers","following_url":"https://api.github.com/users/gnarf/following{/other_user}","gists_url":"https://api.github.com/users/gnarf/gists{/gist_id}","starred_url":"https://api.github.com/users/gnarf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnarf/subscriptions","organizations_url":"https://api.github.com/users/gnarf/orgs","repos_url":"https://api.github.com/users/gnarf/repos","events_url":"https://api.github.com/users/gnarf/events{/privacy}","received_events_url":"https://api.github.com/users/gnarf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gnarf/scratch-audio","description":"Web Audio-based audio engine for Scratch 3.0","fork":true,"url":"https://api.github.com/repos/gnarf/scratch-audio","forks_url":"https://api.github.com/repos/gnarf/scratch-audio/forks","keys_url":"https://api.github.com/repos/gnarf/scratch-audio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gnarf/scratch-audio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gnarf/scratch-audio/teams","hooks_url":"https://api.github.com/repos/gnarf/scratch-audio/hooks","issue_events_url":"https://api.github.com/repos/gnarf/scratch-audio/issues/events{/number}","events_url":"https://api.github.com/repos/gnarf/scratch-audio/events","assignees_url":"https://api.github.com/repos/gnarf/scratch-audio/assignees{/user}","branches_url":"https://api.github.com/repos/gnarf/scratch-audio/branches{/branch}","tags_url":"https://api.github.com/repos/gnarf/scratch-audio/tags","blobs_url":"https://api.github.com/repos/gnarf/scratch-audio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gnarf/scratch-audio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gnarf/scratch-audio/git/refs{/sha}","trees_url":"https://api.github.com/repos/gnarf/scratch-audio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gnarf/scratch-audio/statuses/{sha}","languages_url":"https://api.github.com/repos/gnarf/scratch-audio/languages","stargazers_url":"https://api.github.com/repos/gnarf/scratch-audio/stargazers","contributors_url":"https://api.github.com/repos/gnarf/scratch-audio/contributors","subscribers_url":"https://api.github.com/repos/gnarf/scratch-audio/subscribers","subscription_url":"https://api.github.com/repos/gnarf/scratch-audio/subscription","commits_url":"https://api.github.com/repos/gnarf/scratch-audio/commits{/sha}","git_commits_url":"https://api.github.com/repos/gnarf/scratch-audio/git/commits{/sha}","comments_url":"https://api.github.com/repos/gnarf/scratch-audio/comments{/number}","issue_comment_url":"https://api.github.com/repos/gnarf/scratch-audio/issues/comments{/number}","contents_url":"https://api.github.com/repos/gnarf/scratch-audio/contents/{+path}","compare_url":"https://api.github.com/repos/gnarf/scratch-audio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gnarf/scratch-audio/merges","archive_url":"https://api.github.com/repos/gnarf/scratch-audio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gnarf/scratch-audio/downloads","issues_url":"https://api.github.com/repos/gnarf/scratch-audio/issues{/number}","pulls_url":"https://api.github.com/repos/gnarf/scratch-audio/pulls{/number}","milestones_url":"https://api.github.com/repos/gnarf/scratch-audio/milestones{/number}","notifications_url":"https://api.github.com/repos/gnarf/scratch-audio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gnarf/scratch-audio/labels{/name}","releases_url":"https://api.github.com/repos/gnarf/scratch-audio/releases{/id}","deployments_url":"https://api.github.com/repos/gnarf/scratch-audio/deployments","created_at":"2018-06-15T14:28:42Z","updated_at":"2018-06-15T14:28:44Z","pushed_at":"2018-06-15T14:31:11Z","git_url":"git://github.com/gnarf/scratch-audio.git","ssh_url":"git@github.com:gnarf/scratch-audio.git","clone_url":"https://github.com/gnarf/scratch-audio.git","svn_url":"https://github.com/gnarf/scratch-audio","homepage":"","size":620,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"LLK:develop","ref":"develop","sha":"2ea0867df8681749612741e5935e96e9a3bf3766","user":{"login":"LLK","id":3420800,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0MjA4MDA=","avatar_url":"https://avatars1.githubusercontent.com/u/3420800?v=4","gravatar_id":"","url":"https://api.github.com/users/LLK","html_url":"https://github.com/LLK","followers_url":"https://api.github.com/users/LLK/followers","following_url":"https://api.github.com/users/LLK/following{/other_user}","gists_url":"https://api.github.com/users/LLK/gists{/gist_id}","starred_url":"https://api.github.com/users/LLK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LLK/subscriptions","organizations_url":"https://api.github.com/users/LLK/orgs","repos_url":"https://api.github.com/users/LLK/repos","events_url":"https://api.github.com/users/LLK/events{/privacy}","received_events_url":"https://api.github.com/users/LLK/received_events","type":"Organization","site_admin":false},"repo":{"id":70627500,"node_id":"MDEwOlJlcG9zaXRvcnk3MDYyNzUwMA==","name":"scratch-audio","full_name":"LLK/scratch-audio","owner":{"login":"LLK","id":3420800,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0MjA4MDA=","avatar_url":"https://avatars1.githubusercontent.com/u/3420800?v=4","gravatar_id":"","url":"https://api.github.com/users/LLK","html_url":"https://github.com/LLK","followers_url":"https://api.github.com/users/LLK/followers","following_url":"https://api.github.com/users/LLK/following{/other_user}","gists_url":"https://api.github.com/users/LLK/gists{/gist_id}","starred_url":"https://api.github.com/users/LLK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LLK/subscriptions","organizations_url":"https://api.github.com/users/LLK/orgs","repos_url":"https://api.github.com/users/LLK/repos","events_url":"https://api.github.com/users/LLK/events{/privacy}","received_events_url":"https://api.github.com/users/LLK/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LLK/scratch-audio","description":"Web Audio-based audio engine for Scratch 3.0","fork":false,"url":"https://api.github.com/repos/LLK/scratch-audio","forks_url":"https://api.github.com/repos/LLK/scratch-audio/forks","keys_url":"https://api.github.com/repos/LLK/scratch-audio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LLK/scratch-audio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LLK/scratch-audio/teams","hooks_url":"https://api.github.com/repos/LLK/scratch-audio/hooks","issue_events_url":"https://api.github.com/repos/LLK/scratch-audio/issues/events{/number}","events_url":"https://api.github.com/repos/LLK/scratch-audio/events","assignees_url":"https://api.github.com/repos/LLK/scratch-audio/assignees{/user}","branches_url":"https://api.github.com/repos/LLK/scratch-audio/branches{/branch}","tags_url":"https://api.github.com/repos/LLK/scratch-audio/tags","blobs_url":"https://api.github.com/repos/LLK/scratch-audio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LLK/scratch-audio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LLK/scratch-audio/git/refs{/sha}","trees_url":"https://api.github.com/repos/LLK/scratch-audio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LLK/scratch-audio/statuses/{sha}","languages_url":"https://api.github.com/repos/LLK/scratch-audio/languages","stargazers_url":"https://api.github.com/repos/LLK/scratch-audio/stargazers","contributors_url":"https://api.github.com/repos/LLK/scratch-audio/contributors","subscribers_url":"https://api.github.com/repos/LLK/scratch-audio/subscribers","subscription_url":"https://api.github.com/repos/LLK/scratch-audio/subscription","commits_url":"https://api.github.com/repos/LLK/scratch-audio/commits{/sha}","git_commits_url":"https://api.github.com/repos/LLK/scratch-audio/git/commits{/sha}","comments_url":"https://api.github.com/repos/LLK/scratch-audio/comments{/number}","issue_comment_url":"https://api.github.com/repos/LLK/scratch-audio/issues/comments{/number}","contents_url":"https://api.github.com/repos/LLK/scratch-audio/contents/{+path}","compare_url":"https://api.github.com/repos/LLK/scratch-audio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LLK/scratch-audio/merges","archive_url":"https://api.github.com/repos/LLK/scratch-audio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LLK/scratch-audio/downloads","issues_url":"https://api.github.com/repos/LLK/scratch-audio/issues{/number}","pulls_url":"https://api.github.com/repos/LLK/scratch-audio/pulls{/number}","milestones_url":"https://api.github.com/repos/LLK/scratch-audio/milestones{/number}","notifications_url":"https://api.github.com/repos/LLK/scratch-audio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LLK/scratch-audio/labels{/name}","releases_url":"https://api.github.com/repos/LLK/scratch-audio/releases{/id}","deployments_url":"https://api.github.com/repos/LLK/scratch-audio/deployments","created_at":"2016-10-11T19:21:03Z","updated_at":"2018-06-14T17:58:47Z","pushed_at":"2018-06-15T14:31:12Z","git_url":"git://github.com/LLK/scratch-audio.git","ssh_url":"git@github.com:LLK/scratch-audio.git","clone_url":"https://github.com/LLK/scratch-audio.git","svn_url":"https://github.com/LLK/scratch-audio","homepage":"","size":620,"stargazers_count":32,"watchers_count":32,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":27,"mirror_url":null,"archived":false,"open_issues_count":18,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":27,"open_issues":18,"watchers":32,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/LLK/scratch-audio/pulls/92"},"html":{"href":"https://github.com/LLK/scratch-audio/pull/92"},"issue":{"href":"https://api.github.com/repos/LLK/scratch-audio/issues/92"},"comments":{"href":"https://api.github.com/repos/LLK/scratch-audio/issues/92/comments"},"review_comments":{"href":"https://api.github.com/repos/LLK/scratch-audio/pulls/92/comments"},"review_comment":{"href":"https://api.github.com/repos/LLK/scratch-audio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/LLK/scratch-audio/pulls/92/commits"},"statuses":{"href":"https://api.github.com/repos/LLK/scratch-audio/statuses/43a4b9508fc1bc312fe0fa28893ddf9eacb8c579"}},"author_association":"NONE"}}
{"actor":{"display_login":"gnarf"}}