garnett@cs.utexas.edu (John William Garnett) (01/21/91)
I wish to use C to do the equivalent of the following Objective-C statement: id mySound = [Sound newFromMachO:"SonicBoom.snd"]; That is, I wish to use the SND* routines to read a sound file from a Mach-O sound segment. I do know about the SNDReadSoundFile() function which allows one to read a sound file from disk. If anyone has an idea of how to do this, please let me know. Thanks. -- John Garnett University of Texas at Austin garnett@cs.utexas.edu Department of Computer Science Austin, Texas
wiml@milton.u.washington.edu (William Lewis) (01/25/91)
In article <1050@tokio.cs.utexas.edu> garnett@cs.utexas.edu (John William Garnett) writes: >That is, I wish to use the SND* routines to read a sound file >from a Mach-O sound segment. I do know about the SNDReadSoundFile() >function which allows one to read a sound file from disk. If anyone >has an idea of how to do this, please let me know. Thanks. Well, since no one seems to have jumped in with the Obviously Right Way to do this, here's my (untested) thought on the subject: Segments in Mach-O files have exactly the same format they do on disk (ie. the .snd or .nib or .tiff file is just copied into the executeable at the appropriate position). So, using the call named, I think, getsectbyname(), you can get a pointer into the memory-mapped executeable, pointing to the beginning of your sound segment. At this point, if you don't plan to edit or otherwise modify the sound, I *think* you can just cast this pointer into an (SNDSoundStruct *) -- ie, I think soundfiles have the same format on disk as in memory. If you need to edit the sound, allocate a SNDSoundStruct using SNDAlloc (with the parameters taken from casting the pointer to a SNDSoundStruct * as before), and insert the sample data using one of the SND* calls. -- wiml@milton.acs.washington.edu Seattle, Washington (William Lewis) | 47 41' 15" N 122 42' 58" W "These 2 cents will cost the net thousands upon thousands of dollars to send everywhere. Are you sure you want to do this?"