BTW Edgar, below is what I have so far.
If I've got things right to now then I still need to add together normalized energy and normalized edge information.
After that would be the automaton part. Learning as I go.

Roger D. was very helpful and gave me a couple items that may make this all work with different energy calculations:
----------

"All these measures are related -- peak absolute value, average of squared signal, square root of average, etc. For a given type of sound (like speech) peak amplitude is generally a constant factor different from the RMS amplitude, and once you take logs, that constant factor becomes an offset, and whether you work with intensity (amplitude) or power (amplitude squared) is just a scale factor. The "normal" thing is use RMS because RMS squared is average power (energy / time), but it would not be too surprising to use some other related measure.
...
log(x) is monotonic: x > y > 0 => log(x) > log(y), so if you want the max(log(x)) you can take log(max(x)), provided x > 0."
----------

(defun cubic (frame window-size)
    (let    
        (
            (k (/ 27.0 16.0))       
            (i (round (* frame (/ 2581.0 (1- window-size)))))
        )
                (cond ((> i 1290) (setf i 1290)) ((< i -1290) (setf i -1290)))
        (* k (+ (* i i i) (* 2.0 i i) i))
    )
)
(defun energy (s window-size frame-size)
    (scale 4.34294481 (snd-log (snd-avg (mult s s) window-size frame-size OP-AVERAGE)))
)
(defun norm-g (g)
        (setf neg (scale -1 g))
    (setf shift (snd-maxsamp (snd-maxv neg (const 0.0 (snd-length neg 10000000)))))
    (if (> shift 0.0) (setf g (sum g shift)))
    (setf gmax (snd-maxsamp g))
    (scale (/ 20.0 gmax) (diff g gmax))
)
(defun make-filter (rate)
    (setf ar-f (make-array 15))
    (dotimes (i 15)
            (setf frame (- i 7))
            (setf (aref ar-f i) (cubic frame 15))
    )
    (snd-from-array 0 rate ar-f)
)
(setf g (energy s 240 80))
(setf gnorm (norm-g g))
(setf f (make-filter (snd-srate g)))
(setf edge (convolve g f))
(setf edgenorm (scale (/ 1.0 (snd-maxsamp edge)) edge))








-----Original Message-----
From: edgar-rft@web.de
To: Discussion of developing Nyquist plug-ins for Audacity <audacity-nyquist@lists.sourceforge.net>
Sent: Sun, Jun 28, 2009 1:05 am
Subject: Re: [Audacity-nyquist] Is there a signed version of snd-maxsamp or absolute minimum function for sound?

 > Edgar wrote in a former mail:
> You can "invert" a sound (make the negative samples become positive
> and vice versa) by using Nyquist "scale" or "mult" with a factor
> of "-1".

> Thank you but this doesn't work. See my response to Roger.

Sorry, I was cleaning up my mailbox and hadn't realized that Roger
already had answered before.

> All my original audio signals s have absolute amplitudes
> less than 1 so the energy waveform of s is always negative.

I assume you're talking about "normalized float" samples (like used
in Nyquist and Audacity) with maxPeak=1.0, minPeak=-1.0, what leads
to absolute peak values between min=0.0 and max=1.0, so lg(absPeak)
is always negative.

One of the first things I would try whould look like this:

(scale -1 (s-log (s-abs sound)))

> That's a part of the energy normalization they were referring to
> and had me scratching my head way the formula gave only zero and
> negative values.

Who is "they"? Can you tell what document? Is it one of the
CCRMA/JOSIII papers? I wasn't able to find out by reading the
mails from last week.

In Nyquist you often have to "compute around the corner", so maybe
we need to re-arrange the formula, but therefore I would need the
complete context of the original paper.

Other ideas: In Nyquist there is e.g. "snd-avg", which can compute
the RMS-power of blocks of samples.

- edgar

------------------------------------------------------------------------------
_______________________________________________
Audacity-nyquist mailing list
Audacity-nyquist@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist