[pitch-changer-1]

var timeMultiplication = 0.0001
var amplitudeAddBefore = 1
var amplitudeAddAfter  = 0.8
var amplitudeMultiplication = 0.2
var updatesPerSecond = 10

var startTime

function startTimer() {
	startTime = Date.now()
	setInterval(change, 1000 / updatesPerSecond)
}

startTimer()

function change() {
	var diff = (Date.now() - startTime) * timeMultiplication
	var res = (amplitudeAddBefore + Math.sin(diff)) * amplitudeMultiplication + amplitudeAddAfter
	var rounded = Number(res.toFixed(2))
	var videoEl = document.querySelector('video')
	videoEl.playbackRate = res
	videoEl.preservesPitch = false
	// console.log(rounded)
}

[Back Home]