home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / mac / programm / 18555 < prev    next >
Encoding:
Text File  |  1992-11-17  |  2.2 KB  |  62 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!pageworks.com!world!eff!sol.ctr.columbia.edu!usc!zaphod.mps.ohio-state.edu!swrinde!network.ucsd.edu!news!cod!frantzen
  3. From: frantzen@nosc.mil (Louise E. Frantzen)
  4. Subject: Strange things afoot with SndPlay
  5. Message-ID: <1992Nov17.211757.16475@nosc.mil>
  6. Keywords: SndPlay sound THINK C Sound Manager
  7. Organization: Naval Ocean Systems Center, San Diego, CA
  8. Date: Tue, 17 Nov 1992 21:17:57 GMT
  9. Lines: 51
  10.  
  11.  
  12. Hello everyone, 
  13.  
  14. I am wondering if someone can explain to me why the following call to SndPlay   is not
  15. working.  I am programming in THINK C 5.0 on a IIci running 7.1.  The following
  16. is a part of my program.
  17.  
  18. main()
  19. {
  20. SndChannelPtr chan_ptr;
  21. SoundHeader Header;
  22. Handle GaussHndl;
  23. OSErr myErr;
  24.  other generic declarations as needed in program
  25.  
  26.  GaussHndl = NewHandleClear(442);
  27.  
  28.  calculations for 400 bytes of sound data
  29.  
  30.  myErr = SetupSndHeader(GaussHndl, NUM_CHANNELS,SAMPLE_RATE,SAMPLE_SIZE,COMP
  31.     BASE_FREQ,400,HEADER_LEN_PTR);
  32.  
  33.  code to put 400 bytes of sound data starting at *(*GaussHndl + 42) = 1st data
  34.  (which I've checked and everything gets put in its proper place)
  35.  
  36.  iRsrc = UniqueID( 'snd ');
  37.  AddResource( GaussHndl, 'snd ', iRsrcID, "\pGaussian Noise" );
  38.  
  39.  MoveHHi (GaussHndl);
  40.  HLock (GaussHndl);
  41.  myErr = SndPlay( nil, GaussHndl, TRUE );  /* program BOMBS right here */
  42.  HUnlock (GaussHndl);
  43.  
  44.  DisposHandle( GaussHndl);
  45.  } /* end */
  46.  
  47.  My question is why does SndPlay not behave? According to IM VI p. 22-35, 
  48.  this is all I should have to do to play a sound resource.  I have tried 
  49.  other options which do not make the program bomb directly but don't play
  50.  the sound, either.  Many times the program won't bomb, say if I've allocated
  51.  my own channel instead of passing SndPlay nil, but then I try to run it 
  52.  again and get "Out of memory" error from THINK C or even a system error.  
  53.  
  54.  I am really getting to the end of my inventiveness, here, even after looking
  55.  at all the sample code I can get my hands on. Please help!
  56.  
  57. -------------------------------------------------------------------------
  58. -- 
  59. Louise E. Frantzen NRaD, San Diego CA     "And if you try to cut me down
  60. frantzen@nosc.mil              I know that you'll succeed "
  61. (619) 553-7863                    - A. Lennox
  62.