sox-devel@lists.sourceforge.net unofficial mirror
 help / color / mirror / code / Atom feed
* silence additional patch
@ 2020-09-06  4:16 fbk-qriry
  2020-09-06 11:23 ` Måns Rullgård
  0 siblings, 1 reply; 8+ messages in thread
From: fbk-qriry @ 2020-09-06  4:16 UTC (permalink / raw)
  To: sox-devel


Further to my previous "silence" patch I have discovered
that there is another error involving the rms calculations.

Initially, and after a reset, the rms sample window is empty
yet the rms calculation always uses the window size as
the calculation denominator. This will make the rms
value appear artificially low to start with. Instead, an
actual count of samples should be used.

Incidentally, I think that the hard-coded 1/50 for selection
of a window size should also be parametized. Sometimes a size using
1/20 (100 milliseconds when stereo) can be more appropriate than the
very small 40 millisecond hard-coded sample window size.

The following is the updated patch:

===================================================================
--- sox-downstream-sox-14.4.2.0.modified/src/silence.c.jw
+++ sox-downstream-sox-14.4.2.0.modified/src/silence.c
@@ -55,6 +55,7 @@
     double      *window_current;
     double      *window_end;
     size_t   window_size;
+    size_t   window_count;
     double      rms_sum;
 
     char        leave_silence;
@@ -73,6 +74,7 @@
 
     silence->window_current = silence->window;
     silence->window_end = silence->window + silence->window_size;
+    silence->window_count = 0;
     silence->rms_sum = 0;
 }
 
@@ -277,9 +279,15 @@
 {
   /* When scaling low bit data, noise values got scaled way up */
   /* Only consider the original bits when looking for silence */
-  sox_sample_t masked_value = value & (-1 << (32 - effp->in_signal.precision));
+  double scaled_value;
+  sox_sample_t rounded_value = value;
 
-  double scaled_value = (double)masked_value / SOX_SAMPLE_MAX;
+  /* before we mask we should round the value (a sqrt irrational) */
+  if (effp->in_signal.precision < 32)
+    rounded_value += (1 << (32 - effp->in_signal.precision - 1));
+  rounded_value &= (-1 << (32 - effp->in_signal.precision));
+
+  scaled_value = (double)rounded_value / SOX_SAMPLE_MAX;
 
   if (unit == '%')
     scaled_value *= 100;
@@ -294,12 +302,17 @@
     priv_t * silence = (priv_t *) effp->priv;
     double new_sum;
     sox_sample_t rms;
+    size_t count;
 
     new_sum = silence->rms_sum;
     new_sum -= *silence->window_current;
     new_sum += ((double)sample * (double)sample);
 
-    rms = sqrt(new_sum / silence->window_size);
+    count = silence->window_count;
+    if (count < silence->window_size)
+	count++;
+
+    rms = sqrt(new_sum / count);
 
     return (rms);
 }
@@ -315,6 +328,9 @@
     silence->window_current++;
     if (silence->window_current >= silence->window_end)
         silence->window_current = silence->window;
+
+    if (silence->window_count < silence->window_size)
+	silence->window_count++;
 }
 
 /* Process signed long samples from ibuf to obuf. */
===================================================================

:JW



_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: silence additional patch
  2020-09-06  4:16 silence additional patch fbk-qriry
@ 2020-09-06 11:23 ` Måns Rullgård
  2020-09-06 11:50   ` fbk-qriry
  2020-09-06 11:58   ` fbk-qriry
  0 siblings, 2 replies; 8+ messages in thread
From: Måns Rullgård @ 2020-09-06 11:23 UTC (permalink / raw)
  To: fbk-qriry; +Cc: sox-devel

fbk-qriry@zacglen.net writes:

> Further to my previous "silence" patch I have discovered
> that there is another error involving the rms calculations.
>
> Initially, and after a reset, the rms sample window is empty
> yet the rms calculation always uses the window size as
> the calculation denominator. This will make the rms
> value appear artificially low to start with. Instead, an
> actual count of samples should be used.
>
> Incidentally, I think that the hard-coded 1/50 for selection
> of a window size should also be parametized. Sometimes a size using
> 1/20 (100 milliseconds when stereo) can be more appropriate than the
> very small 40 millisecond hard-coded sample window size.
>
> The following is the updated patch:

I'm certainly not going to take a patch with several unrelated changes
as is, nor am I going to do the work unravelling what's what.

-- 
Måns Rullgård


_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: silence additional patch
  2020-09-06 11:23 ` Måns Rullgård
@ 2020-09-06 11:50   ` fbk-qriry
  2020-09-06 12:45     ` Måns Rullgård
  2020-09-06 11:58   ` fbk-qriry
  1 sibling, 1 reply; 8+ messages in thread
From: fbk-qriry @ 2020-09-06 11:50 UTC (permalink / raw)
  To: mans; +Cc: sox-devel

>fbk-qriry@zacglen.net writes:
>
>> Further to my previous "silence" patch I have discovered
>> that there is another error involving the rms calculations.
>>
>> Initially, and after a reset, the rms sample window is empty
>> yet the rms calculation always uses the window size as
>> the calculation denominator. This will make the rms
>> value appear artificially low to start with. Instead, an
>> actual count of samples should be used.
>>
>> Incidentally, I think that the hard-coded 1/50 for selection
>> of a window size should also be parametized. Sometimes a size using
>> 1/20 (100 milliseconds when stereo) can be more appropriate than the
>> very small 40 millisecond hard-coded sample window size.
>>
>> The following is the updated patch:
>
>I'm certainly not going to take a patch with several unrelated changes
>as is, nor am I going to do the work unravelling what's what.
>
>-- 
>Mns Rullgrd
>

Perhaps that is why there are still so many blatant bugs in sox
after all of these years?

I have only started looking and I am sure I can find many
many more.

It is entirely up to you. I feed information into your brain
and if your brain is incapable or unwilling to digest any of it
then that is entirely your problem.

Please bear in mind that sox currently contains hundred of
related and unrelated lines of code. And that doesn't stop
sox from working does it? Unrelatedness has never been
an obstacle in the past has it?

Anyhow would you care to introduce yourself and explain how
it is that you have apparently become the sole arbiter of what
is good or bad for sox.

Incidentally, I can very easily patch sox entirely for my own
benefit and there is no compulsion for me to publish such
private changes on any public forum. I only do that out of
the goodness of my heart. The patches merely serve as a convenient
way of explaining the bugs in more detail. Once a person such as
your kind self has availed him- or her-self of the wisdom of my discoveries
then your good person is freely available to work very hard at finding
some good reason to cast aspersions upon my discoveries. But I would
submit that the easier path would be to take my discoveries on board
and make good use of what has cost me in time and effort, at no
cost to yourself.

:JW



_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: silence additional patch
  2020-09-06 11:23 ` Måns Rullgård
  2020-09-06 11:50   ` fbk-qriry
@ 2020-09-06 11:58   ` fbk-qriry
  1 sibling, 0 replies; 8+ messages in thread
From: fbk-qriry @ 2020-09-06 11:58 UTC (permalink / raw)
  To: mans; +Cc: sox-devel

>
>> Further to my previous "silence" patch I have discovered
>> that there is another error involving the rms calculations.
>>
>> Initially, and after a reset, the rms sample window is empty
>> yet the rms calculation always uses the window size as
>> the calculation denominator. This will make the rms
>> value appear artificially low to start with. Instead, an
>> actual count of samples should be used.
>>
>> Incidentally, I think that the hard-coded 1/50 for selection
>> of a window size should also be parametized. Sometimes a size using
>> 1/20 (100 milliseconds when stereo) can be more appropriate than the
>> very small 40 millisecond hard-coded sample window size.
>>
>> The following is the updated patch:
>
>I'm certainly not going to take a patch with several unrelated changes
>as is, nor am I going to do the work unravelling what's what.
>

I might also point out that the two issues I have rasied apply
to the one same file, namely silence.c. Since patches must be
applied in the correct order, and since you appear to
unconditionally and irrationally rejected my first patch then
I cannot possibly issue a patch that depends on the prior patch.

Therefore it makes a lot of sense to submit an cumulative patch.

:JW



_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: silence additional patch
  2020-09-06 11:50   ` fbk-qriry
@ 2020-09-06 12:45     ` Måns Rullgård
  2020-09-06 12:50       ` fbk-qriry
  0 siblings, 1 reply; 8+ messages in thread
From: Måns Rullgård @ 2020-09-06 12:45 UTC (permalink / raw)
  To: fbk-qriry; +Cc: sox-devel

fbk-qriry@zacglen.net writes:

>>fbk-qriry@zacglen.net writes:
>>
>>> Further to my previous "silence" patch I have discovered
>>> that there is another error involving the rms calculations.
>>>
>>> Initially, and after a reset, the rms sample window is empty
>>> yet the rms calculation always uses the window size as
>>> the calculation denominator. This will make the rms
>>> value appear artificially low to start with. Instead, an
>>> actual count of samples should be used.
>>>
>>> Incidentally, I think that the hard-coded 1/50 for selection
>>> of a window size should also be parametized. Sometimes a size using
>>> 1/20 (100 milliseconds when stereo) can be more appropriate than the
>>> very small 40 millisecond hard-coded sample window size.
>>>
>>> The following is the updated patch:
>>
>>I'm certainly not going to take a patch with several unrelated changes
>>as is, nor am I going to do the work unravelling what's what.
>>
>>-- 
>>Mns Rullgrd
>>
>
> Perhaps that is why there are still so many blatant bugs in sox
> after all of these years?
>
> I have only started looking and I am sure I can find many
> many more.
>
> It is entirely up to you. I feed information into your brain
> and if your brain is incapable or unwilling to digest any of it
> then that is entirely your problem.
>
> Please bear in mind that sox currently contains hundred of
> related and unrelated lines of code. And that doesn't stop
> sox from working does it? Unrelatedness has never been
> an obstacle in the past has it?
>
> Anyhow would you care to introduce yourself and explain how
> it is that you have apparently become the sole arbiter of what
> is good or bad for sox.
>
> Incidentally, I can very easily patch sox entirely for my own
> benefit and there is no compulsion for me to publish such
> private changes on any public forum. I only do that out of
> the goodness of my heart. The patches merely serve as a convenient
> way of explaining the bugs in more detail. Once a person such as
> your kind self has availed him- or her-self of the wisdom of my discoveries
> then your good person is freely available to work very hard at finding
> some good reason to cast aspersions upon my discoveries. But I would
> submit that the easier path would be to take my discoveries on board
> and make good use of what has cost me in time and effort, at no
> cost to yourself.

If that's the attitude you're going to display, I will have to ask you
to kindly go away until such time as you are able to engage in a polite
conversation.  Perhaps you could use that time to study good software
development practices.

-- 
Måns Rullgård


_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: silence additional patch
  2020-09-06 12:45     ` Måns Rullgård
@ 2020-09-06 12:50       ` fbk-qriry
  2020-09-06 14:00         ` Cary Lewis
  0 siblings, 1 reply; 8+ messages in thread
From: fbk-qriry @ 2020-09-06 12:50 UTC (permalink / raw)
  To: mans; +Cc: sox-devel

>
>If that's the attitude you're going to display, I will have to ask you
>to kindly go away until such time as you are able to engage in a polite
>conversation.  Perhaps you could use that time to study good software
>development practices.
>

Please remove all of my posts from your server.

:JW



_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: silence additional patch
  2020-09-06 12:50       ` fbk-qriry
@ 2020-09-06 14:00         ` Cary Lewis
  2020-09-07 11:32           ` Måns Rullgård
  0 siblings, 1 reply; 8+ messages in thread
From: Cary Lewis @ 2020-09-06 14:00 UTC (permalink / raw)
  To: sox-devel

Please, for the sake of the software, find a way to be civil to each other.

Perhaps a SOX code of conduct is in order?

> On Sep 6, 2020, at 8:50 AM, fbk-qriry@zacglen.net wrote:
> 
> 
>> 
>> 
>> If that's the attitude you're going to display, I will have to ask you
>> to kindly go away until such time as you are able to engage in a polite
>> conversation.  Perhaps you could use that time to study good software
>> development practices.
>> 
> 
> Please remove all of my posts from your server.
> 
> :JW
> 
> 
> 
> _______________________________________________
> SoX-devel mailing list
> SoX-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sox-devel


_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: silence additional patch
  2020-09-06 14:00         ` Cary Lewis
@ 2020-09-07 11:32           ` Måns Rullgård
  0 siblings, 0 replies; 8+ messages in thread
From: Måns Rullgård @ 2020-09-07 11:32 UTC (permalink / raw)
  To: Cary Lewis; +Cc: sox-devel

Cary Lewis <cary.lewis@gmail.com> writes:

> Please, for the sake of the software, find a way to be civil to each other.

It's a shame he felt the need to be so rude.

> Perhaps a SOX code of conduct is in order?

Not if I can help it.

-- 
Måns Rullgård


_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-09-07 11:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-06  4:16 silence additional patch fbk-qriry
2020-09-06 11:23 ` Måns Rullgård
2020-09-06 11:50   ` fbk-qriry
2020-09-06 12:45     ` Måns Rullgård
2020-09-06 12:50       ` fbk-qriry
2020-09-06 14:00         ` Cary Lewis
2020-09-07 11:32           ` Måns Rullgård
2020-09-06 11:58   ` fbk-qriry

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/sox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).