loov / jsfx

Javascript Sound Effect Generator
MIT License
576 stars 49 forks source link

Sound signal appears to be cut-off #10

Closed yurivict closed 9 years ago

yurivict commented 9 years ago

I generated the signal, looked at it in sweep, and it appears that sound shapes are cut-off, as if they were artificially limited.

Natural sound shapes usually look round and smooth, including at the top and at the bottom. But your shape is very different.

I grabbed the sound redirecting chrome sound output into the null sink and saving the output.

egonelbre commented 9 years ago

I'm not quite sure what you mean. Can you upload the thing you are getting from JSFX and the sound you were expecting.

But, yes, there are max/min limits frequency 30Hz-1800Hz.

yurivict commented 9 years ago

I e-mailed you the testcase. Open it in sweep, and zoom it in at 2.400 sec.

It is obviously cut-off in amplitude (not frequency). Cut-off can be seen in both general sound shape (over 20ms period), and individual oscillation bursts (over 0.2ms period).

egonelbre commented 9 years ago

This happens when you set decay to 0, i.e. there is no smoothing to zero for sounds. If decay isn't 0, can you please send me the link for the params. I.e. press "Add" next to "Play" button... and then copy the URL you have.

yurivict commented 9 years ago

I don't know what the parameters were when I generated it. I changed some of them from the default. (My purpose was to generate the short-term, semi-regular signal. But when I looked at the result I saw this problem.)

But no matter what parameters are, it shouldn't clip the amplitude. If you look at any natural sound, you won't see such thing.

egonelbre commented 9 years ago

jsfx is specifically designed to generate chip-tune/old-school sounds; not natural sounds.

Assuming it was the decay issue... It doesn't clip the amplitude, it follows the envelope https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope ... note jsfx uses a different naming (attack, punch, sustain, decay)... If you don't have time set for release/decay the amplitude, it won't smoothly go to zero... it isn't clipping; the sound just ends at a non-zero point.

However I do understand your concern. For your use-case, the fix is simple, don't use decay=0.

As whether to fix the default params... I have to think about it. Such artifacts are fine in a chip-tune or old-school sound. I can imagine theoretical cases where people would want them... but, I'm also leaning towards fixing the attributes, but I'll make the final decision tomorrow.

yurivict commented 9 years ago

I just needed a one-time sample. But I looked at the natural sounds a lot, that's why this artifact immediately caught my eye. It could also be the PulseAudio issue, not sure. It would have been nice if jsfx could save the .wav file so that no external agents would be needed.

So if this is really the issue of the out-of-band sound signal coming from jsfx, this needs to be fixed in some way.

egonelbre commented 9 years ago

It should sound better now, but there still might be very small pop, when the attack or decay is very low... it is as it should be.