Go Back   Home > Forums > >

PC Based Computer music servers, crossovers, and equalization

Dynamic transcoding and convolution in Logitechmediaserver
Dynamic transcoding and convolution in Logitechmediaserver
Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools
Old 2nd November 2020, 10:45 PM   #1
Simofil is offline Simofil  Italy
diyAudio Member
 
Join Date: Feb 2017
Location: Italy
Cool Dynamic transcoding and convolution in Logitechmediaserver

YCLD - Dynamic transcoding and convolution in Logitechmediaserver

I'v always liked the idea to have the option to transcode AND apply convolution in LMS without many headaches. ATM there is C-3PO as a plugin for transcoding (but not optimal for convolution) and the hacked squeezelite SuperPlayer (I love it but it breaks the client-server paradigm where all the load should be on the server).

So I decided to make my own wrapping all the SoX + CamillaDSP logic.
I based it on a previous software which I made for batch audio file conversion (Recursive Audio Converter GUI) and I basically add to it the option to read and write from/to pipes and to read wav headers .

It is ugly, it is in beta and it has bugs.

Installation
Download and untar (Link at the end of the post)
Make sure to have OpenJDK >= 11 installed

Usage
Bad news! Fot the moment you'll have to edit your custom-convert.conf file. I know it is a pain in the *** and I'll try to help anyone but even for me this lms file is dark magic. Later I'll made a GUI (Desktop/web/mobile or whatever).
Before anyone asks me : no, I won't write an official LMS plugin, I'll start writing PERL code in my life only for at least double the hourly wage I take now as a dev. (what an ugly language)

First Example:
Code:
flc flc * *
	# IFT:{START=--skip=%t}U:{END=--until=%v}
	[flac] -dcs $START$ $END$ -- $FILE$ | /usr/bin/java -jar /usr/local/bin/YCLD.jar --debug --input-dir stdin --output-dir stdout --output-bit 24 --output-rate NextSync --output-format flac --convolution /mnt/music/0000-EQ-FILES/LCD2
Explanation:
For whatever input flac file (also from Tidal or Qobuz), upsample it at double its current sample rate (ex 44100->88200) and then search in the convolution folder for an impulse named impulse{target_sample_rate}.bin/dbl/txt. In this case with a 44.1 input it will pick /mnt/music/0000-EQ-FILES/LCD2/impulse88200.dbl

Second example:
Code:
flc dsf * *
	# IFT:{START=--skip=%t}U:{END=--until=%v}
	[flac] -dcs $START$ $END$ -- $FILE$ | /usr/bin/java -jar /usr/local/bin/YCLD.jar --debug --input-dir stdin --output-dir stdout --output-bit 1 --output-rate 5644800 --output-format dsf --convolution /mnt/music/0000-EQ-FILES/LCD2
Explanation:
It will take the input file, apply convolution (with pcm->dsd the impulse MUST be at 352.8kHz) and then convert to DSD128

The possibilities are quite infinite, you can even do DSD64 -> convolution -> DSD256 (internally it will do DSD64->64/352k->HF fir filter->your custom fir filter->DSD256)

Config
In the tar.gz you'll find the main jar and config/config.properties

Example with comment:
Code:
#useless option in this case, useful when used as a batch converter. Dont' write 0 please, any value >= 1 is ok and won't make any difference
Threads=12
#SoX path 
SoXDir=/usr/local/bin/sox
#CamillaDSP path
CamillaDSPDir=/usr/local/bin/camilladsp   
#where to write the debug file when --debug option is active
DebugFile=/usr/local/bin/debug.log 
#Pre gain before apply convolution   
PreProcessGain=-2  
#Useful only for batch conversion, keep it at 0 with LMS 
Normalize=0
#when false you must pick a single impulse to apply, the sample rate of the filter MUST match the output sample rate. When true you can instead specify a directory where multiple convolution files with different sample rates to be applied. The impulses MUST be named with the following syntax "impulse"<samplerate>.<extension> . Example: impulse44100.txt, impulse192000.dbl. When you convert TO DSD the sample rate of the impulse must be 352.8 kHz.
UseMultipleConvolutionFiles=true
#check CamillaDSP wiki, FLOAT64LE = *.dbl, FLOAT32LE = *.bin, TEXT = *.txt
ConvolutionFileFormat=FLOAT64LE
#compression level when output to flac
CompressionLevel=8
Maximum PCM sample rate supported by your dac
MaxSampleRate=384000
Maximum DSD sampel rate supported by your dac
MaxDSDSampleRate=DSD128
Currently tested on Debian and FreeBSD. It should work on Win. Don't know about MacOS.

Downloads
YCLD download -> YCLD

Pre-compiled sox binaries with dsd support -> SoX

Pre-compiled CamillaDSP binaries (only with options needed by YCLD)-> CamillaDSP

If downloading from unix* command line --> curl -A "audiodigitale" -o /path/YCLD.tar.gz https://etc.etc.etc

Don't thank me, thank CamillaDSP and SoX devs and maintainers, and offer them a coffee.

Why YCLD ?
Easy! YourCpuLooksDelicious! Try to run it with both convolution and DSD upsample enabled and you'll understand

Last edited by Simofil; 18th January 2021 at 10:06 AM.
  Reply With Quote
Old 3rd November 2020, 07:35 AM   #2
DRONE7 is offline DRONE7  New Zealand
diyAudio Member
 
Join Date: Aug 2008
Quote:
Why YCLD ?
Easy! YourCpuLooksDelicious! Try to run it with both convolution and DSD upsample enabled and you'll understand
lol.

Thanks again for some interesting adventures !
  Reply With Quote
Old 3rd November 2020, 11:33 AM   #3
HenrikEnquist is offline HenrikEnquist  Sweden
diyAudio Member
 
Join Date: Apr 2016
Location: Lund
This doesn't look that great and I would like to take a look:
Quote:
#resampler quality, check CamillaDSP wiki. P.s. I had awful results full of noise with synchronous resampling
How would I reproduce it? Preferrably without setting up LMS.
  Reply With Quote
Old 3rd November 2020, 01:18 PM   #4
Simofil is offline Simofil  Italy
diyAudio Member
 
Join Date: Feb 2017
Location: Italy
Quote:
Originally Posted by HenrikEnquist View Post
This doesn't look that great and I would like to take a look:

How would I reproduce it? Preferrably without setting up LMS.


Original file : https://i.imgur.com/gFxzpUg.png
After upsampling 44100 -> 88200 with synchronous resampling : https://i.imgur.com/0cChi8t.png

To reproduce:

Input file 24/44 flac

Yaml file:
Code:
devices:
  samplerate: 88200
  chunksize: 4096
  enable_resampling: true
  resampler_type: Synchronous
  queuelimit: 128
  capture_samplerate: 44100
  capture:
    type: Stdin
    channels: 2
    format: S24LE3
  playback:
    type: Stdout
    channels: 2
    format: S24LE3
Command:
Code:
sox.exe 01.flac --type raw - | camilladsp.exe temp.yml | sox.exe --multi-threaded --type raw --bits 24 --rate 88200 --channels 2 --encoding signed-integer -L - --type flac --compression 8 02.flac
When using the same command and configuration but with Asynchronous resampling the result is perfect without high frequency noise

Last edited by Simofil; 3rd November 2020 at 01:22 PM.
  Reply With Quote
Old 3rd November 2020, 05:21 PM   #5
phofman is online now phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
Do pipes on windows behave the same way as on unix/posix, in terms of timing, blocking, etc?

Perhaps using a generated single/multitone instead of complex music would be convenient because a spectrogram of the result (sox spectrogram effect) shows at first sight any imperfections in the chain, even a single missed/incorrect sample in many minutes.
  Reply With Quote
Old 3rd November 2020, 05:25 PM   #6
Simofil is offline Simofil  Italy
diyAudio Member
 
Join Date: Feb 2017
Location: Italy
Quote:
Originally Posted by phofman View Post
Do pipes on windows behave the same way as on unix/posix, in terms of timing, blocking, etc?

Perhaps using a generated single/multitone instead of complex music would be convenient because a spectrogram of the result (sox spectrogram effect) shows at first sight any imperfections in the chain, even a single missed/incorrect sample in many minutes.
This problem with synchronous resampling happens to me on linux too so I don't think it is OS dependent.


BTW
UPDATE 0.2
Some minor fixes and tested the compatibility with windows (Win 10 at least)
Now I need to deeply understand the syntax of the custom-convert file (some help could be needed), and then write an app (even mobile) which creates resampling profiles for every player or customized for each player (you can do that with MAC addresses of the players), auto-generate a correct custom-convert file and automatically reboot lms to apply the rules. But before that I need some testers for YCLD

Last edited by Simofil; 3rd November 2020 at 05:29 PM.
  Reply With Quote
Old 3rd November 2020, 08:10 PM   #7
HenrikEnquist is offline HenrikEnquist  Sweden
diyAudio Member
 
Join Date: Apr 2016
Location: Lund
Quote:
Originally Posted by Simofil View Post
Original file : https://i.imgur.com/gFxzpUg.png
After upsampling 44100 -> 88200 with synchronous resampling : https://i.imgur.com/0cChi8t.png
Thanks, I found the problem and fixed it now. It was caused by a missing "+ 1" that disappeared when I optimized some loops around the end of June. There will be a new release of CamillaDSP shortly.
If you find some other bugs, pleeease let me know right away!
  Reply With Quote
Old 3rd November 2020, 10:19 PM   #8
Simofil is offline Simofil  Italy
diyAudio Member
 
Join Date: Feb 2017
Location: Italy
Awesome, I haven't opened an issue on GitHub before because I needed more testing with Camilla and I thought It was an implementation problem on my side. This Is indeed very good because AccurateAsync, while It provides awesome results, it's quite CPU intensive. Thanks again!
  Reply With Quote
Old 4th November 2020, 10:32 PM   #9
Simofil is offline Simofil  Italy
diyAudio Member
 
Join Date: Feb 2017
Location: Italy
UPDATE 0.3
Now in config file there are two new line:
Code:
MaxSampleRate=384000
MaxDSDSampleRate=DSD128
In this way you can specify the maximum sample rates of your DAC.
When you upsample using the option "MaxSync" or "NextSync" YCLD will never go over the maximum sample rates set in the config file.

I'm starting to write a backend web service app to automate all the editing of the custom-convert file. It will expose some WebMethods that can be used with normal http GET/POST request. I will then write an Android (and maybe iOs) app to configure all the resampling/convolution profiles for each player and for each format. Since the backend app is agnostic about the client anyone can then write a Desktop or Web app too.
  Reply With Quote
Old 5th November 2020, 04:46 PM   #10
Simofil is offline Simofil  Italy
diyAudio Member
 
Join Date: Feb 2017
Location: Italy
Update 0.4
The old "ResamplerQuality=" option is now replace by
Code:
UseMaxResamplerQuality=true
In this way when the output sample rate is a multiple of the input sample rate CamillaDSP will be set to use Synchonous resampling.
If input and output sample rates are not multiple (like 44.1->96):
- If UseMaxResamplerQuality = true AccurateAsync will be used
- If UseMaxResamplerQuality = false BalancedAsync will be used.

Now the code is backward compatible since Java 8. No more Java 11 required.
  Reply With Quote

Reply


Dynamic transcoding and convolution in LogitechmediaserverHide this!Advertise here!
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Logitechmediaserver - Material Skin User interface soundcheck PC Based 13 3rd June 2020 12:35 PM
Help - Convolution STAryo PC Based 16 21st February 2017 07:31 AM
mediatomb transcoding for flac to do replaygain decoding? davygrvy PC Based 1 29th May 2015 05:15 AM
convolution reverb eStatic Everything Else 0 19th March 2008 04:21 PM
DSP for convolution fb Digital Source 4 17th September 2007 03:30 PM


New To Site? Need Help?

All times are GMT. The time now is 10:34 AM.


Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 15.00%
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
Copyright ©1999-2021 diyAudio
Wiki