AudioMasters
 
  User Info & Key Stats   
Welcome, Guest. Please login or register.

Login with username, password and session length
December 16, 2007, 03:24:16 PM
62675 Posts in 6217 Topics by 2169 Members
Latest Member: tone2
News:   | Forum Rules
+  AudioMasters
|-+  Audio Related
| |-+  General Audio
| | |-+  why does this square wave sound cleaner when downsampled?
  « previous next »
Pages: 1 [2] 3 Print
Author
Topic: why does this square wave sound cleaner when downsampled?  (Read 3291 times)
Reply #15
« on: June 03, 2004, 04:30:21 AM »
zemlin Offline
Member
*****
Posts: 2762

WWW

Try 44.1 KHz.
Logged

Reply #16
« on: June 03, 2004, 05:01:27 AM »
DeluXMan Offline
Member
*****
Posts: 910



Yipes!  ya now i'm getting it at 44.1kHz.   Tongue  shocked  huh   I'm getting a 100Hz. spectrum reading at all frequencies for the square-wave.  That is even stranger than intermodulation distortion.  It looks like aliasing or something. Hmm...  I'm getting some very weird spectrums for various frequencies, not just frequencies near the nyquist.  Tongue  shocked   The same goes for all sample rates including 96kHz. and 192kHz., it just takes different tone frequencies.  Presumably this is aliasing, perhaps in the spectrum analyzer or something.  smiley  These alias frequencies are down by 15db from the fundimental at the biggest btw.  It looks ok on the Ozone screen.
Logged

=DeluX-Man=
Reply #17
« on: June 03, 2004, 05:45:57 AM »

Guest

What I meant by cleaner sounding square wave is that the 96khz generated square wave downsampled to 44.1khz sounded better than the 44.1khz generated square wave because it sounded more pure without any artifacts, like a pure tone.
Logged
Reply #18
« on: June 03, 2004, 06:18:40 AM »
DeluXMan Offline
Member
*****
Posts: 910



By downsample do you mean you converted the sample rate in 'convert sample type'  in AA/CEP?
Logged

=DeluX-Man=
Reply #19
« on: June 03, 2004, 07:40:03 AM »

Guest

Yep.
Logged
Reply #20
« on: June 03, 2004, 09:04:25 AM »
SteveG Offline
Administrator
Member
*****
Posts: 8319



Couple of points here - trying to create anything like a 3kHz square wave with a sampling rate of 44.1k is almost bound to fail, and produce a very un-square looking result anyway. So why does producing one at 96k and downsampling it make it look better? Well, I'm afraid that's the other point. The CEP/AA tone generator has some very distinct limits to what it's capable of, and producing accurate aquare waves at low sample rates is one of these limits - it really doesn't do it properly. There are some other things it can't do as well - if you're interested, I've got some notes on this somewhere. But as a precision squarewave generator, you can't trust it at all, I'm afraid.

So don't run away with the idea that recording sound at 44.1k is vastly inferior - because it isn't. What you have here is a very badly generated signal that's causing this immediate problem. If you try, and it's not too hard, you can redraw a small section of the generated signal by hand rather better than the tone generator does it!

Another consideration here is that because of the division ratios, a 3kHz square wave at 44.1k is going to have an uneven number of samples in the low and high transitions, and since we are talking about 7, that's not very many when you come to consider the little matter of the duty cycle - which is never going to be 50% as a result of this. That on its own will alter the harmonic structure considerably, and the fact that this dithers between 7 and 8, producing what amounts to FM, may go some way to explaining the rather large number of extra sidebands.

Bottom line? You can make no assumptions about CEP/AA's audio processing abilities at all from doing something like this - it's a completely invalid test of anything, and even if you have a good squarewave generator, you need to be aware of the implications and restrictions of this method of testing anyway before you can make anything other than a very basic interpretation of the results.
Logged

Reply #21
« on: June 03, 2004, 11:24:41 AM »
Mac Offline
Member
*****
Posts: 1191

WWW

Then this begs the question why doesn't AA have a competent tone generator? Smiley

If you are able to find your notes on how to fool it please could you let me have a look?
Logged

(|-_-|)
Reply #22
« on: June 03, 2004, 11:54:53 AM »
pwhodges Offline
Member
*****
Posts: 940

WWW

A square wave at 3kHz band-limited at 22kHz has only the 3kHz and 9kHz components at all! {edit: oops! as pointed out below, that should include 15kHz and 21kHz - the point is the same, though}  That will look very little like a square wave in any case.  I suppose it would be better to generate a "square wave" in this situation by summing the harmonics that can be represented, rather than by alternating constant high and low values in an irregular duty cycle - the second may look more like a square wave, but actually represents something markedly different as the spectrum showed.

Paul
Logged
Reply #23
« on: June 03, 2004, 01:12:22 PM »
davehk Offline
Member
*****
Posts: 67



Quote from: tannoyingteflon
What I meant by cleaner sounding square wave is that the 96khz generated square wave downsampled to 44.1khz sounded better than the 44.1khz generated square wave because it sounded more pure without any artifacts, like a pure tone.


Er - a pure tone is a sine wave. So if you do something to a squarewave to make it sound more like a pure tone, you're probably removing upper harmonics - this is BAD, not good.

I often remind myself (wrt recording of live acoustic sound) that something that subjectively SOUNDS better may actually be WORSE - ie a less accurate reproduction of the original signal. After all , the person composing/creating the original sound/music might have wanted it to make you wince!
Logged
Reply #24
« on: June 03, 2004, 01:59:55 PM »

Guest

Tone can mean the quality of a persons voice.
Surely thats not a sine wave but a number of sine waves put together.
Timbre. if tone can = tibre why can't a square be classified as one. huh
Logged
Reply #25
« on: June 03, 2004, 04:15:17 PM »
Mac Offline
Member
*****
Posts: 1191

WWW

Quote from: davehk
Quote from: tannoyingteflon
What I meant by cleaner sounding square wave is that the 96khz generated square wave downsampled to 44.1khz sounded better than the 44.1khz generated square wave because it sounded more pure without any artifacts, like a pure tone.


Er - a pure tone is a sine wave. So if you do something to a squarewave to make it sound more like a pure tone, you're probably removing upper harmonics - this is BAD, not good.

Ok ok, he meant it sounds more like a pure square wave.. Smiley
Logged

(|-_-|)
Reply #26
« on: June 03, 2004, 06:46:09 PM »
MusicConductor Offline
Member
*****
Posts: 1300



Just for the record, with a 3KHz square wave you'll encounter these frequencies with a 22Khz bandstop due to odd-numbered multiples:
3K
9K
15K
21K

With 32-bit files and an amplitude of -6, I can't get a "dirty" downsampling from 96Khz to 44.1 in either CEP2.1 or AA1.0.  Is it the Generate/Tones/General drop-down that's being used to select the square wave?  The downsampled version has the correct harmonics and remains clean unless I disable pre-filtering and put the quality slider to a very low number.

Steve, would you kindly elaborate as to why the Generate/tones/square wave generator isn't accurate?  To me these waveforms don't appear to have any room for improvement.

All of this is relatively moot to the original, if arcane, question -- after all, what is a square wave supposed to sound like?  This is a fun theoretical question, and is helpful in assessing how our audio data is handled, but it seems to me to have no substanatial benefit in real life.
Logged
Reply #27
« on: June 03, 2004, 07:57:04 PM »
SteveG Offline
Administrator
Member
*****
Posts: 8319



Quote from: MusicConductor
Just for the record, with a 3KHz square wave you'll encounter these frequencies with a 22Khz bandstop due to odd-numbered multiples:
3K
9K
15K
21K

With 32-bit files and an amplitude of -6, I can't get a "dirty" downsampling from 96Khz to 44.1 in either CEP2.1 or AA1.0.  Is it the Generate/Tones/General drop-down that's being used to select the square wave?  The downsampled version has the correct harmonics and remains clean unless I disable pre-filtering and put the quality slider to a very low number.

Steve, would you kindly elaborate as to why the Generate/tones/square wave generator isn't accurate?  To me these waveforms don't appear to have any room for improvement.

It's the downsampled version that's quite good - in fact it's not even too bad at 32k or 48k - the problem is when you try to create the 3kHz square wave at 44.1k - that's where the almightly mess is! Try it - you'll see what I mean. Specifically, it's all related to the fact that when the generator creates square waves, it just plants the sample points in straight rows, taking no account whatsoever of the nyquist limit - it just divides the requisite number of sample points required for a 3Hkz tone by two, and if it gets an odd result, that screws the symmetry, and the rise and fall times are screwed by the complete lack of filtering to take account of Nyquist. If you adjust the samples at each end of each transition to take account of the risetime limitation (ie so there's no overshoot, and a flat top, you end up with a much more acceptable squarewave at 44.1k - but this is time consuming. In theory, you should be able to achieve the same thing by careful filter selection. But you can make no judgement about the squarewave as is, because of the Nyquist foldback (aliasing), FM effects, you name it!
Logged

Reply #28
« on: June 03, 2004, 08:11:52 PM »
Mac Offline
Member
*****
Posts: 1191

WWW

Quote from: MusicConductor
Just for the record, with a 3KHz square wave you'll encounter these frequencies with a 22Khz bandstop due to odd-numbered multiples:
3K
9K
15K
21K
..
All of this is relatively moot to the original, if arcane, question -- after all, what is a square wave supposed to sound like?  This is a fun theoretical question, and is helpful in assessing how our audio data is handled, but it seems to me to have no substanatial benefit in real life.

Like a 3k, 9k, 15k & 21k sine wave played simultaneously rolleyes


Quote from: pwhodges
A square wave at 3kHz band-limited at 22kHz has only the 3kHz and 9kHz components at all! That will look very little like a square wave in any case.

I thought that by combining all the harmonics that can be represented with 44khz (3,9,15,21khz) you would end up with a very close rendition of a square wave as seen by the limited sampling frequency.  To see the errors you would need to build the same limited set of harmonics in a higher sample rate, eg. lowpassing the same square at 22khz in a 96khz file would show the ripples, which would be effectively invisible if the same were attempted at 44khz?
Logged

(|-_-|)
Reply #29
« on: June 03, 2004, 11:17:04 PM »
MusicConductor Offline
Member
*****
Posts: 1300



My bad!  I glossed over Mac's post and graphics too quickly.  Thank you, Steve.  Now I've reproduced this in AA1.5.  Yes, it certainly is a mess!

Quote from: tannoyingteflon
I was experimenting with square waves in CEP2 and what I found out is that the square wave that I generated (3khz) sounded better on my cd player when it was first generated in 96khz then downsampled to 44.1khz...  Why is this so?

Does this all relate to why we need to record in 96khz and higher.


This is finally all very clear for me.  We know that this is happening because the square wave generator is not accurate at 44.1 but is at other rates -- so the 3Khz wave generated at 44.1fs is not a valid square wave and sounds "dirty."  3Khz works perfectly with 48KHz and 96Khz sample rates because it is an exact division.

Thus, no, it doesn't relate to why anyone would want to record at 96Khz and up.

The workaround is to generate tones at exact fractions of the sampling rate.  For example, 3.15Khz (44,100 / 14) works better, but not perfectly.  But 3.15Khz won't work at 48 or 96KHz fs!  The imperfection in generating at 44.1KHz fs is some clicks that occur when a half of a cycle has 8 samples instead of 7 (check it in spectral view, as it was a diminishing effect for me).  These clicks don't appear at other sample rates.
Logged
Pages: 1 [2] 3 Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS! Ig-Oh Theme by koni.