|Page (1) of 4 - 11/30/04||email article||print page|
Scripting in DVD Studio Pro, Series 2Part 2: Bit-wise operations and binary number conversion
Before we get started, if you're a beginner at DVD scripting, I urge you to go back and read our first series on scripting in DVD Studio Pro, dealing with the bare basics of creating commands and working with various operations. You should read at least the first two articles in Series 1 to give yourself a decent foundation in the principles of scripting. And you should definitely take a look at the first article in Series 2 to gain an understanding of how SPRMs are integrated into scripts.
DVD Studio Pro Scripting, Series 1
Part 1: General scripting information
Part 2: Creating an interactive quiz
Part 3: Keeping track of time
Part 4: Pausing and resuming a timer
DVD Studio Pro Scripting, Series 2
Part 1: The basics of working with SPRMs
Bits and bit-wise operations
So you've seen how to retrieve information from an SPRM and how to move it into a GPRM for integration into your scripts. But not all SPRMs are the same. Some of them keep pieces of information in specific bits within the SPRM so that you're not just asking, "Hey, what's up with SPRM 15?" but rather, "Hey, what's up with bits 11 and 14 within SPRM 15?" Except it's not as simple as that.
If you've read the DVD Studio Pro manual, you know that this sort of thing involves bit-wise operations and binary numbers. The manual (ever-so-helpfully) explains that you need to know about binary numbers to use bit-wise operations, but doesn't bother actually to tell you about them. Don't worry; I will.
Sample project using binaries and bit-wise operations
Here's what we're going to do. We're going to take a hypothetical situation where we want to find out about a DVD player's audio configuration. It the player has DTS capabilities, we'll play the DTS track automatically; it the player doesn't have DTS capabilities but does have AC-3 capabilities, we'll set the AC-3 track to play automatically; and if, on the very off chance, it has neither of these capabilities, we'll set it to play our stereo PCM track. (This would not be a good idea for an approach to track selection unless you also give the user a chance to override this script by manually choosing the preferred audio track. Also keep in mind that a user doesn't necessarily have a surround sound setup just because the player is capable of surround sound. So use this sort of thing with discretion.)
The script we'll create for this will be used as a pre-script for our main feature, which itself will have three audio streams: DTS, AC-3 and stereo. (In the image below, the "audio1.cpt" file is the DTS track; remember that DVD Studio Pro only supports DTS in the .cpt format right now.)
Before we get started, if you wish, you can download my completed script by clicking here.
Initial script setup
To determine which stream will be played, we'll need to access SPRM 15, which is the register that contains information about a DVD player's audio capabilities. So, just as in our previous tutorial, we're going to get this information and put it into a GPRM--in this case, GPRM 7, which I've chosen arbitrarily from among the eight available GPRMs.
1. Create a new script (Project > Add to Project > Script).
2. Select the script in the Outline tab.
3. In the Script Editor, select the first command ("Nop").
4. In the Inspector palette, change this command to "Set GPRM." Set the Operation to "mov." Set the Source Type to "SPRM." Set the Source Value to "SPRM 15." And set the target to "GPRM 7."
Related Keywords:apple dvd studio pro, scripting, sprm, gprm, bit-wise operations, binary numbers
To Comment on This Article, Click HERE
Most Recent Reader Comments:
Click Here To Read All Posts
Must be Registered to Respond (Free Registration!!!, CLICK HERE)
Source:Digital Media Online. All Rights Reserved