Comparing version 1.2.3 to 1.3.0
{ | ||
"name": "zzfx", | ||
"version": "1.2.3", | ||
"version": "1.3.0", | ||
"description": "A Tiny JavaScript Sound FX System", | ||
@@ -5,0 +5,0 @@ "main": "ZzFX.js", |
@@ -67,16 +67,18 @@ # ZzFX - Zuper Zmall Zound Zynth | ||
```javascript | ||
// ZzFXMicro - Zuper Zmall Zound Zynth - v1.2.3 by Frank Force ~ 887 bytes | ||
zzfxV=.3 // volume | ||
zzfx= // play sound | ||
(p=1,k=.05,b=220,e=0,r=0,t=.1,q=0,D=1,u=0,y=0,v=0,z=0,l=0,E=0,A=0,F=0,c=0,w=1,m= | ||
0,B=0)=>{let M=Math,R=44100,d=2*M.PI,G=u*=500*d/R/R,C=b*=(1-k+2*k*M.random(k=[])) | ||
*d/R,g=0,H=0,a=0,n=1,I=0,J=0,f=0,x,h;e=R*e+9;m*=R;r*=R;t*=R;c*=R;y*=500*d/R**3; | ||
A*=d/R;v*=d/R;z*=R;l=R*l|0;for(h=e+m+r+t+c|0;a<h;k[a++]=f)++J%(100*F|0)||(f=q?1<q | ||
?2<q?3<q?M.sin((g%d)**3):M.max(M.min(M.tan(g),1),-1):1-(2*g/d%2+2)%2:1-4*M.abs(M. | ||
round(g/d)-g/d):M.sin(g),f=(l?1-B+B*M.sin(d*a/l):1)*(0<f?1:-1)*M.abs(f)**D*zzfxV | ||
*p*(a<e?a/e:a<e+m?1-(a-e)/m*(1-w):a<e+m+r?w:a<h-c?(h-a-c)/t*w:0),f=c?f/2+(c>a?0: | ||
(a<h-c?1:(h-a)/c)*k[a-c|0]/2):f),x=(b+=u+=y)*M.cos(A*H++),g+=x-x*E*(1-1E9*(M.sin | ||
(a)+1)%2),n&&++n>z&&(b+=v,C+=v,n=0),!l||++I%l||(b=C,u=G,n=n||1);p=zzfxX. | ||
createBuffer(1,h,R);p.getChannelData(0).set(k);b=zzfxX.createBufferSource();b. | ||
buffer=p;b.connect(zzfxX.destination);b.start();return b};zzfxX=new AudioContext; | ||
let // ZzFXMicro - Zuper Zmall Zound Zynth - v1.3.0 by Frank Force ~ 1000 bytes | ||
zzfxV=.3, // volume | ||
zzfxX=new AudioContext, // audio context | ||
zzfx= // play sound | ||
(p=1,k=.05,b=220,e=0,r=0,t=.1,q=0,D=1,u=0,y=0,v=0,z=0,l=0,E=0,A=0,F=0,c=0,w=1,m=0,B=0 | ||
,N=0)=>{let M=Math,d=2*M.PI,R=44100,G=u*=500*d/R/R,C=b*=(1-k+2*k*M.random(k=[]))*d/R, | ||
g=0,H=0,a=0,n=1,I=0,J=0,f=0,h=N<0?-1:1,x=d*h*N*2/R,L=M.cos(x),Z=M.sin,K=Z(x)/4,O=1+K, | ||
X=-2*L/O,Y=(1-K)/O,P=(1+h*L)/2/O,Q=-(h+L)/O,S=P,T=0,U=0,V=0,W=0;e=R*e+9;m*=R;r*=R;t*= | ||
R;c*=R;y*=500*d/R**3;A*=d/R;v*=d/R;z*=R;l=R*l|0;p*=zzfxV;for(h=e+m+r+t+c|0;a<h;k[a++] | ||
=f*p)++J%(100*F|0)||(f=q?1<q?2<q?3<q?Z(g*g):M.max(M.min(M.tan(g),1),-1):1-(2*g/d%2+2) | ||
%2:1-4*M.abs(M.round(g/d)-g/d):Z(g),f=(l?1-B+B*Z(d*a/l):1)*(f<0?-1:1)*M.abs(f)**D*(a< | ||
e?a/e:a<e+m?1-(a-e)/m*(1-w):a<e+m+r?w:a<h-c?(h-a-c)/t*w:0),f=c?f/2+(c>a?0:(a<h-c?1:(h | ||
-a)/c)*k[a-c|0]/2/p):f,N?f=W=S*T+Q*(T=U)+P*(U=f)-Y*V-X*(V=W):0),x=(b+=u+=y)*M.cos(A* | ||
H++),g+=x+x*E*Z(a**5),n&&++n>z&&(b+=v,C+=v,n=0),!l||++I%l||(b=C,u=G,n=n||1);p=zzfxX. | ||
createBuffer(1,h,R);p.getChannelData(0).set(k);b=zzfxX.createBufferSource(); | ||
b.buffer=p;b.connect(zzfxX.destination);b.start()} | ||
``` | ||
@@ -83,0 +85,0 @@ |
91
wav.js
// wav.js by Frank Force - https://github.com/KilledByAPixel/ZzFX | ||
export function buildWavBlob(sampleChannels, sampleRate = 44100) | ||
export function buildWavURL(sampleChannels, sampleRate = 44100) | ||
{ | ||
@@ -8,31 +8,59 @@ const channelCount = sampleChannels.length; | ||
const length = channelCount * sampleCount; | ||
const buffer = new Int16Array(length + 23); | ||
const headerSize = 23; | ||
const buffer = new Int16Array(length + headerSize); | ||
console.assert(channelCount && sampleCount, 'No channels or samples found!'); | ||
// wave header adapted from https://gist.github.com/asanoboy/3979747 | ||
buffer[ 0] = 0x4952; // RI | ||
buffer[ 1] = 0x4646; // FF | ||
buffer[ 2] = (2*length + 15) & 0x0000ffff; // RIFF size | ||
buffer[ 3] = ((2*length + 15) & 0xffff0000) >> 16; // RIFF size | ||
buffer[ 4] = 0x4157; // WA | ||
buffer[ 5] = 0x4556; // VE | ||
buffer[ 6] = 0x6d66; // fm | ||
buffer[ 7] = 0x2074; // t | ||
buffer[ 8] = 0x0012; // fmt chunksize: 18 | ||
buffer[ 9] = 0x0000; // | ||
buffer[10] = 0x0001; // format tag : 1 | ||
buffer[11] = channelCount; // channelCount | ||
buffer[12] = sampleRate & 0x0000ffff; // sample per sec | ||
buffer[13] = (sampleRate & 0xffff0000) >> 16; // sample per sec | ||
buffer[14] = (2*channelCount*sampleRate) & 0x0000ffff; // byte per sec | ||
buffer[15] = ((2*channelCount*sampleRate) & 0xffff0000) >> 16; // byte per sec | ||
buffer[16] = 0x0004; // block align | ||
buffer[17] = 0x0010; // bit per sample | ||
buffer[18] = 0x0000; // cb size | ||
buffer[19] = 0x6164; // da | ||
buffer[20] = 0x6174; // ta | ||
buffer[21] = (2*length) & 0x0000ffff; // data size[byte] | ||
buffer[22] = ((2*length) & 0xffff0000) >> 16; // data size[byte] | ||
{ | ||
// wave header adapted from https://gist.github.com/asanoboy/3979747 | ||
// RIFF (ascii) | ||
buffer[ 0] = 0x4952; // RF | ||
buffer[ 1] = 0x4646; // FF | ||
// RIFF size | ||
const dataSize = 2*length; | ||
const riffSize = dataSize + headerSize*2 - 8; | ||
buffer[ 2] = riffSize & 0x0000ffff; | ||
buffer[ 3] = (riffSize & 0xffff0000) >> 16; | ||
// WAVE (ascii) | ||
buffer[ 4] = 0x4157; // WA | ||
buffer[ 5] = 0x4556; // VE | ||
// fmt (ascii) | ||
buffer[ 6] = 0x6d66; // fm | ||
buffer[ 7] = 0x2074; // t | ||
// format chunk size: 18 | ||
buffer[ 8] = 0x0012; | ||
buffer[ 9] = 0x0000; | ||
// format tag: 1 (PCM format) | ||
buffer[10] = 0x0001; | ||
// channel count | ||
buffer[11] = channelCount; | ||
// samples per second | ||
buffer[12] = sampleRate & 0x0000ffff; | ||
buffer[13] = (sampleRate & 0xffff0000) >> 16; | ||
// bytes per second | ||
buffer[14] = (2*channelCount*sampleRate) & 0x0000ffff; | ||
buffer[15] = ((2*channelCount*sampleRate) & 0xffff0000) >> 16; | ||
// sample size | ||
buffer[16] = 0x0004; // bytes per sample: 4 | ||
buffer[17] = 0x0010; // bit per sample: 16 | ||
buffer[18] = 0x0000; // padding | ||
// DATA (ascii) | ||
buffer[19] = 0x6164; // DA | ||
buffer[20] = 0x6174; // TA | ||
// data size | ||
buffer[21] = dataSize & 0x0000ffff; | ||
buffer[22] = (dataSize & 0xffff0000) >> 16; | ||
} | ||
// copy samples to buffer | ||
@@ -43,7 +71,8 @@ for (let j = channelCount; j--;) | ||
const s = sampleChannels[j][i]; | ||
buffer[i*channelCount + j + 23] = s<1 ? (s * (1<<15) | 0) : (1<<15) - 1; | ||
buffer[i*channelCount + j + headerSize] = s<1 ? (s * (1<<15) | 0) : (1<<15) - 1; | ||
} | ||
// return the blob | ||
return new Blob([buffer], {type:'audio/wav'}); | ||
// return the url | ||
const blob = new Blob([buffer], {type:'audio/wav'}); | ||
return URL.createObjectURL(blob); | ||
} |
97
ZzFX.js
/* | ||
ZzFX - Zuper Zmall Zound Zynth v1.2.3 by Frank Force | ||
ZzFX - Zuper Zmall Zound Zynth v1.3.0 by Frank Force | ||
https://github.com/KilledByAPixel/ZzFX | ||
@@ -106,11 +106,21 @@ | ||
decay = 0, | ||
tremolo = 0 | ||
tremolo = 0, | ||
filter = 0 | ||
) | ||
{ | ||
// init parameters | ||
let PI2 = Math.PI*2, sampleRate = this.sampleRate, sign = v => v>0?1:-1, | ||
let PI2 = Math.PI*2, sign = v => v<0?-1:1, sampleRate = this.sampleRate, | ||
startSlide = slide *= 500 * PI2 / sampleRate / sampleRate, | ||
startFrequency = frequency *= (1 + randomness*2*Math.random() - randomness) * PI2 / sampleRate, | ||
b=[], t=0, tm=0, i=0, j=1, r=0, c=0, s=0, f, length; | ||
startFrequency = frequency *= | ||
(1 + randomness*2*Math.random() - randomness) * PI2 / sampleRate, | ||
b = [], t = 0, tm = 0, i = 0, j = 1, r = 0, c = 0, s = 0, f, length, | ||
// biquad LP/HP filter | ||
quality = 2, w = PI2 * Math.abs(filter) * 2 / sampleRate, | ||
cos = Math.cos(w), alpha = Math.sin(w) / 2 / quality, | ||
a0 = 1 + alpha, a1 = -2*cos / a0, a2 = (1 - alpha) / a0, | ||
b0 = (1 + sign(filter) * cos) / 2 / a0, | ||
b1 = -(sign(filter) + cos) / a0, b2 = b0, | ||
x2 = 0, x1 = 0, y2 = 0, y1 = 0; | ||
// scale by sample rate | ||
@@ -127,15 +137,16 @@ attack = attack * sampleRate + 9; // minimum attack to prevent pop | ||
repeatTime = repeatTime * sampleRate | 0; | ||
volume *= this.volume; | ||
// generate waveform | ||
for(length = attack + decay + sustain + release + delay | 0; | ||
i < length; b[i++] = s) | ||
i < length; b[i++] = s * volume) // sample | ||
{ | ||
if (!(++c%(bitCrush*100|0))) // bit crush | ||
{ | ||
s = shape? shape>1? shape>2? shape>3? // wave shape | ||
Math.sin((t%PI2)**3) : // 4 noise | ||
Math.max(Math.min(Math.tan(t),1),-1): // 3 tan | ||
1-(2*t/PI2%2+2)%2: // 2 saw | ||
1-4*Math.abs(Math.round(t/PI2)-t/PI2): // 1 triangle | ||
Math.sin(t); // 0 sin | ||
if (!(++c%(bitCrush*100|0))) // bit crush | ||
{ | ||
s = shape? shape>1? shape>2? shape>3? // wave shape | ||
Math.sin(t*t) : // 4 noise | ||
Math.max(Math.min(Math.tan(t),1),-1): // 3 tan | ||
1-(2*t/PI2%2+2)%2: // 2 saw | ||
1-4*Math.abs(Math.round(t/PI2)-t/PI2): // 1 triangle | ||
Math.sin(t); // 0 sin | ||
@@ -145,35 +156,37 @@ s = (repeatTime ? | ||
: 1) * | ||
sign(s)*(Math.abs(s)**shapeCurve) * // curve 0=square, 2=pointy | ||
volume * this.volume * ( // envelope | ||
i < attack ? i/attack : // attack | ||
i < attack + decay ? // decay | ||
1-((i-attack)/decay)*(1-sustainVolume) : // decay falloff | ||
i < attack + decay + sustain ? // sustain | ||
sustainVolume : // sustain volume | ||
i < length - delay ? // release | ||
(length - i - delay)/release * // release falloff | ||
sustainVolume : // release volume | ||
0); // post release | ||
sign(s)*(Math.abs(s)**shapeCurve) * // curve | ||
(i < attack ? i/attack : // attack | ||
i < attack + decay ? // decay | ||
1-((i-attack)/decay)*(1-sustainVolume) : // decay falloff | ||
i < attack + decay + sustain ? // sustain | ||
sustainVolume : // sustain volume | ||
i < length - delay ? // release | ||
(length - i - delay)/release * // release falloff | ||
sustainVolume : // release volume | ||
0); // post release | ||
s = delay ? s/2 + (delay > i ? 0 : // delay | ||
(i<length-delay? 1 : (length-i)/delay) * // release delay | ||
b[i-delay|0]/2) : s; // sample delay | ||
s = delay ? s/2 + (delay > i ? 0 : // delay | ||
(i<length-delay? 1 : (length-i)/delay) * // release delay | ||
b[i-delay|0]/2/volume) : s; // sample delay | ||
if (filter) // apply filter | ||
s = y1 = b2*x2 + b1*(x2=x1) + b0*(x1=s) - a2*y2 - a1*(y2=y1); | ||
} | ||
f = (frequency += slide += deltaSlide) * // frequency | ||
Math.cos(modulation*tm++); // modulation | ||
t += f - f*noise*(1 - (Math.sin(i)+1)*1e9%2); // noise | ||
f = (frequency += slide += deltaSlide) *// frequency | ||
Math.cos(modulation*tm++); // modulation | ||
t += f + f*noise*Math.sin(i**5); // noise | ||
if (j && ++j > pitchJumpTime) // pitch jump | ||
{ | ||
frequency += pitchJump; // apply pitch jump | ||
startFrequency += pitchJump; // also apply to start | ||
j = 0; // stop pitch jump time | ||
} | ||
if (j && ++j > pitchJumpTime) // pitch jump | ||
{ | ||
frequency += pitchJump; // apply pitch jump | ||
startFrequency += pitchJump; // also apply to start | ||
j = 0; // stop pitch jump time | ||
} | ||
if (repeatTime && !(++r % repeatTime)) // repeat | ||
{ | ||
frequency = startFrequency; // reset frequency | ||
slide = startSlide; // reset slide | ||
j = j || 1; // reset pitch jump time | ||
if (repeatTime && !(++r % repeatTime)) // repeat | ||
{ | ||
frequency = startFrequency; // reset frequency | ||
slide = startSlide; // reset slide | ||
j = j || 1; // reset pitch jump time | ||
} | ||
@@ -180,0 +193,0 @@ } |
@@ -13,3 +13,3 @@ // ZzFX - Zuper Zmall Zound Zynth - Micro Edition | ||
// ZzFXMicro - Zuper Zmall Zound Zynth - v1.2.3 by Frank Force | ||
// ZzFXMicro - Zuper Zmall Zound Zynth - v1.3.0 by Frank Force | ||
@@ -46,9 +46,19 @@ // ==ClosureCompiler== | ||
pitchJump = 0, pitchJumpTime = 0, repeatTime = 0, noise = 0, modulation = 0, | ||
bitCrush = 0, delay = 0, sustainVolume = 1, decay = 0, tremolo = 0 | ||
bitCrush = 0, delay = 0, sustainVolume = 1, decay = 0, tremolo = 0, filter = 0 | ||
)=> | ||
{ | ||
// init parameters | ||
let PI2 = Math.PI*2, sign = v => v>0?1:-1, startSlide = slide *= 500 * PI2 / zzfxR / zzfxR, | ||
startFrequency = frequency *= (1 + randomness*2*Math.random() - randomness) * PI2 / zzfxR, | ||
b=[], t=0, tm=0, i=0, j=1, r=0, c=0, s=0, f, length; | ||
let PI2 = Math.PI*2, sign = v => v<0?-1:1, | ||
startSlide = slide *= 500 * PI2 / zzfxR / zzfxR, | ||
startFrequency = frequency *= | ||
(1 + randomness*2*Math.random() - randomness) * PI2 / zzfxR, | ||
b=[], t=0, tm=0, i=0, j=1, r=0, c=0, s=0, f, length, | ||
// biquad LP/HP filter | ||
quality = 2, w = PI2 * Math.abs(filter) * 2 / zzfxR, | ||
cos = Math.cos(w), alpha = Math.sin(w) / 2 / quality, | ||
a0 = 1 + alpha, a1 = -2*cos / a0, a2 = (1 - alpha) / a0, | ||
b0 = (1 + sign(filter) * cos) / 2 / a0, | ||
b1 = -(sign(filter) + cos) / a0, b2 = b0, | ||
x2 = 0, x1 = 0, y2 = 0, y1 = 0; | ||
@@ -66,52 +76,55 @@ // scale by sample rate | ||
repeatTime = repeatTime * zzfxR | 0; | ||
volume *= zzfxV; | ||
// generate waveform | ||
for(length = attack + decay + sustain + release + delay | 0; | ||
i < length; b[i++] = s) | ||
i < length; b[i++] = s * volume) // sample | ||
{ | ||
if (!(++c%(bitCrush*100|0))) // bit crush | ||
if (!(++c%(bitCrush*100|0))) // bit crush | ||
{ | ||
s = shape? shape>1? shape>2? shape>3? // wave shape | ||
Math.sin((t%PI2)**3) : // 4 noise | ||
Math.max(Math.min(Math.tan(t),1),-1): // 3 tan | ||
1-(2*t/PI2%2+2)%2: // 2 saw | ||
1-4*Math.abs(Math.round(t/PI2)-t/PI2): // 1 triangle | ||
Math.sin(t); // 0 sin | ||
s = shape? shape>1? shape>2? shape>3? // wave shape | ||
Math.sin(t*t) : // 4 noise | ||
Math.max(Math.min(Math.tan(t),1),-1): // 3 tan | ||
1-(2*t/PI2%2+2)%2: // 2 saw | ||
1-4*Math.abs(Math.round(t/PI2)-t/PI2): // 1 triangle | ||
Math.sin(t); // 0 sin | ||
s = (repeatTime ? | ||
1 - tremolo + tremolo*Math.sin(PI2*i/repeatTime) // tremolo | ||
: 1) * | ||
sign(s)*(Math.abs(s)**shapeCurve) * // curve 0=square, 2=pointy | ||
volume * zzfxV * ( // envelope | ||
i < attack ? i/attack : // attack | ||
i < attack + decay ? // decay | ||
1-((i-attack)/decay)*(1-sustainVolume) : // decay falloff | ||
i < attack + decay + sustain ? // sustain | ||
sustainVolume : // sustain volume | ||
i < length - delay ? // release | ||
(length - i - delay)/release * // release falloff | ||
sustainVolume : // release volume | ||
0); // post release | ||
s = delay ? s/2 + (delay > i ? 0 : // delay | ||
(i<length-delay? 1 : (length-i)/delay) * // release delay | ||
b[i-delay|0]/2) : s; // sample delay | ||
} | ||
sign(s)*(Math.abs(s)**shapeCurve) * // curve | ||
(i < attack ? i/attack : // attack | ||
i < attack + decay ? // decay | ||
1-((i-attack)/decay)*(1-sustainVolume) : // decay falloff | ||
i < attack + decay + sustain ? // sustain | ||
sustainVolume : // sustain volume | ||
i < length - delay ? // release | ||
(length - i - delay)/release * // release falloff | ||
sustainVolume : // release volume | ||
0); // post release | ||
f = (frequency += slide += deltaSlide) * // frequency | ||
Math.cos(modulation*tm++); // modulation | ||
t += f - f*noise*(1 - (Math.sin(i)+1)*1e9%2); // noise | ||
s = delay ? s/2 + (delay > i ? 0 : // delay | ||
(i<length-delay? 1 : (length-i)/delay) * // release delay | ||
b[i-delay|0]/2/volume) : s; // sample delay | ||
if (j && ++j > pitchJumpTime) // pitch jump | ||
{ | ||
frequency += pitchJump; // apply pitch jump | ||
startFrequency += pitchJump; // also apply to start | ||
j = 0; // reset pitch jump time | ||
if (filter) // apply filter | ||
s = y1 = b2*x2 + b1*(x2=x1) + b0*(x1=s) - a2*y2 - a1*(y2=y1); | ||
} | ||
if (repeatTime && !(++r % repeatTime)) // repeat | ||
{ | ||
frequency = startFrequency; // reset frequency | ||
slide = startSlide; // reset slide | ||
j = j || 1; // reset pitch jump time | ||
f = (frequency += slide += deltaSlide) *// frequency | ||
Math.cos(modulation*tm++); // modulation | ||
t += f + f*noise*Math.sin(i**5); // noise | ||
if (j && ++j > pitchJumpTime) // pitch jump | ||
{ | ||
frequency += pitchJump; // apply pitch jump | ||
startFrequency += pitchJump; // also apply to start | ||
j = 0; // stop pitch jump time | ||
} | ||
if (repeatTime && !(++r % repeatTime)) // repeat | ||
{ | ||
frequency = startFrequency; // reset frequency | ||
slide = startSlide; // reset slide | ||
j = j || 1; // reset pitch jump time | ||
} | ||
@@ -118,0 +131,0 @@ } |
@@ -1,24 +0,17 @@ | ||
// ZzFX - Zuper Zmall Zound Zynth - Micro Edition | ||
// MIT License - Copyright 2019 Frank Force | ||
// https://github.com/KilledByAPixel/ZzFX | ||
// This is a tiny build of zzfx with only a zzfx function to play sounds. | ||
// You can use zzfxV to set volume. | ||
// Feel free to minify it further for your own needs! | ||
'use strict';let zzfx,zzfxV,zzfxX | ||
// ZzFXMicro - Zuper Zmall Zound Zynth - v1.2.3 by Frank Force ~ 887 bytes | ||
zzfxV=.3 // volume | ||
zzfx= // play sound | ||
(p=1,k=.05,b=220,e=0,r=0,t=.1,q=0,D=1,u=0,y=0,v=0,z=0,l=0,E=0,A=0,F=0,c=0,w=1,m= | ||
0,B=0)=>{let M=Math,R=44100,d=2*M.PI,G=u*=500*d/R/R,C=b*=(1-k+2*k*M.random(k=[])) | ||
*d/R,g=0,H=0,a=0,n=1,I=0,J=0,f=0,x,h;e=R*e+9;m*=R;r*=R;t*=R;c*=R;y*=500*d/R**3; | ||
A*=d/R;v*=d/R;z*=R;l=R*l|0;for(h=e+m+r+t+c|0;a<h;k[a++]=f)++J%(100*F|0)||(f=q?1<q | ||
?2<q?3<q?M.sin((g%d)**3):M.max(M.min(M.tan(g),1),-1):1-(2*g/d%2+2)%2:1-4*M.abs(M. | ||
round(g/d)-g/d):M.sin(g),f=(l?1-B+B*M.sin(d*a/l):1)*(0<f?1:-1)*M.abs(f)**D*zzfxV | ||
*p*(a<e?a/e:a<e+m?1-(a-e)/m*(1-w):a<e+m+r?w:a<h-c?(h-a-c)/t*w:0),f=c?f/2+(c>a?0: | ||
(a<h-c?1:(h-a)/c)*k[a-c|0]/2):f),x=(b+=u+=y)*M.cos(A*H++),g+=x-x*E*(1-1E9*(M.sin | ||
(a)+1)%2),n&&++n>z&&(b+=v,C+=v,n=0),!l||++I%l||(b=C,u=G,n=n||1);p=zzfxX. | ||
createBuffer(1,h,R);p.getChannelData(0).set(k);b=zzfxX.createBufferSource();b. | ||
buffer=p;b.connect(zzfxX.destination);b.start();return b};zzfxX=new AudioContext; | ||
'use strict'; | ||
let // ZzFXMicro - Zuper Zmall Zound Zynth - v1.3.0 by Frank Force ~ 1000 bytes | ||
zzfxV=.3, // volume | ||
zzfxX=new AudioContext, // audio context | ||
zzfx= // play sound | ||
(p=1,k=.05,b=220,e=0,r=0,t=.1,q=0,D=1,u=0,y=0,v=0,z=0,l=0,E=0,A=0,F=0,c=0,w=1,m=0,B=0 | ||
,N=0)=>{let M=Math,d=2*M.PI,R=44100,G=u*=500*d/R/R,C=b*=(1-k+2*k*M.random(k=[]))*d/R, | ||
g=0,H=0,a=0,n=1,I=0,J=0,f=0,h=N<0?-1:1,x=d*h*N*2/R,L=M.cos(x),Z=M.sin,K=Z(x)/4,O=1+K, | ||
X=-2*L/O,Y=(1-K)/O,P=(1+h*L)/2/O,Q=-(h+L)/O,S=P,T=0,U=0,V=0,W=0;e=R*e+9;m*=R;r*=R;t*= | ||
R;c*=R;y*=500*d/R**3;A*=d/R;v*=d/R;z*=R;l=R*l|0;p*=zzfxV;for(h=e+m+r+t+c|0;a<h;k[a++] | ||
=f*p)++J%(100*F|0)||(f=q?1<q?2<q?3<q?Z(g*g):M.max(M.min(M.tan(g),1),-1):1-(2*g/d%2+2) | ||
%2:1-4*M.abs(M.round(g/d)-g/d):Z(g),f=(l?1-B+B*Z(d*a/l):1)*(f<0?-1:1)*M.abs(f)**D*(a< | ||
e?a/e:a<e+m?1-(a-e)/m*(1-w):a<e+m+r?w:a<h-c?(h-a-c)/t*w:0),f=c?f/2+(c>a?0:(a<h-c?1:(h | ||
-a)/c)*k[a-c|0]/2/p):f,N?f=W=S*T+Q*(T=U)+P*(U=f)-Y*V-X*(V=W):0),x=(b+=u+=y)*M.cos(A* | ||
H++),g+=x+x*E*Z(a**5),n&&++n>z&&(b+=v,C+=v,n=0),!l||++I%l||(b=C,u=G,n=n||1);p=zzfxX. | ||
createBuffer(1,h,R);p.getChannelData(0).set(k);b=zzfxX.createBufferSource(); | ||
b.buffer=p;b.connect(zzfxX.destination);b.start()} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97438
371
99
11