Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!ncar!ncar.ucar.edu!hpoppe From: hpoppe@ncar.ucar.edu (Herb Poppe) Newsgroups: comp.sys.mac.programmer Subject: Sound Manager Message-ID: <9426@ncar.ucar.edu> Date: 6 Dec 90 18:19:31 GMT Sender: news@ncar.ucar.edu Distribution: na Organization: National Center for Atmospheric Research Lines: 95 What with the availability of the latest and greatest Sound Manager in System 6.0.7 I though I'd rework a sound application I wrote last year so that it will support multi-channel sampled sound. (I don't have the new Sound Manager chapter from IM 6; I'm assuming that all the bugs, restrictions, and limitations that Jim Reekes discussed in his Oct. '88 update to the Sound Manager chapter in IM 5 have been removed. Sure would be nice, though, if the new Sound Manager chapter could be put up on apple.com; or, better yet, if the dts directory on ftp.apple.com could be activated.) This time I thought I would allocate my own SndChannel records and pass a pointer to them to SndNewChannel instead of passing nil and having SndNewChannel allocate the storage each time it was called. I planned to allocate the records statically, and since I never have more than 3 or 4 SndCommands in the channel I'd take advantage of the innocent sounding sentence that accompanies the description of SndNewChannel (page 17): "Each channel will hold 128 commands as a default size. The length of a channel can be expanded by the application creating its own channel in memory." (I assumed that "expanded" really meant "changed" and that I could make the channel smaller than 128 commands.) I then tried to figure out how to tell SndNewChannel what the maximum number of SndCommands were in my SndChannel. There is no parameter to SndNewChannel that one can use to provide this information, nor does there appear to be any field in the SndChannel record: SndChannel = PACKED RECORD nextChan: SndChannelPtr; FirstMod: ModifierStubPtr; callBack: ProcPtr; userInfo: LONGINT; wait: Time; cmdInProgress: SndCommand; flags: INTEGER; qLength: INTEGER; qHead: INTEGER; qTail: INTEGER; queue: ARRAY [0..stdQLength-1] OF SndCommand; END; where this information can be provided (I assume the fields qLength, qHead, qTail refer to the dynamic length of the channel, and not to its maximum size). It seems to me, then, that SndNewChannel has no way to determine what the maximum length of the channel is, unless it uses a call like GetPtrSize, which requires that all SndChannel records be allocated in the heap by the Memory Manager. This in turn means that it is bad news to statically allocate SndChannel records. IF THIS IS SO, THIS REQUIREMENT SHOULD BE POINTED OUT IN THE DOCUMENTATION! Is this discussed in the IM 6 documentation? Can SndChannel records be (safely) statically allocated? I was just about to post this when it occurred to me that it might be prudent to look back at the Sound Manager chapter in IM 5. Although Jim Reekes' update was intended to replace the chapter in IM 5, I have occasionally discovered little gems of information there that weren't carried over into the update document. On page V-481, "The SndChannel Record", it says: "QLength specifies the number of commands that the channel can hold; it must always be ORD(stdQLength)." I was apparently wrong in assuming that qLength was the dynamic length. Presumably I could set qLength to the length of my SndCommand array and SndNewChannel (or whoever) could look there for the max channel length without resorting to GetPtrSize. Therefore, I could statically allocate my SndChannel records. On the other hand, it does say: "it MUST ALWAYS be ORD(stdQLength)" which says I can't have records that are different in size from the standard, thus contradicting Jim Reekes' update. The last paragraph on the page goes on to say: "When you've allocated the SndChannel record yourself, the Sound Manager saves the state information from the pointer you pass, (calling HGetState)." This says, I guess, that SndChannel records must be allocated via the Memory Manager (no static allocation). So I'm left asking: 1) Am I permitted to allocate a SndChannel record smaller than the standard length one. 2) Must I set qLength to the number of SndCommands I've allocated before I call SndNewChannel? (SndChannel.queue: ARRAY[0..SndChannel.qLength-1] OF SndCommand; in effect) Herb Poppe hpoppe@ncar.ucar.edu NCAR (303) 497-1296 1850 Table Mesa Dr. Boulder, CO 80307-3000