Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
KilledByAPixel authored Jul 18, 2020
1 parent 1766869 commit 676fd20
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions ZzFX.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ BuildSamples
// init parameters
let PI2 = Math.PI*2,
sampleRate = this.sampleRate,
random =r=> 1 + r*2*Math.random() - r,
sign = v => v>0?1:-1,
startSlide = slide *= 500 * PI2 / sampleRate**2,
modPhase = sign(modulation) * PI2/4,
startFrequency = frequency *= random(randomness) * PI2 / sampleRate;
startFrequency = frequency *= (1 + randomness*2*Math.random() - randomness)
* PI2 / sampleRate;

// scale by sample rate
attack = 99 + attack * sampleRate; // soften attack
Expand Down Expand Up @@ -171,9 +171,9 @@ BuildSamples
b[i-delay|0]/2) : s; // sample delay
}

t += random(noise); // noise
tm += random(noise); // modulation noise
frequency += slide += deltaSlide; // frequency slide
t += 1 - noise + (Math.sin(i)+1)*1e9%2*noise; // noise
tm += 1 - noise + (Math.sin(i)**2+1)*1e9%2*noise; // modulation noise
frequency += slide += deltaSlide; // frequency slide

if (j && ++j > pitchJumpTime) // pitch jump
{
Expand Down Expand Up @@ -343,11 +343,11 @@ const zzfxP = // play a sound
decay = decayIn * sampleRate,
delay = delayIn * sampleRate,
PI2 = Math.PI*2,
random =r=> 1 + r*2*Math.random() - r,
sign =v=> v>0? 1 : -1,
length = attack + decay + sustain + release + delay,
startSlide = slide *= 500 * PI2 / sampleRate**2,
startFrequency = frequency *= random(randomness) * PI2 / sampleRate,
startFrequency = frequency *= (1 + randomness*2*Math.random() - randomness)
* PI2 / sampleRate,
modPhase = sign(modulation) * PI2/4,
t=0, tm=0, i=0, r=0, c=0, s=0, j=1, b = [],
source = zzfxX.createBufferSource(),
Expand Down Expand Up @@ -387,8 +387,8 @@ const zzfxP = // play a sound
b[i - delay|0]/2) : s; // sample delay
}

t += random(noise); // noise
tm += random(noise); // modulation noise
t += 1 - noise + (Math.sin(i)+1)*1e9%2*noise; // noise
tm += 1 - noise + (Math.sin(i)**2+1)*1e9%2*noise; // modulation noise
frequency += slide += deltaSlide // frequency slide
* 500 * PI2 / sampleRate**3; // apply sample rate

Expand Down
2 changes: 1 addition & 1 deletion ZzFX.micro.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// ZzFXMicro - Zuper Zmall Zound Zynth
zzfxV=.3 // volume
zzfx= // play sound
(t=1,a=.05,n=220,e=0,f=0,r=.1,h=0,o=1,M=0,s=0,z=0,i=0,u=0,c=0,x=0,d=0,X=0,b=1,m=0,l=44100,B=99+e*l,C=f*l,P=r*l,g=m*l,w=X*l,A=2*Math.PI,D=(t=>1+2*t*Math.random()-t),I=(t=>0<t?1:-1),S=B+g+C+P+w,j=(M*=500*A/l**2),k=(n*=D(a)*A/l),p=I(x)*A/4,q=0,v=0,y=0,E=0,F=0,G=0,H=1,J=[],K=zzfxX.createBufferSource(),L=zzfxX.createBuffer(1,S,l))=>{for(K.connect(zzfxX.destination);y<S;J[y++]=G)++F>100*d&&(F=0,G=q*n*Math.sin(v*x*A/l-p),G=I(G=h?1<h?2<h?3<h?Math.sin((G%A)**3):Math.max(Math.min(Math.tan(G),1),-1):1-(2*G/A%2+2)%2:1-4*Math.abs(Math.round(G/A)-G/A):Math.sin(G))*Math.abs(G)**o*t*.3*(y<B?y/B:y<B+g?1-(y-B)/g*(1-b):y<B+g+C?b:y<S-w?(S-y-w)/P*b:0),G=w?G/2+(w>y?0:(y<S-w?1:(y-S)/w)*J[y-w|0]/2):G),q+=D(c),v+=D(c),n+=M+=500*s*A/l**3,H&&++H>i*l&&(n+=z*A/l,k+=z*A/l,H=0),u&&++E>u*l&&(n=k,M=j,E=1,H=H||1);return L.getChannelData(0).set(J),K.buffer=L,K.start(),K};zzfxX=new AudioContext
(t=1,a=.05,n=220,e=0,f=0,h=.1,M=0,r=1,z=0,o=0,i=0,s=0,u=0,x=0,c=0,d=0,X=0,b=1,m=0,l=44100,B=99+e*l,C=f*l,P=h*l,g=m*l,w=X*l,A=2*Math.PI,D=(t=>0<t?1:-1),I=B+g+C+P+w,S=(z*=500*A/l**2),V=(n*=(1+2*a*Math.random()-a)*A/l),j=D(c)*A/4,k=0,p=0,q=0,v=0,y=0,E=0,F=1,G=[],H=zzfxX.createBufferSource(),J=zzfxX.createBuffer(1,I,l))=>{for(H.connect(zzfxX.destination);q<I;G[q++]=E)++y>100*d&&(y=0,E=k*n*Math.sin(p*c*A/l-j),E=D(E=M?1<M?2<M?3<M?Math.sin((E%A)**3):Math.max(Math.min(Math.tan(E),1),-1):1-(2*E/A%2+2)%2:1-4*Math.abs(Math.round(E/A)-E/A):Math.sin(E))*Math.abs(E)**r*t*zzfxV*(q<B?q/B:q<B+g?1-(q-B)/g*(1-b):q<B+g+C?b:q<I-w?(I-q-w)/P*b:0),E=w?E/2+(w>q?0:(q<I-w?1:(q-I)/w)*G[q-w|0]/2):E),k+=1-x+1e9*(Math.sin(q)+1)%2*x,p+=1-x+1e9*(Math.sin(q)**2+1)%2*x,n+=z+=500*o*A/l**3,F&&++F>s*l&&(n+=i*A/l,V+=i*A/l,F=0),u&&++v>u*l&&(n=V,z=S,v=1,F=F||1);return J.getChannelData(0).set(G),H.buffer=J,H.start(),H},zzfxX=new AudioContext

// fix compatibility issues with old web audio (optional)
//zzfxX=new(window.AudioContext||webkitAudioContext);zzfxX.Z=zzfxX.createBufferSource;zzfxX.createBufferSource=(s=zzfxX.Z())=>(s.start=s.start||(t=>zzfxX.noteOn(t)),s.stop=s.stop||(t=>zzfxX.noteOff(t)),s)
2 changes: 1 addition & 1 deletion ZzFX.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
ZzFX © <a href=http://www.frankforce.com target=_blank>Frank Force</a> 2019 ☮♥☻␌
<a hidden id=a_downloadLink></a>
<input hidden id=input_importFile type=file accept=.txt>
<script src=ZzFX.js?925></script>
<script src=ZzFX.js?926></script>
<script>

'use strict'; // strict mode
Expand Down

0 comments on commit 676fd20

Please sign in to comment.