Jump to content

Web Audio samples & documentation available


davrous
 Share

Recommended Posts

Ok, you reasons. I did this:

var sons = null, ogg = music.ogg, mp3 = music.mp3, wav = music.wav;var audio = new Audio(); if(ogg != null && audio.canPlayType("audio/ogg") != "") {     sons = new BABYLON.Sound("musicOgg", ogg, scene, null, { loop: true, autoplay: true, spatialSound: true });}else if(mp3 != null && audio.canPlayType("audio/mpeg") != "") {    sons = new BABYLON.Sound("mucicMp3", mp3, scene, null, { loop: true, autoplay: true, spatialSound: true });}else if(wav != null && audio.canPlayType("audio/wav") != "") {    sons = new BABYLON.Sound("musicWav", wav, scene, null, { loop: true, autoplay: true, spatialSound: true });}

:)

Link to comment
Share on other sites

Does anyone knows if Blender has some support for sound?

 

DK, you can open a window/panel called "Video sequence Editor" (see image below highlighted in red)

 

You can open either a video or an audio file in this window/panel, In the case of an audio file, display its waveform, add more audio, scrub through the audio etc.

 

I have not used it a lot as I usually use Audacity.

 

No idea about adding audio to a mesh though.

 

cheers, gryff :)

post-7026-0-62883700-1422650302.jpg

Link to comment
Share on other sites

Yep, video supports only what the browser supports, audio can be the same :-)

I'm not really sure what the benefits of ogg are, but if the browser supports it, why not?

 

I don't understand your point. This is already the case. If the browser supports ogg, Babylon.JS will be able to use it.

Link to comment
Share on other sites

I don't understand your point. This is already the case. If the browser supports ogg, Babylon.JS will be able to use it.

 

All I mean is that, as dad72 said, using something like this - 

new BABYLON.Sound("Audio", ["audio.ogg", "audio.mp3"], scene, null, { loop: true, autoplay: true, spatialSound: true });

would be nice. 

Link to comment
Share on other sites

  • 1 year later...
41 minutes ago, Dad72 said:

I think yes.

Signature of the function:

Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options)

An ArrayBuffer is different from an Array. https://doc.babylonjs.com/overviews/Playing_sounds_and_music#loading-a-sound-from-an-arraybuffer

I don't think it has been implemented. Phaser allows it. (http://phaser.io/examples/v2/audio/play-music) So helpful. It would be great if Babylon did as well.

Link to comment
Share on other sites

Hello,

On 1/29/2015 at 1:04 PM, davrous said:

I don't understand your point. This is already the case. If the browser supports ogg, Babylon.JS will be able to use it.

I was going to post this eventually, but haven't yet gotten around to it. So this ppears that this topic might be an appropriate time to mention this. In the past, I've found the most flexible AV file format to be .ogv (.ogg) files, as there was always less time to decompress and faster loading and playback initialized by the HTML video player. However, in the past 2 yeas there has been a substantial change in Chrome and other browsers where the .ogv file format no longer plays. I didn;t notive this as I was also providing the paths to .webm and .mp4 files if the .ogv files wouldn't play. So I just found that Chrome and other browsers no longer play .ogv (.ogg) files on Android as I was testing specific compression dettings for the best optimization, as I often test from time to time to improve performance.

So I can no longer play .ogv files on my tablets, and am considering dropping support all together for the .ogv file format. I only currently continue support for legacy issues on older devices and OS versions. So if anyone else has found playback of /ogv files to be a problem, I would like to know what you have discovered as well as any other info I might have missed, So I still list .ogv as the first AV file format to call for a videoTexture to ensure backwards compatability, but perhaps this is no longer useful?

Thank you,

DB

Link to comment
Share on other sites

Hi @dbawel,

 This is exactly why I haven't spent time on this feature yet. MP3, even if far from perfect, is now the only format supported by all browsers (Firefox, Chrome/Opera, Safari & IE/Edge). I can't see cases where you need ogg instead of mp3 but I may be wrong. I'm open to feedback.

David

 

Link to comment
Share on other sites

In made Davrous , ogg is lighter for transfer to a server and faster to load, it would be the only advantage . Wav is too heavy, so ogg and mp3 would be good.

But I also agree that mp3 is compatible on all browsers may be sufficient, but a ogg file'll also be faster to load in case a browser supports it.

Link to comment
Share on other sites

  • 1 month later...

I do like this if necessary.

var music = null, fileAudio = null, audio = new Audio(); 

if(audio.canPlayType("audio/ogg") != "") {
	fileAudio = "music.ogg";
}
else if(audio.canPlayType("audio/mpeg") != "") {
	fileAudio = "music.mp3";
}
else if(audio.canPlayType("audio/wav") != "") { 
	fileAudio = "music.wav";
}
music = new BABYLON.Sound("music", fileAudio, scene, null, { loop: true, autoplay: true, spatialSound: true });

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...