Re: CVS commit - 0.95.07
Steve Harris <[email protected]>
| Newsgroups | gmane.comp.audio.jamin.devel |
|---|---|
| Message-ID | <[email protected]> |
On 5 May 2007, at 12:28, Jan Depner wrote:
> On Sat, 2007-05-05 at 12:12 +0100, Steve Harris wrote:
>> On 4 May 2007, at 18:47, Jan Depner wrote:
>>
>>> On Fri, 2007-05-04 at 12:24 -0500, Jan Depner wrote:
>>>> OK, I've got the meters set up for RMS on output and I've got the
>>>> function calls set up in intrim.c to handle it. If someone can
>>>> figure
>>>> out how to compute RMS using Steve's routines -
>>>> http://www.ecs.soton.ac.uk/~swh/rms/ we can get this thing
>>>> working. I
>>>> am assuming that the calls would need to go in the following
>>>> loop in
>>>> process.c :
>>>>
>>>> for (pos = 0; pos < nframes; pos++) {
>>>> for (port = 0; port < nchannels; port++) {
>>>> const float oa = fabs(out[port][pos]);
>>>>
>>>> if (oa > lim_peak[LIM_PEAK_OUT]) {
>>>> lim_peak[LIM_PEAK_OUT] = oa;
>>>> }
>>>> if (oa > out_peak[port]) {
>>>> out_peak[port] = oa;
>>>> }
>>>> }
>>>> }
>>>>
>>>> but I'm probably wrong ;-)
>>>>
>>>
>>> Just for fun I implemented the "naive" RMS in the above loop
>>> and it
>>> looks purty (as we say down here in the South). It's probably not
>>> what
>>> we're looking for but it does prove that I've got the meters and
>>> callbacks set up properly ;-)
>>
>> Great!
>>
>> To hook up the code, you just need to initialise the RMS object with
>> a call to rms_new(), then call rms_run_buffer() on each audio buffer,
>> and the float that you get back is the RMS signal level.
>>
>
> I just put this into process_signal :
>
> for (port = 0 ; port < nchannels ; port++)
> {
> rms *r;
> r = rms_new (sample_rate, 0.1);
>
> rms_peak[port] = rms_run_buffer (r, out[port], nframes);
>
> rms_free (r);
> }
>
> rms_peak is a misnomer but I was just duping the out_peak code and it
> was easier ;-) The RMS meters come up with a value of about -20.0 and
> they don't look quite right to me so I probably did something
> wrong. I
> can commit the changes and then you can take a look to see what's
> wrong
> if you have time.
Unfortunately I'm off to Canada tomorrow, and I'm a bit busy before
then. One immediate problem though is the rms_new(): it needs to be
called once per channel, and the struct needs to be held onto between
calls. You could make them static in the processing function and call
_new if its NULL. eg.
static rms **r = NULL;
if (!r) {
r = malloc(nchannels * sizeof(rms *));
for (port = 0 ; port < nchannels ; port++) {
r[port] = rms_new (sample_rate, 0.1);
}
}
for (port = 0 ; port < nchannels ; port++) {
...
}
the rms_free() can be skipped.
Could also be done in the process initialisation function, if there
is one.
- Steve
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/