Typewriter effect

Share your advanced PureBasic knowledge/code with the community.
Seymour Clufley
Addict
Addict
Posts: 1265
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Typewriter effect

Post by Seymour Clufley »

This should come in handy for someone doing video production.

I wanted to have text appear on the screen as if somebody was typing it on a typewriter - you see this in old films. But since the text had nearly 150 characters, this would mean a lot of manual work, including aligning a sound file to each new "type". So instead I wrote this little program.

You give it the text (which can include line breaks). It wraps the text and draws each frame, including a little bit of human randomness. It uses EasyBMPtoAVI to create an AVI from all these frames. It also creates the necessary soundtrack as a WAV file - including key hits, space bar hits, and carriage returns.

Use Premiere or an equivalent program to watch the AVI and WAV files together.

It's set for PAL - 768x576 at 25fps. This should play fine anywhere, but change it for production if you're in NTSC land.

The rar file below has everything you'll need. The folder "typewriter_resources" should be placed in the C:\ root. The included font looks like an old typewriter - install it, or change the designation in the PB file to "Courier New".

Typewriter effect

Hope somebody has a use for it!
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Typewriter effect

Post by luis »

I like it :D

I played the two files using virtualdub, it's nice, well done !

Thanks for sharing it.


If you want to test the program with the right font without installing it, add a
AddFontResource_("Acoustic Bass.ttf") before the loadfont()
and a RemoveFontResource_("Acoustic Bass.ttf") after freefont()
"Have you tried turning it off and on again ?"
Post Reply