19
A Science Project: Building a sound card based on the Covox Speech Thing ckware v2.6 (4 Jan 2016) By: Yeo Kheng Meng (yeokm1@gm https://github.com/yeokm1 https://github.com/yeokm1/pcb https://github.com/yeokm1/pcb-co https://github.com/yeokm1/covox-mu http://yeokhengmeng.com/2017/01/a-science-project-bringing-the-covox-speech-thin 1

A Science Project: Building a sound card based on the Covox Speech Thing

  • Upload
    yeokm1

  • View
    738

  • Download
    2

Embed Size (px)

Citation preview

Page 1: 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 ([email protected])https://github.com/yeokm1/pcb-covox

https://github.com/yeokm1/pcb-covox-amphttps://github.com/yeokm1/pcb-covox-amp-v2

https://github.com/yeokm1/covox-music-playerhttp://yeokhengmeng.com/2017/01/a-science-project-bringing-the-covox-speech-thing-to-2017/

Page 2: A Science Project: Building a sound card based on the Covox Speech Thing

2

Demo

Page 3: A Science Project: Building a sound card based on the Covox Speech Thing

3

Background: Hackware v2.2 (7 Sept 2016)

Page 4: A Science Project: Building a sound card based on the Covox Speech Thing

4

What is the Covox Speech Thing?• Sound card released in 1986 by Covox, Inc

• 8-bit Mono

• Parallel Port interface

Image source: https://en.wikipedia.org/wiki/Covox_Speech_Thing

Page 5: A Science Project: Building a sound card based on the 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

DB-25 Connector

Image source: https://en.wikipedia.org/wiki/Parallel_port

Page 6: A Science Project: Building a sound card based on the Covox Speech Thing

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

Page 7: A Science Project: Building a sound card based on the Covox Speech Thing

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 outputReference: http://www.circuitbasics.com/build-a-great-sounding-audio-amplifier-with-bass-boost-from-the-lm386/

Page 8: A Science Project: Building a sound card based on the Covox Speech Thing

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

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/

Page 9: A Science Project: Building a sound card based on the Covox Speech Thing

9

My implementation• Covox Speech Thing clone• LM386 amplifier• Adjustable via potentiometers• Volume• Gain• Bass

• Raw and Amplified Output

Page 10: A Science Project: Building a sound card based on the Covox Speech Thing

10

Sending data to the Covox Speech Thing• Native parallel port adapters required• USB-Parallel adapters • Abstracts pin handling

StarTech Expresscard to Parallel Port StarTech PCI-E x1 to serial-parallel combo

Page 11: A Science Project: Building a sound card based on the Covox Speech Thing

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

Page 12: A Science Project: Building a sound card based on the Covox Speech Thing

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

Page 13: A Science Project: Building a sound card based on the Covox Speech Thing

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

Page 14: A Science Project: Building a sound card based on the Covox Speech Thing

14

Program workflow1. 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

16-bit -> uint8_t

uint8_t

Page 15: A Science Project: Building a sound card based on the Covox Speech Thing

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

Page 16: A Science Project: Building a sound card based on the Covox Speech Thing

16

Potential Work

• USB version with FTDI FT245R chip• USB to 8-channel output

Page 17: A Science Project: Building a sound card based on the Covox Speech Thing

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

Raymond Chen image from: http://www.dailytech.com/Microsoft+Exec+Reveals+Steve+Ballmer+Created+Original+Blue+Screen+of+Death+Message/article36512.htm

Page 18: A Science Project: Building a sound card based on the Covox Speech Thing

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.

Taken from: https://blogs.msdn.microsoft.com/oldnewthing/20130319-00/?p=4913

Page 19: A Science Project: Building a sound card based on the Covox Speech Thing

19

The End

http://yeokhengmeng.com/2017/01/a-science-project-bringing-the-covox-speech-thing-to-2017/