News for hackers. Stuff that matters.
Re:Audio Processing for Dummies by jonplackett on Sunday November 10, 2019 @02:53AM (#21496961)
Is an audio stream really just a bunch of samples of volume? I had always assumed you needed to record different wavelengths of sound to capture different pitches. Is my mental model completely wrong? How do you get such variety in sound just from recording the volume?
Re:Audio Processing for Dummies by Ace17 on Sunday November 10, 2019 @03:06AM (#21497009)
PCM doesn't make any special case for different wavelengths. It's simply the air pressure over time (pressure on your ears, on the speaker's membrane, etc.) It doesn't directly correspond to the volume ("f(t)=1" is as silent at "f(t)=0").

So yes, an (uncompressed) audio stream is just a sequence of samples of pressure (or displacement, depending on the medium).

The variety you get comes from the high sampling frequency: a high sampling frequency allows representing vibrations of the air pressure at many frequencies.

Re:Audio Processing for Dummies by layoutIfNeeded on Sunday November 10, 2019 @05:50AM (#21497461)
>Is an audio stream really just a bunch of samples of volume?

Yes.

> I had always assumed you needed to record different wavelengths of sound to capture different pitches

Why? Look at a mono vinyl record. It has a single groove, which is the soundwave carved into the vinyl. Digital audio is the same, except you store a digital image of the groove.

>Is my mental model completely wrong?

Yes.

>How do you get such variety in sound just from recording the volume?

By recording the volume 44100 times per second.

Re:Audio Processing for Dummies by sharpneli on Sunday November 10, 2019 @04:29AM (#21497249)
super simplified explanation

Samples of pressure (or displacement, minor phase difference), so kinda yeah.

How one gets so much variety? By sampling it really often. If you sample it 40000 times per second you actually get the full information for all pitches that are between 0 and 20000Hz.

If you don’t sample it often enough you don’t get all the information needed to store the sound. So yes we kinda indirectly do capture all the different pitches.

Re:Audio Processing for Dummies by grattis on Sunday November 10, 2019 @03:05AM (#21497004)
Sound propogates by displacing the medium it's traveling in. So at every point in time we can only sample the displacement (amplitude/volume). Our cochlear hair cells do a Fourier transform to decompose the sound into component frequencies for the brain to analyze. Similarly, an audio stream is just samples of the amplitude over time and we need to do additional processing to extract the frequencies.
Re:Audio Processing for Dummies by nabla9 on Sunday November 10, 2019 @04:42AM (#21497273)
Yes, it's only a stream of samples.

The magic is the linearity of the signals. They are additive. The different signals pass through the same stream of samples without interacting.

If you add volumes from sine wave in 400 Hz to sine wave in 300 Hz, you can transfer them together in a stream of samples , then separate them later.

Mathematically: f(at + bt) = af(t) + bf(t)

Re:Audio Processing for Dummies by thdrdt on Sunday November 10, 2019 @05:30AM (#21497399)
When a speaker cone is moving in and out at 100hz you will hear a sine bass sound. But when the cone is also vibrating at 10000hz while moving in and out at 100hz there will be another pitch on top of the bass sound.

So different wavelengths added together will tell your brain there are different pitches at the same time.

When all those different wavelengths are using the same volume at the same time you can imagine that all those added waves will become a mess. That is what is called noise.

But when a high pitch wave is 'traveling' on top of a low pitch wave your brain can distinguish the different pitches.

Re:Audio Processing for Dummies by 8bitsrule on Sunday November 10, 2019 @06:30PM (#21500897)
Suppose you're at a rock concert. You hear several string instruments, drums, maybe a keyboard, and a voice or two all together at the same time.

What reaches your ears is continuous differences in the air pressure. That's more-or-less a single changing 'amplitude'. From that, your brain can pull apart the fundamental and overtone pitches from each source ... and sort them out so you can identify each one. Amazing technology ... almost indistinguishable from magic!

These days lots of people haven't seen audio on an oscilloscope ... which shows changes in amplitude with time. Look at this video. You'll see that at each point in time (left to right), there's ONE amplitude, whether he plays one string or more.

https://www.youtube.com/watch?v=Dd5dgajeIOA

Re:Audio Processing for Dummies by atoav on Sunday November 10, 2019 @04:51AM (#21497295)
You were probably mixing the time domain (just samples representing the desired speaker membrane position) up with the frequency domain (the energies of a punch of sines at different frequencies, which you get by running a FFT on the samples).

Both exist and are beeing used, but Samples are the default in uncompressed audio.

Re:Audio Processing for Dummies by jdietrich on Sunday November 10, 2019 @09:31AM (#21498057)
How do you get such variety in sound just from recording the volume?

https://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampli...

Re:Audio Processing for Dummies by fireattack on Sunday November 10, 2019 @03:33AM (#21497106)
You don't record each "waves" (nor is it even possible), you record the final result of all the waves superposed together, just like how your ears work.
Re:Audio Processing for Dummies by jcims on Sunday November 10, 2019 @04:26AM (#21497239)
>You don't record each "waves" (nor is it even possible)

Depends on what you mean by 'record'. Generally the air pressure is sampled instantaneously, but it can be broken down into frequency components before recording/perceiving. That's kind of how our ears work and in DSP you do an FFT (which you can then pass through an iFFT to synthesize the original signal).

Re:Audio Processing for Dummies by fireattack on Sunday November 10, 2019 @10:09AM (#21498205)
It has been a while since I study DSP, so I'm not sure if FFT can mathematically recover all the original sine waves (FT can). But I don't think it is possible practically, at least.
Re:Audio Processing for Dummies by kortex on Sunday November 10, 2019 @12:11PM (#21498889)
Yes, if you use the FFT or any discrete FT, you can perfectly recreate the signal up to the Nyquist frequency. To perfectly recreate the whole signal, you'd need infinite Fourier coefficients.
Re:Audio Processing for Dummies by fireattack on Sunday November 10, 2019 @07:48PM (#21501285)
Thanks
Re:Audio Processing for Dummies by mastax on Sunday November 10, 2019 @11:29AM (#21498632)
If you want to learn more, this article has a good intro to sampling theorem, among other things: http://people.xiph.org/~xiphmont/demo/neil-young.html
Re:Audio Processing for Dummies by clarry on Sunday November 10, 2019 @03:08AM (#21497017)
When samplerate is fixed, different pitches show up as waveforms having a different number of samples (per cycle). Each sample is a constant time step apart; you can count the number of samples (= length of time) of a period. Frequency is inversely proportional to period.
Re:Audio Processing for Dummies by jonplackett on Monday November 11, 2019 @08:27AM (#21504648)
Thanks for all the explanations! Super helpful!