-
Notifications
You must be signed in to change notification settings - Fork 4
/
headphonesCheckAntiPhase.html
66 lines (57 loc) · 2.7 KB
/
headphonesCheckAntiPhase.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!--
Sijia Zhao (2020-2021) sijia.zhao@psy.ox.ac.uk
Read LICENSE file before using
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Demo: Anti Phase Headphone Test</title>
<meta charset="UTF-8">
<meta content="user-scalable=no" name="viewport">
<!-- Required stylesheets: JQuery-UI -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet">
</head>
<body>
<!-- Required libraries: JQuery and JQuery-UI -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js" type="text/javascript"></script>
<!-- Add the headphonesCheck.js JavaScript file -->
<script src="headphonesCheck.js"></script>
<!-- Example usage -->
<script>
// Optional: set options (see JSDoc in headphonesCheck.js for a full list of options).
// For example:
// - set the check type to 'pitch' for a Anti-Phase pitch test
// - set the pass number to 5
// - provide a volume calibration sound
// - provide a set of check sounds
const options = {
checkType: 'antiphase',
passMark: 5,
volumeSound: 'stimuli_AntiPhase/Antiphase_calibration.flac',
checkSounds: [
{answer: 3, file: 'stimuli_AntiPhase/Antiphase_HC_OIS.flac'},
{answer: 2, file: 'stimuli_AntiPhase/Antiphase_HC_OSI.flac'},
{answer: 1, file: 'stimuli_AntiPhase/Antiphase_HC_SIO.flac'},
{answer: 1, file: 'stimuli_AntiPhase/Antiphase_HC_SOI.flac'},
{answer: 3, file: 'stimuli_AntiPhase/Antiphase_HC_IOS.flac'},
{answer: 2, file: 'stimuli_AntiPhase/Antiphase_HC_ISO.flac'},
],
};
// Create a new HeadphonesCheck using the options set above.
const headphonesCheck = new HeadphonesCheck(options);
// Perform the check (optional: call the showResult function when finished).
headphonesCheck.checkHeadphones(showResult);
// Function to display the result after completing the test.
function showResult(result) {
let resultMessage = result ? 'Pass' : 'Fail';
$('body').append('<div id="testResults" style="width: 100%; text-align: center; font-size: 3em;"></div>');
$('#testResults')
.append('<p style="margin-top: 1em;">' + resultMessage + '</p>')
.append('<p>' + headphonesCheck.attemptRecord[headphonesCheck.attemptCount].numberCorrect + ' out of 6 correct<br>after ' + headphonesCheck.attemptCount + ' attempt(s).<br>(The pass mark is 5.)</p>')
.append('<p><a href="https://sijiazhao.github.io/headphonecheck/">Go back to the Headphone Check homepage</a></p>');
}
</script>
<div style="text-align: center; margin: 1em;">Implemented by Sijia Zhao (2020-2021)</div>
</body>
</html>