Archive: oscilliscope visualization = sine wave?


22nd October 2003 04:27 UTC

oscilliscope visualization = sine wave?
Hi, I've been learning about sine waves in trigonometry and I was looking at the oscilliscope visualization in Winamp and wondering if it was the sine wave of the audio being played?

From the equation we learned in trig:

y = (a)sin(bx + c) + d

and from what I've observed listening to music and watching the visualization (not the full screen one), it seems to me that:

the volume level of the current sample is plugged in the equation for "a"

and...

the pitch of the current sample is plugged in for "b"

Obviously, as far as I can tell, "c" and "d" probably aren't used.

For those of you who have forgotten this equation over a few years of higher math, the variables are:

a= amplitude
b= magnitude
c = left/right displacement
d = up/down displacement

In this screenshot I took of Winamp, it appears that multiple samples are taken within single frames or it analyses it as it changes. By the way, I had the refresh rate set to 70fps.

The only thing that bugs me is that sometimes when a lower instrument is played when a higher instrument is played the whole sine wave will move as a sine wav itself. What I mean is something like a sine wave applied on another sine wave instead of the x-axis. Look at my screenshot in the next post to figure out what the hell I'm talking about.

So, if anybody that knows anything in this area could you give me some feedback about my thoughts? Thanks!!


22nd October 2003 04:28 UTC

The sine wave applied on a sine wave screenshot.


22nd October 2003 06:38 UTC

wel.. your on the right track.

Look at a spectrum analyser. Like the one in winamps vis diplay. Its just a bar graph with the frequencies along the x axis and the volumes of each charted on the y axis.

Well, a oscilliscope works in exactly the same way, only it charts it using sin waves.

the frequency of the sound is the frequency of the sin wave, and the volume of each frequency is the amplitude. Its impossible, though, to try and equate the wave using a simple formula like: y = (a)sin(bx + c) + d, unless you are only hearing one single frequency band.

The oscilliscope works by taking 256 frequency bands of the sound. Starting with the lowest frequency, and getting a sin wave out of it.

y = volume * sin(freequncy * x)

Then timsing that wave by the next frequency, and so on.

.wav format sound, and infact all non-lossy digital sound formats work using this method, only with many many more than 256 frequency samples. In fact, sound itself is always measured using sin waves.

the sin wave on a sin wave effect is occuring all the time, but is most obviouse when you have a really pure, low frequency sound, with a trebbely thing over the top. Like just bass and vocals for example. If you find a piece with just bass guitar and no other instruments.. you should see a really nice, and pure looking sin wave.

your two examples both consist of 256 multiplied sin waves. Though, in both, there are some frequencies that have so little volume that they are unrecognisable by eye. In the first, there is practiaclly no low frequencies (bass) and in the second there is very little middle tones.


22nd October 2003 08:07 UTC

Sidd: you're kind of off though. Firstly there aren't 256 frequency bands but 576 afaik, but in fact this doesn't matter.

fanofjapan: An oscilloscope is not so much a sinewave, but simply the sound signal as it is being played by your speakers.
This is the exact way in which your eardrum vibrates as you hear it.

There is really no such thing as 'the sine wave of the audio being played', because the audio consists of tons of different frequencies overlayed.

There's no really good answer to your question, other than 'come back in a few years when you've learnt what Fourier Analysis is'.


22nd October 2003 09:03 UTC

http://hyperphysics.phy-astr.gsu.edu...o/Fourier.html
:)


22nd October 2003 09:14 UTC

bleh.. i tried to simplify..
i failed.


22nd October 2003 10:30 UTC

Actually, .wav files contain WAVEFORM data, which consists of just the current amplitude of each sample. What gets recorded, gets played. MP3 on the other hand, is more complex:

1. Take a sample of WAVEFORM Data

2. Seperate WAVEFORM data into high resolution SPECTRUM bands

3. Throw away all very high frequency and very low frenquency bands.

4. Throw away all SPECTRUM bands starting from the quietest until the specified amount of bitrate is reached which can represent the bands left.

5. Use ZLib compression and store in .MP3 file.
4.


22nd October 2003 11:08 UTC

This is why i use 320Kbit only.


22nd October 2003 11:22 UTC

320kbit/s is useless. MP3 is lossy no matter what, so you're better off just using variable bitrate with a high quality setting. Much better, and you don't waste bytes on encoding the noise in quiet parts.


22nd October 2003 11:45 UTC

So below which ammout of db would the high quality setting start to throw bands out??


22nd October 2003 12:02 UTC

"320kbit/s is useless. MP3 is lossy no matter what" - thats a bit of a strange statement, a higher bit rate will still store better quality sound than a lower bit rate.

320kbit/s is still fairly pointless because a human ear is unlikely to be able to percieve the quantization steps of a 128 kbit/s encoding let alone higher rates, as unconed inferred, there are more fundemental problems with mp3's, such as clipping and normalisation etc...


22nd October 2003 13:18 UTC

Stick to .wav's for your musicj - lol.

Yeah, fourier's are wahat you would need to kow to completely understand what is going on. And they can be a pain in the ass when you have a bunch of them - damn physics classes.


22nd October 2003 13:36 UTC

Originally posted by anubis2003
Stick to .wav's for your musicj - lol.
I probably would. But ... 20GB 320Kbit/s mp3 should be equal to ... um ... ~ 100GB wav files!!! or ~125 CD's

awesome!

22nd October 2003 23:20 UTC

so much info when you realize it is only a simple scope... ahhhh


22nd October 2003 23:31 UTC

Originally posted by Magic.X
I probably would. But ... 20GB 320Kbit/s mp3 should be equal to ... um ... ~ 100GB wav files!!! or ~125 CD's

awesome!
freak! maybe flac is the right thing for you.

23rd October 2003 03:48 UTC

Heh, I always use high VBR mp3s encoded with LAME.

Anyway, thanks for your help guys, I appreciated it!


23rd October 2003 06:33 UTC

UnConeD, I've searched everywhere, but I can't find out HOW to actually perform a FFT or DFT function on waveform data. Could you help me out?


23rd October 2003 07:25 UTC

Originally posted by killahbite
freak! maybe flac is the right thing for you.
Sounds cool, i will give it a try!

Unforutnately Traktor won't support it :(

23rd October 2003 14:41 UTC

Zevensoft: I had the same problem.

Basically on one side, you have the regular fourier transform. You evaluate the integral for every frequency, etc. Much too slow, but it's apparent what's going on. You should understand how this works.

Then there's the fast fourier transform. To this point I only have a sort-of understanding of how it works and I've yet to find a clear explanation of exactly why it works. Most docs that I've seen get lost in the math.
I couldn't write one myself without some more googling.

I have code here that I found somewhere (don't have the URL anymore). I only used it as an FFT, not iFFT so I can't be sure it works that way.

Hope it's useful, I put some comments inside.

For audio you should be able to do a DCT instead (only real input) but I don't have code for that. I used this code for a univ-project and it worked for my needs, so I didn't look further ;).