Auto clock switching for Focusrite(Scarlett, maybe others) when S/PDIF clock unavailable.

jamess

Member
Wrote a utility to automate changing the clock on my focusrite Scarlett.

I use the focusrite as my main audio interface, so when I power of the axe-fx III, I lose audio until I switch to an internal clock.

Hacked together to learn a bit of golang(still have a lot to learn), from a naive understanding of the focusrite control protocol
  • If the clock is set to S/PDIF< and the clock isn't locked, clock is set to Internal.
  • If the clock is set to internal and S/PDIF input has some level, it will set the clock to S/PDIF.
I'm too new to post links...you'll have to join these together...

Its pretty crude, but functional for me https://github.com/dounix/focusrite-autoclock

Pre-compiled executables(under assets) here, https://github.com/dounix/focusrite-autoclock/releases

you can compile yourself if you want using go>=1.17
 
@jamess thank you for writing this! Hard to believe it's still not implemented in FR control...

I tried to run your pre-compiled version in Win10, on the same PC that is connected to my 18i20 by USB and is on the local network. I seem to get approval messages, but nothing is showing up in my FR control panel. Any suggestions?

time="2023-12-07T10:30:08-07:00" level=info msg="Sending UDP discovery to: localhost:30096"
time="2023-12-07T10:30:08-07:00" level=info msg="UDP Server : 127.0.0.1:30096"
time="2023-12-07T10:30:08-07:00" level=info msg="approval message: {{ approval} PCNAME 4536329721646671024 response true}"
 
Yeah, seems like FR would just implement in hardware/firmware, something like "prefer external spdif clock"

Only tested with my scarlett 8i6, I might have failed to abstract away model differences, or hardcoded something stupid.

This was essential with my kemper, since it has to be master, but I don't use it anymore.
For the axefx III, I just changed to allow the focusrite to be master, setting the axefx to slave
Home > Setup > I/O > page to audio page
digital I/O configuration
Input 1 Source: SPDIF/AES
Word Clock: SPDIF/AES IN
IMG_3885.jpeg
The above with FC set to 48 / internal works for me.

Screenshot 2023-12-07 132133.png

If you still need it, I'll poke a the code and see if I can figure something out or add some debugging.
 
Yeah, seems like FR would just implement in hardware/firmware, something like "prefer external spdif clock"

Only tested with my scarlett 8i6, I might have failed to abstract away model differences, or hardcoded something stupid.

This was essential with my kemper, since it has to be master, but I don't use it anymore.
For the axefx III, I just changed to allow the focusrite to be master, setting the axefx to slave
Home > Setup > I/O > page to audio page
digital I/O configuration
Input 1 Source: SPDIF/AES
Word Clock: SPDIF/AES IN
View attachment 131070
The above with FC set to 48 / internal works for me.

View attachment 131071

If you still need it, I'll poke a the code and see if I can figure something out or add some debugging.

Looks like you have an FM3, didn't realize it couldn't external clock, I'll see if I can wrap my head around that code again.
 
Nah that's ok I will keep pressing focusrite about it and can just work around for now. But thank you. Yeah the FM3 is like your Kemper in that regard, an annoying feature.
 
I connect SPDIF in both directions, so I leave the Fractal’s clock source set to SPDIF at all times, even when it’s not connected. Been working fine for a few years now and I don’t have to switch anything when going from home to live.
 
I connect SPDIF in both directions, so I leave the Fractal’s clock source set to SPDIF at all times, even when it’s not connected. Been working fine for a few years now and I don’t have to switch anything when going from home to live.
The FM3 only has s/pdif out. The issue is that our interface should be able to auto revert to internal clock when it doesn't sense an external clock signal, but it doesn't. And when there's no external clock source, the interface doesn't work until it's manually set to internal clock.
 
The FM3 only has s/pdif out. The issue is that our interface should be able to auto revert to internal clock when it doesn't sense an external clock signal, but it doesn't. And when there's no external clock source, the interface doesn't work until it's manually set to internal clock.
yeah that would be a nice feature for Focusrite to implement
 
Had to remember how it works... :)

On startup, if approval is done...
Code:
E:\data\focusrite-autoclock>focusrite-autoclock-windows-amd64.exe
time="2023-12-07T21:30:46-05:00" level=info msg="Sending UDP discovery to: localhost:30096"
time="2023-12-07T21:30:46-05:00" level=info msg="UDP Server : 127.0.0.1:30096"
time="2023-12-07T21:30:46-05:00" level=info msg="approval message: {{ approval}  chimp 9052692934873125920 response true}"

With no debugging, If it has nothing to change, it will only log those three lines, only logging when it switches the clock.


If your clock is currently set to spdif, and has a good lock, it will leave it
If it loses lock(fm3 powered off) it will switch to internal, logging this.
time="2023-12-07T21:36:33-05:00" level=info msg="Setting clock to Internal"

If your clock is currently set to internal, it has to see some level on spdif in before it will change to spdif clock
power the fm3 back up, strum a bit, you should hear it immediately, but you're out of time with the fm3 and will have small pops as a result.
After detecting a bit of level on the spdif in, it will switch to spdif clocking again and log
Code:
time="2023-12-07T21:38:23-05:00" level=info msg="Setting clock to S/PDIF"


You can run it with a -d option to get debug info, which will show it checking spdif levels, etc.
You can also run the windows debug build, available in the 1.0.10 release for the same effect.
https://github.com/dounix/focusrite-autoclock/releases/tag/v1.0.10
focusrite-autoclock-windows-amd64-debug.exe

debug will look like this if it's able to understand your device and its spdif input/clocking config

Code:
time="2023-12-07T22:22:23-05:00" level=debug msg="sending keep alive2023-12-07 22:22:23.5294544 -0500 EST m=+312.011118101"
time="2023-12-07T22:22:23-05:00" level=debug msg="fullmessage: Length=00000d <keep-alive/>"
time="2023-12-07T22:22:23-05:00" level=debug msg="received keepalive message"
time="2023-12-07T22:22:26-05:00" level=debug msg="sending keep alive2023-12-07 22:22:26.5290015 -0500 EST m=+315.010652001"
time="2023-12-07T22:22:26-05:00" level=debug msg="running watchclock2023-12-07 22:22:26.5290015 -0500 EST m=+315.010652001"
time="2023-12-07T22:22:28-05:00" level=debug msg="source input spdif meter ID: -128"
time="2023-12-07T22:22:28-05:00" level=debug msg="clock locked: true"
time="2023-12-07T22:22:28-05:00" level=debug msg="clock source: S/PDIF"
time="2023-12-07T22:22:28-05:00" level=debug msg="fullmessage: Length=00000d <keep-alive/>"
time="2023-12-07T22:22:28-05:00" level=debug msg="spdiflevel:-128"
time="2023-12-07T22:22:28-05:00" level=debug msg="received keepalive message"

If you get it working and don't need any debug/logging I have a version that just runs in the tray and just has minmal tooltip/mouse over clock status.
 
I was just looking into S/PDIF the last days, and i did a quick test of your software version 1.0.10 on the Focusrite Scarlett 18i8 (3rd Gen).
When i have set the Clock Source from the Focusrite to Internal, then as soon as the FM9 gets up and running and has sound on the output, the Clock Source from the Focusrite gets switched to S/PDIF. As soon as i turn the FM9 off, the Clock Source on the Focusrite switches back to Internal.

In other words: i can confirm this works on the FM9.

Thanks for sharing!
 
@jamess and @md1234 I just noticed your replies, thank you!! I bet I wasn't doing things in the proper order. Also I just wanted to note here what FR replied to me:

this is unlikely to be implemented in our current ranges in the way that you would like as this is a hardware and software limitation, but it might be something we could add in the future to newer products but I can not guarantee this as device clocking detection is not simple and also can depend on the other device in the setup.

For example on a hardware level when a digital input signal is detected the unit doesn't know what the sample rate of that signal is, which is why you have to select a sample rate in Focusrite Control, not all devices give sample rate information when transmitting and not all do it in the same way.

The github code is a good workaround, but it does not fully address all issues such as sample rate mismatch and does not account for some units that have RCA and Optical SPDIF as well as ADAT like the 18i20 3rd Gen which might cause issues for some customers using different Digital I/O modes or other digital connections.
 
Yep, they aren't wrong, valid criticisms,
It's certainly not universal, you do have to have the right clock frequency, and it only works for RCA spdif.

Their solution is no solution, click a handful of buttons when you turn off your external device. Just don't forget to reverse that process, or when you record you'll notice those fun clicks/pops, I typically don't hear them when I'm playing, only on playback, brain busy with being a mediocre guitar player.

It certainly doesn't work around any problems it wasn't intended to, ADAT, AES, Dante clocking, etc.
Once you're at that tier, I would think you have all your studio gear on while you're in the studio, and the PC is dedicated.

I was solving for not having to leave my kemper/axefx on all the time in order to get sound from my PC when I'm not doing guitar stuff.
Minimal workaround for a "bedroom" player problem that was too hardheaded to use analog inputs :)
 
I completely have the same issues, and I have a serious need to automate everything like this because there's just no way I'm going to remember the forward/reverses steps each time I want to play. Even more annoying than forgetting to sync is forgetting to unsync, and then, dammit, I have to figure out why in the world sound isn't coming through my interface, which takes me a while because there are about 2 jillion reasons why this could be on my setup, and because I'm too dense to remember this is a recurring issue.

Minimal workaround for a "bedroom" player problem that was too hardheaded to use analog inputs :)

I ran out of space on my last two inputs (I have like 12 instruments permanently wired to input) or else I'd be using those. And I still haven't tested the synced s/pdif to know whether I completely trust it like I could with analog... it's really not the ideal clock source.

edit: @jamess it works! Not until I updated my FR control (d'oh!). I never did have to approve the remote device in FR control.

Thanks man, this is really great.
 
Last edited:
Well this is nice @jamess ! I haven't had opportunity to use it yet, but my situation is that I currently have an interface (Steinberg UR44-C) which has no s/pdif ins or outs. After reviewing @GlennO wonderful recording document with various setups for reamping, it became clear that the only way I could really set it all up and have my mics, 1/4" inputs, and the AxeFX III integrated into one single system without swapping things out all the time for reamping, etc, I'd need an interface with s/pdif in and out because I'm using Windows 10 and can't aggrigate audio systems like a Mac. (i.e. can't use the AxeFx III and the UR44-C at the same time as an interface as ASIO is a one-at-a-time deal on Windows :mad:)

I landed on the Focusrite 18i8 3rd gen as a happy medium, which arrives later this week. I've had nothing but trouble with Focusrite/Scarlett interfaces in the past so I've got some serious trepidation on how this interface will perform, but I'm hopeful as I see others using it and seeming fairly happy with the performance. I can't afford $1000+ for an interface at the moment so this is my only practical option.

All that said, I've been scouring the forums for information on the Focusrite especially since finding GlennO's documentation for focusrite setup, etc, and here I am.

Looks like a great bit of purpose-built code and hoping it'll do exactly what stated purpose is for me. I'm no longer touring or gigging so my gear is in the studio on a permanent basis.

I'll check back in once it's all setup, wanted to say thanks to you all for the discussion and I'm sure I'll have a question or two, but thanks again for sharing this solution with the rest of us and fingers crossed this Focusrite 18i8 will perform as needed.
 
Looks like a great bit of purpose-built code and hoping it'll do exactly what stated purpose is for me. I'm no longer touring or gigging so my gear is in the studio on a permanent basis.

I'm not sure what your use case is, but note that the Axe-FX 24.0 firmware update added the ability to fall back to internal clock when no spdif input is present. That means you can leave your rig set up with the 18i8 as the clock master and, if you want to use your Axe-FX without the 18i8, the Axe-FX should still work fine without changing any clock settings.
 
Well this is nice @jamess ! I haven't had opportunity to use it yet, but my situation is that I currently have an interface (Steinberg UR44-C) which has no s/pdif ins or outs. After reviewing @GlennO wonderful recording document with various setups for reamping, it became clear that the only way I could really set it all up and have my mics, 1/4" inputs, and the AxeFX III integrated into one single system without swapping things out all the time for reamping, etc, I'd need an interface with s/pdif in and out because I'm using Windows 10 and can't aggrigate audio systems like a Mac. (i.e. can't use the AxeFx III and the UR44-C at the same time as an interface as ASIO is a one-at-a-time deal on Windows :mad:)

I landed on the Focusrite 18i8 3rd gen as a happy medium, which arrives later this week. I've had nothing but trouble with Focusrite/Scarlett interfaces in the past so I've got some serious trepidation on how this interface will perform, but I'm hopeful as I see others using it and seeming fairly happy with the performance. I can't afford $1000+ for an interface at the moment so this is my only practical option.

All that said, I've been scouring the forums for information on the Focusrite especially since finding GlennO's documentation for focusrite setup, etc, and here I am.

Looks like a great bit of purpose-built code and hoping it'll do exactly what stated purpose is for me. I'm no longer touring or gigging so my gear is in the studio on a permanent basis.

I'll check back in once it's all setup, wanted to say thanks to you all for the discussion and I'm sure I'll have a question or two, but thanks again for sharing this solution with the rest of us and fingers crossed this Focusrite 18i8 will perform as needed.
Scarlett stuff is honestly great for the money, there’s a stigma around that brand because every beginner has one but they just work. Drivers are rock solid, control software is excellent, decent RTL, mic pres have low THD and decently low noise, low impedance and powerful headphone amp, air mode on the mic pres is great, line inputs and outputs are dead flat, etc. I slightly prefer the hi-z input on the fractal units to the Scarlett’s hi-z input but TBH in a blind A/B I don’t know if I could pick which is which. And since you’re using SPDIF none of the AD conversion matters anyway.
 
Thanks fellas, all great news, appreciate the feedback! I'm so happy the v24 update fixes the clock behavior, sounds like smooth sailing ahead!
 
Very useful QoL addition. I use SPDIF output exclusively with my Focusrite and when moving the AxeFx I don't have to remember to switch it back to Internal clock. This gets an A+ for convenience from me.
 
Back
Top Bottom