{"action":"created","issue":{"url":"https://api.github.com/repos/audiocogs/aurora.js/issues/146","repository_url":"https://api.github.com/repos/audiocogs/aurora.js","labels_url":"https://api.github.com/repos/audiocogs/aurora.js/issues/146/labels{/name}","comments_url":"https://api.github.com/repos/audiocogs/aurora.js/issues/146/comments","events_url":"https://api.github.com/repos/audiocogs/aurora.js/issues/146/events","html_url":"https://github.com/audiocogs/aurora.js/issues/146","id":113589665,"number":146,"title":"Continuous decoding","user":{"login":"agiliator","id":15343899,"avatar_url":"https://avatars.githubusercontent.com/u/15343899?v=3","gravatar_id":"","url":"https://api.github.com/users/agiliator","html_url":"https://github.com/agiliator","followers_url":"https://api.github.com/users/agiliator/followers","following_url":"https://api.github.com/users/agiliator/following{/other_user}","gists_url":"https://api.github.com/users/agiliator/gists{/gist_id}","starred_url":"https://api.github.com/users/agiliator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agiliator/subscriptions","organizations_url":"https://api.github.com/users/agiliator/orgs","repos_url":"https://api.github.com/users/agiliator/repos","events_url":"https://api.github.com/users/agiliator/events{/privacy}","received_events_url":"https://api.github.com/users/agiliator/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-10-27T14:01:08Z","updated_at":"2016-02-29T13:34:18Z","closed_at":null,"body":"   Hi,\r\n\r\nI'm experimenting on decoding and playing a radio stream using aurora.js. So basically, I get the chunks of mp3/aac (XHR possibly the chunks of HLS) which I need to get decoded before playing. However, I hit some issues during the process:\r\n1. It seems that I need to emit 'end' event before the decoding starts - is there a way to get the decoding process running without the 'end'?\r\n2. (Maybe related): I don't seem to be able to emit several pieces of audio (or actually the emit goes through, but the second chunk does not get decoded.\r\n3. Question: It seems that the decoder does not get the frame sync - so I need to find the frame border on my own before passing to decoder?\r\n\r\nMy code to experiment auroras feasibility for this project is as follows. \r\n\r\nAny help is greatly appreciated!\r\n\r\n```javascript\r\n\t\tvar MySource = AV.EventEmitter.extend({\r\n\t\t    start: function() {\r\n\t\t    \tvar source = this;\r\n\t\t\t\tvar url = './media/audio.mp3'; \r\n\t\t\t\tconsole.log(url);\r\n\t\t\t\tvar request = new XMLHttpRequest();\r\n\t\t\t\trequest.open('GET', url, true);\r\n\t\t\t\trequest.responseType = 'arraybuffer';\r\n\t\t\t\trequest.onload = function() {\r\n\t\t\t\t\tvar raw = new Uint8Array(request.response);\r\n\t\t\t\t\tvar rawLength = raw.byteLength;\r\n\t\t\t\t\tsource.emit('data', new AV.Buffer(raw)); // Consecutive ones ignored, frame sync required.\r\n\t\t\t\t\tsource.emit('data', 'end');  // Required?\r\n\t\t\t\t}\r\n\t\t\t\trequest.send();\r\n\t\t    },\r\n\t\t    pause: function() {},\r\n\t\t    reset: function() {}\r\n\t\t});\r\n\r\n\t\tvar src = new MySource();\r\n\t\tvar asset = new AV.Asset(src);\r\n\r\n\t\t// Alt 1. get the audio data.\r\n\t\tasset.on('data', function(buffer) {\r\n\t\t  \tconsole.log(\"Decoded audio, len=\" + buffer.length);\r\n\t\t});\r\n\t\tasset.on('error', function(err) {\r\n\t\t\tconsole.log(\"Error in decoding: \" + err);\r\n\t\t});\r\n\t\tasset.start();\r\n\r\n\t\t// Alt 2. Play the audio direcly (for test purposes.)\r\n\t\t// var player = new AV.Player(asset);\r\n\t\t// player.play();\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/audiocogs/aurora.js/issues/comments/190213704","html_url":"https://github.com/audiocogs/aurora.js/issues/146#issuecomment-190213704","issue_url":"https://api.github.com/repos/audiocogs/aurora.js/issues/146","id":190213704,"user":{"login":"agiliator","id":15343899,"avatar_url":"https://avatars.githubusercontent.com/u/15343899?v=3","gravatar_id":"","url":"https://api.github.com/users/agiliator","html_url":"https://github.com/agiliator","followers_url":"https://api.github.com/users/agiliator/followers","following_url":"https://api.github.com/users/agiliator/following{/other_user}","gists_url":"https://api.github.com/users/agiliator/gists{/gist_id}","starred_url":"https://api.github.com/users/agiliator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agiliator/subscriptions","organizations_url":"https://api.github.com/users/agiliator/orgs","repos_url":"https://api.github.com/users/agiliator/repos","events_url":"https://api.github.com/users/agiliator/events{/privacy}","received_events_url":"https://api.github.com/users/agiliator/received_events","type":"User","site_admin":false},"created_at":"2016-02-29T13:34:18Z","updated_at":"2016-02-29T13:34:18Z","body":"Had another try. This time the there chunks are full frames and they are fed to aurora like below. add():ing consecutively.\r\n\r\n```\r\n\tfunction AuroraPlayTest() {\r\n\r\n\t\tvar MySource = AV.EventEmitter.extend({\r\n\t\t    start: function() {\tconsole.log(\"MySource.start()\") },\r\n\t\t    pause: function() { console.log(\"MySource.pause()\") },\r\n\t\t    reset: function() {\tconsole.log(\"MySource.reset()\") }\r\n\t\t});\r\n\t\tthis.src = new MySource();\r\n\r\n\t\tthis.add = function(mpframes) {\r\n\t\t\tif(!this.asset) {\r\n\t\t\t\tthis.asset = new AV.Asset(this.src);\r\n\t\t\t\tthis.asset.on('data', function(buffer) { console.log(\"asset.on(\\'data\\'), length: \" + buffer.length); });\r\n\t\t\t\tthis.asset.on('error', function(err) { console.log(\"asset.on(\\'error\\'), message: \" + err); });\r\n\t\t\t\t// this.asset.start(); // Decoding only - alternative\r\n\t\t\t\t(this.player = new AV.Player(this.asset)).play();\r\n\t\t\t}\r\n\t\t\tthis.src.emit('data', new AV.Buffer(mpframes));\r\n\t\t\t// this.asset.decodeToBuffer(); // Decoding only - alternative\r\n\t\t}\r\n\t}\r\n```\r\n\r\nFirst notion was that first chunk didn't trigger decoding/play. Thats not an issue, but just mentioning it if it helps any. Once consequent frames are added, only the first bunch seems to be decoded, following an error 'bad main_data_begin pointer'. \r\n\r\nI wonder if this is related to the reservoir bits, as get exactly the same error about the first bunch (once the second is added), if I start from the middle of mp3-stream instead (still at the frame border, though)."}}