The trouble with birds is they get up earlier than I do, so a time-delay start recorder lets me scout locations without loads of early starts.Autonomous recorders are sometimes known as frogloggers in the nature recording community. Commercial variants and great, reliable, but dear. I want something I’m prepared to take the risk of losing to some inquisitive dog-walker, and preferably something I can make enough of to scout several locations.
A Raspberry Pi via Wifi is also a good remote startable recorder over WiFi . A bit like the Tascam DR-44WL but without the nice display. the trouble is the Raspberry Pi has no record facilty. If it had, you can start recording by logging in via SSH and issuing the arecord function. The audio can even be transferred off the Pi remotely via SFTP over WiFi. Enter the Wolfson Audio board – a piggyback audio card for the Pi, which takes over all the IO so you aren’t going to be running any other custom hardware on that Pi.
Installing the Wolfson
Physical installation is easy enough, the Wolfson board uses the bizarre approach of connecting to the GPIO using a standard header and the P5 header using a set of pogo pins.[ref]I did have trouble with these once – what happens is you issue the record for x seconds command and in simply sits there and never times out. Then you press the GPIO down again and it comes good… P5 carries the i2c bus SCL0 and SDA0 pins which control the Wolfson, lose contact on one of those and you aren’t talking to it any more.[/ref] I’d have been easy with soldering an extra set of pins or a header myself and this is probably a reliability hazard, but I’ll run with it for now. Just as well I’m not going to use the badly aligned yellow and white SPDIF sockets, eh?
I started with a Model A running a stock Raspbian image, 2014-06-20-wheezy-raspbian.zip and ignored Wolfson’s recommendation to avoid a USB hub, because I needed that to see what I was doing to set up WiFi.
No standard Raspberry Pi Drivers for the Wolfson
Unlike other bits of hardware, to run up the Wolfson card you can’t use the stock Raspbian and do an apt-get install some-sort-of-wolfson-driver. You’re in for a world of hurt here.
You either download the SD card image which is recommended by Wolfson. It’s 8Gb and it means 8Gb, and wouldn’t fit on my 8Gb card, because it requires a card with no dead sectors presumably.
Maybe time to compile the drivers myself following this? Nope – life is too short and I do not have the skillz to firefight what goes wrong. And what with the takeover of Wolfson by Cirrus it looks like the drivers are delayed still more. I like the Torygraph’s opener
Wolfson Microelectronics, the struggling Scottish microchip company, has been acquired by its American rival Cirrus Logic for £278m.[…]
Wolfson has become increasingly reliant on a few big customers including BlackBerry, which as seen sales of its smartphones collapse.
The company reported flat revenues of $179m and mounting losses of $13m last year.
Wolfson admitted it had been blindsided by the rate at which consumers were adopting 4G smartphones, which gave Qualcomm an advantage because it had developed an all-in-one 4G microchip that included an audio processor.
Damn. Those drivers aren’t going to happen any time soon, or maybe ever… I then used Ragnar Jensen’s zip described in this post, and the usage instructions here to install it. Which worked for me. I have no real idea how.
Don’t get the Wolfson card if you want playback until there are normal drivers available
My only interest in the card is to record – everyone else seems to want to take advantage of the whizzy playback options. To be honest there are alternatives if you want playback only, and it looks like the product is at risk of getting orphaned, since it is Pi Model A or B Rev 2 only, not B+, and is still driverless. You run the risk of getting stuck on an old version of Raspbian. That doesn’t bother me, as I will only use this for recording and not run anything else exotic on the Pi. If you want to run a media centre then you could start to hate being stuck on older versions of Raspbian.
How does it record, then?
I made the mistake of firing up ALSAmixer after installing, it certainly showed a lot of options and stuff going on which gave me a good feeling that the Wolfson card was present. But it is easier to adopt their installed ‘use cases’ that are installed in /home/pi
./Record_from_lineIn.sh
then issue
arecord -c 2 -f S16_LE -d 10 -r 44100 record_from_line_in.wav
to record a 10 second stereo track from Line in (that’s the -d 10 seconds, -d3600 would do you an hour, etc)
I experienced random buffer errors every 30s or so. Mindful of Wolfson’s warning about USB hubs I removed the keyboard (which has a hub) though I still used a hub to power the device, and because this was a Model A I had the wifi on the hub, and still took overruns
arecord -c 2 -f S16_LE -d 130 -r 44100 record_from_line_in1.wav Recording WAVE 'record_from_line_in1.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo overrun!!! (at least 90.703 ms long) overrun!!! (at least 50.601 ms long) overrun!!! (at least 15.111 ms long)
Although it looks ghastly here is an MP3 of the original file that I played into the Pi –
and here is the file recorded with the overruns above, converted to MP3
Which doesn’t sound so terrible to me at all. I should still not be such a cheapskate and buy SD cards from ebay, if a Class 6 card is what’s needed for audio 😉
I still got overruns with FLAC but they were shorter, which points towards disk IO as being the problem, since FLAC ups CPU load a lot but reduces disk writing, because that’s its job
arecord -c 2 -f S16_LE -d 130 -r 44100 | flac -o test1.flac - --channels=2 --sample-rate=44100 -f flac 1.2.1, Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Type `flac' for details. Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo -: 23% complete, ratio=0.468overrun!!! (at least 20.023 ms long) -: 69% complete, ratio=0.513overrun!!! (at least 0.553 ms long) -: wrote 11620131 bytes, ratio=0.507
Using FLAC (free lossless audio compression)
you must apt-get install flac
to get the codec first
Pipe the output of the record chain into FLAC to reduce file sizes by about 40% on field recordings
arecord -c 2 -f S16_LE -d 130 -r 44100 | flac -o test.flac - --channels=2 --sample-rate=44100 -f flac 1.2.1, Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Type `flac' for details. Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo -: wrote 11692886 bytes, ratio=0.510
with the flac command the single – means process stdin and -f means overwrite existing file
FLAC used to be a resource hog so I thought I’d look at the CPU usage, which seems to run about 12-15% on a stock Raspbian (no overclocking etc)
top - 18:07:28 up 1:54, 2 users, load average: 0.05, 0.04, 0.05 Tasks: 74 total, 1 running, 73 sleeping, 0 stopped, 0 zombie %Cpu(s): 12.4 us, 2.3 sy, 0.0 ni, 84.9 id, 0.0 wa, 0.0 hi, 0.3 si, 0.0 st KiB Mem: 187592 total, 145604 used, 41988 free, 14664 buffers KiB Swap: 102396 total, 0 used, 102396 free, 98588 cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 2713 pi 20 0 7488 1380 940 S 12.1 0.7 0:03.71 flac 2710 pi 20 0 4672 1372 1036 R 1.0 0.7 0:00.50 top 2676 root 20 0 0 0 0 S 0.7 0.0 0:03.14 kworker/u2:3 13 root 20 0 0 0 0 S 0.3 0.0 0:00.96 kworker/0:1 2683 root 20 0 0 0 0 S 0.3 0.0 0:01.61 kworker/u2:0 2695 pi 20 0 9260 1584 1000 S 0.3 0.8 0:00.12 sshd 2711 root 20 0 0 0 0 S 0.3 0.0 0:00.18 kworker/u2:1 2712 pi 20 0 4944 1336 1128 S 0.3 0.7 0:00.19 arecord 1 root 20 0 2148 720 616 S 0.0 0.4 0:04.29 init 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 3 root 20 0 0 0 0 S 0.0 0.0 0:00.46 ksoftirqd/0 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H 7 root 20 0 0 0 0 S 0.0 0.0 0:00.75 rcu_preempt 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh 9 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_sched 10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 khelper 11 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
Wolfson Card Analogue Line-up
So it’s time to line the card up and find out what analogue levels it takes. I’m going to need outboard audio processing anyway to bring mic level up to line level, and to be honest that’s probably better done off the board anyway away from all the digital power-supply sizzle. I can control levels in the analogue domain, so no need ot run alsamixer unless I want to do remote live recording.
I injected 1kHz tone from a Farnell Wien bridge oscillator ad found that the default gain setting is exactly right for a 1V rms input
When I ftp the file to my PC and look at it with a WAV player I see it is as close to 0dBFS as you can get
The audio doesn’t start recording instantly, there is an elegant fade in combined with an inelegant DC shift
It isn’t a big deal, but you probably want to start it .1s before the desired sound. That’s neither here nor there with a manual start but if auto-started from a sensor trigger that would be a bear.
Audio performance
I terminated both inputs with 150 ohms and used Audition to gather the stats on silence, starting 3s in, a reasonable way past the initial DC bump.
I then scanned the spectrum of the quiet recording to look for any frequency spurs etc, on a fairly narrow IF bandwidth (wide scanning window). I’m not going to argue with the results –
For reference here is the 1kHz tone (if you analyse it all the distortion comes from my 1970s era Wien Bridge oscillator)
and here is the quiet recording
I didn’t run rightmark on it since I don’t have anything good enough to generate the test signal and don’t know how to play and record at the same time on the Pi.
Since I want this for recording I didn’t bother to test playback – here’s a description of replay.
Time delay recording
The way to use this as a time delay recorder is to set cron to start on boot:
shutdown -h -t 3700
and
arecord -c 2 -f S16_LE -d 3600 -r 44100 record_from_line_in.wav
Then power on the Pi and the microphone preamplifier about half an hour before dawn and pull the power after about an hour and a quarter – the Pi should have halted by then. I will use a PIC microcontroller for that job, because it draws a very low power in the rest state, but an Arduino would work too, though it’s typically 7mA drain is higher than it has to be.
Conclusion
The Wolfson audio card records well, with low noise. You need to use a fast SD card otherwise you will get overruns. But it is poorly supported and the devil’s own job to get going. However, it seems the only game in town for high-quality recording.
Since that’s what I want to go I have to put up with the poor support and idiosyncrasies, it works well enough.