home *** CD-ROM | disk | FTP | other *** search
/ Amiga Dream 59 / CDDream59.ISO / BeOs / Sound / Intel / PPBeDevKit.ZIP / PLAYERPR.TAR / PlayerPRO / Source / OutPut8.c < prev    next >
C/C++ Source or Header  |  1998-12-26  |  4KB  |  150 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. void Sampler8in8AddPolyStereo( Channel *curVoice, register Ptr    ASCBuffer, short chanNo, MADDriverRec *intDriver)
  28. {
  29.     char             *SndBuffer;
  30.     long             i = intDriver->ASCBUFFER, volChn;
  31.     short            temp;
  32.     Boolean            killSample = false;
  33.     
  34.     ///
  35.     long                aDD, aCC = curVoice->lAC, off;
  36.     
  37.     aDD = (AMIGA_CLOCKFREQ2 << BYTEDIV) / ( curVoice->period * (intDriver->DriverSettings.outPutRate>>16));
  38.     ///
  39.     
  40.     if( curVoice->curPtr >= curVoice->maxPtr && curVoice->loopSize == 0) return;
  41.     
  42.     SndBuffer        = (char*)     curVoice->curPtr;
  43.     volChn            = DoVolPanning256( 3, curVoice, intDriver);
  44.     
  45.     while( i-- > 0)
  46.     {
  47.         off = 2*(aCC>>BYTEDIV);
  48.         if( (Ptr) SndBuffer + off >= curVoice->maxPtr)
  49.         {
  50.             if( curVoice->loopSize > 0) 
  51.             {
  52.                 SndBuffer -= curVoice->loopSize;
  53.                 if( SndBuffer + off < curVoice->begPtr) SndBuffer = curVoice->begPtr - off;
  54.             }
  55.             else
  56.             {
  57.                 killSample = true;
  58.                 break;
  59.             }
  60.         }
  61.         temp = (volChn * *(SndBuffer + off)) >> 8;
  62.         off++;
  63.         temp += (volChn * *(SndBuffer + off)) >> 8;
  64.         temp /= 2;
  65.         
  66.         *ASCBuffer    += temp;             aCC += aDD;
  67.         ASCBuffer    += chanNo;
  68.     }
  69.     
  70.     if( !killSample) curVoice->curPtr = (Ptr) (SndBuffer + (long) (aCC>>BYTEDIV));
  71.     else
  72.     {
  73.         curVoice->samplePtr    = 0L;    curVoice->curPtr    = curVoice->maxPtr;
  74.     }
  75.     
  76.     curVoice->lAC = aCC & ((1 << BYTEDIV) - 1);
  77. }
  78.  
  79.  
  80. void Sampler8in8AddPoly( Channel *curVoice, register Ptr    ASCBuffer, short chanNo, MADDriverRec *intDriver)
  81. {
  82.     char             *SndBuffer;
  83.     long             i = intDriver->ASCBUFFER, volChn;
  84.     Boolean            killSample = false;
  85.     ///
  86.     long                aDD, aCC = curVoice->lAC, off;
  87.     
  88.     aDD = (AMIGA_CLOCKFREQ2 << BYTEDIV) / ( curVoice->period * (intDriver->DriverSettings.outPutRate>>16));
  89.     ///
  90.     
  91.     if( curVoice->curPtr >= curVoice->maxPtr && curVoice->loopSize == 0) return;
  92.     
  93.     SndBuffer        = (char*)     curVoice->curPtr;
  94.     volChn            = DoVolPanning256( 3, curVoice, intDriver);
  95.     
  96.         while( i-- > 0)
  97.         {
  98.             off = (aCC>>BYTEDIV);
  99.             if( (Ptr) SndBuffer + off >= curVoice->maxPtr)
  100.             {
  101.                 if( curVoice->loopSize > 0) 
  102.                 {
  103.                     SndBuffer -= curVoice->loopSize;
  104.                     if( SndBuffer + off < curVoice->begPtr) SndBuffer = curVoice->begPtr - off;
  105.                 }
  106.                 else
  107.                 {
  108.                     killSample = true;
  109.                     break;
  110.                 }
  111.             }
  112.             *ASCBuffer    += (volChn * *(SndBuffer + off)) >> 8;             aCC += aDD;
  113.             ASCBuffer    += chanNo;
  114.         }
  115.         
  116.         if( !killSample) curVoice->curPtr = (Ptr) (SndBuffer + (long) (aCC>>BYTEDIV));
  117.         else
  118.         {
  119.             curVoice->samplePtr    = 0L;    curVoice->curPtr    = curVoice->maxPtr;
  120.         }
  121.  
  122.     curVoice->lAC = aCC & ((1 << BYTEDIV) - 1);
  123. }
  124.  
  125. void Sample8BufferAddPoly( Channel *curVoice, register Ptr ASCBuffer, short chanNo, MADDriverRec *intDriver)
  126. {
  127.     if( curVoice->stereo)
  128.     {
  129.         if( curVoice->amp == 8) Sampler8in8AddPolyStereo( curVoice, ASCBuffer, chanNo, intDriver);
  130.     }
  131.     else
  132.     {
  133.         if( curVoice->amp == 8) Sampler8in8AddPoly( curVoice, ASCBuffer, chanNo, intDriver);
  134.     }
  135. }
  136.  
  137. void Play8PolyPhonic( MADDriverRec *intDriver)
  138. {
  139. long    i, x;
  140. Byte    *alpha = (Byte*) intDriver->IntDataPtr;
  141.  
  142.     x = intDriver->ASCBUFFER * intDriver->DriverSettings.numChn;
  143.     while( x-- > 0) *alpha++ = 0x80;
  144.     
  145.     for( i = 0 ; i < intDriver->DriverSettings.numChn; i++)
  146.     {
  147.         Sample8BufferAddPoly( &intDriver->chan[ i], intDriver->IntDataPtr + i, intDriver->DriverSettings.numChn, intDriver);
  148.     }
  149. }
  150.