From 81b61e3c544123ebe30af7941266dea5aafbc067 Mon Sep 17 00:00:00 2001 From: SthephanShi Date: Tue, 3 May 2022 02:33:23 +0300 Subject: [PATCH] Add 'Antarctica' song. Fix typo (#42) --- index.html | 2 +- library/minified/SthephanShi - Antarctica.js | 1 + library/original/SthephanShi - Antarctica.js | 38 ++++++++++++++++++++ library/sthephanshi.json | 15 +++++++- scripts/bytebeat.mjs | 3 +- 5 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 library/minified/SthephanShi - Antarctica.js create mode 100644 library/original/SthephanShi - Antarctica.js diff --git a/index.html b/index.html index 8984a73e..0e5b6896 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - + Bytebeat composer diff --git a/library/minified/SthephanShi - Antarctica.js b/library/minified/SthephanShi - Antarctica.js new file mode 100644 index 00000000..50b481d4 --- /dev/null +++ b/library/minified/SthephanShi - Antarctica.js @@ -0,0 +1 @@ +t/=44100,b=105*t/60%256,C=262,D=294,EE=330,Gb=370,G=392,A=440,B=494,w=a=>1E-4*a*sin(44*t),arp=e=>{return i=b-e,25*((b&16?4:2)*(t+(b&32&&w(6)))*[C,D,G,D,Gb,A,EE,G,B,D,Gb,A,2*C,D,G,2*D,Gb,B,2*EE,G,B,2*D,Gb,A][(i>>1)%8*3+int((b&64?22:2)*i)%3]%2|0)},pad=(p,e)=>20*int(.7*(p*(t+w(4))*[C,D,EE,D,C,D,B/2,C][(b-e>>1)%8]%2)),(b&16|b&32&&(1E4*sin((128*t*'11101000100010001100101010001000'[int(8*b)%32])**2)&255)/10)+(b&32&&55*int(b*(256>>32*b)%2))+arp(0)+.8*arp(.4)+.6*arp(.8)+pad(1,0)+pad(1.5,1)+.5*pad(2,1) \ No newline at end of file diff --git a/library/original/SthephanShi - Antarctica.js b/library/original/SthephanShi - Antarctica.js new file mode 100644 index 00000000..b31ad760 --- /dev/null +++ b/library/original/SthephanShi - Antarctica.js @@ -0,0 +1,38 @@ +t /= 44100, // Sample rate +bpm = 105, // Song speed +len = 256, // Song length +b = (bpm * t / 60) % len, + +// Notes +C = 262, Db = 277, D = 294, Eb = 311, EE = 330, F = 349, +Gb = 370, G = 392, Ab = 415, A = 440, Bb = 466, B = 494, + +// Wave modifier +wave = amp => amp * 1E-4 * sin(44 * t), + +// Square arpeggiator +arp = echo => (i = b - echo, 25 * ((b & 16 ? 4 : 2) * (t + ((b & 32) && wave(6))) * [ + C, D, G, + D, Gb, A, + EE, G, B, + D, Gb, A, + C * 2, D, G, + D * 2, Gb, B, + EE * 2, G, B, + D * 2, Gb, A +][3 * ((i >> 1) % 8) + int((b & 64 ? 22 : 2) * i) % 3] % 2 | 0)), + +// Square bass pad +pad = (pitch, echo) => 20 * int(.7 * (pitch * (t + wave(4)) * [ + C, D, EE, D, C, D, B / 2, C +][((b - echo) >> 1) % 8] % 2)), + +// Hi-hats +((b & 16 | b & 32) && + (1E4 * sin((128 * t * '11101000100010001100101010001000'[int(8 * b) % 32]) ** 2) & 255) / 10) + +// Kick +((b & 32) && 55 * int(b * (256 >> 32 * b) % 2)) + +// Arpeggio +arp(0) + .8 * arp(.4) + .6 * arp(.8) + +// Bass pad +pad(1, 0) + pad(1.5, 1) + .5 * pad(2, 1); diff --git a/library/sthephanshi.json b/library/sthephanshi.json index 96e45d34..bcd15e9c 100644 --- a/library/sthephanshi.json +++ b/library/sthephanshi.json @@ -294,7 +294,7 @@ }] }, { "children": [{ - "description": "Flying deep in dark space, you caught a distress signal and landed on an icy planet. In this frozen world, you have found an abandoned base of colonists. There is not a single survivor... " + "description": "\"Flying deep in dark space, you caught a distress signal and landed on an icy planet. In this frozen world, you have found an abandoned base of colonists. There is not a single survivor...\"" }, { "description": "Frozen Planet", "url": "https://battleofthebits.org/arena/Entry/Frozen+Planet/50767/", @@ -306,5 +306,18 @@ "fileOriginal": true, "starred": 2 }] + }, { + "children": [{ + "description": "\"An endless world of snowy expanses, icebergs, and blue waters...\"
The instruments are the same as in \"Frozen Planet\", but the composition is based on playing with coefficients of square-wave arpeggiator and a sine modifier. A notes array is used to generate different sounds in different iterations." + }, { + "description": "Antarctica", + "url": "https://www.reddit.com/r/bytebeat/comments/ufxliq/antarctica/", + "date": "2022-05-01", + "sampleRate": 44100, + "file": "SthephanShi - Antarctica.js", + "fileMinified": true, + "fileOriginal": true, + "starred": 2 + }] } ] diff --git a/scripts/bytebeat.mjs b/scripts/bytebeat.mjs index 58e5c6db..3d994fd5 100644 --- a/scripts/bytebeat.mjs +++ b/scripts/bytebeat.mjs @@ -14,7 +14,6 @@ const loadScript = src => new Promise(resolve => { } }); - globalThis.bytebeat = new class { constructor() { this.audioCtx = null; @@ -448,6 +447,7 @@ globalThis.bytebeat = new class { el.classList.contains('code-load-minified') ? 'minified' : el.classList.contains('code-load-original') ? 'original' : '' }/${ el.dataset.codeFile }`, true); + xhr.setRequestHeader('Cache-Control', 'no-cache, no-store, must-revalidate'); xhr.send(null); } onclickCodeToggleButton(el) { @@ -491,6 +491,7 @@ globalThis.bytebeat = new class { containerEl.insertAdjacentHTML('beforeend', libraryHTML); }; xhr.open('GET', `./library/${ containerEl.id.replace('library-', '') }.json`, true); + xhr.setRequestHeader('Cache-Control', 'no-cache, no-store, must-revalidate'); xhr.send(null); } onresizeWindow() {