Mac OS X coding

Big Nerd Ranch on NPR and thoughts on HD Audio

April 2, 2007 · Leave a Comment

NPR covered Big Nerd Ranch for a few minutes today. The NPR guy talked about how the programmers were talking about the Spotlight API.

On an unrelated note:

Note: I am not necessarily talking about HD Radio.

HD Audio is of no real use for the simple reason that humans can’t hear any frequencies above 20 kHz. CD quality audio is the best quality audio that humans can appreciate. Who cares if you have 192 kHZ sampling rate (HD Audio) as opposed to CD audio’s sampling rate of 44.1 kHz? Oh, but they all say, “You can hear the difference.” One should say “Only if there is something wrong with your ear or brain!” (This post was inspired by a short aside in a DSP lecture, but any inaccuracies here are mine).

Note: I am writing this pretty late at night..I might have made some mistakes with the exact facts :p

More info(April 3, 2007, 10:48 am) : The reason for sampling at a bit more than twice the maximum frequency is to enable correct reconstruction of the analog signal(music and other audio in this case). You can find more information on the Nyquist-Shannon Sampling Theorem here.

Categories: Telecommunications

Simulating Pulse Amplitude Modulation(PAM) on a Mac

April 2, 2007 · Leave a Comment

One can use the IT++ library: http://itpp.sourceforge.net

This code is actually cross-platform because IT++ is cross-platform.

//Chinmoy Gavini.

//Code licensed under the GPLv2

//Update: I have tested the following code. It works. Note that the binary string below must not have spaces or endlines(of course, your text editor will word-wrap the content–that is fine).

//However, the usual disclaimers in GPLv2 apply to this code.

#include <itpp/itbase.h>
#include <itpp/comm/modulator.h>

int main()
{
PAM p(4); //We want 4-PAM
vec output; //modulated thing
bvec demodded_out;
bvec input = “0100100001100101011011000

110110001101111001000000101011

10110111101110010011011000110010000100001“;

//Binary representation of Hello World!

//The following line of code simulates the transmitter end.
p.modulate_bits(input,output);

//In a realistic simulation, we would have code to add pulse shaping and noise where this comment is

//The following simulates the receiver end.
p.demodulate_bits(output,demodded_out);

if(input == demodded_out)

{

cout<<“Hello World”<<endl;

{

else

{

cout<<“Big Bad World”<<endl;

}

return 0;
}

}

Categories: Cross-platform code · Telecommunications

Digital Pulse Amplitude Modulation(Part 1)

April 2, 2007 · Leave a Comment

Note: I am organizing my notes on Telecommunications topics. I will post programming articles too, for those who look for those kinds of articles.

Update:  April 2, 2007 10:34 PM U.S. Central Time: fixed the typo from 2-PAM to 4-PAM

Digital modulation allows us transfer sequences of bits(digital signal) over analog media(like air). Pulse Amplitude Modulation(PAM) consists of mapping a certain number of bits into symbols. For example in 4-PAM(which is named that way because a pair of bits are mapped onto a symbol), if d denotes some scalar value(like 2?), a mapping table might be:

00 -> 3d
01 -> d
11 -> -d
10 -> -3d

where 3d, d, and so on are the amplitudes of a pulse shape we choose(more on choosing the pulse shape later). For now, if we choose a rectangle wave(even though it can never be implemented exactly in a real system), which can be defined rect(t) = 0 if |t| > \frac{1}{2} and rect(t) = 1 if t < \frac{1}{2}, and rect(t) = \frac{1}{2} if t = \frac{1}{2}.

The baud rate is just another name for the symbol rate. So, if we have a symbol rate of 36 baud (36 symbols/second), in the 4-PAM scheme above, our bit rate is 72 bits/sec(bps)

Also, the mapping above from bits to symbols is optimal because it is based on the Grey code, which is an ordering of groups of bits such that group differs from the consecutive by just one bit(this is cyclical because 10 is just different in one bit from 00). Using the 2-bit Grey code helps the receiver to perform some error correction(because consecutive levels such as -d and -3d “are only 1 bit away”

References on technical info: Dr. Brian L. Evans’ lectures(Google: Brian L. Evans or Digital Pulse Amplitude Modulation(Dr. Evans’ notes should be the first hit for Digital Pulse Amplitude Modulation), Wikipedia: Grey Code

Check out the comments for the “My Favorite Software Tools Post” for more info on embedding \LaTeX in WordPress posts(info from Mr.Ali’s blog)

Examples:

$%latex \int_{-\infty}^{\infty}f(x) dx = 0$ produces \int_{-\infty}^{\infty}f(x) dx = 0

(You shouldn’t put the % in when you do this yourself)

Categories: Telecommunications