home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Sample Code / Movie Toolbox / Inside Mac Movie Toolbox Code / mtb12.c < prev    next >
Encoding:
Text File  |  1994-12-05  |  1.6 KB  |  86 lines  |  [TEXT/MPS ]

  1. /*
  2.   File:            mtb12.c
  3.   Contains:        Sound Functions
  4.   Written by:    DTS and QT Engineering
  5.   Copyright:    © 1992-1994 by Apple Computer, Inc., all rights reserved.
  6.   Change History (most recent first):
  7.   <1>         12/4/94    khs        changed the format of the file to the new look and feel
  8.   To Do:
  9. */
  10.  
  11.  
  12. // INCLUDES
  13. #include "mtb.h"
  14.  
  15.  
  16. // TYPEDEFS AND STRUCTS
  17. typedef SndCommand* SndCmdPtr;
  18.  
  19. typedef struct
  20. {
  21.     short format;
  22.     short numSynths;
  23. } Snd1Header, * Snd1HdrPtr, ** Snd1HdrHndl;
  24.  
  25. typedef struct
  26. {
  27.     short format;
  28.     short refCount;
  29. } Snd2Header, * Snd2HdrPtr, ** Snd2HdrHndl;
  30.  
  31. typedef struct
  32. {
  33.     short synthID;
  34.     long initOption;
  35. } SynthInfo, * SynthInfoPtr;
  36.  
  37.  
  38. // FUNCTIONS
  39. long GetSndHdrOffset(Handle sndHandle)
  40. {
  41.     short howManyCmds;
  42.     long sndOffset = 0;
  43.     Ptr sndPtr;
  44.  
  45.     if (sndHandle == nil)
  46.         return 0;
  47.     sndPtr = *sndHandle;
  48.     if (sndPtr == nil)
  49.         return 0;
  50.  
  51.     if ((*(Snd1HdrPtr)sndPtr).format == firstSoundFormat)
  52.     {
  53.         short synths = ((Snd1HdrPtr)sndPtr)->numSynths;
  54.         sndPtr += sizeof(Snd1Header) + (sizeof(SynthInfo) * synths);
  55.     }
  56.     else
  57.     {
  58.         sndPtr += sizeof(Snd2Header);
  59.     }
  60.  
  61.     howManyCmds = *(short*)sndPtr;
  62.  
  63.     sndPtr += sizeof(howManyCmds);
  64.     // sndPtr is now at the first sound command - cruise all
  65.     //         commands and find the first soundCmd or bufferCmd
  66.     while (howManyCmds > 0)
  67.     {
  68.         switch (((SndCmdPtr)sndPtr)->cmd)
  69.         {
  70.             case (soundCmd + dataOffsetFlag):
  71.             case (bufferCmd + dataOffsetFlag):
  72.                 sndOffset = ((SndCmdPtr)sndPtr)->param2;
  73.                 howManyCmds = 0;                /* done, get out of loop */
  74.                 break;
  75.             default:                            /* catch any other type of commands */
  76.                 sndPtr += sizeof(SndCommand);
  77.                 howManyCmds--;
  78.                 break;
  79.         }
  80.     }                                            /* done with all the commands */
  81.  
  82.     return sndOffset;
  83. }
  84.  
  85.  
  86.