# Build your own sound card!

### How about building your own 16-bit sound card? If you aren't a beginner in building hardware and you have a soldering iron, which is a bit different from the soldering iron to work on sheet-iron, well, your work must succeed. We'll show you how to do the job. All the needed parts of this card can be bought.

The success of the process requires the knowledge of the work of neither the chip nor its environment, it's enough if you put the parts onto the board and solder them. Setting the card up is as easy as setting up any Windows-application, and, after the actual setup, the card can be used by every Windows program.

When the card is at its final place and working, it's time to get known to its job by using the softwares accompanying it. We'll show you an assembler program which does this task. It is very simple- it digitizes, saves and plays back. All the registers on the card are described bit-level and the card can be fully controlled.

The heart of the card

It was Analog Devices that has released the first Microsoft Windows System- compatible sound chip, named AD1848. This chip can be found in most of the high-quality sound cards. A bit later Crystal Seimconductor, from Texas, also released a chip for the same purpose under the name of CS4248. The chip has an advanced compression technique, compared to AD1848. Later an even better sound chip has been released, named CD4231, which is the newest and most powerful MS Windows Sound System-compatible sound chip at the moment. We've chosen this chip for the heart of our card.

###### Pic 1: Settings of the driver program of the soundcard

The CODEC-chip contains two 16-bit A/D converters, and they're used to digitize (sample) sounds. The same stands for the two 16-bit D/A- we replay the recored digital sound (WAW) through them to get the analog signal back and to amplify it with an amplifier and to listen to on loudspeakers. The CODEC chip contains quite a lot of DSP logics, digital receiver- and transmitter-logics, digital mixer, digitally controllable input- and output signal amplifying/weakening, and, in addition, compression- and decompression- parts.

The chip itself is Windows Sound System-compatible and it can both record and play 16-bit stereo sound at 44.1 kHz sampling rate, which is used in CD-players.

Of course, there are cases when it's useless to digitalize the input at 44.1 kHz. In order to save disk space, one can use 11kHz or even 8 kHz as the sampling frequency. The lowest sampling frequency of the card is 5.51 kHz and the highest is 48 kHz. There are also useful digital filters in the chip to help us if we're using low sampling frequencies (to alleviate or even cut the frequency band above the half of the sampling frequency). The SNR rate is always very high, both in record and play mode, thanks to the help of the effective FIR filters.

There are on the card, in addition to the CODEC chip itself, only 4 additional chips to control the ISA bus, 2 to handle the analogue sound signal. One of the latter chips is responsible for the amplifying the out-signal, in order to have the necessary power to drive even loudspeakers, and the task of the other is to handle the incoming signals - both the mike and the LINE-in signals.

There are two inputs on the card for two LINE inputs and one mike with 1V average signal level, and one input to receive the sound coming from the CD-ROM. There are also choices, as regards the output - the LINE-outs offer 1V average signal level outputs for headphones or extrenal amplifiers, and there is an output for loudspeakers as well.

One can buy the board of the entire card, and by using it it'll be far easier to build the entire chip. If one wants to design the card himself, the size of the common ground must be as big as possible, and the digital lines should be as far away from the analog ones as possible. The +5V power of the CODEC chip is got not from the machine's own, noisy 5V but from the regulator on the card, so that the SNR could be as high as possible. And the hard disk, the video card and other cards can't decrease the SNR, either.

It is by the means of a program by Crystal Semiconductors that one has to check the card. This program has shown us the following results:

    Harmonic disortion: 0.006%
    SNR: 75 dB

There is also a spectrum-alalyser in the test program, and with the help of it one can graphically check the above mentioned values. The test signal is shown on the screen as a peak level, which elevates to as high as -10 dB. Noise and disortion stay as low as -90dB in the entire frequency area of 0...20 kHz.

How does the card work?

The mike signal is driven to the CODEC chip through the mike-amlifier IC7A and IC7B. The LINE-level LINE and AUX inputs, from the inputs J9 and J10, are put on the CODEC input through R9...R16. The CD-ROM signal, from the AUX2 input connector J2, is brought to the CODEC through R30-R33. The output signals of the CODEC are brought to the buffered amplifier IC7C and IC7D, and further, via jumpers J14 and J15, to the output socket J11. The CODEC output is also brought to the amplifier chip IC4, and one can use its output as well, if wants to drive not headphones/ext. amplifiers but loudspeakers, by setting the jumpers J14 and J15 to the other position.

As regards the ISA-bus, IC2 is a two-directional bus-buffer between the ISA bus and the CODEC. All the datas coming from the CODEC / to be sent to the CODEC must go through this chip in 8-bit form. E.g. one 16-bit stereo sample contains 32 bits = 4 bytes. The data transfer is not a problem, as we use DMA, so that we can transfer datas between the main memory and the card without making the central CPU do this job itself. There is an another possibility to transfer data between the machine and the card: with the help of the usual I/O ports. All the commands towards the card are to be sent via I/O registers. Look at List 1- the program is able to record and playback, after setting the wanted mode.

IC3 works as an I/O, IRQ- and DMA- buffer between the computer and the card. The programmable GAL, IC6, works as an I/O-address decoder, and IC5 sends the recognition code of the WSS card (04) to the ISA bus. One can check this value reading the 4th register from the I/O base address. This I/O base address can also be changed by J4 and J5,

The DMA-channels, which work when digitising/replaying, can be chosen via J7 and J8. Both jumpers should be set in pairs: one is for DMA request and one is for acknowledging the DMA request. So, 4 jumpers are used on J7 abd J8. The interrupt signal (IRQ) is chosen by jumper J6.

Building the card

To help putting the entire card together, the shape of all the parts is printed on the board. Before soldering the parts onto the card it's recommended to check whether the chips are put in the right direction, because it's almost impossible to remove the fixed components (mainly chips). It's a must to check whether the Codec-chip is put on the card paying attention to the direction of the arrow: it must be the same direction as can be seen on the card. Of course one should also check whether the electrolit condensators are soldered in with the right polarity.

The legs of the components should be bended such a way that there is no possibilities of short circuit between one another. The soldering iron should have very sharp-pointed, because the components are very close to one another and the tin can also cause short circuit. It's very hard to find the errors, and these mistakes can be sometimes extremly dangerous for the chips. At the end, one should check whether there is tin in every holes on the board, turning it against the light.

One should also check with a resistance-meter whether there is short circuit between both the address- and data-lines of the card, the ground/ the +12V/ +5V power lines and each other. At the end, the CODEC should be inserted into its socket, and this part of the entire project is ready.

How to set up the card?

At first, one has to determine what I/O address, DMA channel and IRQ line should be chosen. Only the other cards in the machine can reserve one/some of them - in this case we must choose non-reserved ones. Assuming no other cards use the same settings, we can leave the default settings intact.

J14 and J15 should be set into the position - whether we want to insert headphones/ext. amplifiers or loudspeakers into the output of the card. It's important that the card can generate extremly strong sound signals in case of errors, and it can destroy the appliances used to listen to the card's output. As regards choosing the right, strong enough model of loudspeakers, their power should be around 5 Watts.

Setting the mike-type jumper depends on the type of the microphone we're going to use. In the case of condensator microphone we can receive with the Windows Sound System packet, we have to use the CAP. In the case of using some normal dynamic microphone, set it to DYN.

The card is to be inserted into a 16-bit ISA slot. At the same time, it should be checked that the thickest and longest components of the card, the 1000 microFarad condensators don't touch the card next to ours. To decrease the noise and other problems, put the card as far as possible from the other cards. Of course, when putting in/pulling out the card, the machine should be switched off.

The following list tells us how to set up the card:

1. Start Windows.
2. Put the disk of the chip to the disk drive (A: or B:)
3. Choose the Run command of the File menu in Program Manager
4. Issue the A:SETUP command (or B:SETUP)
5. The program recomends us the target directory C:\CRYSTAL. if it suits us, ENTER.
6. When the Business Audio Setup (fig 1) hits the screen, we have to enter the setting of the card:

       Duplex= Full
       I/O Addr= 534h
       DMA Play= 1
       DMA Capture= 3
       IRQ=7

7. in the DMA Option-screen choose Demand Mode.
8. Don't choose anything in the WSS Compatible Hardware Option- window, just click on the OK button. (Don't choose "Auto-select (WSS) PAL" because there is no automatic DMA- and IRQ-choosing on the card - we have to choose them manually, by the means of jumpers. Don't choose "OPL3 Synthesiser" because we don't have any.)

After this, the program asks us to reboot Windows, in order to invoke the driver of the card. Assuming everything has been right, one should hear the short fanfare of Windows and see the picture of Crystal Business Audio announcing that everything is right and the card is working.

The SETUP program has also created a program group called Crystal, which has the programs both Business Audio Input and Business Audio Mixer.

In Business Audio Input (pic 2) we must choose the input first (mike, line, Aux), we can check the level of the incoming signal on the VU-meter and set the input level to a suitable one. Volume meter (VU On) should be switched on, in order to see the VU-meter and hear the sound also on the output of the card.

In Business Audio Mixer (pic 3) one can mix each input with others, the volume of the monitoring and the volume of the normal playback. When one sets the monitor mode on, the D/A is put just after the A/D module, so one can monitor the digitised information, checking the effect of the different sampling rates, resolution (8 or 16 bits) etc...

###### Pic 2: The sound card is used by this program

###### Pic 3: One can mix each audio input's signal

###### Table 1: Jumper settings. Default settings are marked with a star.

###### Listing 1: We set all the concerned registers into the needed mode. After then, the program shows us the main screen "Record Play Quit". By pressing the R key we digitize the incoming data and put it into the main memory (till it fills up completely), and the key P plays it. It's very easy to develop the code further. REKISTERIEN ASETUSMAKRO: a macro for setting up the registers, indeksiportin osoite: addy of the index port, testataan, onko...: we test whether the CODEC is ready, tilanmuutosbitti 6 päälle: we set the status bit 6 to 1, lisätään indeksi: we increase the index, kirjoitus indeksiporttiin: writing to the index port; dataportin osoite dx:ään: we put into dx the address of the data port, luku: number, data al:ään: we put into al the received data, kirjoitus dataporttiin: writing to the data port, ja mennään indeksiportille: and let's switch to the index port, odotetaan kunnes CODEC on valmis: we wait until CODEC is ready, tilanmuutosbitti 6 pois päältä: we set the status bit 6 to 0, kirjoitus indeksiporttiin: writing to the index port, odotetaan kunnes CODEC on valmis: we wait until CODEC is ready. CODECIN REKISTERIEN ASETUS: we set the registers of CODEC, Vasen ottokanava: the left input channel, Oikea ottokanava: the right input channel, vahvistus: amplifying, 20 dB mikrofonivahvistus: amplyfing the mike input with 20 dB, signaalilähteen valinta: choosing the input source, D/A:n anto: the signal the D/A gives. VAsen/oikea XXX-kanava: left/right XXX channel, mykistys: making dumb, vasen/oikea antokanava: left/right output channel, kide1/2: chrystal 1/2, datan muoto: the data format, näytteottotaajus: sampling frequency, kompressoitu: compressed, 8 bittiä, kompressoituna 8 bittiä, jolloin: 0= u-law, 1=A-law: 8 bits, compressed 8 bit, where 0= u-law and 1=A-law. Liityntätapa: mode, estetään: is prohibited ed, sallitaan: is allowed, DMA kanavat: DMA channels, Automaattinen kalibrointi: automatic calibration, -tapa: -mode, Nastojen ohjaus: DMA/iRQ modes, dithering on (kyllä)/off(ei); Tarkkailukuuntelu: monitoring, A/D > D/A kytkentä päälle:: allowing the monitoring, vaimennus: making the signal -1.5 dB weaker, testi:test.

###### On the left one can see the ISA-bus and its interface. The CODEC-chip is in the middle of the picture. To the right from the CODEC one can find the amplifier of the speaker and, above it, the headphone amplifier . In the upright corner there are the two AUX1 line inputs and the connector to receive the sound from the CD. Data lines (from/to the ISA bus) are marked with thicker line-endings. All data lines with the same symbol (e.g. DB7) are connected. The built electronics doesn't cover the entire board.

###### The list of the needed components.Stereovastake is 3.5 jack socket, and piikkirima is jumper

###### To help in your designing the entire card we show the placing picture of the card. Before soldering the parts onto the card it's recommended to check whether the chips are put in the right direction, because it's almost impossible to remove the fixed components (mainly chips). It's a must to check whether the Codec-chip is put on the card paying attention to the direction of the arrow: it must be the same direction as can be seen on the card. Of course one should also check whether the electrolit condensators are soldered in with the right polarity. Codec-piiri (beginning from the upleft position of the card) is the CODEC-chip, Mikrofonin valinta is the jumper to choose from the two available microphone types, tuoliittimet: cd-rom ääni is input from the CD-ROM, mikrofoni is the mike jack socket, linja 1/2 stand for Line 1 and Line 2, respectively, Antoliitin: linja/kuuloke/kaiuttimet is the output to line in/headphones/loudspeaker. Antosignaalin valinta: is the place where one can set the output device in use. IRQ-linjan valinta is the jumper area where the IRQ is chosen, Nauhitus is used to set the DMA capture address and Toisto the DMA play.

# When the card is ready

In case you want to reconfigure the card, you have to do the following. Choose Control Panel and Drivers on it. Choose Crystal Business Audio and Setup. Change the settings, but do NOT restart Windows - leave it, switch the machine off, grab the card and do the necessary changes. Card back to the machine and start Windows.

How to test the card?

At first, we can check the WAV files added to Windows. Choose Audio Business Mixer. Set the volume-glider Wave Atten to the middle of its track, and switch Mute off. Start Media Player and load some WAV file from e.g. the Windows directory. set the It should be played and the sound should be heard in the headphone/ loudspeakers. By pressing the Alt-Tab combination, we can go back to the Audio Mixer window, and set the volume to the desired value.

In the next step we can test the capture. IN order to do this, one ha to connect something e.g. to the LINE input something, e.g. from some tape deck's headphone output; or a mike to the mic input. After that, set the input source in Business Audio Input to either LINE IN or MIC. One can set the input level here as well - don't let the UV show peak values in the red area. If the microphone is not sensitive enough, we can switch in the +20 dB amplifying.

Next, we can try out the capture capability. Record somethig with the program Sound Recorder. If the replayed digitised sound sounds good, we've managged to build the card.

Programs on the Setup disk

There is a sound recorder, an echoer and jukebox-application. In the sound recorder called Business Audio Transport there are far more services than in the own Sound Recorder of Windows. When we start to record something, and open a window by entering the new filename, a window emegres, in which one can set the sampling frequency, the data format, the compression type and the mono/stereo switch. One record from both only one and more sources at the same time. With the help of OLE one can insert the files made by this program to other Windows applications.

The echoer program (Echo Plexer) is capable of adding any kind of echo to the recordeed sound. One can set the length, the strength and the weakening of the echo. The Echo Elf-service can be quite interesting: it duplicates the frequency of the echo. The same stands for Echo Orge, in the other direction: it divides the frequency by 2.

Jukebox (Multimedia Jukebox) can be used to collect files, residing in different directories, in an order to play them. The program can play WAV-files. The program also handles MIDI, but, as the card doesn't contain syntheser chip, we can't listen to MIDI files.

Other services

The first steps to use the card are Windows's Media Player and Sound Recorder. One can attach the sound effects made by Sound Recorder to file copying etc... - one can add such effects to other parts/services of Windows as well.

With the help of Microsoft Windows Sound System (its price is some 500 mk) one can record to the hard disk with different speed and resolution: from 44.1 kHz/16 bit/stereo to 8 kHz/8 bit/mono (to record speech in a non-disk-consuming way). One can also make the program pack the sound files to a very small size. The program is very useful when handling the files - one can connect the effects in a far more many-sided way than above. E.g. if the spoken message souns to boring, one can add music to its bacjkground. Sound files can be strenghtened/weakened, one can edit them (adding start- and end-fading), one can set the tone (to high/low frequencies can be cut), there are possibilities to play recorded sound files with different speeds, or even in the other direction, from the end to the beginning.

There is a microphone bundled with Microsoft Windows Sound System, which is usable to control Windows by speaking withg the help of Voice Pilot. The computer can be very easily taught to issue simple command like Edit or Copy. The command are also working in the Finnish Windows, and command can also be taught in Finnish. One can, of course, teach the machine to issue several, many-sided commands when we utter one word to invoke this.

There is also a number-reader application in the box, which canb be used to listen to numbers, dates, monetary units etc. Unknown words can be suffixed by the rules of the English grammar. The machine can also read martked areas or tables, which may contain lots of numbers, typed in by hand- it's very col when onme has to enter a great deal of numbers and it's fr easier to compare the numbers in the machine to the original ones when one has only to listenm to the sound and not to stare at the screen.

Sound Blaster-emulation

In the Windows Sound System pack there is a driver which allows the card to act as a Sound Blaster in DOS-based games and applications. The program emulates the Sound Blaster, and it is usable to play both music and digitised sound. The file which does the entire thing is WSSXLAT.EXE, which should be invoked from Config.sys by the following command:

DEVICE=C:\SNDSYS\WSSXLAT.EXE sbio=220 irq=7 dma=1 wave=7 linein=7

The default values in this case are the following ones: I/O address: 220h, DMA: 1 and IRQ: 7. The DMA PLAY on our card should be also 1 and the IRC must be also 7 to hear anything on our own card, while the I/O address of or cared can be 534h.

Some games don't regard this emulation offered by WSSXLAT.EXE fully Sound Blaster-compatible. They require hardware-level SB-compatible cards.

How to use the card in our own programs?

The card gives us the possibility to use sounds in our own programs. The clever programmer adds to his/her program, a great deal of digitised effects, commands, musics, announcements etc...

For the Windows programmers, there is a full documentation on the setup disk about the interface between the driver of the card and his/her own Windows- application. When needed, the manufacturer of the chip, Crystal Semiconductor, helps with advices to program the Windows- interface.

The card can be also used in DOS-based programs. Look at the example of Listing 1, which shows how one can program the card under MS-DOS. We set all the concerned registers to the needed mode. After then, the program shows us the main screen "Record Play Quit". By pressing the R key we digitize the incoming data and put it into the main memory (as much as possible), and the key P plays the previously saved signal. It's very easy to develop the code further, e.g. to add disk-writing and reading-functions. Also, it's very easy to monitor the quality of the different modes with only small changes in the program. The FULL listing of the program can be found on the included disk.

The example program doesn't use DMA, it communicates with the card only through the 4 I/O registers. The first of them (e.g. 534h) is the choosing address of the data register. By sending a byte to this address, the low 4 bits will choose the wanted register, which is one of the 15 possible registers. When writing to this register, one has to pay attention to set the 6th bit to 1. The next I/O address (535h) is the data register of the chosen register we are going to send datas to. The next address (536h) tells the card what to do with the data in capture/playback mode - this register tells us to receive analog signal from the outside world, or do we want to play back the music back. Through the last register (537h) can we receive/send digitised data bytes from/to the card.

If you'd like to get some more additional information on the card, send a letter to MikroBitti, Teuvo Lahti, PL64, 00381 Helsinki, with a stamped, addressed A/4 envelope included.