home *** CD-ROM | disk | FTP | other *** search
/ Amiga Dream 59 / CDDream59.ISO / BeOs / Sound / Intel / PPBeDevKit.ZIP / PLAYERPR.TAR / PlayerPRO / Source / Mac-SoundManager.c < prev    next >
C/C++ Source or Header  |  1998-12-26  |  4KB  |  131 lines

  1. /********************                        ***********************/
  2. //
  3. //    Player PRO 5.0 - DRIVER SOURCE CODE -
  4. //
  5. //    Library Version 5.0
  6. //
  7. //    To use with MAD Library for Mac: Symantec, CodeWarrior and MPW
  8. //
  9. //    Antoine ROSSET
  10. //    16 Tranchees
  11. //    1206 GENEVA
  12. //    SWITZERLAND
  13. //
  14. //    COPYRIGHT ANTOINE ROSSET 1996, 1997, 1998
  15. //
  16. //    Thank you for your interest in PlayerPRO !
  17. //
  18. //    FAX:        (+41 22) 346 11 97
  19. //    PHONE:         (+41 79) 203 74 62
  20. //    Internet:     RossetAntoine@bluewin.ch
  21. //
  22. /********************                        ***********************/
  23.  
  24. #include "RDriver.h"
  25. #include "RDriverInt.h"
  26.  
  27. /*************************/
  28.  
  29. SndChannelPtr CreateSndChannel( long init)
  30. {
  31.     SndChannelPtr     mySndChan;    // pointer to a sound channel
  32.     OSErr             myErr;
  33.  
  34.     mySndChan = 0L;
  35.     myErr = SndNewChannel( &mySndChan, sampledSynth, init, nil);
  36.     
  37.     return mySndChan;            // return SndChannelPtr
  38. }
  39.  
  40. OSErr    DBSndClose( MADDriverRec *inMADDriver)
  41. {
  42. OSErr        err;
  43. short            i;
  44.  
  45.     err = SndDisposeChannel( inMADDriver->MusicChannelPP, true);
  46.     inMADDriver->MusicChannelPP = 0L;
  47.  
  48.     DisposeRoutineDescriptor( (UniversalProcPtr) inMADDriver->TheHeader.dbhDoubleBack);
  49.  
  50.     inMADDriver->TheHeader.dbhDoubleBack = 0L;
  51.  
  52.     for ( i = 0;   i <= 1; i++) { DisposePtr( (Ptr) inMADDriver->TheHeader.dbhBufferPtr[i]); inMADDriver->TheHeader.dbhBufferPtr[i] = 0L;}
  53.  
  54.     return noErr;
  55. }
  56.  
  57. OSErr    InitDBSoundManager( MADDriverRec *inMADDriver, long init)
  58. {
  59.     OSErr            err = noErr;
  60.  
  61.     inMADDriver->MusicChannelPP = 0L;
  62.     inMADDriver->MusicChannelPP = CreateSndChannel( init);
  63.     if( inMADDriver->MusicChannelPP == 0L) return MADSoundManagerErr;
  64.     
  65.     err = DBSndPlay( inMADDriver, inMADDriver->MusicChannelPP);
  66.     return err;
  67. }
  68.  
  69. OSErr DBSndPlay ( MADDriverRec *inMADDriver, SndChannelPtr chan)
  70. {
  71.     SndDoubleBufferPtr             doubleBuffer;
  72.     short                         i;
  73.     OSErr                         err = noErr;
  74.     
  75.     inMADDriver->TheHeader.dbhCompressionID         = 0;
  76.     inMADDriver->TheHeader.dbhPacketSize             = 0;
  77.     
  78.     inMADDriver->TheHeader.dbhDoubleBack             = NewSndDoubleBackProc( &MyDoubleBackProc);
  79.     
  80.     inMADDriver->TheHeader.dbhSampleRate = inMADDriver->DriverSettings.outPutRate;
  81.     inMADDriver->TheHeader.dbhSampleSize = inMADDriver->DriverSettings.outPutBits;
  82.     
  83. //    if( inMADDriver->DriverSettings.outPutMode == MonoOutPut) inMADDriver->TheHeader.dbhNumChannels = 1;
  84. //    else
  85.     
  86.     inMADDriver->TheHeader.dbhNumChannels = 2;
  87.     
  88.     for (i = 0; i <= 1; i++)
  89.     {
  90.         doubleBuffer = (SndDoubleBufferPtr) MADNewPtrClear( sizeof (SndDoubleBuffer) + inMADDriver->BufSize + 20L, inMADDriver->lib);
  91.         if( doubleBuffer == 0L) return MADNeedMemory;
  92.  
  93.         doubleBuffer->dbNumFrames         = 0;
  94.         doubleBuffer->dbFlags             = 0;
  95.         doubleBuffer->dbUserInfo[ 0]    = (long) inMADDriver;
  96.  
  97.         MyDoubleBackProc( chan, doubleBuffer);
  98.         
  99.         inMADDriver->TheHeader.dbhBufferPtr[i] = doubleBuffer;
  100.     }
  101.     
  102.     err = SndPlayDoubleBuffer( chan, &inMADDriver->TheHeader);
  103.     if( err != noErr) return MADSoundManagerErr;
  104.     
  105.     return err;
  106. }
  107.  
  108. void StopChannel( MADDriverRec *inMADDriver)
  109. {
  110. SndCommand            cmd;
  111.  
  112.     cmd.cmd = quietCmd;
  113.     cmd.param1 = 0;
  114.     cmd.param2 = 0;
  115.     SndDoImmediate(    inMADDriver->MusicChannelPP,    &cmd);
  116.     
  117.     cmd.cmd = flushCmd;
  118.     cmd.param1 = 0;
  119.     cmd.param2 = 0;
  120.     SndDoImmediate(    inMADDriver->MusicChannelPP,    &cmd);
  121. }
  122.  
  123. void PlayChannel( MADDriverRec *inMADDriver)
  124. {
  125.     OSErr                    iErr;
  126.  
  127.     MyDoubleBackProc( inMADDriver->MusicChannelPP, inMADDriver->TheHeader.dbhBufferPtr[ 0]);
  128.     MyDoubleBackProc( inMADDriver->MusicChannelPP, inMADDriver->TheHeader.dbhBufferPtr[ 1]);
  129.  
  130.     iErr = SndPlayDoubleBuffer( inMADDriver->MusicChannelPP, &inMADDriver->TheHeader);
  131. }