By Frank Force 2019
// ZzFXmicro - Zuper Zmall Zound Zynth - MIT License - Copyright 2019 Frank Force
zzfx_v=.5;zzfx_x=new AudioContext;zzfx=(g,h,a,b=1,c=.1,k=0,f=0,l=0,m=0)=>{let q=44100,Q=Q=>Q*(Math.random()*2-1),d=2*Math.PI;a=d/q*a*(1+Q(h));k*=500*d/q**2;b=q*b|0;c=c*b|0;l=d/q*l;m=d/2*m;h=[];for(let n=d=0,e=0;e<b;++e)h[e]=g*zzfx_v*Math.cos(d*a*Math.cos(n*l+m))*(e<c?e/c:1-(e-c)/(b-c)),d+=1+Q(f),n+=1+Q(f),a+=k;g=zzfx_x.createBuffer(1,b,q);a=zzfx_x.createBufferSource();g.getChannelData(0).set(h);a.buffer=g;a.connect(zzfx_x.destination);a.start()}
- Tiny synth engine with 9 controllable parameters.
- Small code footprint for full version and the micro version is under 500 bytes!
- Can produce a wide variety of sound effect types.
- Seeded sounds can be played with a tiny function call, ex: ZZFX.z(6)
- Seeded sound paramerters can be overridden, ex: ZZFX.z(26,{frequency:600})
- Random number generator ZZFX.R() can be used in place of Math.random().
- Use ZZFX.Note to get music frequencies, ex: ZZFX.Note(440, 7) // 7 semitons above A4 aka E4
- Generate random sounds from seed.
- Stores sounds in list with local storage persistence.
- Parameters can be modified for more control.
- Lock, reset and mutate buttons for each parameter.
- Displays image of sound wave when played.
- Sounds can be download as a wave file.
- Mark sounds as favorites to keep them from being cleared.
- List of sounds can be exported and imported.
- Supports drag-and-drop of exported files into sound list.