{"action":"created","issue":{"url":"https://api.github.com/repos/qodesmith/thundercats/issues/10","labels_url":"https://api.github.com/repos/qodesmith/thundercats/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/qodesmith/thundercats/issues/10/comments","events_url":"https://api.github.com/repos/qodesmith/thundercats/issues/10/events","html_url":"https://github.com/qodesmith/thundercats/issues/10","id":66168878,"number":10,"title":"XML source errors...","user":{"login":"lionsdwarf","id":10677428,"avatar_url":"https://avatars.githubusercontent.com/u/10677428?v=3","gravatar_id":"","url":"https://api.github.com/users/lionsdwarf","html_url":"https://github.com/lionsdwarf","followers_url":"https://api.github.com/users/lionsdwarf/followers","following_url":"https://api.github.com/users/lionsdwarf/following{/other_user}","gists_url":"https://api.github.com/users/lionsdwarf/gists{/gist_id}","starred_url":"https://api.github.com/users/lionsdwarf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lionsdwarf/subscriptions","organizations_url":"https://api.github.com/users/lionsdwarf/orgs","repos_url":"https://api.github.com/users/lionsdwarf/repos","events_url":"https://api.github.com/users/lionsdwarf/events{/privacy}","received_events_url":"https://api.github.com/users/lionsdwarf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-03T15:35:09Z","updated_at":"2015-04-03T18:40:18Z","closed_at":null,"body":"@harimohanraj89 @DrRobotmck @williamfshaw @bigtone1284\r\n\r\nA user wants immediate playback of sounds on click\r\n\r\nThis requires low latency which involves populating a sound buffer via XMLHttp request to sound byte urls, the files for which are then decoded and added to the buffer. To do so I am using the AudioSampleLoader.js file linked via the MDN docs for Web Audio Api. \r\n\r\nWhile there could be some sort of decoding issue, I believe the loader is not accessing the source urls properly. If I hard code a source url, I get a CORS error.\r\n\r\n```js\r\nlocalhost/:1 XMLHttpRequest cannot load http://www.lettersnstuff.com/sounds/animals/mule.wav. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.\r\naudioSampleLoader.js:108 AudioSampleLoader: XMLHttpRequest called onerror\r\n```\r\n\r\n Otherwise, running thru our db, the url points to a single JSON object in the db, not the url specifically and I get this error:\r\n\r\n```js\r\nAudioSampleLoader: ctx.decodeAudioData() called onerroraudioSampleLoader.js:101 (anonymous function)\r\n```\r\n\r\nHere's the code from the audioSampleLoader:\r\n\r\n```js\r\nAudioSampleLoader.prototype.loadOneBuffer = function (url) {\r\n  \"use strict\";\r\n  var console = window.console,\r\n    loader = this,\r\n    XHR = new XMLHttpRequest();\r\n  XHR.open('GET', url, true);\r\n  XHR.responseType = 'arraybuffer';\r\n  \r\n  XHR.onload = function () {\r\n    loader.ctx.decodeAudioData(\r\n      XHR.response,\r\n      function (buffer) {\r\n        loader.response = buffer;\r\n        loader.onload();\r\n      },\r\n      function () {\r\n        console.error('AudioSampleLoader: ctx.decodeAudioData() called onerror');\r\n        loader.onerror();\r\n      }\r\n    );\r\n  };\r\n  \r\n  XHR.onerror = function () {\r\n    console.error('AudioSampleLoader: XMLHttpRequest called onerror');\r\n    loader.onerror();\r\n  };\r\n  XHR.send();\r\n};\r\n```\r\n\r\n\r\nAnd here's my code that runs the loader and defines the source:\r\n\r\n```js\r\nbutton.onclick = function() {\r\n  var audioCtx = new (window.AudioContext || window .webkitAudioContext)();\r\n    //Audio Sample Loader is a library that helps   load and decode one or more audio samples.  Functions asynchronously.\r\n    var loader = new AudioSampleLoader();\r\n    //Connects the loader to it's audio context\r\n    loader.ctx = audioCtx;\r\n    //FIXME -- the url is currently directed to a single sound file for testing purposes\r\n    loader.src = 'sounds/1';\r\n    //After a successful decode, the data is  availacle at loader.response as, in our case, an   array of AudioBuffers\r\n    loader.onload = function() {\r\n      window.soundsArray = loader.response;\r\n      console.log('ASL onload complete:');\r\n    };\r\n    //Error msg upon failure\r\n    loader.onerror = function() {\r\n      console.log('Decode failed.');\r\n    };\r\n    //Activates the ASL\r\n    loader.send();\r\n    return loader.response;\r\n  };\r\n```\r\n\r\nI've debugged to confirm that my source attr is not retrieving the url properly, however the request is hitting the server.\r\nI've also researched the proper setup for the source url and the most common setup appears that the audio file exists within host server, whereas I'm trying to route some else's .wav file through my server in order to avoid CORS errors. Must I host the audio on our server directly? If not, how must I direct the source?\r\n\r\nPlease halp!\r\n\r\nA frustrated learner."},"comment":{"url":"https://api.github.com/repos/qodesmith/thundercats/issues/comments/89385663","html_url":"https://github.com/qodesmith/thundercats/issues/10#issuecomment-89385663","issue_url":"https://api.github.com/repos/qodesmith/thundercats/issues/10","id":89385663,"user":{"login":"harimohanraj89","id":4241399,"avatar_url":"https://avatars.githubusercontent.com/u/4241399?v=3","gravatar_id":"","url":"https://api.github.com/users/harimohanraj89","html_url":"https://github.com/harimohanraj89","followers_url":"https://api.github.com/users/harimohanraj89/followers","following_url":"https://api.github.com/users/harimohanraj89/following{/other_user}","gists_url":"https://api.github.com/users/harimohanraj89/gists{/gist_id}","starred_url":"https://api.github.com/users/harimohanraj89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harimohanraj89/subscriptions","organizations_url":"https://api.github.com/users/harimohanraj89/orgs","repos_url":"https://api.github.com/users/harimohanraj89/repos","events_url":"https://api.github.com/users/harimohanraj89/events{/privacy}","received_events_url":"https://api.github.com/users/harimohanraj89/received_events","type":"User","site_admin":false},"created_at":"2015-04-03T18:40:18Z","updated_at":"2015-04-03T18:40:18Z","body":"```js\r\n    //Activates the ASL\r\n    loader.send();\r\n    return loader.response;\r\n  };\r\n```\r\n\r\nAfter you call `loader.send()`, you're expecting the response to be ready before the next line of code `return loader.response` is executed, but this is not the case. This may be involved in the problem."}}