KilledByAPixel / ZzFX

A Tiny JavaScript Sound FX System
https://zzfx.3d2k.com
MIT License
585 stars 36 forks source link

Custom modulation function #9

Closed dy closed 3 years ago

dy commented 3 years ago

Right now half-cosine is used for modulation, eg.

zzfx.play(...[,0,1925,,2.4,0,,,,,,,,,2,,,.5])

produces the following spectrogram: image

Would be nice to have another modulation types, eg. sin: image saw: image tri: image

dy commented 3 years ago

although the difference is not so much noticeable. Maybe that needs somewhat generic approach instead. Any param can actually be a curve, not static value. Erlang has nice notion of atoms/tuples, passing them instead of static values would allow for really expressive description:

zzfx.play(...[,0,{linear, 2, 4},,2.4,0,,,,,,,,,{sin, 2},,,.5])

That brings to an idea that some params, like slide etc could be replaced with such "tokens".

KilledByAPixel commented 3 years ago

Nice spectograms! It uses cosine for the modulation, not half cosine, what makes you think that?

The reason I chose cosine over sine is that for slow modulations the cosine is 1 at 0 so the sound will begin at its given frequency rather then ramping in from 0.

You are right though, it would be cool to have more options for this!

dy commented 3 years ago

For spectrograms I used webaudio-viz

dy commented 3 years ago

It uses cosine for the modulation, not half cosine, what makes you think that?

Right, to goes below 0, so f turns to negative, I missed it, thought it does Math.abs somewhere.