There are mp3’s that are designed to improve both Beat Speed Detection
and Beat Speed Difference Sensitivity.
Subscribe to howtotunepianos.com to be updated when they are available.
//faster = [447.5, 447, 446.5, 446, 445.75, 445.63, 445.5, 445.4, 445.3, 445.25, 445.2, 445.15, 445.1, 445.05];
//slower = [443.33,443.57,443.85,444.17,444.35,444.44,444.55,444.63,444.72,444.76,444.81,444.85,444.9,444.95];
function setup() {
levelString = document.startingValues.bsdStart.value;
level = Number(levelString);
refBpsString = document.startingValues.bpsStart.value;
refBps = Number(refBpsString);
faster = [
440+((bsd[0]+1)*refBps),
440+((bsd[1]+1)*refBps),
440+((bsd[2]+1)*refBps),
440+((bsd[3]+1)*refBps),
440+((bsd[4]+1)*refBps),
440+((bsd[5]+1)*refBps),
440+((bsd[6]+1)*refBps),
440+((bsd[7]+1)*refBps),
440+((bsd[8]+1)*refBps),
440+((bsd[9]+1)*refBps),
440+((bsd[10]+1)*refBps),
440+((bsd[11]+1)*refBps),
440+((bsd[12]+1)*refBps),
440+((bsd[13]+1)*refBps),
440+((bsd[14]+1)*refBps),
440+((bsd[15]+1)*refBps)
];
slower = [
440 + refBps/(bsd[0]+1),
440 + refBps/(bsd[1]+1),
440 + refBps/(bsd[2]+1),
440 + refBps/(bsd[3]+1),
440 + refBps/(bsd[4]+1),
440 + refBps/(bsd[5]+1),
440 + refBps/(bsd[6]+1),
440 + refBps/(bsd[7]+1),
440 + refBps/(bsd[8]+1),
440 + refBps/(bsd[9]+1),
440 + refBps/(bsd[10]+1),
440 + refBps/(bsd[11]+1),
440 + refBps/(bsd[12]+1),
440 + refBps/(bsd[13]+1),
440 + refBps/(bsd[14]+1),
440 + refBps/(bsd[15]+1)
];
alert("Test has been set up with the following parameters:\n\
Starting beat speed difference: " + bsd[level]*100 + "%\n\
Reference beat speed: " + refBps + "bps\n\
Click OK to continue.");
}
bsd = [0.5, 0.4, 0.3, 0.2, 0.15, 0.13, 0.1, 0.08, 0.06, 0.05, 0.04, 0.03, 0.02, 0.01, 0.005, 0.0025];
passed = [0,0,0,0,0,0,0,0,0,0,0,0,0,0];
conCorrect = 0;
level = 0;
choice = "empty";
document.getElementById("bsd").innerHTML = "50%";
document.getElementById("currentLevel").innerHTML = level + 1;
document.getElementById("currentLevel").innerHTML = level + 1;
document.getElementById("currentLevel").innerHTML = level + 1;
// Initialize the Audio Context
var context = new AudioContext(); // Create audio container with webkit prefix
// Declare variables in the global scope so they can be disconnected
var a440, a445, constRef, moveablePitch;
var a440Gain, a445Gain, constRefGain, moveablePitchain;
//Return a pitch that gives the required bsd randomly faster or slower
function getPitch() {
var coin = Math.random();
if (coin > 0.5) {
return faster[level];
} else {
return slower[level];
}
}
//Do if user chooses faster
function fasterChoice() {
constRef.stop(0); // Stop oscillator after 0 seconds
constRef.disconnect(); // Disconnect oscillator so it can be picked up by browser's garbage collector
moveablePitch.stop(0); // Stop oscillator after 0 seconds
moveablePitch.disconnect(); // Disconnect oscillator so it can be picked up by browser's garbage collector
choice = "Faster";
if (difference > refBps) {
//Correct?
document.getElementById("Choice").innerHTML = "Correct";
conCorrect = conCorrect + 1;
document.getElementById("curConCorrect").innerHTML = conCorrect;
if (conCorrect > 2) {
//if third correct
if (passed[level] === 1) {
//2nd time completing this level
var r = confirm("Your Beat Speed Sensitivity is " + bsd[level]*100 + "%\n\Do you want to play again?");
if (r === true) {
//Play again
bsd = 0.5
window.location.reload();
} else {
//Finished playing
alert("Thanks for playing.\n\Please subscribe to howtotunepianos.com");
return;
}
} else {
//1st time completing this level
passed[level] = 1;
level = level + 1;
if (level > 15) {
//highest level
var r = confirm("You got the highest level!\n\Your Beat Speed Sensitivity is 0.25%!\n\Do you want to play Again?");
if (r === true) {
//Play again
window.location.reload();
} else {
//Finished playing
alert("Thanks for playing.\n\Please subscribe to howtotunepianos.com");
return;
}
} else {
//Not at highest level yet. Setup for next level.
document.getElementById("currentLevel").innerHTML = level + 1;
document.getElementById("bsd").innerHTML = bsd[level]*100 + "%";
conCorrect = 0;
document.getElementById("curConCorrect").innerHTML = " ";
}
}
} else {
//Not third correct
document.getElementById("curConCorrect").innerHTML = conCorrect;
}
} else {
//if wrong
document.getElementById("Choice").innerHTML = "Wrong";
conCorrect = 0
level = level - 1;
if (level < 0) {
//failed first level
var r = confirm("Your Beat Speed Sensitivity is " + bsd*100 + "%\n\Do you want to play Again?");
if (r === true) {
//Play again
window.location.reload();
} else {
//Finished playing
alert("Thanks for playing.\n\Please subscribe to howtotunepianos.com");
return;
}
}
}
choice = "empty";
playInterval()
var clearChoice = setTimeout(function(){
document.getElementById("Choice").innerHTML = "";
},3000);
}
function stopTest() {
window.location.reload();
}
//Do if user chooses slower
function slowerChoice() {
constRef.stop(0); // Stop oscillator after 0 seconds
constRef.disconnect(); // Disconnect oscillator so it can be picked up by browser�s garbage collector
moveablePitch.stop(0); // Stop oscillator after 0 seconds
moveablePitch.disconnect(); // Disconnect oscillator so it can be picked up by browser�s garbage collector
choice = "Slower";
if (difference < refBps) {
//Correct?
document.getElementById("Choice").innerHTML = "Correct";
conCorrect = conCorrect + 1;
document.getElementById("curConCorrect").innerHTML = conCorrect;
if (conCorrect > 2) {
//if third correct
if (passed[level] === 1) {
//2nd time completing this level
var r = confirm("Your Beat Speed Sensitivity is " + bsd[level]*100 + "%\n\Do you want to play again?");
if (r === true) {
//Play again
window.location.reload();
} else {
//Finished playing
alert("Thanks for playing.\n\Please subscribe to howtotunepianos.com");
return;
}
} else {
//1st time completing this level
passed[level] = 1;
level = level + 1;
if (level > 15) {
//highest level
var r = confirm("You got the highest level!\n\Your Beat Speed Sensitivity is 0.25%!\n\Do you want to play Again?");
if (r === true) {
//Play again
window.location.reload();
} else {
//Finished playing
alert("Thanks for playing.\n\Please subscribe to howtotunepianos.com");
return;
}
} else {
//Not at highest level yet. Setup for next level.
document.getElementById("currentLevel").innerHTML = level + 1;
document.getElementById("bsd").innerHTML = bsd[level]*100 + "%";
conCorrect = 0;
document.getElementById("curConCorrect").innerHTML = " ";
}
}
} else {
//Not third correct
document.getElementById("curConCorrect").innerHTML = conCorrect;
}
} else {
//if wrong
document.getElementById("Choice").innerHTML = "Wrong";
conCorrect = 0
level = level - 1;
if (level < 0) {
//failed first level
var r = confirm("Your Beat Speed Sensitivity is " + bsd*100 + "%\n\Do you want to play Again?");
if (r === true) {
//Play again
window.location.reload();
} else {
//Finished playing
alert("Thanks for playing.\n\Please subscribe to howtotunepianos.com");
return;
}
}
}
choice = "empty";
playInterval()
var clearChoice = setTimeout(function(){
document.getElementById("Choice").innerHTML = "";
},3000);
}
function playInterval(){
pitch = getPitch();
document.getElementById("bsd").innerHTML = bsd[level]*100 + "%";
document.getElementById("currentLevel").innerHTML = level + 1;
difference = pitch - 440;
// Play a440 immediately for 2s
var playA440 = setTimeout(function(){
a440 = context.createOscillator(); // Create sound source
a440.type = "sine"; // Sine wave
a440.frequency.value = 440; // Frequency in hertz (passed from input button)
a440.start(0); // Play oscillator instantly
a440Gain = context.createGain(); // Create gain node
a440Gain.gain.value = 1; // Set gain to full volume
a440.connect(a440Gain); // Connect oscillator to gain
a440Gain.connect(context.destination); // Connect gain to output
},0);
var stopA440 = setTimeout(function(){
a440Gain.gain.value = 0; // Set gain to zero
a440.stop(0); // Stop oscillator after 0 seconds
a440.disconnect(); // Disconnect oscillator so it can be picked up by browser�s garbage collector
},3000);
// Play a445 immediately for 2s
var playA445 = setTimeout(function(){
a445 = context.createOscillator(); // Create sound source
a445.type = "sine"; // Sine wave
a445.frequency.value = 440 + refBps; // Frequency in hertz (passed from input button)
a445.start(0); // Play oscillator instantly
a445Gain = context.createGain(); // Create gain node
a445Gain.gain.value = 1; // Set gain to full volume
a445.connect(a445Gain); // Connect oscillator to gain
a445Gain.connect(context.destination); // Connect gain to output
},0);
var stopA445 = setTimeout(function(){
a445Gain.gain.value = 0; // Set gain to zero
a445.stop(0); // Stop oscillator after 0 seconds
a445.disconnect(); // Disconnect oscillator so it can be picked up by browser�s garbage collector
},3000);
// Play constRef after 2s for 2s
var playConstRef = setTimeout(function(){
constRef = context.createOscillator(); // Create sound source
constRef.type = "sine"; // Sine wave
constRef.frequency.value = 440; // Frequency in hertz (passed from input button)
constRef.start(0); // Play oscillator instantly
constRefGain = context.createGain(); // Create gain node
constRefGain.gain.value = 1; // Set gain to full volume
constRef.connect(constRefGain); // Connect oscillator to gain
constRefGain.connect(context.destination); // Connect gain to output
},3500);
var stopConstRef = setTimeout(function(){
constRef.stop(0); // Stop oscillator after 0 seconds
constRef.disconnect(); // Disconnect oscillator so it can be picked up by browser�s garbage collector
},6800);
// Play moveablePitch after 2s for 2s
var playMoveablePitch = setTimeout(function(){
moveablePitch = context.createOscillator(); // Create sound source
moveablePitch.type = "sine"; // Sine wave
moveablePitch.frequency.value = pitch; // Frequency in hertz (passed from input button)
moveablePitch.start(0); // Play oscillator instantly
moveablePitchGain = context.createGain(); // Create gain node
moveablePitchGain.gain.value = 1; // Set gain to full volume
moveablePitch.connect(moveablePitchGain); // Connect oscillator to gain
moveablePitchGain.connect(context.destination); // Connect gain to output
},3500);
var stopA445 = setTimeout(function(){
moveablePitch.stop(0); // Stop oscillator after 0 seconds
moveablePitch.disconnect(); // Disconnect oscillator so it can be picked up by browser�s garbage collector
},6800);
}