-
Notifications
You must be signed in to change notification settings - Fork 4
/
index_query.html
141 lines (124 loc) · 4.76 KB
/
index_query.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
<!DOCTYPE html>
<html>
<head>
<title>My experiment</title>
<script src="https://unpkg.com/jspsych@7.0.0"></script>
<script src="js/jspsych-audio-tokens-v7.js"></script>
<script src="js/audio-tokens.js"></script>
<script src="//d3js.org/d3.v4.min.js"></script>
<link href="https://unpkg.com/jspsych@7.0.0/css/jspsych.css" rel="stylesheet" type="text/css" />
</head>
<body>
</body>
<script>
function getTrials() {
// Array with stimulus file paths
var stimuli = [
'data/cven_00_02286_84473_617520.wav',
'data/cven_03_26059_84473_17388318.wav',
'data/cven_05_14026_84473_17255724.wav',
'data/cven_06_31405_84473_97708.wav',
'data/cven_07_27838_84473_566483.wav',
'data/cven_08_19497_84473_17246733.wav',
'data/cven_09_26764_84473_17637624.wav',
'data/cven_10_19680_84473_665433.wav',
'data/cven_17_17551_84473_512103.wav'
]
var single_feature_trial = {
type: jsPsychAudioTokens,
ratingtype: 'features',
stimuli: stimuli.slice(0,4), // select only first four stimuli
label: ['Feature 1'],
anchors: [['low', '', 'high']],
force_listen: false,
loop: true
}
var multiple_feature_trial = {
type: jsPsychAudioTokens,
ratingtype: 'features',
stimuli: stimuli.slice(0,4),
label: ['Feature 1', 'Feature 2', 'Feature 3'],
anchors: [['low', '', 'high'],
['low', '', 'high'],
['low', '', 'high']],
force_listen: false,
loop: true,
draw_edges: true
}
var features2d_trial = {
type: jsPsychAudioTokens,
ratingtype: 'features2d',
stimuli: stimuli, // select all stimuli
label: ['Feature 1', 'Feature 2'],
anchors: [['low', '', 'high'],
['low', '', 'high']],
force_listen: false,
loop: true,
draw_edges: true
}
var categories_trial = {
type: jsPsychAudioTokens,
ratingtype: 'categories',
stimuli: stimuli,
label: ['Category 1', 'Category 2'],
force_listen: false,
loop: true
}
var cluster_trial = {
type: jsPsychAudioTokens,
ratingtype: 'cluster',
stimuli: stimuli,
force_listen: false,
loop: true
}
var similarity_trial = {
type: jsPsychAudioTokens,
ratingtype: 'similarity',
stimuli: stimuli,
force_listen: false,
loop: true,
draw_edges: true
}
var triplets_trial = {
type: jsPsychAudioTokens,
ratingtype: 'triplets',
stimuli: stimuli,
force_listen: false,
loop: true
}
return {
'single_feature': single_feature_trial,
'multiple_feature': multiple_feature_trial,
'features2d': features2d_trial,
'categories': categories_trial,
'cluster': cluster_trial,
'similarity': similarity_trial,
'triplets': triplets_trial
}
}
var trials_all = getTrials()
var url = new URL(window.location.href)
var ratingtype = url.searchParams.get('type')
var trial = trials_all[ratingtype]
if (url.searchParams.get('force_listen')) {
trial.force_listen = url.searchParams.get('force_listen')=='true'
}
if (url.searchParams.get('loop')) {
trial.loop = url.searchParams.get('loop')=='true'
}
if (url.searchParams.get('draw_edges')) {
trial.draw_edges = url.searchParams.get('draw_edges')=='true'
}
if (url.searchParams.get('mute_key')) {
trial.mute_key = url.searchParams.get('mute_key')
}
var show_progress = false
var jsPsych = initJsPsych({
show_progress_bar: show_progress,
on_finish: function(){
jsPsych.data.displayData();
}
});
jsPsych.run([trial]);
</script>
</html>