-
Notifications
You must be signed in to change notification settings - Fork 5
/
TheAudiometer.html
147 lines (124 loc) · 6.08 KB
/
TheAudiometer.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="../../examples/example.css">
<style>
.audiometerScreen {
position: fixed;
padding: 0;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
transition: background-color 200ms linear;
}
.audiometerScreen:active {
background-color: lightgray;
}
</style>
<script src="../../thefragebogen.js"></script>
<script type="text/javascript" src="src/theaudiometer_beepgenerator.js"></script>
<script type="text/javascript" src="src/theaudiometer_calibration.js"></script>
<script type="text/javascript" src="src/theaudiometer_screen.js"></script>
<script>
/**
Calibration data for the audiometer (i.e., mapping of hearing level to gain by frequency and channel).
Only the values provided here can be later used.
*/
const audiometerCalibrationData = {
//channel: left ear
0: {
//frequency
500: {
//hearing level dbHL to gain
"-20": 0.00001,
"-15": 0.00002,
"-10": 0.00003,
"-5": 0.00004,
"0": 0.00005,
"5": 0.00006,
"10": 0.00007,
"15": 0.00008,
"20": 0.00009,
"30": 0.00010,
"40": 0.00011,
"45": 0.00012,
"50": 0.00013,
"55": 0.00014,
}
},
//channel: right ear
1: {
//frequency
500: {
//hearing level dbHL to gain
"-20": 0.00001,
"-15": 0.00002,
"-10": 0.00003,
"-5": 0.00004,
"0": 0.00005,
"5": 0.00006,
"10": 0.00007,
"15": 0.00008,
"20": 0.00009,
"30": 0.00010,
"40": 0.00011,
"45": 0.00012,
"50": 0.00013,
"55": 0.00014,
}
}
};
//This array stores all screens that will be shown.
const screens = [];
screens.push(new ScreenUIElements(
new UIElementHTML(undefined, "Welcome to TheAudiometer.<br>This is a proof-of-concept implementation of an audiometer (<a href='https://en.wikipedia.org/wiki/Audiometer'>Wiki</a>) for TheFragebogen.<br><p><b>ATTENTION:</b> This software is working while using work-in-progress web standards (Web Audio API).<br>Moreover, for real use, the software needs to be precisely calibrated to the audio equipment.<p>")
));
screens.push(new ScreenUIElements(
new UIElementHTML(undefined, "<i>Instructions:</i><br><p>A series of beeps is played (one ear at one frequency).<br>If you hear the beeps, please press your left mouse button and keep it until you do not hear the beeps anymore.<br>Please release the mouse button, when you cannot hear the beeps anymore.</p>" +
"<br><p><i>Note:</i> Please use a pair of headphones.</p><br><p><b>WARNING:</b> Please be careful not hurting your ears.<br>Do not put the pair of headphones directly onto your ears without testing the produced sound volume!")
));
screens.push(new ScreenUIElements(
new UIElementHTML(undefined, "Ear: <b>left</b><br>Frequency: <b>500Hz</b>"),
new UIElementHTML(undefined, "If you hear the beeps, please press your left mouse button and keep it until you do not hear the beeps anymore.<br>Please release the mouse button, when you cannot hear the beeps anymore.</p>")
));
screens.push(new TheAudiometerScreen("audiometerScreen", new TheAudiometerCalibration(audiometerCalibrationData), 500, 0, -10, 15));
screens.push(new ScreenUIElements(
new UIElementHTML(undefined, "Audiometry for the left ear finished.")
));
screens.push(new ScreenUIElements(
new UIElementHTML(undefined, "Ear: <b>right</b><br>Frequency: <b>500Hz</b>"),
new UIElementHTML(undefined, "If you hear the beeps, please press your left mouse button and keep it until you do not hear the beeps anymore.<br>Please release the mouse button, when you cannot hear the beeps anymore.</p>")
));
screens.push(new TheAudiometerScreen("audiometerScreen", new TheAudiometerCalibration(audiometerCalibrationData), 500, 1, -10, 15));
screens.push(new ScreenUIElements(
new UIElementHTML(undefined, "Audiometry for the right ear finished.")
));
screens.push(new ScreenDataPreview(undefined));
screens.push(new ScreenWaitDataDownload(undefined, "The End<br>All data should now be downloaded."));
const screenController = new ScreenController(screens);
</script>
<script>
document.oncontextmenu = function() {
return false;
}; //Disable context menu (right click)
//Having the start()-function in an extra script-tag makes sure that it will be executed even if there are errors in the script-tag configuring TheFragebogen.
function start() {
document.body.innerHTML += "TheFragebogen loaded.";
if (typeof(screenController) === "undefined") {
document.body.innerHTML += "<br><i>Something went wrong:<\/i> Please check that thefragebogen.js was loaded and that the configuration is ok.";
return;
}
screenController.init(document.body);
screenController.start();
}
</script>
</head>
<body class="bodySpecial" onload="start()">
<p>
TheFragebogen will be shown here.<br> If something fails while starting, an error message will be shown here.
</p>
</body>
</html>