soundcards and memory

Hello and thanks. I am not sure where to post.

I am an electrical and electronics engineer interested in sound.

I am trying to write or develop an audio program.

From a hardware perspective, I am wondering whether soundcards can be accessed by reading memory locations off the motherboard. Eg. Com ports.

For the soundcard on this pc, the interrupt is 17, and the Input/Output is from 1000 - 143F etc.

I am wondering does the sound data that is recorded by a microphone, into the sound card
get stored in a buffer on the soundcard? Or does it take the input directly from the soundcard and store it in the computer’s RAM. (DMA memory access)?

The next question is whether soundcard come with programming manuals.

I am also confused about the soundcard, whether or not soundcards have a clock on them that can be read programmatically.

Eg reading the soundcard input froma mic along with time infromation. Not just the mic input.

The second thing that is driving me nuts, is how mixing occurs. If the sound card only has one input.
does teh soundcard store one mic sample (eg guitar), write the guitar sound into buffer and read a second microphone input (eg vocals) into a buffer and then mix the two signals.

Or rather, you record the microphone input one at a time into a file, then mix the files.

Does teh soundcard do mixing on the soundcard board or between different files in RAM?

In theory as a programmar depending windows and whether it gives you access the memory,
you should be able to read the soundacards memeory location. At the same time read from
memory to the soundcard’s output.

Eg the soundcard has a DATA register, CONTROL registers and teh other one which I cant remember…
By programming the registers you should be able to write sound sequences to/from memory.

When it comes to mixing, I have consulted a few books for information on these subjects but none of the books say how to mix two signals (or sequences).

Is this done
by logically ORing two mic samples (mic seq 1) OR (mic seq 2)
or do you logically AND them (mic seq 1) AND (mic seq 2)
or XOR (exclusive OR) between the two sequences.

And do you use OR, AND, or XOR to accomplish panning or channel seperation?

I am trying to skip linux API such as ALSA and microsoft API’s.
I want raw access to the soundcard.

I have seen electronic mixing circuits but if the sound card only has one input, they are redundant.

I would think or believe you record a sequence, dump it into file, then read a second sequence dump it to
a file, then down-mix or mix togheter teh two files or sequences into a third file.

Thankyou kindly for your assistance.

Regards
Greg Evans

I can’t answer all of your questions, but I’ll answer what I can and hopefully that will give some pointers of where to look next.

Audio programs access the sound card via the sound card driver rather than directly accessing the hardware. Your questions revolve around “how to write your own sound card driver”.

I’ve never yet seen a sound card that comes with programming manuals.
Sound cards generally have their own clock.
Cheap sound cards will generally mix in software whereas more expensive sound cards usually have on-board hardware mixing.
Proprietary sound card drivers are often closely guarded secrets.
Exactly what (and how) a sound card does internally is rarely published anywhere and varies from one sound card to another. The people that develop open source drivers invest a lot of time and effort in building up relationships with sound card manufacturers to gain access to the technical details required for writing drivers.

One approach that you could take would be to research one specific sound card chipset, for example the AC’97 digital controller and associated codec.
Although you do not want to use ALSA drivers, as they are open source, you could start by analysing at the ALSA driver code for the chipset that you are interested in.

There is an article here about writing ALSA drivers: http://www.alsa-project.org/~tiwai/writing-an-alsa-driver/

Processing, such as mixing or filtering comes under Digital Signal Processing (DSP). You will probably take a DSP class before you graduate. There is a great [u]FREE online DSP book[/u].

When it comes to mixing, I have consulted a few books for information on these subjects but none of the books say how to mix two signals (or sequences).

Mixing is done by summing. Analog mixers are built around a summing amplifier, which is can be built with a very simple op-amp circuit.*

When you mix digital files (or digital streams) the samples (1.e. 44,100 samples per second) from the files (two or more) are simply summed together… The 1st sample from the file-A is added to the 1st sample from file-B, etc. X1= A1+B1, X2= A2+B2… Xn= An + Bn. Of course you can offset the data if you want to start mixing-in the 2nd file half way into the 1st file, or if you want to crossfade the start of the 2nd file at the end of the 1st file.

When you mix, you usually have the option of adjusting the mixed-in volume, which is done by scaling (i.e. X1= 0.5A1+0.7 B1, X2= 0.5A2+0.7B2… Xn= 1.5An + 0.7Bn.

And do you use OR, AND, or XOR to accomplish panning or channel seperation?

If you want to pan left, you simply stick the signal in the left channel (or mix into the left channel): L1=X1, L2=X2… If you want to pan to the center, you stick the signal into both channels: L1=X1, R1=X1, L2=X2, R2=X2… Or typically, you want to keep constant power so you’d reduce both channels by -3dB: L1=0.707X1, R1=0.707X1, L2=.0707X2, R2=0.707X2…

BTW - Amplification (and volume adjustment) is done by multiplication. Or if you want to attenuate, you multiply by a fraction… If you want to reduce the level by -6dB, you multiply all of the samples by 0.5.

I am trying to skip linux API such as ALSA and microsoft API’s.
I want raw access to the soundcard.

Windows user aplications cannot directly access hardware (I think Linux is similar). So as Steve said, you’d have to write a driver. Typically the driver is written by the hardware manufacturer. With the API acting as a common interface, any Windows application can talk to any soundcard/driver. (In the old DOS days there was no common interface… for example, word processing applications came with many drivers for all of the popular printers. If you got a new printer, you just had to had to hope the word processing developer would write a driver to work with it. If you had a spreadsheet, you’d need to get a new driver from the spreadsheet developer too, because the word processor-to-printer driver would not work with the spreadsheet application!)

I have seen electronic mixing circuits but if the sound card only has one input, they are redundant.

There are audio interfaces with multiple inputs for multitrack recording, and there are analog mixers with USB outputs.

I would think or believe you record a sequence, dump it into file, then read a second sequence dump it to
a file, then down-mix or mix togheter the two files or sequences into a third file.

Audacity (or any audio editor) can mix files. Typically, you’d use a program called a DAW (Digital Audio Workstation) to mix multiple files together while adding effects, etc.

\

  • If you add another op-amp, you can make an inverter for one input and create a subtraction amplifier. If you subtract left from right, the “center channel” is removed and you have a “vocal remover”. But, this more easily done with an audio editor.