| run-length encoding, all of one component at the time, one scan line at a time (24-bit pixels only)
Scheme 4 will store the alpha channel also if cmpCount is set to to four. PackSize is not used and
should be set to zero for compatibility reasons.
See Inside Macintosh, Volume 6, for complete details.
QIs there any way to stop the Dialog Manager from playing with the txSize and txFace fields of a dialog's grafPort so that I can draw Geneva 9-point text from
within a userItem proc?
AUnfortunately, because the Dialog Manager forgets about your previous calls to TextFont and
TextSize when you put up your dialog again, you will need to call TextFont and TextSize every time
your userItem proc is called.
QWhen should the Color Manager be used and when should the Palette Manager be used?
AThe Palette Manager is by far the friendlier and more versatile of the two. It provides all the
functionality you need to customize and animate the colors in your application. You shouldn't ever
need to use the Color Manager unless you require custom color search and complement functions.
Unless you really understand the Color Manager in detail, you are likely to have problems getting
the Color Manager to work in a clean fashion.
When using the Palette Manager, applications following the rules will maintain their respective
color environments safely as windows move back and forth from foreground to background, and
from one screen to another. Accomplishing this with the Color Manager calls is not worth the effort.
For additional information, see the Palette Manager article in this issue.
QI would like to make my fills print better. Currently, they come out as 72 dpi patterns. Is
there a way that
I can make them print at a higher resolution, but have my patterns still print as patterns?
ATo make your patterns print at the printer's resolution, you need to use Printing Manager
PrGeneral's GetRslData and SetRsl opcodes to get and set the resolution, and you must
scale the pattern to match. Let
me explain.
If we do not scale our patterns up to the printer's resolution before print time, we would get "big
chunky" patterns because the printer driver would need to scale the patterns on the fly from 72 dpi
to its resolution. Therefore, we use the "cookie cutter" approach to "place" the pattern into the
object that is being filled. The size of the "cookie cutter" (the destination Rect) depends on the
"scaleFactor." For example, a "scaleFactor" of 2 will have a destination rect of 16 x 16. We will then
CopyBits the pattern one square at a time into the object that is being filled.
You might find the article "Meet PrGeneral" from the July 1990 issue
of develop useful for describing the functionality of PrGeneral in greater detail.
QWhat versions of Apple Color Printer software work with what system software versions?
Can Apple Color Printer software distributed with System 6.0.7 work with System 6.0.5
and earlier versions? I am distributing LaserWriter ® drivers with modified pgsz resources. I
would like to cut back on the number of files I need to distribute.
AThe software sent with version 6.0.7 will work with all other 6.0.x systems. This should be the rule
with most other LaserWriter printer software as well. Color has been supported since LaserWriter
driver 6.0, for color depths of 8 bits or less. Depths greater than 8 bits must be converted before
printing.
There really isn't any simple way to match up the version of released printer software with what
version of the system it is compatible. LaserWriter 7.x is compatible with both System 7 and System
6. It's still prerelease software, however. Do not ship the preliminary LaserWriter 7.x driver with
your application. You'll be able to ship the final LaserWriter 7 driver with your product as soon as
System 7 is final.
QHow can I use SndPlay to function asynchronously? It seems to ignore the async parameter.
ATo use SndPlay asynchronously, you must have allocated a sound channel without passing NIL as
the chan parameter. There is one thing to be aware of in doing this, which often confuses
developers. If the 'snd' resource being used with SndPlay specifies a 'snth' resource, then you cannot
create the sound channel with a synth. Because of a Sound Manager bug that has been present in all
releases through System 6.0.7, SndPlay has not worked correctly for a 'snd' resource specifying a
'snth', with a user channel initialized with a 'snth'. For example, the following code will fail:
SndNewChannel(myChan, sampledSound, init, @myCallBack);
SndPlay(myChan, sndHdl, async);
{sndHdle is a sampled sound}
The Sound Manager attempts to link this 'snth' to the channel with every call to SndPlay. If the
synthesizer has already been installed, the Sound Manager attempts to install it again, only this time
as a modifier. The same 'snth' code ends up being installed more than once in the channel. If the
'snd' contains 'snth' information, then SndPlay can be used once and only once on a channel. A
format 2 'snd' resource is assumed to be a sampled sound. For format 1, check the number of snths
specified in the 'snd' and then check each one. The latest version of SoundApp has source code that
does these tests.
This limitation has been fixed in System 7. In System 7, SndPlay can be called any number of times
on a channel. For older system releases you need to create and dispose of the channel each time after
calling SndPlay, as in the following code:
#include <Resources.h>
#include <Sound.h>
#define TRUE 0xFF
#define FALSE 0
main()
{
Handle Sound;
SndChannelPtr chan;
int i;
OSErr err;
Sound = GetResource('snd', 100);
if (ResError() != noErr || Sound == nil)
Debugger();
for (i = 0; i < 3; ++i)
{
chan = nil;
err = SndNewChannel(
&chan, 0, 0, nil);
if (err != noErr)
Debugger();
err = SndPlay (chan,
Sound, FALSE);
if (err != noErr)
Debugger();
}
}
A good method for playing sampled sound asynchronously on any Macintosh is to create a sound channel
and use the bufferCmd. Find the sound header from the 'snd ' resource and pass the pointer to
this in the bufferCmd. Use this with SndDoCommand or SndDoImmediate. To determine when the sound has completed so that you can know when
to dispose of the channel, send a bufferCmd with SndDoCommand (in order to queue it)
after the bufferCmd. Once your callback procedure is called, set a global signalling that
the sound has finished. The new Sound Manager (System 6.0.7 and beyond) supports a new call, SndChannelStatus, which
will tell you if the channel is playing a sound or not. Instead of the callback procedure,
you can poll the channel’s status to determine when to dispose of the channel.
Example code using the callback procedure can be found in the DTS sample code SoundApp.
Q What is the difference between North and West?
A
North is an absolute direction on the globe. Once you are on the North Pole it is impossible to go any
"further North." West, on the other hand,
is a relative position. No matter where you are on the surface of the Earth, it’s always possible to go further West.
Q
I have found that sounds recorded at good or better quality will not play with system software prior to 6.0.7.
That’s expected, but the fact that SndPlay does not return an error message is not.
How can I check to see if a sound is compressed when running older system software?
A
There is a byte in the SoundHeader
data structure (and thus in a 'snd' resource), called "encode." If the sound is compressed,
the value of this byte will be $FE, which is defined as the constant cmpSH in the headers for the Sound Manager.
Q
Why do golf balls have pocks?
A
As counter intuitive as it may seem
at first, the pocks on golf balls actually make them fly farther. A golf ball builds turbulence in front of it as it flies through the air. If the ball is pocked, the turbulence “fills” the pockets as the ball spins, resulting in less resistance and more flight. 747s have pocks on their wings for the same reason. Dolphins presumably have these pocks on their fins for this purpose as well, but to date none of them have come out publicly and said so.
Q
We generate sounds using the Sound Driver’s four-tone synthesizer. Our application must run on all Macintosh computers and all system software versions starting with System 6.0.
According to an early version of Inside Macintosh, Volume VI, the new Sound Manager's
wave-table synthesizer, which replaces the Sound Driver's four-tone synthesizer, does not
perform as expected on some Macintosh systems. When should we use the Sound Manager and
when should we use the Sound Driver?
AThe Sound Driver is no longer supported, as of System 6.0.7. The wave-form synthesizer in the Sound
Manager released with 6.0.7 does not work correctly for non-Apple Sound Chip machines (Macintosh
Plus, SE, Classic, and LC), but this will be fixed in System 7. If you need to use the wave-form
synthesizer for non-ASC machines running 6.0.7, you could try the Sound Driver with 6.0.7 on the
chance it'll work for your purpose. Use the Sound Driver for non-ASC machines running System 6.0.5
and earlier.
QDoes stereo work? I was hoping to init the left and right channels separately
(using initChanLeft and initChanRight) and send different sampled sounds out both
channels. But the Sound Manager documentation says stereo is not supported. I figured this
would be a "cheap" way of playing two sounds at the same time, sending them out the left
and right channels and letting the Macintosh mix them together (or telling the user to flip
the MONO switch on their stereo).
AStereo and mixing multiple channels
are new features of the Sound Manager released with System 6.0.7. If you create a mono channel, the
sounds come out both speakers. If you create a left channel, it is a mono sound coming from only the
left channel. Alternatively, creating a right channel will only come from the right.
If you create a stereo channel, then
the sound's left or right position is determined by the sound header you
use (with the bufferCmd). A stereo sound is only supported by a compressed or extended sound header.
You cannot control the left or right panning of a stereo sound. This is only determined by the sound
header and its interleaved data. The left or right init params will have no affect on a stereo channel.
True stereo sounds can only occur by using a stereo sound header. Two mono channels, one for the
left speaker and one for the right, could be opened for the affect that most developers want.
Only the Macintosh SE/30 and the Macintosh IIsi have both the left and right sources mixed to the
internal speaker. A stereo sound on all other Macintosh systems have the left source only sent to the
internal speaker. The right source is only sent to the external port, and it isn't possible to determine
if the external port is in use or not.
QIs it necessary to lock a 'snd' resource that is to be played asynchronously with SndPlay?
AYes, if you are playing a sound resource asynchronously with SndPlay, then you have to lock the
sound. SndPlay will restore the handle's state as soon as the trap returns to the caller. If the call is
asynchronous, the handle's state is restored immediately after calling SndPlay, before the sound
finishes playing.
QWhen converting stacks from HyperCard 1.2.5 to 2.0, the default "fixed line height" setting
for text fields sometimes enlarges the space required by text and destroys the layout of the
screen. For example,text tends to disappear outside the edges of the field, or be misaligned. Deselecting "fixed line
height" corrects the problem in most instances, but there can still be a slight discrepancy in the
amount of space taken up by identical fonts in identical fields between 1.2.5 and 2.0, such that
layouts are disrupted even if "fixed line height" is not selected.
AInherent in the design of HyperCard 2.0, the way a field is displayed may
be different in HyperCard 2.0 than
in HyperCard 1.2.5. Converting a
stack to HyperCard 2.0 from HyperCard 1.2.5 may require that
fields be tweaked to appear properly. Therefore, developers may want to provide special versions of
their stacks for use with HyperCard 2.0, regardless of whether features specific to HyperCard 2.0 are
incorporated.
QSince I have received HyperCard 2.0 I have converted several stacks for 1.x to 2.0 and have
experienced several problems with scripts that worked fine in 1.x. I have recently learned
that HyperCard 1.x will NOT run on System 6.0.7 and later versions. For HyperCard 1.x
users this results in stacks that cannot be used in HyperCard 2.0. For HyperCard stack
developers this presents a nightmare in converting old 1.x stacks for users into 2.0 stacks.
Since encountering these problems I have changed my scripts in 1.x so that when converted
they work. What is Apple's position on "seamless conversion" of HyperCard 1.x stacks to
HyperCard 2.0?
AMost functioning 1.x scripts will work without modification under HyperCard 2.0. However,
HyperCard 2.0 is a bit more strict in enforcing some of the grammar of HyperTalk. For example,
keywords can no longer be used as variable names under 2.0. Under 1.x, keywords could be used as
variable names, but the documentation specifically warned against doing this.
Kudos to our readers who care enough to ask us terrific and well-thought-out questions. The answers to these puzzles have
been supplied courtesy of our teams of technical gurus; our thanks to all. Special thanks to Pete "Luke Skywalker"
Alexander, Mark Baumwell, Jeremy Bornstein, Rich Collyer, Dennis Hescox, Jim Luther, Guillermo Ortiz, Jim Reekes, Bryan
Stearns, Robert Stobel,Forrest Tanaka,Vince Tapia, Jon Zap, and Scott "Zz" Zimmerman for the material in this Q & A
column. *
Have more questions? Need more answers? Take a look at the new developer technical library on AppleLink (updated
weekly) or the Q & A stack on each Developer CD Series disc. *
Software Updates via MacUpdate
Price Scanner via MacPrices.net
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.
|