raksa

add audio buffer to cache

Recommended Posts

hi i'm a newbie for phaser framework

i want to know that is it possible to load audio from existing buffer or blob data to cache?

for instant after i got audio buffer from input audio, i want to play it by phaser audio.

because there a problem in Android browser, i can't play audio from converted dataurl via html5 audio tag.

thanks,

Share this post


Link to post
Share on other sites

i got the answer:rolleyes:

var fileReader = new FileReader();
fileReader.onload = function () {
   game.cache.addSound("key", "filename.wav", this.result);
   //and use it
   var audio = game.add.audio("key");
   audio.play();
};
fileReader.readAsArrayBuffer(blob);

 

Share this post


Link to post
Share on other sites

Hi... If you have to do complex operations to prepare the sound data, 23 ms may be not much. Additionally there may be some overhead to handle the DMA interrupt at the end of the transmission of each sound buffer and to manage the data cache, which is required to ensure, the sound data can be written out using DMA. Unfortunately I cannot specify, how much overhead this will take, without doing complex measurements, but I guess it will be not more than a few milliseconds.

Share this post


Link to post
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...

  • Recently Browsing   0 members

    No registered users viewing this page.