PDA

View Full Version : Resampling with sox



lauret
2009-02-18, 14:43
As of version 7.3.2 extended resampling is supported:

>Improved playback of high-resolution audio tracks. Sound eXchange (SoX) now >resamples higher-rate FLAC or Ogg tracks to lower sample-rate FLAC compatible >with your player. Previous 7.3.1 release resampled only to MP3 format.

My question is: is it possible to select the output bit depth for resampling? My DAC is a 16-bit DAC, so the last bits get truncated.

And is it possible to select the preferred sampling frequency? I would like to transcode 96kHz in 48kHz and 88.2kHz in 44.1kHz as the sampling frequency is then halved.

andyg
2009-02-18, 15:02
The bit depth of the source file is not changed. The sample rate is halved, as you describe.

lauret
2009-02-19, 11:21
The bit depth of the source file is not changed. The sample rate is halved, as you describe.

Is it possible to add anywhere a command that the file also gets downsampled to 16-bit whenever sox is processing hi-rez files?

andyg
2009-02-19, 11:30
Probably, you could hack the convert.conf file.

lauret
2009-02-22, 07:46
Ok, I tried to edit the convert.conf. First I created /etc/slimserver/custom-convert.conf. Then I thought that this one is for normal flac playback:

flc flc * *
-

And that this one is for transcoding:

flc flc transcode *
# FT:{START=--skip=%t}U:{END=--until=%v}D:{RESAMPLE=-r %d}
[flac] -dcs $START$ $END$ -- $FILE$ | [sox] -q -t wav - -t flac -C 0 -b 16 dither $RESAMPLE$ -

I added the "-b 16 dither". Is that about correct? I wasn't sure about the $RESAMPLE$ command, because dithering should be last.

Thanks!

schiegl
2009-02-22, 08:14
Hi,

$RESAMPLE$ is just a placeholder for D:{RESAMPLE=-r %d} and will be evaluated on runtime.

You should take a look at the running process and its parameters to see if it fits your needs...
You could also exec this command manually and redirect the output to a new flac file, for analysis with foobar2000 or similar tools.

kind regards,
Markus

lauret
2009-02-23, 07:05
Ok, I changed it in:

flc flc transcode *
# FT:{START=--skip=%t}U:{END=--until=%v}D:{RESAMPLE=-r %d -2}
[flac] -dcs $START$ $END$ -- $FILE$ | [sox] -q -t wav - -t flac -C 0 $RESAMPLE$ -

Where the "-2" is 2 bytes or 16 bits. But now some 44.1/16-bits music is also converted (it says so in the More Info menu). This music didn't play yesterday (I thought maybe because dithering is a heavy process for a PII), so I removed it. But why is some 44.1/16-bit music transcoded? (I have only flacs, and I can't see a difference between cd's)

lauret
2009-02-24, 06:28
Has anybody an idea what invokes the 'flc flc transcode *' rule rather that the 'flc flc * *' rule?

Mick Seymour
2009-02-24, 07:21
Has anybody an idea what invokes the 'flc flc transcode *' rule rather that the 'flc flc * *' rule?

Rules concerning the different SBs hardware decoding capabilities.

lauret
2009-02-24, 14:28
Rules concerning the different SBs hardware decoding capabilities.

But why are 44.1kHz/16-bit FLACs transcoded? Why aren't they streamed unprocessed to the SB?

Mick Seymour
2009-02-25, 00:35
But why are 44.1kHz/16-bit FLACs transcoded? Why aren't they streamed unprocessed to the SB?

Testing on my SB3 with a 44.1khz/16-bit ripped to FLAC CD track, 'More Info' is not showing it as being transcoded. If, however, I play the same track on SoftSqueeze where I have created a custom-convert.conf transcoding FLAC to FLAC to 44.1khz/16-bit via sox, it does show as being transcoded. This is what I would expect.

If you still have 'D:{RESAMPLE=-r %d -2}' in your 'flc flc transcode *' section of convert.conf, I still don't see a reason why that section would be chosen over the standard 'flc flc * *' if the file being streamed is 44.1khz/16-bit. However, if you have modified the 'flc flc * *' section to include sox, that would explain it.

Incidentally, it was your '[sox] -q -t wav - -t flac -C 0 -b 16 dither $RESAMPLE$ - ' that gave me the idea of how to stream files greater than 44.1k and/or greater than 16-bit to SoftSqueeze so thanks.

gharris999
2009-03-02, 13:37
44.1kHz/16-bit FLACs get transcoded when the flac has an embedded cuesheet. I.E. whole-album flacs are always transcoded vs. track-per-flac flacs which should get streamed "unprocessed" as you say.