This document describes a science project to build a sound card based on the Covox Speech Thing from 1986. Key points include:
- The project involves designing PCBs and writing software to interface the Covox Speech Thing, which uses an 8-bit DAC and parallel port, with modern computers.
- Challenges include sending audio data at consistent rates without direct memory access and ensuring low-latency playback on Linux.
- The project meets Raymond Chen's definition of a "science project" by solving a problem few consider important using obsolete hardware for technical challenge rather than practical user benefit.
Unblocking The Main Thread Solving ANRs and Frozen Frames
A Science Project: Building a sound card based on the Covox Speech Thing
1. A Science Project:
Building a sound card based on the Covox Speech Thing
Hackware v2.6 (4 Jan 2016)
By: Yeo Kheng Meng (yeokm1@gmail.com)
https://github.com/yeokm1/pcb-covox
https://github.com/yeokm1/pcb-covox-amp
https://github.com/yeokm1/pcb-covox-amp-v2
https://github.com/yeokm1/covox-music-player
http://yeokhengmeng.com/2017/01/a-science-project-bringing-the-covox-speech-thing-to-2017/
1
4. What is the Covox Speech Thing?
• Sound card released in 1986 by Covox, Inc
• 8-bit Mono
• Parallel Port interface
4Image source: https://en.wikipedia.org/wiki/Covox_Speech_Thing
5. What is a parallel port?
• External Computer interface
• Introduced by Centronics in 1970
• Standardised as IEEE 1284 in 1994
• 8 data lines
• Notable uses:
• Printers
• ZIP drives
• CNC machines
• Obsolete by 2000s 5
DB-25 Connector
Image source: https://en.wikipedia.org/wiki/Parallel_port
6. How does the Covox Speech Thing work?
• R-2R resistor ladder
• 8-bit Digital-Analog Converter
• Each output adds a voltage step to
the output
• MSB – Data7
• LSB – Data0
• Requires ≤ 1% tolerance resistors
6
7. LM386 Amplifier
• Amplifies the R-2R signal
• Volume: Voltage divider on original signal
• Gain: Resistor-Capacitor (RC) circuit between Gain pins
• Bass: RC Circuit between Pin1 and output
7
Reference: http://www.circuitbasics.com/build-a-great-sounding-audio-amplifier-with-bass-boost-from-the-lm386/
8. How do typical sound cards get data?
• Direct Memory Access (DMA)
• PCI/PCI-E devices can access RAM
• DMA Engine in every peripheral
1. CPU -> RAM: Sound Data
2. CPU -> Peripheral DMA Engine: Memory addresses of data to transfer
3. CPU -> Peripheral: Start transfer. CPU can do other things
4. RAM -> Peripheral: Data at memory addresses
5. Peripheral -> CPU: Transfer complete interrupt
• Covox Speech Thing
• Bunch of resistors do not a DMA Engine make
• Entirely CPU-driven
8
CPU
PCI-E Root Complex RAM
PCI-E Device
(Audio)
PCI-E Device
(Network)
DMA Engine DMA Engine
Reference: https://geidav.wordpress.com/2014/04/27/an-overview-of-direct-memory-access/
9. My implementation
• Covox Speech Thing clone
• LM386 amplifier
• Adjustable via potentiometers
• Volume
• Gain
• Bass
• Raw and Amplified Output
9
10. Sending data to the Covox Speech Thing
• Native parallel port adapters required
• USB-Parallel adapters
• Abstracts pin handling
10
StarTech Expresscard to Parallel Port StarTech PCI-E x1 to serial-parallel combo
11. Consistent data send rate
• CD quality
• Bit rate = 16 bits per sample
• Channels = 2 x sample (Stereo)
• Sampling rate = 44100 Hz
• Play time per frame = 1 second / 44100 = 22.68 microseconds
11
12. A DOS media player
• Written by Martin Rehak in 2007
• Default DOS Interrupt Service Routine(ISR) has 55 millisecond resolution
• Install new timer ISR
• DOS is single-tasking, applications can take control of the entire system
• https://www.youtube.com/watch?v=iOxOxpSg3WE 12
13. My media player
• Tested on Linux Mint 18 (Ubuntu 16.04)
• Requires address to parallel port
• lspci –v
• cat /proc/ioports | grep parport
• Written in C for maximum performance and ease of API calls
• Prints out frames skipped number
• Frame contains all the samples of channels per unit time 13
14. Program workflow
1. If the file is not a WAV, call FFMpeg to convert it to WAV
2. Use the libsndfile C library to parse the WAV file
• http://www.mega-nerd.com/libsndfile/
3. Convert each frame to mono uint8_t (1-byte)
4. Write the uint8_t value to the parallel port
5. Go back to Step 3 until the file ends
14
16-bit -> uint8_t
uint8_t
15. Ensuring a consistent playback
• Calculate the time required to play each frame
• long long nanosecondsPerFrame = 1E9 / sampleRate;
• Run a tight while loop
• Loop until X nanoseconds passes before playing
15
17. What is a “Science Project”?
• By Raymond Chen
• Principal Software Engineer, Microsoft
• Joined 1992
• Runs a blog “Old New Thing”
• Mar 2013 post: https://blogs.msdn.microsoft.com/oldnewthing/20130319-00/?p=4913
17
Raymond Chen image from: http://www.dailytech.com/Microsoft+Exec+Reveals+Steve+Ballmer+Created+Original+Blue+Screen+of+Death+Message/article36512.htm
18. A Science Project by Raymond Chen
1. A feature that is really cool and challenging from a technological
standpoint but is overkill for the user-scenario.
2. Requires hardware few people have.
3. Trying to solve a problem that nobody really considers to be a
problem. You're doing it just for the Gee Whiz factor.
18Taken from: https://blogs.msdn.microsoft.com/oldnewthing/20130319-00/?p=4913