U
U
unclechu2012-12-21 04:37:04
JavaScript
unclechu, 2012-12-21 04:37:04

Panning HTML5 Audio

Good day! Looking for an answer to my own question: Is HTML5 Audio panning possible? Or some manual control of the volume of the right left channel at the source? Not a common master channel, but from individual sources. I can’t google anything on the topic, maybe I’m looking badly, of course, but if anyone knows the answer to the question: I will be very happy! Thanks to!

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Anton Bobylev, 2012-12-21
@dpigo

Here's what I found, hope it helps:

Audio Stereo Panning
HTML5 Audio currently has no way of panning audio tracks left or right (adjusting the balance). Recommended adding a HTMLMediaElement.balance property, floating point decimal, with a range of "-1" (full left speaker), to "0.0" (center, both channels at full volume), to "1.0" (full right speaker). This should work on both mono and stereo tracks.
var sound = new Audio('env/water-loop.mp3');
sound.balance = -1; // full left speaker
sound.play();

Changing this value should have an immediate effect on audio that is already playing - ie balance should not be buffered.

K
Konstantin Kitmanov, 2012-12-21
@k12th

And if you make two identical tracks, one with only the left channel, the second with the right, and control their volumes?

U
unclechu, 2012-12-21
@unclechu

In theory, you can programmatically change the signal data and make software gain on the channel - but this is a computational load, there will be a lot of sounds (2D game for example).

A
Aleks_ja, 2012-12-23
@Aleks_ja

Perhaps, in some case, it will help to transfer the required balance from the server immediately.

T
Timur Sergeevich, 2014-03-18
@MyAlesya

Audio API Help)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question