Trying out Box2d

Dominoes falling towards a house.

What is Box2D? It’s a free and open source 2D physics engine. It is developed with C++, and has fortunately been ported to many other languages, including Actionscript and Java. I was eager to try it out.

At the same time, I was eager to get more familiar with the new C++11 standard I’ve been hearing about (a.k.a. C++0x). So I made a small program to get a taste of Box2D and C++11 features. You can view and download the program here.

To use it, drag out a rectangle with your mouse. When you release the mouse, the rectangle becomes a object in the world. It is affected by gravity, and interacts realistically with other objects. If you happen to own a touch screen, you can press space to hide the mouse cursor. You’re welcome.

Mixing Box2D with SFML graphics was a quite tricky. To keep track of the objects, I created an std::vector of this struct:

Environment.h:19 (rev f3238b80)
typedef struct {
    shared_ptr graphic;
    shared_ptr body;
} PhysicsObject;

There was a problem though: The Box2D world’s coordinates are 1 unit = 1 meter, and the Y-axis increases upwards. SFML coordinates, however, are more conventional computer graphics coordinates: 1 unit = 1 pixel, and the Y-axis increased downwards. To add to these troubles, the SFML view (sf::view) has to be able to scale (zoom) and move around the world.

Read this article

Storing Digital Data on an Audio Cassette

The cassette recorder hooked up to my computer's front audio ports.

A few days ago my dad bought a simple audio cassette player/recorder to make a digital copy of an old tape recording he had of Pioneer 10 leaving the solar system. I had the opportunity to try something I always wanted to try: Storing data on an audio cassette. After some researching, I decided to use RTTY (Radioteletype). I found an awesome program called Digital Master 780, which is part of a freeware Ham Radio software package, Ham Radio Deluxe.

To connect the tape player, I needed to use two 3.5mm TRS cables, one for my computer to hear the cassette player’s output, and another one to send audio to the player’s audio input for recording.

My DIY 3.5mm TRS cable from two earphone cables.

Since I only own one cable, I made a second one by using two old earphone wires, wire strippers, two alligator clips, and tape. It looks messy, but it gets the job done!

For reading and writing digital data to the tape, I tried out several audio formats that the program could use. Due to the low audio quality that the tape can store, I was only able to get away with using RTTY. After further experimentation, I decided that these are the best settings I can use:

    100 Baud, 170 Hz shift, 7 bits (ASCII), 2 stop bits.

Success! Here’s a video of me writing two paragraphs of “Lorem ispum” text to the tape:

Read this article