Re: synth seems to generate "pops"?

Brian Watson <[email protected]> Tue, 25 Mar 2025 13:52:48 -0300
Newsgroups gmane.comp.audio.sox
Message-ID <CAN255p6Mwx8biefPbAJ9TBxa1RBbmHmRSqf5NGJfM7z7fQ0M+A@mail.gmail.com>
--===============9124334526066706868==
Content-Type: multipart/alternative; boundary="000000000000a1236006312d8db0"

--000000000000a1236006312d8db0
Content-Type: text/plain; charset="UTF-8"

On Tue, 25 Mar 2025 at 12:56, Jan Stary <[email protected]> wrote:

> On Mar 25 11:58:15, [email protected] wrote:
> > I'm thinking of using sox's synth capability to make myself a simple
> > hearing tester.  It will play a bunch of tones at various frequencies,
> > channels and volumes and record my response, or not.
>
> What version of SoX is it?
>

 bwatson@puck:~$ sox --version
sox:      SoX v14.4.2
bwatson@puck:~$ dpkg -l | grep alsa
ii  alsa-base                              1.0.25+dfsg-0ubuntu7
           all          ALSA driver configuration files
ii  alsa-topology-conf                     1.2.5.1-2
            all          ALSA topology configuration files
ii  alsa-ucm-conf                          1.2.6.3-1ubuntu1.12
            all          ALSA Use Case Manager configuration files
ii  alsa-utils                             1.2.6-1ubuntu1
           amd64        Utilities for configuring and using ALSA
ii  libsox-fmt-alsa:amd64
 14.4.2+git20190427-2+deb11u2ubuntu0.22.04.1 amd64        SoX alsa format
I/O library
bwatson@puck:~$ uname -a
Linux puck 5.15.0-134-generic #145-Ubuntu SMP Wed Feb 12 20:08:39 UTC 2025
x86_64 x86_64 x86_64 GNU/Linux

> After a bit of reading I have figured that something like this:
> > play -r 44100 -n -t alsa synth 0.5 sin 5000 vol -25dB remix 1 0
> > wrapped into a script with the frequency, gain and remix parameters
> > replaced with variables will work exactly as I had hoped.
>
> Why do you need the 44100 sample rate?
>

Just because it was the sample rate in the example that I learned this
syntax from.


> Why are you only using half a second of sound?
>

Because I want to generate lots (probably hundreds) of tones one after the
other and see if I hear them or not.  Half a second seems long enough that
I should be able to hear it, but not long enough that I waste time
listening once it has been heard.

>
> > Except - when I listen to the generated sounds there is a small pop, or
> > crack, at the start and end of each sound.
>
> I suspect being off the zero crossings:
> Half a second of a 5 kHz sine wave at 44100
> will not result in a full, finished period of the wave.
> You will have "jumps" at the seams.
>
> play -n synth 10 sin 440 gain -3 dcshift 0.5
>

That was REALLY loud for me - I'm glad my headphones were on the desk!

play WARN alsa: can't encode 0-bit Unknown or not applicable

 File Size: 140T
  Encoding: n/a
  Channels: 1 @ 32-bit
Samplerate: 48000Hz
Replaygain: off
  Duration: unknown

In:0.00% 00:00:04.10 [00:00:00.00] Out:193k  [!=====|=====!] Hd:0.0
Clip:49.3k
play WARN dcshift: dcshift clipped 49322 samples; decrease volume?


> > The obvious answer is that this pop/crack comes from ALSA,
> > or my DAC or my headphones.
>
> I don't how that's obvious,
> but I cannot replicate the pops and cracks with my SoX.
>

My experience has been that people tend to blame some external entity
rather than the subject of the question - so, I like to try to rule them
out.


> > The only thing that makes me think that it is sox is that the
> > "vol" given to "synth" changes the volume of the pop/crack.  If I do, for
> > example:
> > play -r 44100 -n -t alsa synth 0.5 sin 5000 vol -100dB remix 1 1
> > I get nothing but silence.
>
> At -100 dB,there is no audible sound,
> so this is not an example of anything.
>

I had suspected that maybe the act of opening or closing the sound device
might be causing the pop I'm hearing.  I believe playing this effectively
silent sound still opens and closes the sound hardware and rules that out?

> I'm taking this as sox being able to open my
> > sound hardware and play the very quiet sound with no pop/crack?
>
> With the line above, you are effectively playing silence.
> There are no pops and cracks in silence.
>

The pop is only at the end - I had suspected that maybe it was the closing
of the sound device/hardware that caused it.


> > I've seen discussion on similar topics where duration of the tone is
> > manipulated to ensure it aligns with write buffers.  I suspect that's the
> > problem I am seeing
>
> Mee too.
>
> play -r 48000 -n synth 10 sin 480
>

I had to add "vol -30dB" so as not to deafen myself - this generates the
same pop at the end.

Brian

--000000000000a1236006312d8db0
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_quote gmail_quote_container"><div dir=
=3D"ltr" class=3D"gmail_attr">On Tue, 25 Mar 2025 at 12:56, Jan Stary &lt;<=
a href=3D"mailto:[email protected]">[email protected]</a>&gt; wrote:<br></div><bloc=
kquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:=
1px solid rgb(204,204,204);padding-left:1ex">On Mar 25 11:58:15, <a href=3D=
"mailto:[email protected]" target=3D"_blank">[email protected]=
m</a> wrote:<br>
&gt; I&#39;m thinking of using sox&#39;s synth capability to make myself a =
simple<br>
&gt; hearing tester.=C2=A0 It will play a bunch of tones at various frequen=
cies,<br>
&gt; channels and volumes and record my response, or not.<br>
<br>
What version of SoX is it?<br></blockquote><div><br></div><div>=C2=A0bwatso=
n@puck:~$ sox --version<br>sox: =C2=A0 =C2=A0 =C2=A0SoX v14.4.2</div><div>b=
watson@puck:~$ dpkg -l | grep alsa<br>ii =C2=A0alsa-base =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A01.0.25+dfsg-0ubuntu7 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0all =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0ALSA driver configuration files<br>ii =C2=A0alsa-topology-conf =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 1.2.5.1-2 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 all =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0ALSA topology configuration files<br>ii =C2=A0alsa-ucm-conf =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A01.2.6.3-1ubuntu1.12 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 all =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0ALSA Use Case Manager configuration files<br>ii =C2=A0alsa-utils =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 1.2.6-1ubuntu1 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0amd64 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0Utilities for configuring and using ALSA<br>ii =C2=
=A0libsox-fmt-alsa:amd64 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A014.4.2+git20190427-2+deb11u2ubuntu0.22.04.1 amd64 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0SoX alsa format I/O library</div><div>bwatson@puck:~$ unam=
e -a<br>Linux puck 5.15.0-134-generic #145-Ubuntu SMP Wed Feb 12 20:08:39 U=
TC 2025 x86_64 x86_64 x86_64 GNU/Linux</div><div><br></div><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid r=
gb(204,204,204);padding-left:1ex">
&gt; After a bit of reading I have figured that something like this:<br>
&gt; play -r 44100 -n -t alsa synth 0.5 sin 5000 vol -25dB remix 1 0<br>
&gt; wrapped into a script with the frequency, gain and remix parameters<br=
>
&gt; replaced with variables will work exactly as I had hoped.<br>
<br>
Why do you need the 44100 sample rate?<br></blockquote><div><br></div><div>=
Just because it was the sample rate in the example that I learned this synt=
ax from.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"m=
argin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left=
:1ex">
Why are you only using half a second of sound?<br></blockquote><div><br></d=
iv><div>Because I want to generate lots (probably hundreds) of tones one af=
ter the other and see if I hear them or not.=C2=A0 Half a second seems long=
 enough that I should be able to hear it, but not long enough that I waste =
time listening once it has been heard. <br></div><blockquote class=3D"gmail=
_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204=
,204);padding-left:1ex">
<br>
&gt; Except - when I listen to the generated sounds there is a small pop, o=
r<br>
&gt; crack, at the start and end of each sound.<br>
<br>
I suspect being off the zero crossings:<br>
Half a second of a 5 kHz sine wave at 44100<br>
will not result in a full, finished period of the wave.<br>
You will have &quot;jumps&quot; at the seams.<br>
<br>
play -n synth 10 sin 440 gain -3 dcshift 0.5<br></blockquote><div><br></div=
><div>That was REALLY loud for me - I&#39;m glad my headphones were on the =
desk!</div><div><br></div><div>play WARN alsa: can&#39;t encode 0-bit Unkno=
wn or not applicable<br><br>=C2=A0File Size: 140T<br>=C2=A0 Encoding: n/a<b=
r>=C2=A0 Channels: 1 @ 32-bit<br>Samplerate: 48000Hz<br>Replaygain: off<br>=
=C2=A0 Duration: unknown<br><br>In:0.00% 00:00:04.10 [00:00:00.00] Out:193k=
 =C2=A0[!=3D=3D=3D=3D=3D|=3D=3D=3D=3D=3D!] Hd:0.0 Clip:49.3k<br>play WARN d=
cshift: dcshift clipped 49322 samples; decrease volume?</div><div>=C2=A0<br=
></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;=
border-left:1px solid rgb(204,204,204);padding-left:1ex">
&gt; The obvious answer is that this pop/crack comes from ALSA,<br>
&gt; or my DAC or my headphones.<br>
<br>
I don&#39;t how that&#39;s obvious,<br>
but I cannot replicate the pops and cracks with my SoX.<br></blockquote><di=
v><br></div><div>My experience has been that people tend to blame some exte=
rnal entity rather than the subject of the question - so, I like to try to =
rule them out.</div><div>=C2=A0<br></div><blockquote class=3D"gmail_quote" =
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pa=
dding-left:1ex">
&gt; The only thing that makes me think that it is sox is that the<br>
&gt; &quot;vol&quot; given to &quot;synth&quot; changes the volume of the p=
op/crack.=C2=A0 If I do, for<br>
&gt; example:<br>
&gt; play -r 44100 -n -t alsa synth 0.5 sin 5000 vol -100dB remix 1 1<br>
&gt; I get nothing but silence.<br>
<br>
At -100 dB,there is no audible sound,<br>
so this is not an example of anything.<br></blockquote><div><br></div><div>=
I had suspected that maybe the act of opening or closing the sound device m=
ight be causing the pop I&#39;m hearing.=C2=A0 I believe playing this effec=
tively silent sound still opens and closes the sound hardware and rules tha=
t out?</div><div><br></div><blockquote class=3D"gmail_quote" style=3D"margi=
n:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex=
">
&gt; I&#39;m taking this as sox being able to open my<br>
&gt; sound hardware and play the very quiet sound with no pop/crack?<br>
<br>
With the line above, you are effectively playing silence.<br>
There are no pops and cracks in silence.<br></blockquote><div><br></div><di=
v>The pop is only at the end - I had suspected that maybe it was the closin=
g of the sound device/hardware that caused it.</div><div>=C2=A0<br></div><b=
lockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-le=
ft:1px solid rgb(204,204,204);padding-left:1ex">
&gt; I&#39;ve seen discussion on similar topics where duration of the tone =
is<br>
&gt; manipulated to ensure it aligns with write buffers.=C2=A0 I suspect th=
at&#39;s the<br>
&gt; problem I am seeing<br>
<br>
Mee too.<br>
<br>
play -r 48000 -n synth 10 sin 480<br></blockquote><div><br></div><div>I had=
 to add &quot;vol -30dB&quot; so as not to deafen myself - this generates t=
he same pop at the end.</div></div><div class=3D"gmail_quote gmail_quote_co=
ntainer"><br></div><div class=3D"gmail_quote gmail_quote_container">Brian</=
div></div>

--000000000000a1236006312d8db0--


--===============9124334526066706868==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============9124334526066706868==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Sox-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sox-users

--===============9124334526066706868==--