Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 | 2x 2x 2x 2x 2x 58x 58x 58x 16x 44x 16x 2x 1x 1x 1x 1x 58x | /** * @public * @class utils */ /** * Converts a base64 string into a Uint8Array of "binary" data. * * @private * @method base64ToUint8 * @param {string} base64String The base64 string that you'd like to be converted. * @return {Uint8Array} A Uint8Array of converted "binary" audio data. */ export function base64ToUint8(base64String) { const sB64Enc = base64String.replace(/[^A-Za-z0-9+/]/g, ''); const nInLen = sB64Enc.length; const nOutLen = nInLen * 3 + 1 >> 2; const taBytes = new Uint8Array(nOutLen); for (let nMod3, nMod4, nUint24 = 0, nOutIdx = 0, nInIdx = 0; nInIdx < nInLen; nInIdx++) { nMod4 = nInIdx & 3; nUint24 |= b64ToUint6(sB64Enc.charCodeAt(nInIdx)) << 18 - 6 * nMod4; if (nMod4 === 3 || nInLen - nInIdx === 1) { for (nMod3 = 0; nMod3 < 3 && nOutIdx < nOutLen; nMod3++, nOutIdx++) { taBytes[nOutIdx] = nUint24 >>> (16 >>> nMod3 & 24) & 255; } nUint24 = 0; } } return taBytes; } /** * Strips extraneous stuff from a soundfont and splits the soundfont into a JSON * object. Keys are note names and values are base64 encoded strings. * * @private * @method mungeSoundFont * @param {string} soundfont A soundfont as a long base64 string * @return {object} A JSON representation of all the notes in the font */ export function mungeSoundFont(soundfont) { const begin = soundfont.indexOf('=', soundfont.indexOf('MIDI.Soundfont.')) + 2; const end = soundfont.lastIndexOf('"') + 1; const string = (`${soundfont.slice(begin, end)}}`) .replace(new RegExp('data:audio/mp3;base64,', 'g'), '') .replace(new RegExp('data:audio/mpeg;base64,', 'g'), '') .replace(new RegExp('data:audio/ogg;base64,', 'g'), ''); return JSON.parse(string); } function b64ToUint6(nChr) { return nChr > 64 && nChr < 91 ? nChr - 65 : nChr > 96 && nChr < 123 ? nChr - 71 : nChr > 47 && nChr < 58 ? nChr + 4 : nChr === 43 ? 62 : nChr === 47 ? 63 : 0; } |