[LAU] Explodomatica - explosion sound effect generator

Jeremy Salwen jeremysalwen at gmail.com
Sat Oct 29 20:56:44 UTC 2011


At the end of the day, you are only getting clipping when you pass the
audio back to libsndfile.  Go to the part of the code right before you call
the libsndfile function to write the audio to the file.  If at that point,
you loop through all the samples, and find the one with the biggest
absolute value, and then loop through again and divide every sample by that
value, you will remove any clipping.   Or you could hard clip it and
instead just set any value >1 to 1.  The fact that you wrote this program
in the first place clearly shows that you have enough understanding to do
either one of these things.

You don't need to know any more about DSP than what I'm telling you now
(and you don't need to know anything about jack):
1. All the samples passed to libsndfile should be between -1<x<+1.
2. If you divide all the samples by the same value, this will make all the
samples lie within a smaller range, and will lower the volume of the audio.

If you're interested in playing around with your computer some more, you
could add code to write out the sound from the intermediate steps, so that
you could see precisely where it is inserted. But this is not necessary at
all, as clipping can be removed easily at any point up until it is written
to file.  All you need it two "for" loops.

Jeremy

On Sat, Oct 29, 2011 at 1:11 AM, Stephen Cameron <smcameron at yahoo.com>wrote:

>
>  Yeah, I know there's a bit of clipping.
>
>  I think it's because I'm summing what amount to a bunch of normalized
> random data -- so some of those sums end up outside -1 < x < +1, though I
> do normalizing steps between sums, so... I don't know exactly where the
> clipping is coming from -- I think it's coming from my "poor man's reverb"
> effect, which, that thing should probably be replaced with something better
> and faster, but... like I said, I don't know JACK about DSP, I'm just
> playing around with my computer and my compiler and my soundcard.
>
>  Best thing ever would be to send me a patch!
>
>  -- steve
>
>
> ------------------------------
> *From:* Jeremy Salwen <jeremysalwen at gmail.com>
> *To:* Stephen Cameron <smcameron at yahoo.com>
> *Cc:* "linux-audio-user at lists.linuxaudio.org" <
> linux-audio-user at lists.linuxaudio.org>
> *Sent:* Friday, October 28, 2011 9:09 PM
> *Subject:* Re: [LAU] Explodomatica - explosion sound effect generator
>
> Very cool.  I was playing around with it.  I do have one suggestion
> though: It seems you are introducing unwanted artifacts due to clipping.
>
> First, you probably don't want clipping.  However, it is showing up, even
> in your demo samples.
>
> Second, you might want clipping (Probably we've ingrained digital clipping
> in our perception of explosion sounds), but if you do, you're not clipping
> in the right way.  I haven't looked at your code, but because I had the
> exact same symptoms while using libsndfile, I'm guessing that what you are
> doing is feeding libsndfile floats with values >1 or <-1.  If you want
> proper clipping, these samples would be pulled to the closest value within
> the range [-1,1].  However, due to performance reasons (I'm guessing), this
> is not what libsndfile does, but instead it wraps around.  So 1.1 will be
> interpreted as the amplitude of -0.9.
>
> Here's what it looks like:  http://i.imgur.com/sselM.png
>
> That image is from demo0.wav.  This causes the "clicking" artifacts you
> hear in the file.  In order to fix this, just go through and find any
> samples > 1 and replace them with 1, and similarly with -1, right before
> you write the data out with libsndfile.  This should give you proper
> "chopped peaks" clipping.  Or, if you don't want clipping at all, just
> calculate the max amplitude and divide every sample by it before outputting.
>
> Good luck and thanks,
> Jeremy
>
>
>
> On Fri, Oct 28, 2011 at 2:05 PM, Stephen Cameron <smcameron at yahoo.com>wrote:
>
>
> I made a little explosion sound effect generator, the idea being to help
> out people looking for such things for making video games, and so on.  It
> relies on portaudio, libsndfile, and gtk2.
>
> I don't really know what I'm doing when it comes to DSP, so probably some
> of you will laugh when you see my algorithms.  But it does more or less
> make explosion sounds.
>
> It's here:
> http://smcameron.github.com/explodomatica
>
> Enjoy
>
> -- steve
>
> _______________________________________________
> Linux-audio-user mailing list
> Linux-audio-user at lists.linuxaudio.org
> http://lists.linuxaudio.org/listinfo/linux-audio-user
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxaudio.org/pipermail/linux-audio-user/attachments/20111029/5a3a9006/attachment.htm>


More information about the Linux-audio-user mailing list