2
\$\begingroup\$

Below is a primitive representation of audio flow in a PC:

schematic

simulate this circuit – Schematic created using CircuitLab

A program executes a code, after many steps in binary/transistor level finally the audio is sent from the CPU to the soundcard in digital domain. The sound card then processes this incoming information to analog signal and amplifies and outputs to a speaker.

Knowing that the CPU is a serial processor, how come we can still hear several different sounds from the speaker as they are distinct. Somehow the soundcard does not mix simultaneous incoming audio data. And most confusingly imagine one executes three programs where all outputs different audio. But at the end there is one single current passes through the speaker.

What is that current composed of? Is that the addition of three different waveforms? If so are they added in soundcard or before? Is sound card parallel processing and adding them at the end?

\$\endgroup\$
  • 1
    \$\begingroup\$ It's a good question and I'm going to enjoy reading those struggling to answer this; designed to make clear and comprehensive sense at this level of question. \$\endgroup\$ – jonk Nov 22 '18 at 21:07
  • \$\begingroup\$ Hi, @jonk. I didn't struggle with my answer below. Now I feel it must be no good. ;^) \$\endgroup\$ – Transistor Nov 22 '18 at 22:51
  • \$\begingroup\$ Somehow the soundcard does not mix simultaneous incoming audio data. .... that conclusion is incorrect ..... if the sound is emanating from one speaker, then it is mixed .... your ears and brain separate the sound into distinctly perceived components .... it is same thing as when you can clearly hear your own name being called in a crowded room, but not so much somebody else's name \$\endgroup\$ – jsotola Nov 23 '18 at 0:59
4
\$\begingroup\$

... how come we can still hear several different sounds from the speaker as they are distinct.

Each ear hears the sum of the sound pressure oscillations on the eardrum. There is only one signal felt by the eardrum yet our brains can clearly identify the multiple sources in a musical piece or a voice over background noise.

Analog electrical sound signals are exactly that - an analog. The voltage rises and falls as an analogy of the sound pressure on the microphone, etc.

enter image description here

Figure 1. Three individual sinewaves and their sum. If you hit three different frequency tuning forks the sines would represent the audio waveform from each and the yellow curve would represent the sum of those reaching the ear. In their electrical form the process is the same.

Somehow the soundcard does not mix simultaneous incoming audio data.

Yes it does.

And most confusingly imagine one executes three programs where all outputs different audio. But at the end there is one single current passes through the speaker.

The sound card sums the signals it receives. For audio at CD quality the soundcard will do a digital to analog conversion at > 40 kHz so the three data streams would have to arrive at that frequency too. Each sample from each source would be buffered (as they are coming in serially in your example), summed and converted to an analog output sample.

What is that current composed of? Is that the addition of three different waveforms? If so are they added in soundcard or before?

Generally it would be done digitally but there could be an analog mixer for special applicatons.

Is sound card parallel processing and adding them at the end?

For a simple sum of three signals it would: Buffer all the inputs for one sample. Sum them. Output the analog value of the sum. It can get way more complicated than that however. Your Windows audio mixer, for example, allows you to adjust the volume of each sound source so there would be some multiplication taking place on each signal before the summation. Tone controls would add another layer of increasing complexity and any time dependent effects such as reverb, echo, chorus, pitch-change, etc., would require much more computation on each signal before conversion to analog.

enter image description here

Figure 2. Sound card block diagram by Alexander Pimpas.

The random web image above shows several features. I can't vouch for its accuracy or age.

  • Note that the audio in and audio out are connected to an audio mixer. This implies that the mic, line in or CD audio out could be fed to the audio out without any digital processing. They could also be mixed with the digital audio.
  • We can see ACD (analog to digital) and DAC (digital to analog) blocks interfacing the digital and analog domains.
  • The Waveblaster is a MIDI synthesiser which will generate synthetic instruments based on the MIDI data.
\$\endgroup\$
1
\$\begingroup\$

How does the sound card process different incoming audio signals before outputting to the same speaker simultaneously?

I'm just going to start with a brief blurb about what a sound card does. The soundcard can store, mix, process and buffer sound. Only the analog input(if present) and non digital outputs share the same "type" of signal as the speaker receives. The connection to the CPU as well as any fiber optic or HDMI inputs or outputs are all digital, and are capable of transmitting much more data than is required for a single audio signal. The slowest PCI Express standard is capable of 250 MB/s and a single channel of CD quality audio only uses 705.6 Kbps, so one PCI express lane without overhead can keep up with roughly 2.8 million CD quality audio signals, so getting information to and from the card is no problem.

A program executes a code, after many steps in binary/transistor level finally the audio is sent from the CPU to the soundcard in digital domain. The sound card then processes this incoming information to analog signal and amplifies and outputs to a speaker.

The programs running on the computer determine what audio signals must play and when. Data representing audio signals must be brought from slow storage and kept in memory.

All of the signals meant to play at once must be processed and mixed, which can be done by the CPU or the sound card. Almost all soundcards are capable of mixing a large number of channels, but the better and newer a soundcard is the more likely it can perform significant amounts of processing, things like converting to directional audio, echo or room effects and normalization to take processing load off the CPU and/or provide a better quality experience. To mix two audio signals, they must be converted to compatible format(if stored compressed), the amplitude of the signals at each point in time can be summed(literally added together) and then normalized(volume adjusted because doing this doubles effective amplitude). You have to either have headroom(storage space and ability to process larger numbers than the original signals contained) or normalize before summing, which could reduce signal resolution if not done correctly.

Knowing that the CPU is a serial processor, how come we can still hear several different sounds from the speaker as they are distinct. Somehow the soundcard does not mix simultaneous incoming audio data. And most confusingly imagine one executes three programs where all outputs different audio. But at the end there is one single current passes through the speaker.

Once the audio has been processed and mixed, it is still in digital form and as the soundcard produces the actual output (1 digital signal per output channel), it wouldn't be efficient to design the soundcard to produce this output at precisely the correct rate, so it's put in a buffer at whatever rate it is produced. The output is then converted to analog from the buffer at the correct rate and that output is what goes to the headphone jack on your computer.

What is that current composed of? Is that the addition of three different waveforms? If so are they added in soundcard or before? Is sound card parallel processing and adding them at the end?

The current is composed of moving electrons. Yes, the waveforms are literally added(Any number can be simultaneously mixed btw, so you can use (Signal1+Signal2+Signal3+Signal4+Signal5)/5 = OutputSignal rather than adding them together 2 at a time.), and this can be done by the cpu or the soundcard. It could be the application, the operating system, or the soundcard doing the processing.

I'm just going to add an example to put it together. You have a first person shooter game running, an MP3 player playing music connected to the aux input jack and several other programs running that provide audible notifications. You have 5.1 channel speakers attached to your computer.

The MP3 player provides audio to an ADC in the soundcard, which converts the signal to digital and feeds it to the audio driver, which provides a volume adjustment, and may also split the 2 channel audio into 5.1 channel audio(to make it play on all 5.1 speakers instead of just front left and front right), at which point the signal is ready to be output. The CPU can either perform the volume adjustment and splitting itself or provide the soundcard with parameters instead.

Each of the programs using audible notifications will provide a volume adjustment, may split the audio into multiple channels if it comes from a mono file, and pass it to the audio driver, which might provide a second volume adjustment and/or split it into 5.1 channel audio, at which point the signal is ready to be output. Again, the CPU can either perform the processing functions or pass it off to the soundcard.

Finally you have your FPS shooter game running, and it's running in native 5.1 channel mode. At any given point in time we'll say it's playing an average of 15 different sounds, ambients, grey noise, running engines, footsteps, gunshots and echoes or some such. Because all of these are sounds stored in normalized wave files, once the sound has been loaded in memory, you can't simply send it to the soundcard at the correct time because direction and distance must be taken into account, so directional sounds must have their volume modified based on distance and be split into the correct channels to be played on the correct speakers. All of these sounds must be mixed, which again may be done by the CPU or the soundcard. Finally the data may undergo a volume adjustment. This application(gaming), in particular, can amount to a considerable workload, and having the soundcard perform these tasks rather than the cpu is beneficial. At this point the signal from the game is ready to be output.

Now we have three audio streams from different programs, which, again, must be mixed, normalized, and the master volume adjustment performed. Each of these audio streams may be 2 channel or 5.1 channel. If neither the operating system or soundcard is instructed to split the 2 channel into 5.1 channel, two channel is mixed with the front left and front right speakers.

Once all of this is done, you have 6 signals being output to their own DAC, each of which consists of a mixture of many.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.