[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: High-frequency hearing in humans
On Fri, Feb 4, 2011 at 10:53, Hermes, D.J. <D.J.Hermes@xxxxxx> wrote:
> Just to show that it is not a simple question of loudspeaker quality but also of recording quality I send you a Matlab script producing one square wave "sampled" at 48000 and another at 192000 Hz. The difference is audible through any loudspeaker.
>
> clear all
> sf1 = 48000;
> sf2 = 192000;
> dt1 = 1/sf1;
> dt2 = 1/sf2;
> du = 1;
> f0 = 5000;
> t1 = 0:dt1:du;
> t2 = 0:dt2:du;
> s1 = square(2*pi*f0*t1);
> s2 = square(2*pi*f0*t2);
> sound(s1, sf1)
> wavwrite(s1, sf1, 's48000')
> pause(1)
> sound(s2, sf2)
> wavwrite(s2, sf2, 's192000')
>
Actually, that's due to aliasing. You can't generate (good) square
waves in sampled domain in this fashion - just try plot(abs(fft(s1)))
and plot(abs(fft(s1))). The spectrum of a real square wave should
have only odd harmonics, but if you try those commands you see that
there are many other components.
One way to think of it is as jitter introduced by the fact that 5000
is not a simple divisor of 48000 or 192000: the edges of the square
wave periods are not regularly spaced.
There is a large amount of literature on how to generate square waves
that sound correct - typically by additive synthesis - and usually
these methods include significant rolloff at high frequencies.
Joe.
--
Joachim Thiemann :: http://www.tsp.ece.mcgill.ca/~jthiem