puppetSound and paths

Last week I continued debugging Meet MediaBand. As sheep said in his blog post, Director 2/3 is nearing completion, and while Director 4 is a bit further from completion, it’s also getting there. Most of the important, low-hanging fruit in D2-4 is gone, and while that’s mostly a good thing, it means that the things left to do can be quite tedious.

One example of this is the puppetSound command. We had already fully implemented it, but it turned out it was bugged in some subtle ways. Normally, sound is controlled by the score. Each frame has two sound channels, and putting a sound in that channel will, of course, cause that sound to play:

puppetSound allows sound to be controlled programmatically instead. For example, using the Director 4 version of the command, puppetSound 2, 8 will play sound 8 in sound channel 2. From then on, sound channel 2 is a “puppet,” meaning it is controlled by Lingo until control is returned to the score with puppetSound 2, 0.

Previously, we implemented “puppet” status universally—either every sound channel was a puppet, or every sound channel was not a puppet. When a movie used a mix of puppet and non-puppet sound channels, the non-puppet sound channels would be incorrectly ignored. In addition, our previous puppetSound implementation played sounds immediately, while in the original, puppet sounds would not play until the movie went to a different frame or updateStage was called.

These may seem like minor details, but in an interactive music video like Meet MediaBand, small sound bugs can make a big difference. So I had to fix them, which required quite a bit of reworking the engine’s sound code.

Another feature which took quite a bit of work was handling ‘/’ in file names. Director was originally a Mac-centric product, and since classic Mac OS allowed ‘/’ to be used in file names, quite a few Director games did that. Nowadays, ‘/’ is commonly used as a directory separator, including in ScummVM, and it’s typically forbidden in file names. To solve this, I created a Path type which is used to pass paths to/from common file functions, allowing arbitrary directory separators to be used. Once my pull request is reviewed and merged, it will let the engine use ‘:’ as a directory separator, like the original Macintosh version of Director did.

Besides these fixes, I implemented some rather uncommon features including the closeXlib, framesToHMS, and HMSToFrames commands. These don’t pop up often, but when they do, it’s better that they work. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *