CamillaDSP - Cross-platform IIR and FIR engine for crossovers, room correction etc

Hi TNT,

Thank you very much for this information. I will look for the posts about this on this thread.
Hi @jheoaustin

Before I will try to help you with the automatic samplerate switching filter's... tell me, are you using squeezelite?
Case is, that my script need's to read the "player's" log file for seeing the samplerate change there!?

I did once made a script for MPD player... so I think it's doable with all player's as long as they will "paste" when samplerate is changing in theyre .log file.

Please let me know 🙂

Jesper.
 
On macOS there is an easier way. The system sends a notification when the sample rate changes, which includes the new rate value. When this happens, camilladsp stops and provides the new rate when asked for the stop reason.
This can be used to modify the config and restart processing. Someone made a short python script for that but I can't find it now. It was basically a loop containing lines 206 to 232 of this script: https://github.com/Wang-Yue/CamillaDSP-Monitor/blob/main/monitor.py
Modify it so that it makes appropriate changes to the config that is used. And add a little sleep in the loop so it doesn't hog the cpu.
 
  • Like
Reactions: jheoaustin
Hi Jesper,

Thank you very much for your script help, and I guess I need to find a way to read the sample rate from BlackHole. I am planning to use BD players, music/movie streaming apps and file players, so the best seems to be reading from BlackHole. If you could help with any information on this, I'd heartily appreciate.

Regards,
Jay
 
Hi Henrik,

While looking into adapting to the upstream sample rate, another question naturally rose: How about the channel configuration? Switching the media can possibly change the channel configuration of the incoming audio stream, like 2.0, 5.1, 7.1.4, etc. Is CamillaDSP ready to adapt to this change without reloading the Camilla config?

Regards,
Jay
 
On macOS there is an easier way. The system sends a notification when the sample rate changes, which includes the new rate value. When this happens, camilladsp stops and provides the new rate when asked for the stop reason.
This can be used to modify the config and restart processing. Someone made a short python script for that but I can't find it now. It was basically a loop containing lines 206 to 232 of this script: https://github.com/Wang-Yue/CamillaDSP-Monitor/blob/main/monitor.py
Modify it so that it makes appropriate changes to the config that is used. And add a little sleep in the loop so it doesn't hog the cpu.
Hi Henrik,

Thank you very much for this valuable information, and also to the author. I guess I will try to combine Jesper's script and part of monitor.py to achieve my goal.
 
Hi Henrik,

Thank you very much for your information. I was hoping that at least I could avoid running some filters on zeros of non-existent channels. If I just assume the maximum channel configurations(in example, 7.1.2) but there is no actual audio content from the players, does MacOS fill up those buffers with 0s?

Regards,
Jay
 
Hi Henrik/Jesper,

I am trying to test the sample rate change, but I am not getting there. I started with playing DVD from Leawo S/W player, then switched the disc to a CD. But CamillaDSP doesn't crash and the log shows the sample rate is still 48kHz. I switched the device selection to bypass Dirac, so direct from the player(Apple Music App/VLC) to BlackHole, but Camilla just played on showing 48kHz Fs. The music pitch sounds correct, so I guess CoreAudio is doing some resampling. But I don't understand why. I don't remember specifying 48kHz anywhere. A Dirac rep told me that DiracLiveProcessor doesn't change I/O sample rates. Maybe the audio/video players on Mac just resamples 44.1 to 48?

I continued testing with different DVD-A discs, but Leawo didn't play some, and others(might just play DVD-V portion of the disc, not showing what exactly it plays) and Camilla went on. I switched to a BD disc with 96kHz track, but no change. I tried playing "hi-res" source from Apple Music app, but not sure what the Fs was. Camilla never crashed. Do you see something similar?

Regards,
Jay
 
Check out "Audio Midi Setup" and the source device (Blackhole) - what Fs is shown? Thats what "you" set it to. OS X will resample anything sent to Blackhole to match the setting. There is an other audio layer in Mac OS but that would be more transparent to Fs but it is not supported by CDSP - yet 😉

//
 
When an app opens a device for playback on macOS, it's optional to switch the sample rate of the device. If you don't then you get automatic resampling to the rate the device is currently set to. That's the rate you see in audio midi setup.
It seems like all the apps you tried so far leave the device rate as it is and rely on the automatic resampling. Not much to do for those if you want to avoid resampling, but the advantage is of course that things just work.
Some apps do change the device rate. I don't have a list but I think mpd does for example.
You can also simulate a rate change. Just change the sample rate of BlackHole in audio midi setup.


There is an other audio layer in Mac OS but that would be more transparent to Fs but it is not supported by CDSP - yet 😉
CoreAudio is huge, exactly what did you have in mind?
 
I dont recall the name - we have discussed this before - you where not ready to adopt to it you said if I recall correctly. Surely there must be a way to handle and transport a sound stream so that it is transparent to its original Fs?

But as I read your answer above I feel I don't recall correctly...

//
 
Hi Henrik/TNT,

Thank you very much for your help and information. I think I am almost there, and just one question or report. I tried to use 192kHz Fs, and camilla doesn't seem able to start with it. I could use 96000, but not 192000. I get following logs. Could you check on this?

2023-04-07 02:56:28.757666 INFO [src/bin.rs:711] CamillaDSP version 1.0.3

2023-04-07 02:56:28.757810 INFO [src/bin.rs:712] Running on macos, aarch64

2023-04-07 02:56:28.758421 DEBUG [src/bin.rs:754] Read config file Some("test.conf")

2023-04-07 02:56:28.762554 DEBUG [src/biquad.rs:43] a1=-1.9708564240827537 a2=0.97106601128019 b0=0.6333401668819032 b1=-1.2434876623830315 b2=0.6103570826985643

2023-04-07 02:56:28.762570 DEBUG [src/biquad.rs:43] a1=-1.9708564240827537 a2=0.97106601128019 b0=0.6333401668819032 b1=-1.2434876623830315 b2=0.6103570826985643

2023-04-07 02:56:28.762577 DEBUG [src/biquad.rs:43] a1=-1.9074888914066745 a2=0.9115817346362141 b0=0.0010232108073849123 b1=0.0020464216147698245 b2=0.0010232108073849123

2023-04-07 02:56:28.762584 DEBUG [src/biquad.rs:43] a1=-1.9074888914066745 a2=0.9115817346362141 b0=0.0010232108073849123 b1=0.0020464216147698245 b2=0.0010232108073849123

2023-04-07 02:56:28.762592 DEBUG [src/bin.rs:773] Config is valid

2023-04-07 02:56:28.762618 DEBUG [src/socketserver.rs:260] Start websocket server on 127.0.0.1:1234

2023-04-07 02:56:28.762669 DEBUG [src/bin.rs:857] Wait for config

2023-04-07 02:56:28.762700 DEBUG [src/bin.rs:890] Config ready

2023-04-07 02:56:28.762773 DEBUG [src/bin.rs:213] Using channels [true, true]

2023-04-07 02:56:28.762911 DEBUG [src/filters.rs:450] Build new pipeline

2023-04-07 02:56:28.762923 DEBUG [src/coreaudiodevice.rs:305] Using a playback channel capacity of 9 chunks.

2023-04-07 02:56:28.762921 DEBUG [src/coreaudiodevice.rs:583] Using a capture channel capacity of 17 buffers.

2023-04-07 02:56:28.762945 DEBUG [src/filters.rs:355] Build from config

2023-04-07 02:56:28.762954 DEBUG [src/biquad.rs:43] a1=-1.9708564240827537 a2=0.97106601128019 b0=0.6333401668819032 b1=-1.2434876623830315 b2=0.6103570826985643

2023-04-07 02:56:28.762964 DEBUG [src/filters.rs:355] Build from config

2023-04-07 02:56:28.762976 DEBUG [src/biquad.rs:43] a1=-1.9708564240827537 a2=0.97106601128019 b0=0.6333401668819032 b1=-1.2434876623830315 b2=0.6103570826985643

2023-04-07 02:56:28.762996 DEBUG [src/filters.rs:355] Build from config

2023-04-07 02:56:28.763008 DEBUG [src/biquad.rs:43] a1=-1.9074888914066745 a2=0.9115817346362141 b0=0.0010232108073849123 b1=0.0020464216147698245 b2=0.0010232108073849123

2023-04-07 02:56:28.763016 DEBUG [src/filters.rs:355] Build from config

2023-04-07 02:56:28.763024 DEBUG [src/biquad.rs:43] a1=-1.9074888914066745 a2=0.9115817346362141 b0=0.0010232108073849123 b1=0.0020464216147698245 b2=0.0010232108073849123

2023-04-07 02:56:28.763033 DEBUG [src/processing.rs:19] build filters, waiting to start processing loop

2023-04-07 02:56:28.850756 ERROR [src/bin.rs:344] Playback error: The requested sample rate is not available

2023-04-07 02:56:28.850770 DEBUG [src/bin.rs:349] Error while starting, release barrier

2023-04-07 02:56:28.896765 DEBUG [src/coreaudiodevice.rs:255] Set capture stream format

2023-04-07 02:56:28.896848 DEBUG [src/coreaudiodevice.rs:269] Opened CoreAudio capture device BlackHole 16ch

2023-04-07 02:56:28.897058 DEBUG [src/coreaudiodevice.rs:685] Capture device ready and waiting

2023-04-07 02:56:28.897068 DEBUG [src/coreaudiodevice.rs:691] Capture device starts now!

2023-04-07 02:56:28.897073 DEBUG [src/processing.rs:21] Processing loop starts now!

2023-04-07 02:56:28.897102 DEBUG [src/bin.rs:352] Wait for capture thread to exit..

2023-04-07 02:56:28.927951 DEBUG [src/coreaudiodevice.rs:703] Exit message received, sending EndOfStream

2023-04-07 02:56:28.927998 INFO [src/processing.rs:37] Playback thread has already stopped.

2023-04-07 02:56:28.954840 DEBUG [src/bin.rs:915] Restarting with new config

2023-04-07 02:56:28.954853 DEBUG [src/bin.rs:857] Wait for config

2023-04-07 02:56:28.954857 DEBUG [src/bin.rs:860] No config and not in wait mode, exiting!
 
TNT, Henrik, Jesper, phofman,

Thank you very much for all your helps. I am now sure I can put this system together. Since I think I will rely on CoreAudio SRC, I'd like to know your opinions on the quality of these automatic SRC. Could you share your subjective quality evaluation of CoreAudio SRC?

Regards,
Jay
 
My complete pipe look like:

1) Mostly 44,1 files or Tidal -> 2) Squeezplay -> 3) Blackhole 2ch -> 4) CDSP -> 5) RME Digiface USB (Opto) -> 6) 2 x SMSL SU6 -> 7..) amps/speakers.

Sound is handled by CoreAdudio from out of 2) to in of 5) - I presume. Perhaps there are SRC running in one ore more interfaces for this sub-path. I don't know the workings of CoreAudio. But I don't want that to happen really. There is no need for it as things don't start getting synchronous until out from stage 5).

In windows there are more then one audio service - one is apparently evil and one is OK. There is only one in OS X? It's nagging me that I can manipulate my audio stream (volume) via OS X preference panes / apps. Who knows what goes on. Is it bit perfect at attenuation = 0?

//