KarelAnker Posted October 27, 2015 Share Posted October 27, 2015 Is this possible with Babylon, as creating a new BABYLON.Sound will preload your song fully before you can listen to it. I basically want it to download parts. When you have a 10 minute song, I don't want it to download all the 10 minutes, I want it to download the part it's currently playing + some minutes. Quote Link to comment Share on other sites More sharing options...
davrous Posted October 27, 2015 Share Posted October 27, 2015 Currently, I'm using a XHR to load & decode the sound with Web Audio. If you'd like just to stream the music from your web server, simply use the HTML5 audio tag. Isn't it enough? David Quote Link to comment Share on other sites More sharing options...
KarelAnker Posted October 27, 2015 Author Share Posted October 27, 2015 Currently, I'm using a XHR to load & decode the sound with Web Audio. If you'd like just to stream the music from your web server, simply use the HTML5 audio tag. Isn't it enough? DavidBut there's no way to have it 3D spatial with a HTML audio tag? Quote Link to comment Share on other sites More sharing options...
davrous Posted October 28, 2015 Share Posted October 28, 2015 Ok, I've just added support for sound streaming based on HTML5 Audio tag as input to Web Audio. I need to do further testing before shipping it on the github but it seems to work well so far. Thanks for the feature request ;-) Dad72, iiceman and RaananW 3 Quote Link to comment Share on other sites More sharing options...
davrous Posted October 30, 2015 Share Posted October 30, 2015 I've just finished my tests and published the updated version of BABYLON.Sound on the github: https://github.com/BabylonJS/Babylon.js/blob/master/src/Audio/babylon.sound.ts It will be on the playground soon and I'll share a demo on it. In the meantime, it's very easy to use. Just set a 'streaming: true' in the options of the Sound constructor and it will stream the sound using the HTML Audio tag rather than downloading & decoding it first. Ex: var violons18 = new BABYLON.Sound("Violons", "./coding4fun2015.mp3", scene, null, { loop: true, autoplay: true, streaming: true }); All other features are implemented to support this new source: pause, stop, play, 3D spatialization, analyser & directional sound. jerome, Dad72 and Wingnut 3 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted October 30, 2015 Share Posted October 30, 2015 Cool. Quote Link to comment Share on other sites More sharing options...
davrous Posted October 31, 2015 Share Posted October 31, 2015 Here is a simple sample: http://www.babylonjs-playground.com/#1Y9YWK then use the Sound element as described in the doc to apply 3D, playrate, whatever. You can see in the Web Audio tab of Firefox that a MediaElement (HTML5 Audio tag) is being used as a source with the streaming: true option being enabled. KarelAnker 1 Quote Link to comment Share on other sites More sharing options...
iiceman Posted October 31, 2015 Share Posted October 31, 2015 Just on a side note: Is that SpeechSynthesisUtterance actually a "real" thing yet? I think it's pretty cool using plain text and transform it into audio. Any plans on integrating it with Babylon, yet? Quote Link to comment Share on other sites More sharing options...
KarelAnker Posted November 1, 2015 Author Share Posted November 1, 2015 EDIT:It seems that the HTML5 audio tag does not allow any streaming outside of the local file system. Try streaming "http://ccmixter.org/content/teru/teru_-_We_re_on_the_Roll.mp3", the header has Access-Control-Allow-Origin: *, but for some reason when you're trying to stream Chrome outputs "MediaElementAudioSource outputs zeroes due to CORS access restrictions for ......." You can check the receiving headers at http://www.rexswain.com/httpview.html Quote Link to comment Share on other sites More sharing options...
KarelAnker Posted November 1, 2015 Author Share Posted November 1, 2015 Got it to work! You basically forgot to set the crossOrigin attribute to anonymous.var music = new BABYLON.Sound("Music", ........................);music._htmlAudioElement.crossOrigin = "anonymous";I would create a pull request but I don't dare to touch it (Also, it seems that you can't attach the audio to an object, it's always 2D with the streaming tag) Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 1, 2015 Share Posted November 1, 2015 I would create a pull request but I don't dare to touch it Do not hesitate. Quote Link to comment Share on other sites More sharing options...
KarelAnker Posted November 1, 2015 Author Share Posted November 1, 2015 Do not hesitate. I'm unsure how, as I don't know how to create the TypeScripts and the minified files, and I don't know which file to exactly edit EDIT:created a pull request Quote Link to comment Share on other sites More sharing options...
davrous Posted November 2, 2015 Share Posted November 2, 2015 Got it to work! You basically forgot to set the crossOrigin attribute to anonymous.var music = new BABYLON.Sound("Music", ........................);music._htmlAudioElement.crossOrigin = "anonymous";I would create a pull request but I don't dare to touch it (Also, it seems that you can't attach the audio to an object, it's always 2D with the streaming tag) You can make it a 3D sound. Simply attach the sound to a mesh or use the boolean to make it 3D. David Quote Link to comment Share on other sites More sharing options...
davrous Posted November 2, 2015 Share Posted November 2, 2015 For instance: http://www.babylonjs-playground.com/#2DXHIC You'll hear the sound moving around your head and if you're moving too far way from the box, you won't hear the music anymore. adam 1 Quote Link to comment Share on other sites More sharing options...
davrous Posted November 2, 2015 Share Posted November 2, 2015 I'm unsure how, as I don't know how to create the TypeScripts and the minified files, and I don't know which file to exactly edit EDIT:created a pull request I've just added it in the TypeScript file. We've just updated the Playground with this new version! Enjoy! Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 7, 2015 Share Posted November 7, 2015 This new feature has been forgotten to be added in "what's new.md" for 2.3 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 9, 2015 Share Posted November 9, 2015 yes @davrous needs to update it Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 11, 2015 Share Posted November 11, 2015 I added Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.