On Thu, Sep 15, 2016 at 02:13:28PM +0200, Jan Stary wrote:
> Putting this together with ratchov@'s recent patch,
> mostly to clarify for myself.
> 
> On Feb 09 10:24:47, com...@daknet.org wrote:
> > I'm trying to record audio with 24-bits precision with sox
> > and it seems to be impossible:
> > 
> > rec -t flac -c 2 -r 48000 -b 24 test.flac
> > 
> > Input File : 'default' (sndio)
> > Channels : 2
> > Sample Rate : 48000
> > Precision : 32-bit
> > Sample Encoding: 32-bit Signed Integer PCM
> > 
> > In:0.00% 00:00:16.90 [00:00:00.00] Out:807k [ | ] Clip:0
> > 
> > It is always encoded with 32-bits precision
> 
> That's a slight missunderstanding. SoX does whatever the
> underlying audio system enables it to do. Here, you asked
> for 24bit samples, but the underlying audio (presumably)
> cannot record 24bit samples, so SoX records 32bit samples
> instead AND re-encodes them to 24bit for you.
> What you see above are the parameters of the input;
> the output is what you wanted - a 24bit file.
> 
> > Is it a known bug with sox generally (however i didn't find
> > anything on this) or a bug with sox only on openbsd ?  Or maybe
> > a problem with my configuration ?
> 
> It is a general problem: if you want to record 24 bit samples,
> but the audio hardware can only record 16b or 32b,
> what is SoX gonna do? Record 32b and reencode for you.
> 
> > For information, i use this sndiod configuration :
> > sndiod_flags="-r 48000 -e s24le -s default"
> 
> With a running sndiod, audio applications are layered away from
> the physical audio hardware, and sndiod will reencode and resample
> on the fly to and from just about anything. For example, if you
> ask SoX to record 24bit samples, the the running sndiod will
> provide 24bit samples, whatever the underlying device really does.
> 
> BTW, I don't think your '-e s24le' succeeds in configuring the device
> to using 24bits, as the device probably cannot really do that.
> 
> 
> On Feb 09 23:30:41, a...@caoua.org wrote:
> > This should fix the problem.  If bits_per_sample is set, then use
> > it to configure sndiod; otherwise, pick a value close to precision
> > or the default sox precision.
> 
> Yes, this makes SoX ask for the right parameters,
> and if the underlying audio system supports them,
> they will be used (tested on amd64, i386, macppc).
> Thank you!
> 
> A running sndiod does support e.g. 24bits;
> Morgan's audio device (and mine too) does not.
> In that case, SoX _will_ directly play/record the 24bit samples
> without reencoding - it will be sndiod doing the conversion.
> 
> (Right, Alex?)

this is exact.

Note that, to get actual 24-bit precision, the full signal
processing chain must use 24-bit precision, so sndiod must be
recompiled with:

        make COPTS=-DADATA_BITS=24

FWIW, besides the format conversions, sndiod does minimal
processing (mixing, resampling).  Internally it uses 16-bit
integers because it's natively supported by most hardware and
software, and thus avoids the need for conversions.  This saves few
CPU cycles, which used to be important for slow machines (like the
now defunct zaurus).

The plan is to make 24-bit precision the default.

Reply via email to