var context= new (window.AudioContext || window.webkitAudioContext)(); var oscillator = context.createOscillator(); oscillator.frequency.value = 5000; oscillator.start(); oscillator.connect(context.destination);
This starts with a tone with a frequency of 5000 which most people with hearing should be able to notice it.
If you create a tone with a frequency greater than 15000 only those under 40 will be able to hear it and a frequency above 17500 can be heard by only by those 18 and younger.
oscillator.frequency.value = 15000; oscillator.frequency.value = 17500;
This festive season why not turn your speakers up high and use this method (starting at 17500 and then reducing by 1000 at a time) to figure out who is the youngest in your office.
If you want the sound to stop simple run this:
The following demo shows how you could record and visualise audio coming from a Microphone:
The following demo shows how you can build a simple tuner: