Skip to content

Instantly share code, notes, and snippets.

View bad_color.js
// some color conversion code i didnt end up using but might as well put somewhere
function hcl2rgb(arr) {
function lab2xyz(t){return t>6/29?t*t*t:6/29*3*(6/29)*(t-4/29)}
function xyz2rgb(x){return 255*(x<=.0031308?12.92*x:1.055*Math.pow(x,1/2.4)-.055)}
var h = arr[0], c = arr[1], l = arr[2];
y = (l+16)/116,
a = Math.cos(h)*c, b = Math.sin(h)*c,
x = isNaN(a)?y:y+a/500, z = isNaN(b)?y:y-b/200;
View 001.htm
<script>
for(rnd=w=>'#'+Math.random().toString(16).slice(-6),i=0;i<99;i++)
document.write(`<div style=background:linear-gradient(0.25turn,${rnd()},${rnd()},${rnd()},${rnd()})></div>`)
</script>
<style>body{background:#222;column-count:3;column-gap:6px}div{height:48;break-inside:avoid}</style>
<!--
background: repeating-linear-gradient(45deg, #3f87a6, #ebf8e1 5%, #f69d3c 20%);
clip-path: polygon(5% 5%, 100% 0%, 100% 75%, 75% 75%, 75% 100%, 50% 75%, 0% 75%);
-->
@bryc
bryc / st.txt
Created Nov 20, 2019
Scream Tracker Manual (1990)
View st.txt
Scream Tracker
<<<<< USERS MANUAL >>>>>
(C) 1990 Sami Tammilehto
==============================================================================
@bryc
bryc / VRC7_patch_guesses.txt
Last active Feb 3, 2020
not mine, just a collection
View VRC7_patch_guesses.txt
// Patch names
1 Buzzy Bell
2 Guitar
3 Wurly
4 Flute
5 Clarinet
6 Synth
7 Trumpet
8 Organ
9 Bells
@bryc
bryc / !notes.txt
Last active Jun 14, 2021
Optimized CRC implementations
View !notes.txt
Some notes...
This gist contains a bunch of optimized tableless CRC implementations intended for microcontrollers.
As far as performance goes.. they are about 2x or 3x faster than the double-looped variants. But that's not saying much, because
it's still 35% slower than HalfSipHash. And it cannot even compare to MurmurHash3 (~80% slower).
CRC may be able to be optimized with multi-byte read versions.
However for CRC-32, it seems that you can unroll the inner-loop and performance is still comparable to the hand-optimized version
(within 10%). So take that with a grain of salt.
@bryc
bryc / lzjb.js
Last active Oct 18, 2019
proof of concept tiny compression
View lzjb.js
// tiny simple hash (TSH)
TSH=s=>{for(var i=0,h=6,c=5;i<s.length;)h=Math.imul(h^s[i],9**9),c=Math.imul(c^s[i++],7**9);return 2**32*(2097151&(c^c>>>9))+(h^h>>>9)}
// LZB minified 512 bytes.
LZB={e:(e,f)=>{for(var r,l,o,i,s,a=0,g=0,h=128,n=[],t=e.length;a<t;)if(256==(h<<=1)&&(h=1,l=g,f[g++]=0),a>t-3)f[g++]=e[a++];else if(i=a-n[s=66*e[a]^33*e[a+1]^e[a+2]]&1023,n[s]=a,(r=a-i)!=a&&e[a]==e[r]&&e[a+1]==e[r+1]&&e[a+2]==e[r+2]){for(o=3;o<66&&e[a+o]==e[r+o];o++);a+=o,f[l]|=h,f[g++]=o-3<<2|i>>8,f[g++]=i&255}else f[g++]=e[a++]},d:(e,f)=>{for(var r,l,o,i=0,s=0,a=128;i<e.length;)if(256==(a<<=1)&&(a=1,l=e[i++]),l&a)for(r=s-(1023&(e[i]<<8|e[i+1])),o=3+(e[i]>>2),i+=2;o>0;o--)f[s++]=f[r++];else f[s++]=e[i++]}}
var sum = [], packed = [], unpacked = [], data = [0,0,0,0,0,0,0,0,9,0,255,79,127,191,191,191,143,5,4,7,129,0,0,0,0,0,0,0,0,0,3,1,0,0,0,1,0,103,60,84,47,53,27,26,30,2,0,0,0,0,0,0,68,65,7,109,0,0,0,0,0,0,0,0,9,0,255,79,127,191,191,191,143,5,4,7,129,0,0,0,0,0,0,0,0,0,3,1,0,0,0,1,0,103,60,84,47,53,27,26,30,2,0,0,0,0,0,0,68,
View base.js
// Arbitrary precision base conversion, WIP
function baxx(str, src_base, dst_base) {
var number = [], output = "", res = [], quotient, remainder;
var charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
//decode
for(var i = 0; i < str.length; i++) number[i] = charset.indexOf(str[i]);
while (number.length) {
// divide successive powers of dst_base
quotient = [], remainder = 0;
View filevalidmockup.js
/*
a mockup of a fileformat with a 8 byte header. 56-bit magic, 8-bit version code, and 64-bit hash.
*/
var data = [250,222,222,175,98,83,80,0,149,227,98,114,223,2,65,139,212,54,64,54,169,172,160,90,58,126,203,87,217,240,53,186,160,226,221,133,70,56,95,24,49,66,201,41,182,75,120,164,236,222,80,145,147,117,15,88,219,136,158,2,20,70,140,78,163,103,32,199,173,219,175,24,97,78,33,93,215,188,212,50,218,155,63,171,40,68,17,134,244,173,170,70,180,159,32,245,135,233,57,203,196,84,18,249,120,73,72,71,223,101,226,87,42,132,104,173,25,242,197,218,55,191,232,94,192,124,90,38,130,209,31,191,73,175,162,149,144,23,144,228,157,185,200,43,59,215,220,70,173,60,188,142,168,51,132,136,82,197,155,28,157,175,122,82,138,217,234,9,24,64,128,54,248,145,159,140,63,244,94,168,188,196,252,32,159,36,223,9,154,195,52,215,181,53,168,184,107,167,233,180,210,240,211,64,230,41,117,26,64,97,101,137,182,14,0,84,201,78,142,38,219,37,110,27,125,58,187,170,101,208,21,58,211,245,119,11,118,33,74,61,23,197,29,34,155,132,182,48,37,20,89,44,106,253,1
@bryc
bryc / Adler-32.js
Last active Jul 26, 2020
legit checksums
View Adler-32.js
// Adler-32
// Appears simpler than Fletcher, yet even better (possibly due to a = 1).
function adler32(data) {
var a = 1, b = 0;
for (var i = 0; i < data.length; i++) {
a = (a + data[i]) % 65521;
b = (b + a) % 65521;
}
return a | (b << 16);
}
View !Algorithms.md

DX7

image

Note: One of the algorithms is incorrect due to a missing operator. Need to update the image. Will have to get on that soon.

These are the original 32 algorithms as used in Yamaha DX7.

The later Yamaha FS1R and Yamaha SY77 may have compatibility with these algorithms, but that's beyond the current scope. The FS1R contains 88 algorithms, while the SY77 contains 45 algorithms.