-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
532 lines (462 loc) · 26.8 KB
/
index.html
File metadata and controls
532 lines (462 loc) · 26.8 KB
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
<!-- canvas editor taken from http://www.williammalone.com/articles/create-html5-canvas-javascript-drawing-app/ -->
<!-- sound transformations from http://arss.sourceforge.net/code.shtml -->
<!-- JS port of FFTW from https://github.com/j-funk/js-dsp-test/tree/master/fft/fftw -->
<!-- JS port of SAM from https://github.com/discordier/sam -->
<style>
li, label, input { display: inline-block; }
#playground { width: 400px; margin-top: 1em; }
label { width: 25% }
input[type="checkbox"] + label { width: 20%; }
input[type="range"] { width: 70%; }
#canvas { cursor: default; }
</style>
<ul style="list-style-type:none;padding-left:0">
<li><button id="clearCanvas" type="button">Clear</button></li>
<li id="chooseColor"><button type="button" style="background-color:black"> </button><button type="button" style="background-color:dimgray"> </button><button type="button" style="background-color:lightgray"> </button><button type="button" style="background-color:white"> </button></li>
<li id="chooseSize"><button type="button" style="border-width:1px"> </button><button type="button" style="border-width:2.5px"> </button><button type="button" style="border-width:5px"> </button><button type="button" style="border-width:10px"> </button></li>
<li><button id="play" type="button">Play</button></li>
<li><input id="loop" type="checkbox" checked>Loop</input></li>
<li><button id="copy" type="button">Copy</button></li>
</ul>
<div class="image">
<canvas id="canvas" />
</div>
<div id="playground">
<div>
<input size="40" id="textinput" value="Write something nice here">
<button type="button" id="transcribe">Transcribe</button>
<input size="45" id="speechinput" value="PRIYVEH3T, /X/XAH5BRAA/X/XAA4BRER8. YAA5 UXMEH4YUW GAXVAHRIY4TIX PAX7QAHNGLIY3SKIX.">
<button type="button" id="say">Say</button>
<input id="use-pitch" type="checkbox" checked /><label id="pitch-lbl" for="pitch">Pitch:</label><input type="range" id="pitch" min="0" max="255" value="0" />
<label id="speed-lbl" for="speed">Speed:</label><input type="range" id="speed" min="1" max="255" value="0" />
<label id="mouth-lbl" for="mouth">Mouth:</label><input type="range" id="mouth" min="0" max="255" value="0" />
<label id="throat-lbl" for="throat">Throat:</label><input type="range" id="throat" min="0" max="255" value="0" />
<label id="bandwidth-lbl" for="bandwidth">Bandwidth:</label><input type="range" id="bandwidth" min="1" max="20" step="0.5" value="0" />
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.js"></script>
<script src="FFTW.js"></script>
<script src="parser.js"></script>
<script src="renderer.js"></script>
<script>
var canvasWidth = 400;
var canvasHeight = 225;
var clickX;
var clickY;
var paint;
var canvasContext;
function prepareCanvas()
{
var canvas = document.getElementById('canvas');
canvas.width = canvasWidth;
canvas.height = canvasHeight;
canvasContext = canvas.getContext("2d"); // Grab the 2d canvas context
var initialImage = new Image();
initialImage.src = location.hash ? location.hash.substring(1) : "habr.png";
initialImage.onload = function() {
canvasContext.drawImage(initialImage, 0, 0, canvasWidth, canvasHeight);
}
canvasContext.lineWidth = 5;
canvasContext.strokeStyle = "white";
canvasContext.lineJoin = "round";
var undoBuffer;
// Add mouse events
// ----------------
$('#canvas').mousedown(function(e) {
undoBuffer = canvasContext.getImageData(0, 0, canvasWidth, canvasHeight);
// Mouse down location
clickX = e.pageX - this.offsetLeft;
clickY = e.pageY - this.offsetTop;
paint = true;
canvasContext.beginPath();
canvasContext.moveTo(clickX - 1, clickY);
canvasContext.lineTo(clickX, clickY);
canvasContext.closePath();
canvasContext.stroke();
});
$('#canvas').mousemove(function(e) {
if (paint) {
canvasContext.beginPath();
canvasContext.moveTo(clickX, clickY);
clickX = e.pageX - this.offsetLeft;
clickY = e.pageY - this.offsetTop;
canvasContext.lineTo(clickX, clickY);
canvasContext.closePath();
canvasContext.stroke();
}
});
$('#canvas').mouseup(function(e) {
paint = false;
});
$('#canvas').mouseleave(function(e) {
paint = false;
});
$('#chooseColor button').click(function(e) {
canvasContext.strokeStyle = e.target.style.backgroundColor;
});
$('#chooseSize button').click(function(e) {
canvasContext.lineWidth = e.target.style.borderWidth.match(/\d+/) * 2;
});
$('#clearCanvas').click(clear);
function clear() {
canvasContext.fillStyle = 'black';
canvasContext.fillRect(0, 0, canvasWidth, canvasHeight);
}
$('#copy').click(function(e) {
var imageData = canvasContext.getImageData(0, 0, canvasWidth, canvasHeight);
for (var y=0; y<canvasHeight; y++)
for (var x=0; x<canvasWidth; x++)
imageData.data[4*(canvasWidth*y+x)+1] =imageData.data[4*(canvasWidth*y+x)+2] =0;
canvasContext.putImageData(imageData, 0, 0);
});
$('#play').click(play);
$(document).keydown(function(e) {
if (e.keyCode == 90 && e.ctrlKey && undoBuffer)
canvasContext.putImageData(undoBuffer, 0, 0);
});
if (!window.AudioContext) {
if (!window.webkitAudioContext) {
alert("Your browser does not support any AudioContext and cannot play back audio.");
return;
}
window.AudioContext = window.webkitAudioContext;
}
var context;
function play() {
if (!context)
context = new AudioContext();
$('#play').prop("disabled", true);
var imageData = canvasContext.getImageData(0, 0, canvasWidth, canvasHeight).data;
var pixels = [];
for (var y=0; y<canvasHeight; y++)
{
pixels[y] = [];
for (var x=0; x<canvasWidth; x++)
pixels[y][x] = (//imageData[4*(canvasWidth*y+x)] +
imageData[4*(canvasWidth*y+x)+1] +
imageData[4*(canvasWidth*y+x)+2]) / (255.0 * 2.0); // Conversion to grey by averaging the three channels
}
var audioBuffer = synt_sine(pixels);
// Create a source node from the buffer
var source = context.createBufferSource();
// Fill in source.buffer from audioBuffer
var soundBuffer = context.createBuffer(1, audioBuffer.length, samplerate);
var buffer = soundBuffer.getChannelData(0);
for(var i=0; i<audioBuffer.length; i++)
buffer[i] = audioBuffer[i];
source.buffer = soundBuffer;
// Connect to the final output node (the speakers)
source.connect(context.destination);
// Play immediately
source.start(0);
source.onended = function(){ if ($('#loop').prop("checked")) play(); else $('#play').prop("disabled", false); };
}
function say() {
var x = frame => frame * opts.speed / 139;
var y = freq => canvasHeight - log_pos_inv(freq / samplerate, basefreq, maxfreq) * (canvasHeight-1);
var color = v => 'rgba(' + [v,v,v,1].toString() + ')';
var alpha = v => 'rgba(' + [0,0,0,v].toString() + ')';
function renderSample(frame, index, factor) {
for (var y = 0; y < canvasHeight; y++) {
canvasContext.fillStyle = color(~~(samples[index][y] * factor));
canvasContext.fillRect(x(frame), canvasHeight - y, x(1), 1);
}
}
clear();
var formantsCanvas = document.createElement('canvas');
formantsCanvas.width = canvasWidth;
formantsCanvas.height = canvasHeight;
var formantsContext = formantsCanvas.getContext('2d');
formantsContext.lineWidth = opts.bandwidth;
var harmonicsCanvas = document.createElement('canvas');
harmonicsCanvas.width = canvasWidth;
harmonicsCanvas.height = canvasHeight;
var harmonicsContext = harmonicsCanvas.getContext('2d');
var factor = 1;
var prev = 0;
var parsed = Parser($('#speechinput').val());
var sentence = Renderer(parsed, opts.pitch|0, opts.mouth, opts.throat, /*singmode*/false);
var [frameCount, frequency, pitches, amplitude, sampledConsonantFlag] = sentence;
if ($('#use-pitch').prop('checked')) {
harmonicsContext.strokeStyle = 'white';
for (var pos=1; pos<frameCount; pos++) {
var prev = 22050 / pitches[pos-1];
var pitch = 22050 / pitches[pos]; // Hz
var low = Math.ceil(basefreq * samplerate / pitch);
var high = Math.floor(maxfreq * samplerate / pitch);
for (var band = low; band <= high; band++) {
var x0 = x(pos-1), y0 = y(band * prev);
var x1 = x(pos), y1 = y(band * pitch);
harmonicsContext.beginPath();
harmonicsContext.moveTo(x0, y0);
harmonicsContext.lineTo(x1, y1);
harmonicsContext.stroke();
}
}
} else {
harmonicsContext.fillStyle = 'white';
harmonicsContext.fillRect(0, 0, canvasWidth, canvasHeight);
}
for (var pos=0; pos<frameCount; pos++) {
let flags = sampledConsonantFlag[pos];
if (flags == prev)
factor *= .9;
else {
factor = 1;
prev = flags;
}
if (flags)
renderSample(pos, flags, factor);
if (!(flags & 248) && pos && !(sampledConsonantFlag[pos-1] & 248)) {
for (var formant = 0; formant < 3; formant++) {
var x0 = x(pos-1), y0 = y(frequency[formant][pos-1] * 24);
var x1 = x(pos), y1 = y(frequency[formant][pos] * 24);
var grad = formantsContext.createLinearGradient(x0, y0, x1, y1);
grad.addColorStop(0, alpha(amplitude[formant][pos-1] / 15));
grad.addColorStop(1, alpha(amplitude[formant][pos] / 15));
formantsContext.beginPath();
formantsContext.moveTo(x0, y0);
formantsContext.lineTo(x1, y1);
formantsContext.strokeStyle = grad;
formantsContext.stroke();
}
}
}
harmonicsContext.globalCompositeOperation = 'destination-in';
harmonicsContext.drawImage(formantsCanvas, 0, 0);
canvasContext.drawImage(harmonicsCanvas, 0, 0);
if (!$('#play').prop("disabled"))
play();
}
$('#say,#use-pitch').click(say);
$('#use-pitch').click(function() {
$('#pitch').prop('disabled', !this.checked);
$('#pitch-lbl').text('Pitch: ' + (this.checked ? $('#pitch').val() : 'N/A'));
});
var opts = {
debug: 1,
pitch: 128,
speed: 128,
mouth: 128,
throat: 128,
bandwidth: 3
};
for (var name of ['speed', 'pitch', 'mouth', 'throat', 'bandwidth']) {
$('#'+name).change(function(e) {
opts[this.id] = this.value;
document.getElementById(this.id + '-lbl').innerText =
this.id.charAt(0).toUpperCase() + this.id.substring(1) + ': ' + this.value;
say();
}).val(opts[name]);
}
var translit = {
b: 'B', p: 'P', v: 'V', f: 'F',
d: 'D', t: 'T', z: 'Z', s: 'S',
d\u0292:'J', t\u0283:'CH', \u0292: 'ZH', \u0283: 'SH',
g: 'G', k: 'K', h: '/H', \u00f0: 'DH',
m: 'M', n: 'N', \u014b: 'NX', \u03b8: 'TH',
l: 'L', r: 'R', j: 'Y', w: 'W',
\u00e6: 'AE', \u025b: 'EH', \u026a: 'IH', i: 'IY',
\u028c: 'AH', \u0254: 'AO', \u028a: 'UH', u: 'UX',
\u0252: 'OH', \u0251: 'AA', \u0259: 'AX', \u025c: 'ER',
e\u026a:'EY', a\u026a:'AY', \u0254\u026a: 'OY',
a\u028a:'AW', o\u028a:'OW', \u02a4: 'J', \u02a7: 'CH'
};
$('#transcribe').click(function() {
$('#transcribe').prop("disabled", true);
var text = $('#textinput').val();
var url = 'https://cors-anywhere.herokuapp.com/https://tophonetics.com/';
fetch(url, { method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: 'submit&output_dialect=am&weak_forms=on&text_to_transcribe=' + encodeURIComponent(text)
}).then(r=>r.text()).then(function(response) {
// quick and dirty scraping
var output = response.match(/<div id="transcr_output">(.+?)<\/div>/)[1]
.replace(/<span class="[\w]+">(.+?)<\/span>/g, "$1")
.replace(/<a .+?">(.+?)<\/a>/g, "$1")
.replace(/\ /g, " ")
.replace(/<br \/>/g, "")
.replace(/\u02cc/g, "").trim();
var result = '', stress = false;
for (var i=0; i<output.length; i++) {
if (output[i] == '\u02c8') {
stress = true;
continue;
} else if (translit[output.substring(i, i+2)]) {
result += translit[output.substring(i, i+2)];
i++;
} else if (translit[output[i]])
result += translit[output[i]];
else if (output[i] == '!')
continue;
else
result += output[i];
if (stress && ['AE','EH','IH','IY','AH','AO','UH','UX','OH','AA','AX','ER','EY','AY','OY','AW','OW']
.includes(result.substring(result.length-2))) {
result += '5';
stress = false;
}
}
$('#speechinput').val(result.trim());
$('#transcribe').prop("disabled", false);
say();
});
});
}
function log_pos(x, min, max) // turns a logarithmic position (i.e. band number/band count) to a frequency
{
return min * Math.pow(2.0, x * (Math.log2(max) - Math.log2(min)));
}
function log_pos_inv(x, min, max) // turns a frequency to a logarithmic position (i.e. band number/band count)
{
return Math.log2(x / min) / (Math.log2(max) - Math.log2(min));
}
function smallprimes(x) // returns 1 if x is only made of these small primes
{
var i, p=[2, 3];
for (i=0; i<2; i++)
while (x%p[i] == 0)
x/=p[i];
return x;
}
function nextsprime(x) // returns the next integer only made of small primes
{
while (smallprimes(x)!=1)
x++;
return x;
}
var basefreq = 110, maxfreq = 7900, samplerate = 44100, pixpersec = 50;
var bpo = (canvasHeight-1) / (Math.log2(maxfreq) - Math.log2(basefreq));
var sbsize = nextsprime(canvasWidth * 2); // In Circular mode keep it to sbsize = Xsize * 2;
var Bc = Math.round(0.25 * sbsize);
var Mh = (sbsize + 1) >> 1;
var TRANSITION_BW_SYNT = 16.0; // defines the transition bandwidth for the low-pass filter on the envelopes during synthesis
var tbw = (1.0/TRANSITION_BW_SYNT) * (Mh-1), bwl = Math.ceil(tbw); // double transition bandwidth
var freq = [], filter = [];
maxfreq /= samplerate
basefreq /= samplerate; // basefreq is now in fraction of the sampling rate instead of Hz
pixpersec /= samplerate; // pixpersec is now in fraction of the sampling rate instead of Hz
for (var i=0;i<canvasHeight;i++)
{
freq[i] = log_pos(i/(canvasHeight-1), basefreq, maxfreq); //band's central freq
}
// generation of the frequency-domain filter
for (var i=1; i<Mh; i++)
filter[i] = 1.0;
for (var i=0; i<bwl; i++)
{
var x = i / tbw; // position in the antiderivate of the Blackman function of the sample we're at, between 0.0 and 1.0
var coef = 0.42*x - (0.5/(2.0*Math.PI))*Math.sin(2.0*Math.PI*x) + (0.08/(4.0*Math.PI))*Math.sin(4.0*Math.PI*x); // antiderivative of the Blackman function
coef *= 1.0/0.42;
filter[i+1] = coef;
filter[Mh-1-i] = coef;
}
var FFTW_ESTIMATE = (1 << 6);
var fftwModule = FFTWModule({});
var fftw_plan_r2r_1d = fftwModule.cwrap('fftwf_plan_r2r_1d', 'number', ['number', 'number', 'number', 'number', 'number']);
var fftw_execute = fftwModule.cwrap('fftwf_execute', 'void', ['number']);
var fftw_destroy_plan = fftwModule.cwrap('fftwf_destroy_plan', 'void', ['number']);
function fft_alloc(N)
{
var ptr = fftwModule._malloc(N*4);
var a = new Float32Array(fftwModule.HEAPU8.buffer, ptr, N);
return [a, ptr];
}
var fft_free = fftwModule._free;
function fft(ptr, N, method) /* method : 0 = DFT, 1 = IDFT, 2 = DHT */
{
var p = fftw_plan_r2r_1d(N, ptr, ptr, method, FFTW_ESTIMATE);
fftw_execute(p);
fftw_destroy_plan(p);
}
function synt_sine(d)
{
/*
d is the original image (spectrogram)
s is the output sound
sband is the band's envelope upsampled and shifted up in frequency
sbsize is the length of sband
sine is the random sine look-up table
*samplecount is the output sound's length
ib is the band iterator
i is a general purpose iterator
bands is the total count of bands
Fc is the index of the band's centre in the frequency domain on the new signal
Bc is the index of the band's centre in the frequency domain on sband (its imaginary match being sbsize-Bc)
Mh is the length of the real or imaginary part of the envelope's FFT, DC element included and Nyquist element excluded
Mn is the length of the real or imaginary part of the sound's FFT, DC element included and Nyquist element excluded
freq is the band's central frequency
rphase is the band's sine's random phase
*/
var samplecount = Math.round(0.5*sbsize/pixpersec); // Do not change this value as it would stretch envelopes
var Mn = (samplecount + 1) >> 1;
var [s, s_ptr] = fft_alloc(samplecount); // allocation of the sound signal
var [sband, sband_ptr] = fft_alloc(sbsize); // allocation of the shifted band
var sine = [];
s.fill(0);
for (var ib=0; ib<canvasHeight; ib++)
{
sband.fill(0); // reset sband
//********Frequency shifting********
var rphase = (Math.random() - 0.5) * 2 * Math.PI; // random phase between -pi and +pi
for (var i=0; i<4; i++) // generating the random sine LUT
sine[i]=Math.cos(i*2.0*Math.PI*0.25 + rphase);
for (var i=0; i<canvasWidth; i++) // envelope sampling rate * 2 and frequency shifting by 0.25
{
if ((i & 1) == 0)
{
sband[i<<1] = d[canvasHeight-ib-1][i] * sine[0];
sband[(i<<1) + 1] = d[canvasHeight-ib-1][i] * sine[1];
}
else
{
sband[i<<1] = d[canvasHeight-ib-1][i] * sine[2];
sband[(i<<1) + 1] = d[canvasHeight-ib-1][i] * sine[3];
}
}
//--------Frequency shifting--------
fft(sband_ptr, sbsize, 0); // FFT of the envelope
var Fc = Math.round(freq[ib] * samplecount); // band's centre index (envelope's DC element)
//********Write FFT********
for (var i=1; i<Mh; i++)
{
if (Fc-Bc+i > 0 && Fc-Bc+i < Mn) // if we're between frequencies 0 and 0.5 of the new signal and that we're not at Fc
{
s[i+Fc-Bc] += sband[i] * filter[i]; // Real part
s[samplecount-(i+Fc-Bc)] += sband[sbsize-i] * filter[i]; // Imaginary part
}
}
//--------Write FFT--------
}
fft(s_ptr, samplecount, 1); // IFFT of the final sound
samplecount = Math.round(canvasWidth/pixpersec); // chopping tails by ignoring them
// normalise the signal to the +/- 1.0 range
var max=0;
for (var ix=0; ix<samplecount; ix++)
if (Math.abs(s[ix])>max)
max=Math.abs(s[ix]);
if (max!=0.0)
max = 1.0/max;
for (var ix=0; ix<samplecount; ix++)
s[ix]*=max;
var wavfile = new Float32Array(s.slice(0, samplecount));
fft_free(s_ptr);
fft_free(sband_ptr);
return wavfile;
}
$(prepareCanvas);
var samples = {
241: [61,59,57,55,53,50,48,46,43,42,43,44,44,45,45,46,46,47,48,48,49,50,50,51,52,52,53,54,54,55,55,56,57,57,58,59,58,57,56,55,54,53,52,50,49,48,47,45,44,43,42,40,39,38,37,37,36,36,36,35,35,35,36,36,36,37,37,38,39,40,41,42,42,40,38,36,34,33,32,31,30,29,30,31,32,33,33,33,32,32,31,30,30,29,28,27,26,25,24,23,23,24,24,24,24,23,21,17,15,19,22,25,28,30,30,29,30,30,30,29,28,29,28,25,23,22,21,21,25,33,35,35,31,31,33,35,35,31,33,34,31,25,22,22,22,28,34,35,31,22,22,23,25,28,29,26,20,14,22,34,34,25,21,20,20,19,15,21,27,23,23,20,21,24,23,24,24,24,29,49,69,141,161,80,49,47,34,35,32,22,30,15,18,28,28,25,26,27,22,23,36,36,34,32,33,26,35,16,16,16,18,25,28,20,16,13,38,40,35,20,16,21,17,14,11],
25: [46,43,39,35,31,27,23,19,15,14,15,16,17,18,19,20,21,22,23,25,26,27,28,29,32,35,39,42,46,49,53,57,61,65,69,73,73,72,71,69,68,67,66,64,63,61,55,48,42,36,29,23,16,10,9,9,8,8,8,7,7,9,11,12,14,16,18,21,24,27,30,33,34,33,33,32,31,31,32,33,34,35,41,48,55,62,67,72,77,83,74,62,50,39,35,30,25,27,30,32,36,41,46,40,29,18,15,14,15,34,52,62,66,68,62,55,55,58,57,55,53,54,46,24,10,6,3,2,6,12,38,62,59,53,44,38,28,9,9,21,49,43,28,11,9,29,39,36,41,36,39,34,38,42,26,18,12,9,6,5,11,25,19,20,11,6,7,8,8,2,9,30,24,23,40,45,22,15,25,71,83,135,188,94,36,34,36,7,9,26,48,7,13,40,17,1,3,22,15,40,62,20,42,12,23,42,24,16,32,25,15,23,25,11,16,15,35,30,18,3,10,13,14,12,4],
226: [51,50,50,50,49,49,48,48,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,46,47,47,48,49,49,50,51,51,52,53,54,54,55,56,56,57,57,58,59,59,60,60,60,60,60,60,60,61,61,61,60,60,60,60,60,60,60,60,61,61,62,62,63,63,63,63,63,64,63,62,60,59,57,57,58,59,60,62,64,66,68,70,70,69,68,67,67,68,68,69,73,76,80,77,73,69,69,70,71,71,71,70,70,71,72,75,78,79,79,79,77,76,74,72,70,68,66,61,60,65,67,67,63,58,57,58,56,56,63,69,75,85,91,90,86,80,72,71,71,71,74,82,93,105,117,111,110,97,90,107,133,146,132,138,146,166,162,167,175,150,135,134,139,130,122,112,107,113,108,100,79,77,72,93,89,78,75,63,70,69,57,53,64,65,67,74,62,61,53,52,68,42,55,65,46,30,35,48,42,44,54,41,52,52,49,52,44,43,41,46,42,29,27,22,26,16,28,23,17,20,19],
114: [49,49,49,49,49,49,49,49,49,49,49,49,49,49,50,50,50,50,50,50,51,51,51,51,52,53,55,56,58,59,61,62,64,66,67,69,69,68,67,66,64,63,62,61,60,59,58,57,57,56,55,54,54,53,54,54,55,56,56,57,58,57,56,56,55,55,54,55,55,56,57,57,57,56,55,53,52,51,51,50,50,50,53,57,61,66,66,65,64,62,65,69,73,76,76,76,76,70,62,54,53,54,55,58,62,66,68,71,72,70,67,66,67,67,66,65,66,68,70,72,72,71,70,68,67,66,69,75,73,65,58,52,51,58,72,75,76,75,73,69,63,53,48,49,57,70,82,94,111,106,116,109,98,103,126,159,154,136,145,154,141,152,176,164,145,140,136,133,108,105,109,109,102,98,79,82,78,98,98,98,79,51,65,60,47,56,77,76,75,88,74,69,57,57,55,29,59,77,49,24,37,53,59,53,49,42,50,59,47,56,47,51,41,46,42,29,29,21,28,20,26,24,19,20,22],
211: [53,48,43,38,33,27,22,16,11,8,9,9,9,10,10,10,11,11,11,12,12,12,13,13,14,14,15,15,15,16,16,17,17,18,18,19,19,19,19,20,20,20,20,20,20,20,20,19,19,19,18,18,17,17,16,16,16,15,15,14,14,13,13,13,13,12,12,13,14,14,15,16,16,15,15,14,13,13,13,13,13,13,13,13,12,12,12,11,10,10,12,14,17,20,22,25,27,28,30,31,30,30,29,27,26,24,27,30,34,38,42,45,48,51,52,53,50,45,40,35,32,33,34,35,35,33,31,29,37,50,59,65,64,62,60,51,45,46,47,50,52,55,57,59,59,60,60,55,41,32,31,32,33,35,34,26,24,40,48,41,31,35,39,35,37,39,26,23,24,34,32,23,30,30,21,24,36,28,22,18,20,19,25,21,16,10,12,19,14,3,5,11,13,37,44,25,18,19,14,11,6,7,11,4,6,10,9,8,8,5,6,3,4,1,1,5,5,4,2,3,0,0,0,2,1],
187: [53,48,43,38,32,27,22,16,10,8,8,9,9,10,10,10,11,11,12,12,13,13,13,14,14,14,15,15,15,15,15,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,16,16,16,16,15,15,15,15,14,14,14,14,14,14,13,13,13,12,12,12,12,12,13,13,13,13,13,12,12,11,11,11,10,10,9,10,10,11,11,11,11,11,11,13,16,18,21,23,24,26,27,29,30,31,32,32,32,30,28,29,31,34,39,44,49,54,57,54,51,44,36,32,32,32,33,34,35,35,35,35,35,42,52,59,65,63,63,65,56,51,52,53,53,51,54,58,60,61,62,61,56,45,34,34,34,34,36,36,25,22,39,48,40,34,38,46,39,34,35,25,24,23,33,28,17,20,27,22,22,32,31,23,17,19,18,25,22,16,9,8,17,17,3,4,9,11,30,48,28,20,17,14,10,5,7,12,2,5,10,9,6,6,7,5,5,4,1,1,5,5,4,2,3,0,0,0,2,1],
27: [50,45,40,34,29,23,18,12,6,3,3,3,3,3,2,2,2,2,2,2,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,5,9,14,18,22,26,30,35,39,43,48,47,41,35,29,23,19,17,16,14,12,11,9,7,6,6,6,7,7,7,6,5,4,4,5,5,14,25,36,43,48,52,51,45,39,41,44,47,49,51,55,60,65,72,79,82,86,72,44,27,20,23,42,54,57,58,56,57,59,86,110,110,87,43,31,37,69,72,54,10,19,51,91,82,45,21,21,38,39,66,67,53,40,31,31,28,51,39,52,29,23,7,1,3,20,59,47,48,62,68,41,27,34,33,20,21,25,9,23,27,8,13,14,4,9,24,10,34,14,3,10,3,40,26,12,32,11,53,2,0,0,0,0,0,2,0,23,2,2,0,0,2,0,0,0,0,0,1,0,0,0,0,4,6],
124: [58,53,48,43,38,33,27,22,16,13,13,12,12,11,11,10,10,9,9,8,8,7,7,6,6,7,7,8,8,9,9,10,10,11,11,12,12,12,12,11,11,11,11,11,11,11,11,11,11,10,10,10,10,10,11,12,13,14,15,16,16,15,14,13,12,11,9,15,21,27,33,39,46,52,58,65,72,72,66,60,54,47,44,42,39,36,40,46,53,59,59,57,55,54,52,50,48,53,60,67,71,74,77,82,88,95,95,95,92,75,58,51,50,50,48,46,43,40,37,34,32,32,31,29,26,22,19,15,9,3,3,4,7,8,6,6,8,10,11,12,14,17,22,26,22,23,27,33,40,40,60,76,97,121,123,94,72,63,65,50,45,61,47,20,30,49,70,60,42,62,38,23,23,21,7,1,6,14,14,8,6,10,20,15,17,25,19,24,9,1,1,2,2,0,6,5,8,4,1,4,1,5,5,5,3,1,0,1,3,1,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0],
149: [55,50,44,39,34,28,23,17,11,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,13,13,13,14,14,14,14,13,13,13,12,12,12,12,12,12,12,12,12,14,15,17,19,20,22,23,24,25,27,27,27,27,27,26,25,24,23,22,21,21,21,20,26,32,39,43,41,39,36,38,39,41,50,63,76,86,94,102,100,97,93,91,89,81,68,56,55,55,52,50,48,46,48,55,69,93,118,142,151,145,129,109,89,70,56,50,50,45,37,21,23,27,26,27,29,31,20,12,9,11,16,18,14,11,10,9,10,5,1,2,7,6,13,16,9,14,23,25,21,10,7,9,8,6,4,5,8,9,5,17,19,9,16,28,31,21,12,18,5,1,5,4,14,27,18,2,6,2,0,0,9,3,3,6,8,3,1,0,0,0,0,0,1,3,1,0,0,2,0,0,0,0,0,0,0,0,0],
1: [31,32,33,34,35,36,37,38,40,40,39,38,37,37,36,35,34,33,32,31,30,30,29,28,27,27,26,26,26,25,25,24,24,24,23,23,24,25,27,28,30,31,33,34,36,37,35,34,33,32,30,29,28,26,26,26,25,25,25,24,24,25,26,27,28,29,30,29,27,26,24,23,22,22,21,21,21,21,22,22,22,23,22,21,20,18,18,18,18,18,18,18,18,18,17,16,15,15,15,15,15,15,14,14,14,13,14,14,14,14,14,14,13,13,14,15,15,15,15,13,13,14,14,14,13,12,12,12,12,12,11,10,10,10,10,10,10,10,10,11,12,13,13,13,15,16,17,16,17,17,17,17,16,14,14,14,12,10,10,10,9,10,10,11,13,12,15,14,13,16,12,10,9,6,5,5,5,11,13,22,28,34,40,44,44,50,45,49,42,49,36,29,23,16,10,6,4,4,4,4,5,6,6,7,7,7,7,7,7,6,5,3,2,2,2,1,1,2,2,2,2,2,2,2,2],
2: [22,22,21,21,21,21,21,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,19,19,19,19,18,18,18,17,17,17,17,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,18,18,19,19,19,20,20,20,21,21,21,22,23,23,24,24,24,24,24,24,24,24,25,25,26,26,27,27,26,25,25,24,24,25,26,25,24,23,22,22,22,22,22,22,21,20,20,20,21,21,22,22,23,23,25,26,27,27,28,30,31,31,30,32,34,33,32,33,34,34,34,36,38,40,41,43,46,51,51,52,58,59,56,62,62,60,62,60,58,57,54,52,46,45,41,35,33,28,23,21,17,16,12,12,10,10,9,9,8,7,7,6,6,5,5,4,4,3,3,3,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0],
3: [43,44,45,46,47,48,49,51,52,52,51,50,49,49,48,47,46,45,44,43,42,42,41,40,39,38,38,37,37,36,35,35,34,34,33,32,33,34,35,36,38,39,40,41,43,43,42,41,40,38,37,36,34,33,33,32,32,31,31,30,30,30,31,31,32,32,33,32,31,30,29,28,27,26,25,25,24,24,24,25,25,25,25,25,25,24,24,24,24,24,24,24,25,25,25,25,25,26,26,26,26,27,28,28,29,29,29,29,29,30,30,31,32,33,33,33,33,33,34,35,36,36,37,37,37,37,37,37,39,41,40,39,40,41,43,42,41,41,43,44,43,42,42,44,44,42,41,42,42,38,38,37,36,35,34,32,31,31,29,28,27,25,25,24,23,22,22,21,21,21,21,20,22,20,19,20,16,16,15,14,13,12,12,12,11,10,10,9,7,8,6,6,5,6,6,7,7,9,9,9,9,9,8,6,5,4,3,3,3,3,3,3,3,2,2,2,1,1,1,0,0,0,0,0,0]
};
</script>