Page 3 of 3

Re: Molding a tone to a given audio sample (matching silence

Posted: Fri Aug 28, 2009 1:19 am
by steve
Storer wrote:Was just looking at this thread and noticed the rather complex code for a half-wave rectifier.

There is already such a function built into Nyquist: (s-max sound1 sound2). This takes two sounds (mono or multi-channel), or a sound and a FLONUM (or two FLONUM's for that matter) and for corresponding samples in the sounds, it returns the maximum. So the expression (s-max s 0.0) will replace all the negative valued samples with zero.

To grab only the negative side of the signal, use (s-min s 0.0).
That's true, but it does not solve the original issue (see the first post in the thread). The half wave rectifier was only one part of the job - the code in the previous post does more than that.