home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / apps.to.go / Kibitz / Sound.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-06  |  1.9 KB  |  104 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:             sound.c
  5. ** Originally from:  SoundCdev by Jeremy Bornstein
  6. ** Modified by:      Eric Soldan
  7. **
  8. ** Copyright © 1990-1992 Apple Computer, Inc.
  9. ** All rights reserved. */
  10.  
  11.  
  12.  
  13. /*****************************************************************************/
  14.  
  15.  
  16.  
  17. #include "Kibitz.h"                /* Get the Kibitz includes/typedefs, etc.    */
  18. #include "KibitzCommon.h"        /* Get the stuff in common with rez.        */
  19. #include "Kibitz.protos"        /* Get the prototypes for Kibitz.            */
  20.  
  21. #ifndef __ERRORS__
  22. #include <Errors.h>
  23. #endif
  24.  
  25. #ifndef __FILES__
  26. #include <Files.h>
  27. #endif
  28.  
  29. #ifndef __SOUND__
  30. #include <Sound.h>
  31. #endif
  32.  
  33. #ifndef __SOUNDINPUT__
  34. #include <SoundInput.h>
  35. #endif
  36.  
  37. #ifndef __UTILITIES__
  38. #include <Utilities.h>
  39. #endif
  40.  
  41.  
  42.  
  43. /*****************************************************************************/
  44. /*****************************************************************************/
  45.  
  46.  
  47.  
  48. #pragma segment Main
  49. OSErr    RecordSound(FileRecHndl frHndl)
  50. {
  51.     Handle    newSnd, oldSnd;
  52.     OSErr    err;
  53.     Point    corner = {50, 50};
  54.  
  55.     if (!(newSnd = NewHandle(31 * 1024))) return(memFullErr);
  56.  
  57.     err = SndRecord(nil, corner, siBetterQuality, &newSnd);
  58.  
  59.     if (!err) {
  60.         oldSnd = (*frHndl)->doc.sound;
  61.         if (oldSnd) DisposeHandle(oldSnd);
  62.         (*frHndl)->doc.sound = newSnd;
  63.     }
  64.     else DisposeHandle(newSnd);
  65.  
  66.     return(err);
  67. }
  68.  
  69.  
  70.  
  71. /*****************************************************************************/
  72.  
  73.  
  74.  
  75. /* SoundInputAvaliable
  76. **
  77. ** Sound input is avaliable if there's a device registered… */
  78.  
  79. #pragma segment Main
  80. Boolean SoundInputAvaliable(void)
  81. {
  82.     Boolean        siPresent;
  83.     Handle        devIconHandle;
  84.     Str255        devName;
  85.     NumVersion    vers;
  86.     
  87.     siPresent = false;
  88.     
  89.     if (gSystemVersion >= 0x0700) {
  90.         vers = SndSoundManagerVersion();
  91.         if (vers.majorRev > 0) {
  92.             if (SPBGetIndexedDevice(1, devName, &devIconHandle) == noErr) {
  93.                 DisposeHandle(devIconHandle);
  94.                 siPresent = true;
  95.             }
  96.         }
  97.     }
  98.  
  99.     return(siPresent);
  100. }
  101.  
  102.  
  103.  
  104.