Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8010585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:46:54+00:00 2026-06-04T18:46:54+00:00

Hi I’m currently working on an audio waveform editor written in pure HTML5 w/

  • 0

Hi I’m currently working on an audio waveform editor written in pure HTML5 w/ Javascript.

I’ve made some progress using the <audio>.MozAudioAvailable event from Mozilla, to get the data in each frame and draw them on a canvas. However with MozAudioAvailable I can only get the frame which it is NOW playing.

As a waveform editor, my program have to seek and preprocess the data about several seconds PRIOR TO the currently playing, i.e. when playing 00:05:00, my program should probably be showing the waveform from 00:04:50 to 00:05:10, so I have to preprocess the data between 00:05:00 and 00:05:10 before they got played.

I’ve searched the Internet to get a solution (not restricted to the Mozilla approaches, Chrome or Opera ones are also accepted), but got no answer. The preload property and onprogress event doesn’t help. Now I’m trying to make another <audio> tag which plays the same music as the original one, but several seconds faster to get the data in advance. However the solution is quite dirty as you seen.

I’m wondering if HTML5 group is working on some more flexible ways to deal with the multimedia objects, or if some browser development team is working on this. If you have any idea or experience on this topic, plz give me some instructions. Thx.

UPDATE:

Maybe I have not described my question clearly. Below is a picture taken from Audacity which may demonstrate my target.

A Screenshot from Audacity

The vertical line at about 1:55.10 indicates the frame currently playing. For frames to the left of the line, I can use the historical frames saved by my program. But for frames to the right of the line, which have not yet been played, I’m not able to get them before they’ve been played.

An ugly solution may be to add another <audio> tag which plays faster than the original one (should be playing 1:55.90 in the screenshot) so that I can get the frames to the right of the vertical line. But that’s ugly, and not easy to implement, isn’t it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:46:55+00:00Added an answer on June 4, 2026 at 6:46 pm

    From https://wiki.mozilla.org/Audio_Data_API

    The data you’re looking for is in the framebuffer property of the event object passed to your listener function

    To access a particular section of historical data, simply cache previous framebuffer captures yourself

    var channels,
        rate,
        frameBufferLength,
        samples;
    
    function audioInfo() {
      var audio = document.getElementById('audio');
    
      // After loadedmetadata event, following media element attributes are known:
      channels          = audio.mozChannels;
      rate              = audio.mozSampleRate;
      frameBufferLength = audio.mozFrameBufferLength;
    }
    
    function audioAvailable(event) {
      var samples = event.frameBuffer;
      var time    = event.time;
    
      for (var i = 0; i < frameBufferLength; i++) {
        // Do something with the audio data as it is played.
        processSample(samples[i], channels, rate);
      }
    }
    

    ADDENDUM:

    OK, so you need your program to look into the future. As far as I know, this isn’t doable unless you can use some kind of clever preload solution (although I suspect this won’t work either – perhaps a subscription to the moz mailing list may enable you to request this as a future feature).

    I still don’t know what exactly it is you’re trying to do, but I have an HTML5 player that uses a drawn waveform background and draws an oscilloscope during playback using RAW audio data which I rip from the audio file myself on the server – I don’t use the mozilla API because I want it to work in all ogg-supporting browsers, so I load a separate data blob altogether. This of course means a) it is not pure HTML5 and Javascript, and b) my player only plays files that originate from my server. In any case, the stages are:

    1) Use a command-line utility (I recommend sox) to extract the RAW data – I downmix it to mono, 8-bit 1khz PCM which is relatively small yet high enough resolution to be useful (1kb/sec). If you want to keep it (to draw an oscilloscope during playback in non-mozilla browsers) cache it in a database as a blob.

    2) Use the RAW PCM to draw a PNG of the wave using php_gd, and cache that (for your player background)

    3) if using the RAW data then you can load it into javascript as a base64-encoded string

    It is not impossible for you to do this even with external audio files if you use your server simply as a proxy to extract the RAW data, but then you will need to take care of the security issues that introduces.

    If this applies to you at all then let me know and I’ll post some source code for these.
    The program in question will be released as an open source project at http://jukenix.org as soon as I’ve tidied it up a bit.

    P.S. screenshot of this in action is at bottom of page of link above

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.