OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to change the pitch with JavaScript?

  • Thread starter Thread starter chipmunkpassion
  • Start date Start date
C

chipmunkpassion

Guest
Let’s say you have an audio variable called audio and it stores a sound.

I know how to change the speed for example:

Code:
audio.playBackRate = 2;

But I don't know how to change the pitch.

Is there an audio.pitch attribute or do I have to create it myself?

I want to do something like this:

Code:
var audio = new Audio();
audio.src = "sound_effect.wav";
audio.pitch = 2 //doubling the pitch but there is no pitch attribute
audio.play();

<p>Let’s say you have an audio variable called <code>audio</code> and it stores a sound. </p>

<p>I know how to change the speed for example: </p>

<pre><code>audio.playBackRate = 2;
</code></pre>

<p>But I don't know how to change the pitch. </p>

<p>Is there an <code>audio.pitch</code> attribute or do I have to create it myself? </p>

<p>I want to do something like this: </p>

<pre><code>var audio = new Audio();
audio.src = "sound_effect.wav";
audio.pitch = 2 //doubling the pitch but there is no pitch attribute
audio.play();
</code></pre>
 
Top