-
Notifications
You must be signed in to change notification settings - Fork 6
/
dataset.html
316 lines (297 loc) · 14 KB
/
dataset.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
<!-- Copyright 2019 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dataset</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="description" content="Exploring the Bach Doodle dataset">
<link href="style.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Work+Sans:400,700&display=swap" rel="stylesheet">
<style>
.horizontal h3 {
padding: 0 14px;
}
button.toggle, button.play {
border-top: 2px solid black;
border-left: 2px solid black;
border-right: 2px solid black;
background: white;
margin: -3px 0;
}
button.toggle {
min-width: 90px;
}
button.toggle:hover {
opacity: 1 !important;
}
button.toggle:not(.active) {
opacity: 0.5;
}
button.toggle.active {
font-weight: bold;
}
table {
font-size: inherit;
font-family: inherit;
width: 100%;
margin-bottom: 24px;
}
table td {
padding: 8px;
}
table tr:nth-child(even) {
background-color: #f2f2f2;
}
table td:first-of-type {
width: 170px;
}
table td:nth-of-type(2) {
font-weight: bold;
min-width: 50px;
}
.box {
overflow: auto;
padding: 0;
}
.circle {
width: 40px;
height: 40px;
font-size: 20px;
font-weight: bold;
border-radius: 50%;
box-shadow: var(--small-shadow);
}
@media screen and (max-width: 700px) {
.horizontal.left {
width: 100%;
justify-content: space-between;
}
}
</style>
</head>
<body>
<header>
<div class="horizontal">
<button class="menu-btn" aria-label="nav drawer button" onclick="document.body.classList.toggle('drawer-opened')">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/></svg>
</button>
<a href="index.html">Bach Doodle Dataset</a>
</div>
<div class="menu">
<div class="hide-from-toolbar">
<a href="overall.html">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path d="M12 7.13l.97 2.29.47 1.11 1.2.1 2.47.21-1.88 1.63-.91.79.27 1.18.56 2.41-2.12-1.28-1.03-.64-1.03.62-2.12 1.28.56-2.41.27-1.18-.91-.79-1.88-1.63 2.47-.21 1.2-.1.47-1.11.97-2.27M12 2L9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2z"/></svg>
Top overall melodies
</a>
<a href="world.html">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56zm2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z"/></svg>
Compositions around the world
</a>
<a href="unique.html">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M22 11h-4.17l3.24-3.24-1.41-1.42L15 11h-2V9l4.66-4.66-1.42-1.41L13 6.17V2h-2v4.17L7.76 2.93 6.34 4.34 11 9v2H9L4.34 6.34 2.93 7.76 6.17 11H2v2h4.17l-3.24 3.24 1.41 1.42L9 13h2v2l-4.66 4.66 1.42 1.41L11 17.83V22h2v-4.17l3.24 3.24 1.42-1.41L13 15v-2h2l4.66 4.66 1.41-1.42L17.83 13H22z"/><path fill="none" d="M0 0h24v24H0z"/></svg>
Most unique regional compositions
</a>
<a href="dataset.html">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path d="M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V6h16v12zM6 10h2v2H6zm0 4h8v2H6zm10 0h2v2h-2zm-6-4h8v2h-8z"/></svg>
Random dataset samples
</a>
</div>
<a href="https://magenta.tensorflow.org/datasets/bach-doodle" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path d="M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"/></svg>
Get the data
</a>
<a href="https://www.google.com/doodles/celebrating-johann-sebastian-bach" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M15 6H3v2h12V6zm0 4H3v2h12v-2zM3 16h8v-2H3v2zM17 6v8.18c-.31-.11-.65-.18-1-.18-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3V8h3V6h-5z"/></svg>
Play the game
</a>
<a target="_blank" href="https://twitter.com/intent/tweet?hashtags=madewithmagenta&text=What%20do%2024%20million%20melodies%20composed%20with%20the%20Bach%20Doodle%20look%20like%3F%20https%3A%2F%2Fmagenta.github.io%2Fbach-doodle-visualization">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92 1.61 0 2.92-1.31 2.92-2.92s-1.31-2.92-2.92-2.92z"/></svg>
Share
</a>
</div>
</div>
</header>
<section>
<h1>What does the <br><span class="accent primary">data</span> look like?</h1>
<p>
Of the more than 50 million requests to the doodle itself, the user contributed dataset contains
21.6 million miniature compositions totaling 78.8 years spent composing.
The compositions are split across 8.5 million sessions -- each session represents
an anonymous user's interaction with the web app and may contain multiple data points.
Below you can explore <b>20</b> different sessions from the dataset, and each of their harmonizations
</p>
</section>
<section>
<div class="horizontal left">
<button class="accent secondary circle" onclick="prevSession()" aria-label="view previous session"><</button>
<h3>Session: <b id="activeSession"></b>/20</h3>
<button class="accent secondary circle" onclick="nextSession()" aria-label="view next session">></button>
</div>
<div class="horizontal left">
<button class="accent secondary circle" onclick="prevHarmonization()" aria-label="view previous harmonization"><</button>
<h3>Harmonization: <b id="activeHarmonization"></b>/<b id="harms"></b></h3>
<button class="accent secondary circle" onclick="nextHarmonization()" aria-label="view next harmonization">></button>
</div>
<div class="horizontal">
<div>
<button class="toggle active" onclick="viewInput()" id="btnViewInput">input</button>
<button class="toggle" onclick="viewOutput()" id="btnViewOutput">output</button>
</div>
<button class="play" onclick="playOrPause()" id="btnPlay">play</button>
</div>
<div class="box">
<svg id="visualizer"></svg>
</div>
<h3>Metadata</h3>
<table class="box small">
<tbody>
<tr>
<td>Backend</td>
<td id="backend"></td>
<td><b>r</b> means the harmonization was sent to a cloud TPU unit,
<b>l</b> that it was done in the user's browser using TensorFlow.js
</td>
</tr>
<tr>
<td>Loops Listened</td>
<td id="loops"></td>
<td>How many times this session listened to the composition</td>
</tr>
<tr>
<td>Session ID</td>
<td id="sid"></td>
<td>Represents a user in the dataset. To avoid any personally
identifiable information, a user (or a session) represents a
new request to the doodle, not an IP -- if the same
physical person opened the doodle in multiple tabs, this would
result in multiple sessions (or users), one for each tab</td>
</tr>
<tr>
<td>Country code</td>
<td id="country"></td>
<td>The location the doodle was accessed from</td>
</tr>
<tr>
<td>Composition time</td>
<td id="comp"></td>
<td>The length of time the doodle was open in this session, in ms</td>
</tr>
<tr>
<td>Feedback</td>
<td id="feedback"></td>
<td>If a rating is present, 0 is poor, 1 is neutral, 2 is good</td>
</tr>
<tr>
<td>Key Signature</td>
<td id="keysig"></td>
<td>If the user changed the key in the advanced mode option, it would appear here</td>
</tr>
</tbody>
</table>
</section>
</body>
<script src="https://cdn.jsdelivr.net/npm/@magenta/[email protected]"></script>
<script src="common.js"></script>
<script>
let allData;
let sessionIndex = 0;
let harmIndex = 0;
fetch('data/dataset.json').then(response => response.json()).then((data) => {
allData = data;
updateView();
});
function updateView() {
let data = allData[sessionIndex];
activeSession.textContent = sessionIndex + 1;
activeHarmonization.textContent = harmIndex + 1;
harms.textContent = data['backend'].length;
backend.textContent = data['backend'][harmIndex];
loops.textContent = data['loops_listened'][harmIndex];
sid.textContent = data['session_id'][harmIndex];
country.textContent = data['country'][harmIndex];
comp.textContent = data['composition_time'][harmIndex];
feedback.textContent = data['feedback'][harmIndex];
keysig.textContent = data['key_sig'][harmIndex];
// TODO: check if we need this hack after fixing the dataset.json to jsonl
data['output_sequence'][harmIndex].notes.forEach(n => {
n.quantizedStartStep = parseInt(n.quantizedStartStep || 0)
n.quantizedEndStep = parseInt(n.quantizedEndStep);
});
data['input_sequence'][harmIndex].notes.forEach(n => {
n.quantizedStartStep = parseInt(n.quantizedStartStep || 0)
n.quantizedEndStep = parseInt(n.quantizedEndStep);
});
// Ensure the two visualizers are the same height by making them
// have the same note ranges.
const outputSequence = data['output_sequence'][harmIndex];
const pitches = outputSequence.notes.map(n => n.pitch);
minPitch = Math.min(...pitches);
maxPitch = Math.max(...pitches);
if (btnViewInput.classList.contains('active')) {
viewInput();
} else {
viewOutput();
}
}
function nextSession() {
sessionIndex = Math.min(sessionIndex + 1, allData.length - 1);
harmIndex = 0;
updateView();
}
function prevSession() {
sessionIndex = Math.max(sessionIndex - 1, 0);
harmIndex = 0;
updateView();
}
function nextHarmonization() {
harmIndex = Math.min(harmIndex + 1, allData[sessionIndex]['backend'].length - 1);
updateView();
}
function prevHarmonization() {
harmIndex = Math.max(harmIndex - 1, 0);
updateView();
}
function viewInput() {
const ns = allData[sessionIndex]['input_sequence'][harmIndex];
ns.totalQuantizedSteps = parseInt(ns.totalQuantizedSteps);
player.loadSamples(ns);
visualizeNoteSequence(ns, 'visualizer', minPitch, maxPitch);
btnViewInput.classList.add('active');
btnViewOutput.classList.remove('active');
}
function viewOutput() {
const ns = allData[sessionIndex]['output_sequence'][harmIndex];
ns.totalQuantizedSteps = parseInt(ns.totalQuantizedSteps);
player.loadSamples(ns);
visualizeNoteSequence(ns, 'visualizer', minPitch, maxPitch);
btnViewInput.classList.remove('active');
btnViewOutput.classList.add('active');
}
function playOrPause() {
if (player.isPlaying()) {
player.stop();
btnPlay.textContent = 'play';
} else {
const key = btnViewInput.classList.contains('active') ? 'input_sequence' : 'output_sequence';
const ns = allData[sessionIndex][key][harmIndex];
ns.totalQuantizedSteps = parseInt(ns.totalQuantizedSteps);
ns.tempos[0].time = 0;
player.start(ns).then(() => btnPlay.textContent = 'play');
btnPlay.textContent = 'stop';
}
}
</script>
</html>