I'm a beginner learning javascript. I've got various projects in mind with an interactive page on my site related to microtonal frequencies and planetary frequencies. I need to be able to play my audio sample .wav file in a loop but have the audio sample timestretched with a corresponding change in pitch.
I tried myAudio.playbackRate = 0.5;
which plays the audio 0.5 slower but keeps pitch same.
I researched and found something. But how do i set preservesPitch
to false or true? And this only works in 'Google Chrome' I think, so other program i found is here :
https://github.com/janesconference/KievII/blob/master/dsp/pitchshift.js
Can't seem to get it working, i don't know how i am supposed to modify it, where do i paste my Audio .wav file URL in the program ? Any other tips related to this would be much appreciated. Thanks in advance for your time and help.
In audio production, time stretching refers to a form of audio processing that extends or contracts the duration of a sample or sound without changing its pitch or tonal characteristics.
Time stretching is the process of changing the speed or duration of an audio signal without affecting its pitch. Pitch scaling is the opposite: the process of changing the pitch without affecting the speed. Pitch shift is pitch scaling implemented in an effects unit and intended for live performance.
This function allows you to change the length and tempo of the selected audio without affecting the pitch. The available options are: Define Bars section. If you use the tempo setting, you can set the length of the selected audio and the time signature in this section.
you can set the mozPreservesPitch
property to false to change the pitch of an element or soundfile with Firefox. webkitPreservesPitch
is supposed to work with webkit browsers but note that "this API is not yet standardized" ...
https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement
This worked for me:
var soundPlayer = new Audio();
function playLowerNote() {
soundPlayer.src = "piano.mp3";
soundPlayer.mozPreservesPitch = false;
soundPlayer.playbackRate = 0.5;
soundPlayer.play();
}
playLowerNote();
Still looking myself for a better way to loop.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With