From: Brian W. <bri...@gm...> - 2025-03-25 16:53:26
|
On Tue, 25 Mar 2025 at 12:56, Jan Stary <ha...@st...> wrote: > On Mar 25 11:58:15, bri...@gm... 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 |