-
Notifications
You must be signed in to change notification settings - Fork 3
Clock operation
Clocking system is the feature of Sonochan MkII that makes it fundamentally different from a normal USB Audio Class 1 (UAC1) device. In this section, the system will be described in closer detail.
SMkII clock system goals are following:
- Avoid losing samples due to buffer underrun/overrun by adaptive clock adjustments
- Avoid OS-side re-sampling by supporting many sampling rates natively (usual UAC1 device offer just one or two native sampling rates)
- Allow user-adjustable clock for clock-related testing (usual UAC1 runs fixed master clock)
- Allow user-configurable clock multipliers to support various DUT
System-wise, the main clock from which the other clocks are derived, is the Master Clock (MCLK).
However, user-wise, the main value is the sampling frequency. Sampling frequency is selected in the audio application, either in some settings or simply derived from sampling frequency of the audio file being played.
The audio application informs USB Audio device (=SMkII) about the sampling frequency. SMkII then uses this sampling frequency value and:
- derives Frame Synchronization frequency (
FSYNC) based on this sampling frequency (FSYNC= sampling frequency) - derives Bit Clock (
BCLK) signal based onFSYNCand user-configured multiplier.BCLKis always higher than FSYNC, at least as many times as there is bits in the sample word and number of channels. - derives Master Clock (
MCLK) signal based onFSYNCand user-configured multiplier.MCLKis always higher or equal toMCLK.
Therefore, the final clock values used in SMkII are result of:
- Configuration settings (the
MCLKandBCLKmultipliers andMCLKadjustment offset) - Audio application settings (
FSYNCas the sampling frequency)
Adaptive clock adjustment is mechanism which prevents buffer overrun/underrun by adjusting clock speed (buffer full -> speed-up clock, buffer empty -> slow down clock.
SMkII employs two methods of clock adjustment:
UAC1 standard defines two modes of delivering audio data over USB:
- isosynchronous mode
- asynchronous mode
SMkII uses only asynchronous mode of operation. In asynchronous mode, it is expected that the OS clock and the UAC1 clock may diverge and there will be a risk of buffer overrun/underrun.
For that reason, UAC1 standard defines an optional feedback endpoint (USB logic), which allows UAC1 device to "tell" the host OS to adjust the sample rate by small amount (e.g. from 48000 Hz to 47999 Hz) to prevent data loss without "serious" audible effects for a listener.
SMkII attempts to use this mechanism every time it's available. While generally supported on Linux, the feedback endpoint implementation on Windows is bad or nonexistent, and therefore cannot be relied upon.
When data stream cannot be controlled on the OS side, it's still possible to avoid buffering problems by directly adjusting the MCLK generator. For that exact reason, SMkII uses a precise Phased-locked loop (PLL) IC for the main clock generation and adjusts it's settings based on the buffer state.
This method is configurable using the Auto tune PLL when audio feedback not work in the user-configured multiplier. As the name suggests, this method is only used when the above-described feedback endpoint method fails.
When adaptive PLL is active, the updated value of MCLK is displayed on SMkII LCD (#6).
For measurement purposes, it's sometimes desirable to adjust the MCLK manually by some value. For that reason, SMkII configuration offers Offset of MCLK in PPM option.
When using this option, the Adaptive (Auto-tune) option must be disabled.