Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Audio tag: Is Audio tag the same as Web Audio API?

I saw this question asked but didn't see an answer to the question directly. I was wondering if the HTML5 Audio tag is still accessing a web api? If so, is it different from the Web Audio API? I am just trying to understand the difference between the 2.

like image 490
Raymon Opie Avatar asked Jan 23 '19 04:01

Raymon Opie


2 Answers

They can be used completely independently.

  • An HTML page can use an <audio> tag and the Web Audio API isn't involved.

  • A JavaScript can use the Web Audio API and the <audio> tag isn't involved.

Here's how you would use Web Audio API:

var context = new AudioContext();
var osc = context.createOscillator();
osc.connect(context.destination);
osc.frequency.value = 440;
osc.start();

This will make a loud sound so get ready to close your browser. Here an oscillator is the source of sound.

The only cross over between the two is that the Web Audio API can use an <audio> tag on the page as a source of sound.

See: createMediaElementSource

This is useful for adding audio effects to a <audio> or <video> tag, among other audio processing things.

like image 130
MikeHelland Avatar answered Oct 12 '22 23:10

MikeHelland


These two concepts are different.

For example, the Introduction of the W3C proposal sed standard for Web Audio makes statements like The introduction of the audio element in HTML5 is very important, allowing for basic stream audio playback back. But, it is not powerful enough to handle more complex audio applications

Hence hinting at the difference between these two concepts:

HTML5 Audio element = basic playback by embedding audio data in HTML.

Web Audio API = An ECMA Script (JavaScript) based API to support audio capabilities comparable to those of a modern stand-alone PC, such as:
  • mixing

  • processing and

  • filtering (e.g. cave or cathedral effects etc., distance attenuation,

  • Doppler shift etc...

tasks related to audio production applications capabilities found in modern game audio engines

A word of caution: this API is still relatively not supported on all browsers and mobile devices.

caniuse.com site may be useful to determine the amount of support found for HTML5 and various related technologies on different platforms. The fact that W3C drafts standards for Web Audio are a strong the indication that this API will, in time, receive universal acceptance and broad support, but this is not yet the case.

Refer this Url For Better Understanding, https://developers.google.com/web/updates/2012/02/HTML5-audio-and-the-Web-Audio-API-are-BFFs

like image 20
Asiya Fatima Avatar answered Oct 13 '22 01:10

Asiya Fatima