Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/KilledByAPixel/ZzFX
Browse files Browse the repository at this point in the history
  • Loading branch information
KilledByAPixel committed Aug 19, 2021
2 parents 62abee0 + 93c18aa commit 98a5e2e
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

Here are a few more examples examples...

```
```javascript
zzfx(...[,,925,.04,.3,.6,1,.3,,6.27,-184,.09,.17]); // Game Over
zzfx(...[,,537,.02,.02,.22,1,1.59,-6.98,4.97]); // Heart
zzfx(...[1.5,.8,270,,.1,,1,1.5,,,,,,,,.1,.01]); // Piano
Expand All @@ -32,12 +32,32 @@ zzfx(...[,,129,.01,,.15,,,,,,,,5]); // Drum

![ZzFX Image](/screenshot.png)

## ZzFX Music
## [ZzFX Music](https://keithclark.github.io/ZzFXM/)

- [ZzFX now supports music via ZzFXM by Keith Clark!](https://keithclark.github.io/ZzFXM/)
- Both the player and songs are super tiny and compress well.
- [NoteCraft](https://killedbyapixel.github.io/NoteCraft/) can also export to ZzFXM.

# ZzFX Micro Code

Here's all the code you need to play ZzFX sounds with JavaScript!

```javascript
// ZzFXMicro - Zuper Zmall Zound Zynth - v1.1.7 ~ 884 bytes minified
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*p*zzfxV*(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 (window.AudioContext||webkitAudioContext) // audio context
```

## ZzFX UI Features

- Generates random sounds from presets.
Expand Down

0 comments on commit 98a5e2e

Please sign in to comment.