develop-11 9208 August 1992
From the originals
13 scansMachine-transcribed text and image descriptions. Check the linked original for uncertain words or fine print.
These are transcribed pages from the documents, not the full publications. Open the original for the remaining pages.
Image 1
develop The Apple Technical Journal THE ASYNCHRONOUS SOUND HELPER AROUND AND AROUND: MULTIBUFFERING SOUNDS LIVING IN AN EXCEPTIONAL WORLD THE NETWORK PROJECT: DISTRIBUTED COMPUTING ON THE MACINTOSH WRITING DIRECTLY TO THE SCREEN KON & BAL'S PUZZLE PAGE MACINTOSH Q & A Issue 11 August 1992
A magazine cover with a lowercase masthead at top, a colorful 3D illustration of musical notes, staff lines, and waveform shapes in green, orange, and red on the left, and a list of article titles in bold sans-serif at right with an Apple logo and issue line at bottom right.
Reading notes: Masthead letter spacing is stylized; the tagline 'The Apple Technical Journal' is small and widely spaced. Issue line reads 'Issue 11' with 'August 1992' beside it; the Apple logo sits above it.
- Printed dates
- August 1992
- Languages
- English
PDF page 1
develop The Apple Technical Journal THE ASYNCHRONOUS SOUND HELPER AROUND AND AROUND: MULTIBUFFERING SOUNDS LIVING IN AN EXCEPTIONAL WORLD THE NETWORK PROJECT: DISTRIBUTED COMPUTING ON THE MACINTOSH WRITING DIRECTLY TO THE SCREEN KON & BAL'S PUZZLE PAGE MACINTOSH Q & A Issue 11 August 1992
A cover with a large isometric illustration of green and orange musical staves, sound waveforms, and music notes on a split green and orange background, with the magazine title at top right and a list of article titles down the right side.
Reading notes: The 'develop' masthead is set in a stylized lowercase wordmark with letter-spaced tagline; the tagline is rendered as 'The Apple Technical Journal' in spaced small capitals and may be read with slight spacing variation. Issue number and date appear at bottom right beside the Apple logo; reading order of the cover lines is top to bottom in the right column.
- Printed dates
- August 1992
- Languages
- English
PDF page 2
E D I T O R I A L S T A F F Editor-in-Cheek Caroline Rose Technical Buckstopper Dave Johnson Our Boss Greg Joswiak His Boss David Krathwohl Review Board Pete (“Luke”) Alexander, Neil Day, C. K. Haun, Jim Reekes, Bryan K. (“Beaker”) Ressler, Larry Rosenstein, Andy Shebanow, Gregg Williams Managing Editor Monica Meffert Assistant Managing Editor Ana Wilczynski Contributing Editors Lorraine Anderson, Toni Haskell, Judy Helfand, Rebecca Pepper, Rilla Reynolds Indexer Ira Kleinberg A R T & P R O D U C T I O N Production Manager Hartley Lesser Art Director Diane Wilcox Technical Illustration Nurit Arbel, John Ryan Formatting Forbes Mill Press Printing Wolfer Printing Company, Inc. Film Preparation Aptos Post, Inc. Production PrePress Assembly Photography Sharon Beals, Lisa Jongewaard Online Production Cassi Carpenter develop, The Apple Technical Journal, is a quarterly publication of the Developer Support Systems and Communications group. Cleo Huggins of Rucker Huggins used Ray Dream Designer 2.0 to orchestrate this 3-D score of sound and music. The music symbols are characters from Sonata, a noteworthy typeface that Cleo designed at Adobe Systems. The Developer CD Series disc for August 1992 or later contains this issue and all back issues of develop along with the code that the articles describe. The develop issues and code are also available on AppleLink and via anonymous ftp on ftp.apple.com.
Reading notes: Transcript is intentionally empty because the exact extracted text is preserved separately; no image was supplied for independent verification. No headline is present; the spaced-out 'E D I T O R I A L S T A F F' and 'A R T & P R O D U C T I O N' lines are section labels, not headlines. Visual description and layout are inferred from the supplied copy only and may not match the original page. Product names and the date were taken from the body copy; 'Sonata' is described as a typeface and 'develop' as a journal title. No advertised prices appear in the supplied copy.
- Printed product names
- Ray Dream Designer 2.0 · Sonata · Developer CD Series · develop, The Apple Technical Journal
- Printed dates
- August 1992
- Languages
- English
PDF page 3
CONTENTS August 1992 1 © 1992 Apple Computer, Inc. All rights reserved. Apple, the Apple logo, APDA, Apple IIGS, AppleLink, AppleShare, AppleTalk, ImageWriter, LaserWriter, LocalTalk, MacApp, Macintosh, MPW, MultiFinder, SADE, and StyleWriter are trademarks of Apple Computer, Inc., registered in the U.S. and other countries. Balloon Help, develop, Finder, Macintosh Quadra, PowerBook, QuickDraw, QuickTime, Sound Manager, System 7, and TrueType are trademarks of Apple Computer, Inc. HyperCard is a registered trademark of Claris Corporation. DEC is a trademark of Digital Equipment Corporation. UNIX is a registered trademark of UNIX System Laboratories. All other trademarks are the property of their respective owners. Out with the old, in with the new (and improved). 2 Please keep ’em coming! Your opinions matter. 4 The Asynchronous Sound Helper by Bryan K. (“Beaker”) Ressler Confused about the Sound Manager? Here’s help: a detailed walk-through of useful routines for accomplishing common Sound Manager tasks. 7 Around and Around: Multibuffering Sounds by Neil Day The inside world of multibuffering sounds is exposed to the light, and we discover that it’s really not that gory. 38 Living In an Exceptional World by Sean Parent Ever get mad at those “Real programs check errors here” comments you see so often in sample code? Here’s a workable error-handling methodology that might interest you. 65 The NetWork Project: Distributed Computing on the Macintosh by Günther Sawitzki Distributed computing is looming large on the horizon, and programmers need to be ready. NetWork enables you to experiment with distributed computing right now. 82 Graphical Truffles: Writing Directly to the Screen by Brigham Stevens and Bill Guschwan The message hasn’t changed: Don’t write directly to the screen. But if you absolutely need to break the rules, here are some clues for success. 59 The Veteran Neophyte: Quantum Lunch by Dave Johnson, with Michael Greenspon Is it possible to simulate a brain? Can thought and matter be separated? Should you care? 106 KON & BAL’s Puzzle Page: An Off-Color Puzzle by Konstantin Othmer and Bruce Leak Think historically and you just might get this one. 123 Macintosh Q & A Answers to your product development questions. 110 126 I N D E X Q & A C O L U M N S A R T I C L E S L E T T E R S E D I T O R I A L
Reading notes: Reading order of the table of contents page numbers and article titles is slightly uncertain due to layout of the extracted text.
- Printed product names
- Apple IIGS · AppleLink · AppleShare · AppleTalk · ImageWriter · LaserWriter · LocalTalk · MacApp · Macintosh · MPW · MultiFinder · SADE · StyleWriter · Balloon Help · develop · Finder · Macintosh Quadra · PowerBook · QuickDraw · QuickTime · Sound Manager · System 7 · TrueType · HyperCard · DEC · UNIX
- Printed dates
- August 1992 · 1992
- Languages
- English
PDF page 4
Dear Readers, Time marches on, and with it, inevitably, comes change. I’ll be telling you here about some recent changes in the world of Macintosh documentation and develop . We think they’re changes for the better—but of course you, the developer, are the final judge. First, the “bible,” Inside Macintosh , is on its way out, starting with the imminent publication of New Inside Macintosh . I know only too well what your problems were with the first three IM volumes, which I slaved over for a good chunk of my life—not enough examples, not enough explanation of how the parts work together as a whole—and (till now) I’ve resisted the urge to defend myself here by telling you how time- and staff-restricted we were, how the software kept changing out from under us, and numerous other excuses. Volumes IV through VI sparked new complaints, primarily that the information on a specific topic was scattered over several volumes. All these problems have been addressed in New Inside Macintosh , which brings everything together in an organized and understandable way that should, once it’s published in its entirety, have you happily discarding all your old volumes (except for you sentimentalists who will never part with your old “phone book” edition). The first NIM books are due to appear in bookstores in September, and the last books in the series should be available by May 1993. The electronic versions of these books will show up on the Developer CD Series disc as soon as they’re ready. References to Inside Macintosh in develop will continue to point to the original IM volumes until next year when the transition to NIM is complete. Tech Notes have also undergone a reincarnation, as you’ll notice when you look at them on the CD. Our new Tech Note poobah, Neil Day, talks about this at the end of the Letters section, on page 6. The Notes are no longer numbered, but are now organized by subject, similar to the organization of New Inside Macintosh . As a result of this change, develop ’s references to Tech Notes now refer to numbered Notes as things of the past (for example, “formerly #161”). Another change in this issue of develop is one we want to be sure you know is an aberration: There’s no Print Hints column this time. It turns out that Luke Alexander committed one of the very printing crimes he wrote about in Issue 10, and he couldn't pay the bail. Well, actually, Luke was very busy preparing for his talk at the Worldwide Developers Conference while this issue was being written, and we had to let him off the hook. He promises he’ll be back stronger than ever in Issue 12. d e v e l o p August 1992 CAROLINE ROSE (AppleLink: CROSE) first interviewed at Apple in 1982, when she was shown a Macintosh with balls bouncing all over its screen. Having been raised on computers as card sorters and number crunchers, she thought this was pretty exciting, and signed up to write its technical documentation. Her love affair with the Macintosh suffered a blow when she left in 1986 to join NeXT, but she came back after five years away, and all was forgiven. Caroline recently learned from a bio in an early issue of develop that 8/8/88 was considered a very lucky day by the Chinese, and she ponders the significance of having missed that day entirely due to crossing the international date line. She loves to travel, whether in planes, trains, and automobiles, on foot, or simply back and forth in a swimming pool.• 2 CAROLINE ROSE
Reading notes: Some phrasing near the end of the Caroline Rose biography may be jumbled in extraction order.
- Printed product names
- Inside Macintosh · New Inside Macintosh · Developer CD Series · develop · Tech Notes · Macintosh
- Printed dates
- August 1992 · September · May 1993 · 8/8/88 · 1982 · 1986 · Issue 10 · Issue 12
- Languages
- English
PDF page 5
Speaking of the Worldwide Developers Conference, it was wonderful to meet so many of you there, hear your good words about develop , answer your questions, and set you straight on a few things. Many developers didn’t know, for example, that develop accepts articles from outside Apple (though we rigorously review them just like our own) and that they don’t have to already be at the polished level of writing you’re used to seeing in develop (we have editors who help with that). The overwhelming majority of Associates and Partners expressed their displeasure at no longer receiving develop in printed form in their monthly mailing (though some of them still hadn’t realized this, because it usually takes a long time for develop to get to them anyway). Not all of them knew that they could subscribe to get printed develop (through APDA, AppleLink DEV.SUBS, or the subscription card in an actual printed issue). We’ll keep trying to spread the word; meanwhile, please tell two friends. On to the trivia . . . Issue 10’s editorial asked: What character in develop ’s body font is upside-down (not just one-time-only, but defined that way)? The answer is “8”—see? If it were a snowman, it would topple over. Some of you wondered about my answer to this earlier trivia question: What word was used instead of “click” to describe the action of pressing a button on that first mouse? The answer was “bug,” and I was asked whether the choice of that word was a joke, or what. I called Doug Engelbart himself to find out, and he said that in those days the cursor was called a “bug,” so it became short for “to put the bug somewhere by pressing this button.” It had nothing to do with the meaning of “bug” as a problem in a program. As to why “bug” was used to refer to the cursor, he didn’t know the history of that. So I guess—unless one of you can shed some light on this—the bug stops there. Caroline Rose Editor EDITORIAL August 1992 3 SUBSCRIPTION INFORMATION You can subscribe to develop through APDA (see the inside back cover) or by using the subscription card in the back of this issue. Please address all subscription-related inquiries to develop, Apple Computer, Inc., P.O. Box 531, Mt. Morris, IL 61054 (or AppleLink DEV.SUBS).• BACK ISSUES For information about back issues of develop and how to obtain them, see the last page of this issue. Back issues are also on the Developer CD Series disc.•
Reading notes: Source text appears to be OCR-like with irregular spacing in places, e.g. 'develop accepts' and 'Issue 10's editorial' Editorial reading order mixes conference remarks with trivia answers and subscription boxes
- Printed product names
- develop · APDA · AppleLink DEV.SUBS · Developer CD Series
- Printed dates
- August 1992
- Languages
- English
PDF page 6
DEVELOP ON FTP.APPLE.COM I think develop is the greatest Macintosh journal around. I’ve gotten lots of help from the articles and the code on the CD. One thing about the CD: It would be nice if I could ftp the files from apple.com, since I don’t have a CD- ROM player. —Jim Wintermyre Thanks for the kind words about develop, a nd for the idea of putting the files on apple.com (actually, it’s now ftp.apple.com). Like Technical Notes, DTS Sample Code, and Snippets, develop articles and code are now available via anonymous ftp on ftp.apple.com, thanks to Mark Johnson, manager of Apple’s Core Technical Support group, who does this on his own time. —Caroline Rose OUR AUTHORS ARE REAL I would like to suggest that you publish your authors’ e-mail addresses. I wanted to send a note of praise, thanks, and encouragement to Bryan K. (“Beaker”) Ressler, author of the excellent article “The TextBox You’ve Always Wanted” in Issue 9— but I didn't know how to reach him. Even a “Find Address” search on AppleLink turned up nothing. Are you sure this guy’s for real? —James Plamondon Yes, we’re sure. Since receiving your suggestion, we’re asking all authors if they’d like to put their e-mail addresses in their bios. Many would prefer not to be contacted directly. And sometimes the authors are in flux and don’t have a stable or convenient address for a while. Where no address is provided, letters should be sent to the AppleLink address DEVELOP, and they’ll be forwarded. —Caroline Rose ASSOCIATES MISS DEVELOP In Issues 8 and 9 of develop , you mentioned that Apple Partners and Associates no longer receive a printed copy of the publication. If I were an Associate, and I plan to become one soon, I would continue to subscribe to the printed version. First, there’s the “curling up in front of a fire” factor you mentioned. There are many places I take develop that I couldn’t take a Macintosh and CD-ROM drive. It slips easily into a briefcase and can be read on a bus or while waiting in line. While I’m reading develop , somebody else can use the Macintosh. Some of the articles require some effort to understand, which is easier while sitting in an overstuffed chair with the article in my hands than while looking at a computer screen. Oh, yeah, put a cat in my lap for good measure. Second, the aesthetic experience of the printed version would be hard to give up. The beautiful covers are the most obvious part of this, but the care you put into laying out the pages, providing just the right amount of white space, selecting the typefaces to complement each other and make the content easy to read makes reading develop a very pleasant experience. Then there’s the smell of a newly printed develop and the faint “crick” sound of it being opened for the first time. Third, the printed version has material that would be impossible to view on the 1-bit screen I’m using. How would I know what “Konenna” looks like d e v e l o p August 1992 IT MAKES OUR DAY WHEN YOU WRITE We welcome timely letters to the editors, especially from readers reacting to articles that we publish in develop. Letters should be addressed to Caroline Rose (or, if technical develop-related questions, to Dave Johnson) at Apple Computer, Inc., 20525 Mariani Avenue, M/S 75-2B, Cupertino, CA 95014 (AppleLink: CROSE or JOHNSON.DK). All letters should include your name and company name as well as your address and phone number. Letters may be excerpted or edited for clarity (or to make them say what we wish they did). • 4 LETTERS
Reading notes: Some words are split by spacing artifacts (e.g., 'a nd', 'Konenna' quoted text unclear in context) Reading order of letter sections is inferred from headings
- Printed product names
- Macintosh · CD-ROM · AppleLink · Technical Notes · DTS Sample Code · Snippets · CD-ROM drive
- Printed dates
- August 1992 · Issue 9
- Languages
- English
PDF page 7
without a printed copy? How would I know what you look like? Even if I could display some of the artwork and photographs, it would take some effort and time, and I might not bother. Turning a page is a very simple thing to do. And the access time is much faster than a CD-ROM could ever be. Fourth, the “green” factor. A Macintosh uses electricity even when you’re just sitting there staring at the screen. I haven’t noticed develop using any, no matter how long I spend reading it. I believe you use partially recycled paper, and you don’t have to worry about my copies being recycled because they’ll sit on the bookshelf until I die or get a room in the loony bin. Sort of like National Geographic . develop , in its physical form, is beautiful, informative, sometimes funny, interesting, and occasionally inspiring. I won’t give it up when I become an Associate, though for what that costs I darn well shouldn’t be asked to. Keep up the good work. I appreciate it! —Lyle Gunderson I’ve been a fan of develop since its first issue, and still look forward to each one. I take mouse in hand to share my angst about hardcover versions of develop . I love them. Hey, we recycle at home. We have a compost heap. We’re down to one car. But, for a mag like develop , I like the feel of hefting it, scanning through to see what’s up, and snooping through the bios looking for the ever present chuckles. It’s a magazine I sit on the couch with and, what else, browse. This is not the Technical Notes stack, nor is it Inside Macintosh . I’m prepared to look at them through the glass keyhole of my Apple monitor, since they’re only mildly amusing, very functional, and I usually need them when I’m in front of it anyway. That’s what references are for. But develop is a different beast. develop is Life magazine for Mac-crazed software craftspeople. It needs to be perused, thoughtfully, where it can be set down and have some latte dripped on it. I hope the developer mailing resumes the practice of sending develop in paper form. —David Kauffman I love these letters—and the similar comments that we got at this year’s Worldwide Developers Conference. As a result of all this feedback, which has been pouring in since develop was taken out of the developer mailing, people in high places at Apple no longer believe that this is what most Associates and Partners want. No changes are imminent, but the subject is not dead. For now I can only urge you to pay the $30 to subscribe to develop in its printed form. —Caroline Rose NEW SINCE LAST DEVELOP? Could you prevail on the Developer CD folks to include a “What’s new since last develop” folder on CDs that come with develop ? It would be done like the very nice “What’s new on this CD?” folder, but cover three months rather than one. —John Baxter The “What’s new on this CD?” folder now indicates (separately) what’s new for each of LETTERS August 1992 5
Reading notes: Source is a fragmented letters-page excerpt with broken line endings and mid-sentence column breaks, so reading order is uncertain. Several sentences are truncated at the start and end of the excerpt, and the 'What's new' passage is cut off.
- Printed product names
- Macintosh · CD-ROM · National Geographic · Inside Macintosh · Apple monitor · Developer CD · What's new on this CD?
- Printed prices
- $30
- Printed dates
- August 1992
- Languages
- English
PDF page 8
the last three months—in this case, June, July, and August. Thanks for the idea! —Caroline Rose FAKIN’ IT develop is a great publication, and the Q & A section is especially useful. In Issue 10 you define the term “fakey” as “riding your snowboard backwards.” There are two problems with this. First, the correct spelling is “fakie.” The greatest mistake, however, was not attributing the word to its original source: skateboarding. Snowboarding has taken almost all of its trick names from skateboarding, “fakie” included. Keep up the good work, but get the facts straight! ;-) —Frank Giraffe We here at develop are embarrassed and chagrined that such an obvious and important error could have slipped past us, and we apologize profusely for any inconvenience this misrepresentation of fact has caused you, either real or imagined. Thank you for your comments. —Dave Johnson d e v e l o p August 1992 A note for international folks: Tech Notes now print on A4 paper as well as US Letter, so you don’t need to spend hours reformatting them by hand! • Send your feedback on Tech Notes or Sample Code to Neil at AppleLink NMDAY or on the Internet at nmday@apple.com. • 6 It’s 3:00 A.M. You’ve just finished polishing that code that you’ve been slugging it out with for the last several nights. It works beautifully, you’re happy and full of energy. Instead of waking up the nearest person for a demo (and risking being murdered), you decide to start work on “just one more thing” before hitting the sack. So here you are with Inside Macintosh, a tureen of Dark French Roast, and about 15 Tech Notes open, trying to figure out how to get some gadget to work. The feeling of success has been replaced by annoyance. It took 20 minutes of index scouring to find these Tech Notes, and you’re still not sure you’ve got the whole picture. Writing great software is challenging enough without fighting with documentation. If you take a look at the latest Developer CD Series disc, you’ll see that Tech Notes and Sample Code have been reorganized; we believe this new system will be far easier for you to use. The first thing you’ll notice is that Tech Notes and Sample Code have new categories; these are based on the ones used in New Inside Macintosh, which will be released over the next nine months or so. We want you to be able to quickly collect all the information on a given problem. Take a look at the Categories document to familiarize yourself with the new categories. Tech Notes have also lost their numbers; the actual document simply has a name. “Numbers have worked fine for me for all these years; why change now?” you ask. Now that the Notes are organized by category, using numbers makes less sense. And using names instead of numbers solves the problem of gaps in the numbering scheme, which happens when Tech Notes are removed. We expect even more of them to be removed than before, because they’ll be incorporated into New Inside Macintosh periodically as it’s revised. In the Indexes folder, you’ll see “alias indexes” that will let you get to the information in several different ways, including by the old Tech Note number. We’re trying to cover all the bases. We hope you’ll check out the Tech Notes and let us know what you think of the new scheme! TECH NOTES TAKE A NEW PATH; CHECK IT OUT! BY NEIL DAY
Reading notes: Reading order between the develop letters and body columns is uncertain due to spaced-out masthead text. Several product names are italicized or stylized in the source and may be imprecisely captured.
- Printed product names
- develop · Inside Macintosh · New Inside Macintosh · Developer CD Series · Tech Notes · Sample Code · AppleLink
- Printed dates
- August 1992 · June · July · August · Issue 10 · Q & A
- Languages
- English
PDF page 9
In system software version 6.0.7 and later, the Sound Manager has impressive sound input and output capabilities that are largely untapped by the existing body of application software. This article presents a code module called the Asynchronous Sound Helper that’s designed to make asynchronous sound input and output easily accessible to the application programmer, yet provide an interface flexible enough to facilitate extensive application features. Of all the Managers in Inside Macintosh, the Sound Manager may be the winner of the Most Startling Metamorphosis contest. On the earliest Macintosh computers, sound was produced by direct calls to a Sound Driver, as described in Inside Macintosh Volume II. Later, with the advent of system software version 4.1 and the more powerful sound-generation hardware of the Macintosh SE and Macintosh II, the Sound Driver was superseded by a fairly buggy initial implementation of the Sound Manager, which was first documented in Inside Macintosh Volume V. The new Sound Manager presented a problem for developers, because there was a large installed base of Macintosh 128K, 512K, 512K enhanced, and Plus computers that didn’t have the ROMs or system software to support the Sound Manager. At this point, all but the heartiest developers decided the tradeoffs for including sound in a non–sound-related application were too severe. By the time version 6.0.7 rolled around, many of the details of the Sound Manager had changed, and sound input support was added. In fact, the Sound Manager in 6.0.7 and System 7 is relatively stable. So if you’ve been waiting for the right moment to add sound support to your application, the moment has arrived. The Macintosh Sound Manager acts as a buffer between your application and the complexities of the sound hardware (see Figure 1). Sounds are produced by sending sound commands to a sound channel . The sound channel sends the commands through a synthesizer that knows how to control the audio hardware. Among the Sound Manager’s current 38 commands are operations such as playing simple frequencies, THE ASYNCHRONOUS SOUND HELPER August 1992 7 BRYAN K. (“BEAKER”) RESSLER (AppleLink: ADOBE.BEAKER) Looking back, it seems clear that Bryan sacrificed quality time with his wife during the writing of this article. So, in the spirit of fairness, develop asked Bryan’s wife, Nicole, to contribute the bio for her husband. Here it is: ”I owe it all to my wife, without whom I wouldn’t be the man I am today. The End.”• BRYAN K. (“BEAKER”) RESSLER THE ASYNCHRONOUS SOUND HELPER
Reading notes: Garbled phrase 'develop asked Bryan’s wife' may be a layout or extraction artifact Reading order of author bio and headline fragments is uncertain
- Printed product names
- Macintosh · Macintosh SE · Macintosh II · Macintosh 128K · System 7 · Inside Macintosh · Inside Macintosh Volume II · Inside Macintosh Volume V
- Printed dates
- August 1992 · 6.0.7 · 4.1
- Languages
- English
PDF page 10
playing complex recorded sounds, and changing sound volume. The Sound Manager also allows you to record new sounds if the appropriate hardware is available. Recording is performed through a sound input driver. Sound playback and recording through the Sound Manager can be performed synchronously or asynchronously . When you make a synchronous call to the Sound Manager, the function doesn’t return control to your application until the entire operation (sound playback, for instance) is complete. In general, it’s easy to use the Sound Manager to play or record sound synchronously. Asynchronous calls return control immediately to your application and perform their operations in the background, which makes asynchronous operations somewhat trickier. Many developers feel that there are too many details to make asynchronous sound worthwhile in an application not specifically oriented toward sound. However, with sound input devices becoming more common, the market impetus to add sound is growing. This article presents the Asynchronous Sound Helper, a code module designed to take much of the heartburn out of asynchronous sound input and output. The goals of Helper, as we’ll be calling it from now on, are threefold: • Provide a straightforward and uncomplicated interface for asynchronous sound I/O specifically tailored toward common application requirements. • Encourage developers to include support for sound as a standard type of data, just like text or graphics. d e v e l o p August 1992 8 Application Sound Manager Synthesizer Sound input driver Figure 1 The Sound Manager
- Printed dates
- August 1992
- Languages
- English
PDF page 11
• Function as a tutorial on how to perform asynchronous sound input and output using the Sound Manager. Helper provides two-tiered support—“easy” calls for basic operations and “advanced” calls for more complex operations. You choose which calls to use depending on your application’s specific needs and user interface. For simple asynchronous recording and playback, only a few routines are required. Or go all out and use Helper routines to easily provide a “sound palette” with tape-deck–like controls for your application. To top it off, the overhead for Helper is fairly small. The code compiles to about 4K, and it adds 86 bytes of global data to your application. At run time, it uses around 4K in your application’s heap. Helper uses clean Sound Manager techniques—nothing skanky that might cause compatibility problems in the future. HOOKING UP WITH HELPER First let’s take a quick look at how Helper works and how your application uses it. We’ll leave the details for later. Before you can use Helper you need to add a global Boolean flag to your application —the attention flag. At initialization time, your application calls Helper’s initialization routine and provides the address of the attention flag. In its main event loop, your application checks the value of the attention flag and, if true, calls Helper’s idle routine. Because Helper’s main function is to spawn asynchronous sound tasks, communication between your application and Helper is carried out on an as-needed basis. Here are the basic phases of communication for a typical sound playback sequence (the numbers correspond to Figure 2). 1. Your application tells Helper to play some sound. 2. Helper uses the Sound Manager to allocate a sound channel and begins asynchronous playback of your sound. 3. The application goes on its merry way, with the sound playing asynchronously in the background. 4. The sound completes playback. Helper has set up a sound command that causes Helper to be informed immediately upon completion of playback (this occurs at interrupt time). At that time, Helper sets the application’s global attention flag. 5. The next time through your application’s event loop, the application notices that the attention flag is set and calls SHIdle to free up the sound channel. THE ASYNCHRONOUS SOUND HELPER August 1992 9
- Printed dates
- August 1992
- Languages
- English