Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From <a href="https://wiki.mozilla.org/Audio_Data_API" rel="nofollow">https://wiki.mozilla.org/Audio_Data_API</a></p> <p>The data you're looking for is in the framebuffer property of the event object passed to your listener function</p> <p>To access a particular section of historical data, simply cache previous framebuffer captures yourself</p> <pre><code>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 &lt; frameBufferLength; i++) { // Do something with the audio data as it is played. processSample(samples[i], channels, rate); } } </code></pre> <p>ADDENDUM:</p> <p>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).</p> <p>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:</p> <p>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.</p> <p>2) Use the RAW PCM to draw a PNG of the wave using php_gd, and cache that (for your player background)</p> <p>3) if using the RAW data then you can load it into javascript as a base64-encoded string</p> <p>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.</p> <p>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 <a href="http://jukenix.org" rel="nofollow">http://jukenix.org</a> as soon as I've tidied it up a bit.</p> <p>P.S. screenshot of this in action is at bottom of page of link above</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload