Skip to content

Commit

Permalink
fix micro
Browse files Browse the repository at this point in the history
  • Loading branch information
KilledByAPixel authored Jun 17, 2020
1 parent 3c70f7a commit 46983ec
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ZzFX.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ const zzfxP = // play a sound
repeatTime = repeatTimeIn * sampleRate,
length = attack + decay + sustain + release + delay,
b=[], t=0, tm=0, i=0, j=1, r=0, c=0, s=0, d=.5,
source = zzfxX.createBufferSource()
source = zzfxX.createBufferSource(),
buffer = zzfxX.createBuffer(1, length, sampleRate)
)=>
{
// generate waveform
Expand Down Expand Up @@ -414,7 +415,6 @@ const zzfxP = // play a sound
}
}

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

// fix compatibility issues with old web audio (optional)
// if this is used, you must remove the zzfxX=new AudioContext line above!
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,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?914></script>
<script src=ZzFX.js?915></script>
<script>

'use strict'; // strict mode
Expand Down

0 comments on commit 46983ec

Please sign in to comment.