Wednesday 28th November 2007
Parallel builds in Visual C++ 2005
(via Herb Sutter's blog)
If you haven't upgraded to Visual Studio 2008 yet, or like me, discovered that the mighty Boost doesn't build with it yet, then you might be interested to know that one of its most useful new features for C++ developers is available, undocumented, in '2005.
If you've got SMP (which is pretty likely these days), you probably know that Visual C++ 2005 already offers parallel project builds, and that they're useless if your solution contains a single monolithic project, or a bunch of interdependent projects.
However, VC 2005 actually has the ability to parallelise compiles at the source file level, too. In your project's properties, go to C/C++ -> Command Line, and in the Additional options box, add "/MP". Now it'll build as many compilation units (i.e. .cpp files) in parallel as you have CPUs. I did a "dual core on a budget" upgrade last week, and /MP has actually halved my build times. Now I can stop rueing my liberal usage of slow-building C++ templates!
Caveat: The compiler output can look a little mixed up, but you get used to it.
Don't let this revelation stop you upgrading to 2008, but if you're stuck with 2005 for reasons financial, technical, or political then /MP might be the most productive three characters you could type.
Thursday 17th May 2007
DLL Hell and the first DirectX 10 game
The first ever DirectX 10 game demo appeared on the 'net on Tuesday. I found out about it Wednesday night, when I found some 20 new comments on my D3DX DLL download page. Turns out the site had over 12,000 unique visitors on Wednesday, an order of magnitude above the usual daily few 747s-full.
So that's a lot of folks unable to run the latest big PC game (it's "Lost Planet: Extreme Condition", incidentally) because they're missing the latest D3DX DLL. Did Capcom actually test on any PCs besides their latest-DirectX-SDK-having dev. machines?
Developers, it's pretty trivial to create a basic DirectX "redist" and include it in your installer. I know, you're under enough pressure to ship the game on time as it is. But I added DirectX setup to an NSIS install script at work just recently, and it took minutes to get it working. If you're bothered about space, you can assume DirectX 9.0c, and just install the incarnation of D3DX that you built your game against. In this configuration, it'll add a few MB to your installer, which is nothing when your h0t game demo is pushing 500MB anyway. Make sure your installer runs dxsetup with the /silent option, so the user doesn't get a chance to say "Hey, I've already got DirectX!" and cancel it, which I suspect may be the problem in many cases.
The more gamers have to hunt for DLLs to get their new games running, the more of them are going to jump ship for the plug'n'play ease of the consoles. You can debate the ethics of updating DirectX "by stealth" if you like, but in reality all it's going to do is copy a DLL or two that the user is bound to need anyway. The core components (D3D9.DLL et al) haven't been updated since DirectX 9.0c - so if this is already installed (likely), it doesn't even require a reboot. We're long past the murky days when installing a new DirectX (like, say, DirectX THREE) could actually break stuff.
Lost Planet is significant in PC games land, since it's the first commercial game demo to use DirectX 10 on Windows Vista, and the first chance for Geforce 8800 owners to give their pricey early-adopter toys a proper run. In honour of the moment, I downloaded the Lost Planet demo (the DX9 version) and had a go. Sadly, my ageing single core processor and sixth generation graphics card couldn't really deliver the immersive experience I believe the designers intended. There sure is a lot of snow, though.
Video conversion cheat sheet
I was faffing around with batched video conversion at work today, trying to recall how to get the powerful yet forboding interfaces of MEncoder and ImageMagick to play ball. I've used them both quite extensively before - most recently when encoding in-game footage from Millennium 3. As a younger hacker, I could remember arcane command line options forever, but these days it's a frustrating cycle of never using these tools quite often enough for the syntax to really stick. Such are the ravages of maturity on the capacity to learn!
Anyway, having wasted a load of time today scouring through 1,000KB man pages, I figured I'd jot down the command lines that did what I wanted, and publish them here for future reference. In my experience, what you want is an example of a use case that's vaguely similar to what you want to do, and then you can go look up individual options in the documentation and tweak things to fit your needs.
I'll expand this page as I find new examples. If you have any to share, or if I've said something blatantly wrong, post in the box below.
Examples
Open foo.png, resize to 640x480 ignoring aspect ratio, save to foo.jpg with JPEG quality 60.
The ! (ignore aspect ratio) may need to be escaped in some shells (e.g. \!).
convert -resize 640x480! -quality 60 foo.png foo.jpg
Extract audio track from foo.avi, resample to 32KHz, output to foo.wav.
-ni means force non-interleaved mode, useful for reading badly interleaved files correctly.
mplayer -ni -vc null -vo null -af resample=32000 -ao pcm:file=foo.wav foo.avi
Output frames of foo.avi to BMPs named foo_00001.bmp, foo_00002.bmp, etc.
The % needs to be escaped if you're inside a Windows batch file, i.e. foo_%%05d.bmp.
ffmpeg infers the output format from the filename. For JPEG, though, I couldn't find a way to control the compression level (quality), so I output to BMPs and then converted those to JPEG with Imagemagick's "convert".
ffmpeg -i foo.avi -f image2 foo_%05d.bmp
This outputs frames of foo.avi to JPEG files. Each frame is scaled to 640x480 and saved in directory foo_frames with JPEG quality 80.
-noframedrop stops MPlayer from trying to do the conversion in realtime. Without this option, it drops frames, and you end up with fewer JPEGs than you expected.
-noframedrop wasn't included in the MPlayer man page's huge list of command line options, but was sneakily mentioned in a usage example at the end.
mplayer -ni -noframedrop -vo jpeg:quality=80:outdir=foo_frames -vf scale=640:480 foo.avi
This creates a video foo.avi from all the JPEGs in the current directory, with foo.wav as the audio track.
Video format is MS MPEG4 v2 (a good lowest common denominator format for Windows XP/Vista systems) at 25fps. The audio track is encoded to MP3 format using LAME.
mencoder -audiofile foo.wav mf://*.jpg -ovc lavc -lavcopts vcodec=msmpeg4v2 -mf fps=25 -oac mp3lame -o foo.avi
For each foo.avi in the current directory, extract the audio track to foo.wav.
FOR %%i IN (*.avi) DO CALL :encode "%%i" "%%~ni.wav"
GOTO :end
:encode
mplayer -ni -noframedrop -vc null -vo null -ao pcm:fast:file=%2 %1
:end
For each foo.avi in the current directory, make a new movie with_new_audio/foo.avi, with a video track copied from foo.avi, and a PCM audio track from foo.wav.
FOR %%i IN (*.avi) DO CALL :encode %%i
goto :end
:encode
mencoder -ovc copy -oac pcm -audiofile "%~n1.wav" -o with_new_audio/%1 %1
:end
Finally, I always end up needing a list of the codecs available via mencoder -ovc lavc -lavcopts vcodec:codec_name. So here are the possible values for codec_name:
mjpeg, ljpeg, h261, h263, h263p, mpeg4, msmpeg4, msmpeg4v2, wmv1, wmv2, rv10, mpeg1video, mpeg2video, huffyuv, ffvhuff, asv1, asv2, ffv1, flv, dvvideo, svq1, snow
Links
IBM developerWorks ImageMagick tutorial
ffmpeg Windows binaries (you'll need 7-Zip)
Gentoo MEncoder HOWTO
Monday 9th April 2007
Towards a non-data-driven design
In the specific case of the Object Orientated system, some of the boxes are round and some are square, which suggests complexity not found in the functional model, where all the boxes are square.
My learned colleague, Tom Morton, has published his groundbreaking paper on what you can get away with handing in on a Computer Science degree and still get a 2:1. Software Architecture Design and Analysis: A Spellchecking System Specification Or Something.
Saturday 26th August 2006
Pianoteq demo review
David Ellis linked me to Pianoteq, a brand new VST instrument from French team MODARTT. What Pianoteq apparently achieves is particularly satisfying for me, as I had often wondered whether (and when) such a thing would be possible on a PC.
Pianoteq is a piano virtual instrument, but not in the same vein as the likes of Native Instruments' Akoustik Piano and Steinberg's The Grand. Rather than playing back recordings of individual key strikes on real pianos, Pianoteq is a simulation - it models the horribly complex vibrations of the strings and soundboard when a key is struck.
This has all sorts of cool implications - the obvious one being that the vibrations of different strings can interact properly. You also (finally) get realistic sustain pedal response - you can half-pedal, quarter-pedal, or 1/128th-pedal, or depress the pedal after releasing a chord, capturing notes during their decay.
Whether the "nice" pianos Pianoteq produces are as good or as "real" as those of sample-based instruments will be open to debate. I tried the time-limited demo, and the treble range sounded slightly weird to me, but being a decidedly average pianist raised mostly on digital pianos, I'm hardly an expert judge. Try it and make your own call!
Besides, the potential for customisation is where I think this product will shine. You see, with the default patches, the lower treble ranges were rather overpowered by the bass for my liking, but altering the hammer hardness quickly improved things. Then, when I tired of my concert grand, I adjusted the unison width slider (which controls the difference in frequencies across the multiple strings that combine to play a single note), and increased the octave stretch. I immediately had the reassuring sound of a homely beast that hadn't been tuned in a while. You do not get this kind of control with a sample-based digital piano.
Indeed, an eternal limitation of sample-based pianos (both hardware and software) has been that everything they can create is derived from the same set of samples of some huge, expensive, "perfect" grand (or three). But the Steinway sound gets boring, and isn't necessarily what you want if you're trying to be Bill Evans. Native Instruments included a wonderfully mellow upright in their Akoustik Piano package, which was a step in the right direction. But with Pianoteq you can create your own instrument, from the massive concert grand to the cantankerous pub stalwart, via faithful reproductions of tinny early proto-pianos.
That appears to be the beauty of Pianoteq - there are no right answers for everyone, just a big array of variables you can tweak until you find a piano that suits your taste and mood. You can alter dozens of parameters which affect how the "piano" sounds and responds - with the potential to create some entirely new and alien instruments. In that sense, Pianoteq has the synthesiser's spirit as much as it has the piano's. It's not hard to see a future in hardware synths and digital pianos that have piano modelling technology built in.
In case you can't tell, I want the full version, but I'm holding off on an immediate purchase, as I haven't tried playing it through the X8 yet - only the V-Synth, with its decidedly non-piano-like keys. That, and I don't have a job!
Sunday 16th April 2006
Quest for the Celestine Spatula
Download: Quest for the Celestine Spatula.mp3 (MP3, 18.7MB).
Blurb:
Quest for the Celestine Spatula tells the story of a perilous journey to find a lost kitchen implement of interminable power. It was written and recorded at our student digs in Leamington Spa in Feb/March 2006, in my final year at Warwick University.Credits:
Guitar: Hywel Bennett
Keyboards: Paul Roberts
Vocals: Ollie Curnick, Hywel Bennett, Charles Gill, Paul Roberts
Tuesday 11th April 2006
M3 physics video fun
Here's a video of some new explosion shockwave physics that I've been working on in Millennium 3. It shows a large ship exploding and taking a load of nearby ships with it. The shockwave travels out and eventually hits the ship that the camera's looking out from. The video's off a cheap digital camera, hence the ghetto image quality and awkward file format, but the effect is quite cool regardless!
Tuesday 4th April 2006
What to do?
There are two things preventing me from getting this site back on its feet.
The first, perversely, is the existing content. So much of it is out of date and/or embarrassing it's, well, embarrassing. It's easier to pretend it doesn't exist than to try to sift through and streamline it. But it does exist. I still advertise it in my email and forum signatures. It's still standing up here on the web providing ever more new people with a window on my life as of, uh, three years ago. To begin to rework the content, I need to confront what's already here, which I'm fatally reluctant to do.
The second involves SPAM. Around 100 'comments' are left on this site every day. Typically, 99 of these are garbage - links to gambling sites, ads for replica Rolexes (Roleces?) and doomed attempts to send actual spam emails through my comments system. Back when the influx was a little gentler, I was manually deleting them as they appeared, but pretty soon I decided I didn't want them appearing on the site at all. So I made comments stay hidden by default until I 'approved' them. This worked for a while, but the signal to noise ratio soon decreased so far it became very time-consuming to identify the occasional genuine contribution. I stopped trying. This has meant that while the site appears peacefully dormant to the casual visitor, a cancer spreads behind the scenes, as I have a burgeoning database of junk and neither the time nor the inclination to act as a human spam filter on the whole lot.
So, if I can bring myself to hack a captcha into my comments system (remind me why I thought writing a blog/CMS from scratch was a good idea?) and to filter a five figure quantity of comments, then we're halfway there. Then I'll attack the rotting mass of Younger Paul's attempts at content. Should I come out the other side with something that, at this point in time, I consider relevant, then great! Now, that's a lot of conditionals right there, and I know we've been down this road before. But since it's that time of year when I have lots of arguably more important things I should be doing, it just might happen :-)
Wednesday 13th April 2005
Stealing news from Slashdot again
So much for one entry a day, but moving on... Some MIT grad students created An Automatic CS Paper Generator, which is cool all by itself. However, this brilliant piece of work it spat out got accepted as a "non-reviewed paper" to the WMSCI 2005 conference! Priceless.
Tempted as I am to reference "Rooter: A Methodology for the Typical Unification of Access Points and Redundancy" in the final report for my third year project, I can't find a vaguely relevant context in which to cite it. [Edit: Maybe I'll just bury the citation in an appendix that the markers probably won't reach anyway. Come on, fellow comp scis - let's start a "Rooter" citation cult!]
The students say their next goal is "to go there and give a completely randomly-generated talk, delivered entirely with a straight face."
Procedural content generation one, academia nil.
Here's a link to the Slashdot story.
Monday 28th March 2005
Underdogs
I was in HMV in Stratford today and spotted several copies of Darwinia on the shelves, priced £29.99. Darwinia is the latest offering from hip indie developers Introversion Software, mildly famous for their previous game, Uplink, which they marketed and sold themselves via their website (i.e. without going through a publisher like EA). I didn't realise their new title had been released, let alone distributed to physical retailers.
I couldn't find a publisher's logo on the box, so I guess they made some kind of direct deal with the distributors. Which is cool. Introversion are now proof that it's possible to get an original PC game to full price retail without a 50-man team and a seven figure budget. In 2005.
As an aside, I spotted a familiar box on the shelf below - Agassi Tennis Generation! Priced at a modest fiver, mind, but still occupying valuable shelf space several years after I worked on it.
Anyway, good work, Introversion. I have yet to try the Darwinia demo, but I ought to wait until my dissertation's in and the exams are over...
Powered by clunkyblog release 3.00. clunkyblog is Copyright © 2003, 2004, 2007 Paul Roberts. Generated in 294ms.
