[ntp:hackers] audio refclock debugging

gnu not unix gnu at wraith.sf.ca.us
Thu Nov 10 11:04:22 PST 2005

Hi Folks--

Here's some hints with regards to audio refclock debugging.

Make sure your audio device is setup ok for your version
of os/soundcard. Example, can you play an MP3? If so, 
that's a good start. 

Once you can play sound, try to get input working. I tend
to use the "line" input of my sound cards. I built a couple
of cables for the input. One simply uses a mono input plug
(the audio code handles this, its the left channel). Another
cable uses a stereo plug (clipped off a pair of defunct
earphones), with both channels wired up to the irig output
(or the wwv receiver output).

Plug your stuff together and use your mixer/aumix software to
enable the sound "record" function, and see if you can
hear anything. You must be able to get record/input working
before trying ntpd refclocks.

Once you have your audio hardware tested and cabled up, you
can try playing with the ntpd audio refclocks.

The refclock config itself is a bit tricky. I've had to
fuss around with the ntp.audio config here to get things going.

Here's what I use for irig and wwv:

# irig b (audio)
# flag2 1 is line port, flag4 1 is verbose stats
#server  version 4
#fudge flag2 1 flag4 1

# wwv radio clock. time1 wwv, time2 wwvh, flag2 0=mike, 1=line. 
#server version 4
#fudge time1 0.0019 time2 0.00773634 flag2 1 flag4 1

Here's my ntp.audio file:

idev    /dev/audio0
cdev    /dev/mixer0
agc     line
monitor vol

Here's a comment I made to myself with regards to a soundblaster
live (pci) in a p133/freebsd host:

jane4 (P133) with sb live wants rec 20
and agc rec (which seems to adjust line anyways)
but it brings up IRIG

With linux, I configure for ALSA audio fragment size with echo:

echo "ntpd 2 128" > /proc/asound/card0/pcm0c/oss

To actually debug the ntpd audio setup, build an ntp.conf with only
the irig/wwv/chu driver, then "ntpd -D2" to get a view of the
audio gain adjustments. I see things like this:

audio_gain: gain 139/54
audio_gain: gain 143/56

Note that some os/soundcard combinations simply Do Not Work
with input, although their output might work.

The devices I've had working here include a motherboard
based C-Media PCI CMI8738, a PCI slot based soundblaster
live, an ISA soundblaster awe64 gold, and a PCI slot
based sb128 (ENS1371). OS include fbsd 5.3, fbsd 4.7/4.11,
linux 2.4.20-NANO, linux 2.6.3 ppskit lite.

Yes, there are a  lot of things to fuss with to get this
going. Dave's code is awesome, though, and I can get the
WWV chiming within 100 microseconds with 10's of microseconds
jitter, compared to the GPS refclocks here. The IRIG also
gets down to that range, or better. 

Hope this helps. 


More information about the hackers mailing list