Domain: sagenb.org
Stories and comments across the archive that link to sagenb.org.
Comments · 10
-
Re:Sage or Python + IPython + SciPy + NumPy
Rather than running Sage in terminal, look at Sage Notebook. It is Sage with a web-based GUI. I have not played with it since they went to the new versions that include the OpenID auth; however, the math department at my alma mater host s server and had students use it for class as a replacement for Mathematica in a number of courses. I found it worked well for many things. You could either run a local copy or use one of the freely accessible online servers.
-
Re:The bit depth does matter
This isn't my field, so correct me if I go wrong here. Usually FFT gives you back bins from the sample period to the nyquist limit, spaced by sample-length periods. There's no reason you couldn't use non-integer periods for your bins in a DFT, but it's just an alternate representation of the same data.
Ah. Yes, I believe that's true of a discrete Fourier transform (FFT is a method of computing DFTs), but there are also continuous Fourier transforms. What I was thinking of is what you'd get when performing a continuous Fourier transform after reconstructing a continuous function from samples.
This is where we disagree. That sequence of points will uniquely correspond to that function if that function is a sum of sines. It's not true for arbitrary audio. You can find a sum of sines that will recreate the sampled waveform, but the aliasing distortion is already present in the sampled data. Unless you can assume that the function is in the set you described, you can only create a function, not the function, that generated those samples; and the one you get isn't necessarily going to accurately represent frequencies near the Nyquist frequency. You just get back the distorted waveform, and that distorted waveform won't sound like the original when played back, even though the original had no components above the Nyquist frequency.
The thing is, you can assume that the function you should be interested in reconstructing (for audio purposes) is a member of that set. I think we both agree that all audio can be represented as the sum of an infinite series of sinusoids. But it's also true that, for most audio content, you can filter out the sinusoidal components most humans can't hear, i.e. those above 20KHz or so, and nobody can tell the difference between the filtered signal and the original one.
Don't get me wrong, I'm not denying there are people who can hear above 20K. But there are caveats which render that meaningless in practice. This is mostly due to masking, the psychoacoustic phenomenon where people literally can't perceive soft tones at one frequency in the presence of louder tones at other frequencies, combined with the fact that people who can hear above 20K are nonetheless partially deaf at those frequencies (meaning, it takes a loud noise for them to even perceive a soft noise). Such HF tones are attenuated a lot by all the substances they pass through from musical instrument to cochlea (just as with EM radiation, for most substances higher frequency implies more attenuation), so they're very easily masked by lower frequencies.
But this is somewhat of a tangent from the question of whether there are significant distortions below 20K for a 44.1KHz sampler.
Here, a picture is worth a thousand words.
http://sagenb.org/home/pub/4502/950Hz in, 1000Hz plus some lower frequency components back out.
It is worth a lot of words, because it shows me the thing you're missing
:)The sampling system you've modeled is missing an essential step: reconstruction, the act of "curve fitting" using the knowledge that the input function was band limited. It is certainly true that without reconstruction you'll get all kinds of weird things like what you plotted. But that's not how the real systems work.
The method used in audio systems is to make a DAC which holds the value of each sample for the entire sample time, generating a stairstepped waveform rather than the triangle waves you've plotted. This waveform is fed through a so-called "brickwall" filter, one which passes all frequency components below Nyquist and completely blocks all frequencies above Nyquist. That filter is also known as the reconstruction filter, because it's what "fits the curve".
The key to understanding this is that Claude Shannon proved that sampling errors are frequency components gre
-
Re:The bit depth does matter
No. You added in something which isn't true: the bit about "a mixed signal that doesn't change over time". The sampling theorem states that any arbitrary mathematical function f(t) can be perfectly reconstructed from an infinite series of samples, so long as the sampling frequency is >2X the highest frequency component of f(t). It does not matter if that function is as simple as sin(t), or a ridiculously complex function which generates the exact same waveform output by an orchestra playing Beethoven.
You are mostly correct, but you're missing a finer point: you can't accurately reconstruct the original signal/function from the samples (unless that function is in a specific set) - you can only reconstruct the approximation as sampled. More on that in a moment.
Real world implementations of sampling approximate the theoretical ideal of perfect reconstruction much more closely than you seem to think, despite having finite sampling windows.
I never said it was bad. Aliasing distortion isn't huge until you're in the neighborhood of half the Nyquist frequency, and our ability to perceive it decreases well before it becomes significant.
Er, what? Fourier transforms do not output a number of frequency bands equal to the number of samples used as input.
This isn't my field, so correct me if I go wrong here. Usually FFT gives you back bins from the sample period to the nyquist limit, spaced by sample-length periods. There's no reason you couldn't use non-integer periods for your bins in a DFT, but it's just an alternate representation of the same data.
No. You've got a very distorted (heh) idea of how sampling systems work.
Think of it this way. Make a set of all functions f(t) which have no frequency components greater than F. Shannon proved mathematically that if you sample any member of that set at a sampling frequency greater than 2*F, the resulting sequence of points uniquely corresponds to that function, and no other member of the set. Another thing which fell out of this result was a method of mathematically reconstructing the original continuous waveform from the samples -- a form of curve fitting, if you will.
This is where we disagree. That sequence of points will uniquely correspond to that function if that function is a sum of sines. It's not true for arbitrary audio. You can find a sum of sines that will recreate the sampled waveform, but the aliasing distortion is already present in the sampled data. Unless you can assume that the function is in the set you described, you can only create a function, not the function, that generated those samples; and the one you get isn't necessarily going to accurately represent frequencies near the Nyquist frequency. You just get back the distorted waveform, and that distorted waveform won't sound like the original when played back, even though the original had no components above the Nyquist frequency. See my link below for what that distortion looks like.
When I run that thought experiment in my head, I get a 999Hz tone with no warble. You need a lot more explanation of your chain of reasoning as to why one should expect a 1000 Hz tone back!
Here, a picture is worth a thousand words.
http://sagenb.org/home/pub/4502/950Hz in, 1000Hz plus some lower frequency components back out.
The thing I originally found objectionable in your post was the idea that things rapidly go downhill after 5KHz or so.
I actually said "5kHz pretty well, up to 10kHz passably, and up to the high teens with increasing levels of distortion". I didn't mean it started to die after 5KHz; I meant that it was pretty damn clean at that point, and it wasn't really falling apart until the high teens. So perhaps we're just arguing over what I meant by "passably".
:)Thanks for taking the time to reply in depth. If you still think I'm fucked in the head, could you point me to what I should be reading to straighten myself out?
-
$170 isn't much for a calculator?
For not much more than $170, you could get a netbook that would give you access to SAGE Notebook, and much else besides.
$170 for a crippled computer is a ripoff.
-
Re:Teach the kids to learn...
There's also Sage Math. You could use the Sage Notebook to try it out. The programming interface is based on Python.
-
Re:Python for Scientific use
> I don't want to load 20 modules before I can begin coding. I just want to input my algorithm and get a result I expect (not 5/2=2). You might want to try Sage (sagemath.org and sagenb.org). It's Python, but it fixes the "5/2" issue and preloads numerous modules.
-
Re:For most people ...
Join the fun! You can use a Linux calculator from your browser -- no Linux required!
-
Re:Poor QA
(1/10)^n for integer n is irrational in base 2 and the truncation was unavoidable.
Whether or not a number is irrational does not depend on the base. The number (1/10)^n is rational in any base. By irrational, maybe you meant "finite decimal expansion"?
Unrelated: The article starts with the example 599999999999999 - 599999999999998 = 0 in Google. Fortunately some software gives the correct result by default.
-
Re:3d cube
In the Sage (AJAX...) notebook we https://www.sagenb.org/home/pub/1693/render
a 3d cube using the
awesome Jmol library. -
SageMath
The open source mathematic software compendium Sage already has something similar that you can test right away in SageNB. Interestingly, one of the possible backends is Mathematica.