home *** CD-ROM | disk | FTP | other *** search
/ Amiga Dream 59 / CDDream59.ISO / BeOs / Sound / Intel / PPBeDevKit.ZIP / PLAYERPR.TAR / PlayerPRO / Source / DelayOutPut.c < prev    next >
C/C++ Source or Header  |  1998-12-26  |  32KB  |  1,000 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 MADCreateOverShoot( MADDriverRec *intDriver)
  28. {
  29.     long    i, x;
  30.     
  31.     switch( intDriver->DriverSettings.outPutBits)
  32.     {
  33.         case 16:
  34.             intDriver->DASCBuffer = (long*) MADNewPtrClear( ( (long) intDriver->ASCBUFFER * 8L) + intDriver->MDelay*2L*8L, intDriver->lib);
  35.         break;
  36.         
  37.         case 8:
  38.             intDriver->DASCBuffer8 = (short*) MADNewPtrClear( ( (long) intDriver->ASCBUFFER * 4L) + intDriver->MDelay*2L*4L, intDriver->lib);
  39.             
  40.             intDriver->OverShoot = (Ptr) MADNewPtrClear( 256L * 32L, intDriver->lib);
  41.     
  42.             for( i = 0; i < 256L * 16L; i++)                        intDriver->OverShoot[ i] = 0;
  43.             for( i = 256L * 16L, x = 0; i < 256L * 17L; i++, x++)    intDriver->OverShoot[ i] = x;
  44.             for( i = 256L * 17L; i < 256L * 32L; i++)                intDriver->OverShoot[ i] = 0xFF;
  45.             
  46.             
  47.             intDriver->OverShoot += 256L*16L;
  48.             intDriver->OverShoot += 128L;
  49.         break;
  50.     }
  51. }
  52.  
  53. void MADKillOverShoot( MADDriverRec *intDriver)
  54. {
  55.     switch( intDriver->DriverSettings.outPutBits)
  56.     {
  57.         case 16:
  58.             if( intDriver->DASCBuffer != 0L) DisposePtr( (Ptr) intDriver->DASCBuffer);
  59.             intDriver->DASCBuffer = 0L;
  60.         break;
  61.  
  62.         case 8:
  63.             if( intDriver->OverShoot != 0L)
  64.             {
  65.                 intDriver->OverShoot -= 128L;
  66.                 intDriver->OverShoot -= 256L*16L;
  67.                 DisposePtr( (Ptr) intDriver->OverShoot);
  68.                 intDriver->OverShoot = 0L;
  69.             }
  70.             
  71.             if( intDriver->DASCBuffer8 != 0L) DisposePtr( (Ptr) intDriver->DASCBuffer8);
  72.             intDriver->DASCBuffer8 = 0L;
  73.         break;
  74.     }
  75. }
  76.  
  77. void Sampler16AddDelay( Channel *curVoice, long    *ASCBuffer, MADDriverRec *intDriver)
  78. {
  79.     long                chnVol, chnVol2;
  80.     long                i = intDriver->ASCBUFFER;
  81.     char                tByte = 0;
  82.     long                *ASCBuffer1, *ASCBuffer2;
  83.     Boolean            killSample = false;
  84.     
  85.     ///
  86.     long                aDD, aCC = curVoice->lAC, off;
  87.     
  88.     aDD = (AMIGA_CLOCKFREQ2 << BYTEDIV) / ( curVoice->period * (intDriver->DriverSettings.outPutRate>>16));
  89.     if( curVoice->pingpong == true && curVoice->loopType == ePingPongLoop) aDD = -aDD;    // PINGPONG
  90.     ///
  91.     
  92.     chnVol2    = DoVolPanning256( 0, curVoice, intDriver);
  93.     chnVol    = DoVolPanning256( 1, curVoice, intDriver);
  94.     
  95.     if( (curVoice->ID % 2) == 0)
  96.     {
  97.         ASCBuffer1 = ASCBuffer;
  98.         ASCBuffer2 = ASCBuffer +1L + intDriver->MDelay*2L;
  99.     }
  100.     else
  101.     {
  102.         ASCBuffer2 = ASCBuffer +1L;
  103.         ASCBuffer1 = ASCBuffer + intDriver->MDelay*2L;
  104.     }
  105.     
  106.     //*****************************************
  107.     if( intDriver->DriverSettings.TickRemover) MADTickRemoverStart8( curVoice, ASCBuffer1, ASCBuffer2, intDriver);
  108.     //*****************************************
  109.     
  110.     if( curVoice->curPtr >= curVoice->maxPtr && curVoice->loopSize == 0) return;
  111.     
  112.     {
  113.         Ptr        SndBuffer = curVoice->curPtr;
  114.         long    RightWeight, LeftWeight, preOff = curVoice->preOff;
  115.       char  preVal = curVoice->preVal, preVal2 = curVoice->preVal2;
  116.         
  117.         while( i-- > 0)
  118.         {
  119.             RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight;        off = (long) (aCC>>BYTEDIV);
  120.             
  121.             if( preOff != off)
  122.             {
  123.                 if( curVoice->loopType == ePingPongLoop && curVoice->loopSize > 0)        // PINGPONG
  124.                 {
  125.                     preOff = off;
  126.                     if( (SndBuffer + off +1 >= curVoice->maxPtr && !curVoice->pingpong) ||
  127.                             (SndBuffer + off +1 <= curVoice->begPtr + curVoice->loopBeg && curVoice->pingpong))
  128.                     {curVoice->pingpong = !curVoice->pingpong; aDD = -aDD; aCC += aDD; RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight; off = (long) (aCC>>BYTEDIV);}
  129.                     preVal = *(SndBuffer + off);
  130.                 }
  131.                 else
  132.                 {
  133.                     preVal = preVal2;
  134.                     preOff = off;
  135.                     
  136.                     if( SndBuffer + off + 1 >= curVoice->maxPtr)
  137.                     {
  138.                         if( curVoice->loopSize > 0) 
  139.                         {
  140.                           aCC = aCC & ((1 << BYTEDIV) - 1);    
  141.                           RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight;        off = (long) (aCC>>BYTEDIV);
  142.                           preOff = off;
  143.                           
  144.                           SndBuffer = curVoice->begPtr + curVoice->loopBeg;
  145.                           SndBuffer--;
  146.                         }
  147.                         else    // If TICK remove
  148.                         {
  149.                             MADTickLoopFill8( curVoice, ASCBuffer1, ASCBuffer2, i, (tByte * chnVol), (tByte * chnVol2));
  150.                             killSample = true;
  151.                             break;
  152.                         }
  153.                     }
  154.                     preVal2 = *(SndBuffer + off + 1);
  155.                 }
  156.             }
  157.             
  158.             tByte = (    LeftWeight *     preVal  + RightWeight *     *(SndBuffer + off + 1)) >> BYTEDIV;            aCC += aDD;
  159.             
  160.             *ASCBuffer1 += (tByte * chnVol);                ASCBuffer1 += 2;
  161.             *ASCBuffer2 += (tByte * chnVol2);                ASCBuffer2 += 2;
  162.         }
  163.         
  164.         if( killSample)
  165.         {
  166.             curVoice->samplePtr    = 0L;    curVoice->curPtr    = curVoice->maxPtr;
  167.         }
  168.         else
  169.         {
  170.             if( (aCC>>BYTEDIV) == preOff) curVoice->preOff = 0;
  171.             else curVoice->preOff = 0xFFFFFFFF;    //(long) (aCC>>BYTEDIV);
  172.             curVoice->preVal = preVal;
  173.             curVoice->preVal2 = *(SndBuffer + off + 1);
  174.             curVoice->curPtr = SndBuffer + (aCC>>BYTEDIV);
  175.         }
  176.         
  177.         curVoice->lAC = aCC & ((1 << BYTEDIV) - 1);
  178.         
  179.         curVoice->lastWordL = (tByte * chnVol);
  180.         curVoice->lastWordR = (tByte * chnVol2);
  181.     }
  182. }
  183.  
  184. void Sampler16AddDelayStereo( Channel *curVoice, long    *ASCBuffer, MADDriverRec *intDriver)
  185. {
  186.     long                chnVol, chnVol2;
  187.     long                i = intDriver->ASCBUFFER;
  188.     char                tByteL = 0, tByteR = 0;
  189.     long                *ASCBuffer1, *ASCBuffer2;
  190.     Boolean            killSample = false;
  191.     
  192.     ///
  193.     long                aDD, aCC = curVoice->lAC, off;
  194.     
  195.     aDD = (AMIGA_CLOCKFREQ2 << BYTEDIV) / ( curVoice->period * (intDriver->DriverSettings.outPutRate>>16));
  196.     if( curVoice->pingpong == true && curVoice->loopType == ePingPongLoop) aDD = -aDD;    // PINGPONG
  197.     ///
  198.     
  199.     chnVol2    = DoVolPanning256( 0, curVoice, intDriver);
  200.     chnVol    = DoVolPanning256( 1, curVoice, intDriver);
  201.     
  202.     if( (curVoice->ID % 2) == 0)
  203.     {
  204.         ASCBuffer1 = ASCBuffer;
  205.         ASCBuffer2 = ASCBuffer +1L + intDriver->MDelay*2L;
  206.     }
  207.     else
  208.     {
  209.         ASCBuffer2 = ASCBuffer +1L;
  210.         ASCBuffer1 = ASCBuffer + intDriver->MDelay*2L;
  211.     }
  212.     
  213.     //*****************************************
  214.     if( intDriver->DriverSettings.TickRemover) MADTickRemoverStart8( curVoice, ASCBuffer1, ASCBuffer2, intDriver);
  215.     //*****************************************
  216.     
  217.     if( curVoice->curPtr >= curVoice->maxPtr && curVoice->loopSize == 0) return;
  218.     
  219.     {
  220.         Ptr        SndBuffer = curVoice->curPtr;
  221.         long    RightWeight, LeftWeight, preOff = curVoice->preOff;
  222.       char    preVal = curVoice->preVal, preValR = curVoice->preValR, preVal2 = curVoice->preVal2, preVal2R = curVoice->preVal2R;
  223.         
  224.         while( i-- > 0)
  225.         {
  226.             RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight;        off = (long) 2*(aCC>>BYTEDIV);
  227.             
  228.             if( preOff != off)
  229.             {
  230.                 if( curVoice->loopType == ePingPongLoop && curVoice->loopSize > 0)        // PINGPONG
  231.                 {
  232.                     preOff = off;
  233.                     if( (SndBuffer + off +3 >= curVoice->maxPtr && !curVoice->pingpong) ||
  234.                             (SndBuffer + off +2 <= curVoice->begPtr + curVoice->loopBeg && curVoice->pingpong))
  235.                     {curVoice->pingpong = !curVoice->pingpong; aDD = -aDD; aCC += aDD; RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight; off = (long) 2*(aCC>>BYTEDIV);}
  236.                     preVal = *(SndBuffer + off);
  237.                     preValR = *(SndBuffer + off + 1);
  238.                 }
  239.                 else
  240.                 {
  241.                     preVal = preVal2;
  242.                     preValR = preVal2R;
  243.                     preOff = off;
  244.                     
  245.                     if( SndBuffer + off + 3 >= curVoice->maxPtr)
  246.                     {
  247.                         if( curVoice->loopSize > 0) 
  248.                         {
  249.                           aCC = aCC & ((1 << BYTEDIV) - 1);    
  250.                           RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight;        off = (long) 2*(aCC>>BYTEDIV);
  251.                           preOff = off;
  252.                           
  253.                           SndBuffer = curVoice->begPtr + curVoice->loopBeg;
  254.                           SndBuffer-=2;
  255.                         }
  256.                         else    // If TICK remove
  257.                         {
  258.                             MADTickLoopFill8( curVoice, ASCBuffer1, ASCBuffer2, i, (tByteL * chnVol), (tByteR * chnVol2));
  259.                             killSample = true;
  260.                             break;
  261.                         }
  262.                     }
  263.                     preVal2 = *(SndBuffer + off + 2);
  264.                     preVal2R = *(SndBuffer + off + 3);
  265.                 }
  266.             }
  267.             
  268.             tByteL = (    LeftWeight *     preVal + RightWeight *     *(SndBuffer + off + 2)) >> BYTEDIV;            *ASCBuffer1 += (tByteL * chnVol);        ASCBuffer1 += 2;
  269.             tByteR = (    LeftWeight *     preValR + RightWeight *     *(SndBuffer + off + 3)) >> BYTEDIV;        *ASCBuffer2 += (tByteR * chnVol2);    ASCBuffer2 += 2;
  270.             
  271.             aCC += aDD;
  272.         }
  273.         if( killSample)
  274.         {
  275.             curVoice->samplePtr    = 0L;    curVoice->curPtr    = curVoice->maxPtr;
  276.         }
  277.         else
  278.         {
  279.             if( 2*(aCC>>BYTEDIV) == preOff) curVoice->preOff = 0;
  280.             else curVoice->preOff = 0xFFFFFFFF;
  281.             curVoice->preVal = preVal;
  282.             curVoice->preValR = preValR;
  283.             curVoice->preVal2 = *(SndBuffer + off + 2);
  284.             curVoice->preVal2R = *(SndBuffer + off + 3);
  285.             curVoice->curPtr = SndBuffer + 2*(aCC>>BYTEDIV);
  286.         }
  287.         
  288.         curVoice->lAC = aCC & ((1 << BYTEDIV) - 1);
  289.         
  290.         curVoice->lastWordL = (tByteL * chnVol);
  291.         curVoice->lastWordR = (tByteR * chnVol2);
  292.     }
  293. }
  294.  
  295.  
  296. void Sampler16Addin16Delay( Channel *curVoice, long    *ASCBuffer, MADDriverRec *intDriver)
  297. {
  298.     long                i = intDriver->ASCBUFFER;
  299.     long                chnVol, chnVol2;
  300.     long                off, tShort = 0;
  301.     long                *ASCBuffer1, *ASCBuffer2;
  302.     Boolean            killSample = false;
  303.     ///
  304.     long                aDD, aCC = curVoice->lAC;
  305.     
  306.     aDD = (AMIGA_CLOCKFREQ2 << BYTEDIV) / ( curVoice->period * (intDriver->DriverSettings.outPutRate>>16));
  307.     if( curVoice->pingpong == true && curVoice->loopType == ePingPongLoop) aDD = -aDD;    // PINGPONG
  308.     ///
  309.     
  310.     chnVol2        = DoVolPanning256( 0, curVoice, intDriver);
  311.     chnVol         = DoVolPanning256( 1, curVoice, intDriver);
  312.     
  313.     if( (curVoice->ID % 2) == 0)
  314.     {
  315.         ASCBuffer1 = ASCBuffer;
  316.         ASCBuffer2 = ASCBuffer +1L + intDriver->MDelay*2L;
  317.     }
  318.     else
  319.     {
  320.         ASCBuffer2 = ASCBuffer +1L;
  321.         ASCBuffer1 = ASCBuffer + intDriver->MDelay*2L;
  322.     }
  323.     
  324.     //*****************************************
  325.     if( intDriver->DriverSettings.TickRemover) MADTickRemoverStart8( curVoice, ASCBuffer1, ASCBuffer2, intDriver);
  326.     //*****************************************
  327.     
  328.     if( curVoice->curPtr >= curVoice->maxPtr && curVoice->loopSize == 0) return;
  329.  
  330.     {
  331.         short        *SndBuffer = (short*)    curVoice->curPtr;
  332.         long        RightWeight, LeftWeight, preOff = curVoice->preOff;
  333.         short     spreVal = curVoice->spreVal, spreVal2 = curVoice->spreVal2;;
  334.         
  335.         while( i-- > 0)
  336.         {
  337.             RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight;    off = (aCC>>BYTEDIV);
  338.             
  339.             if( preOff != off)
  340.             {
  341.                 if( curVoice->loopType == ePingPongLoop && curVoice->loopSize > 0)        // PINGPONG
  342.                 {
  343.                     preOff = off;
  344.                     if( (SndBuffer + off +1 >= (short*) curVoice->maxPtr && !curVoice->pingpong) ||
  345.                             (SndBuffer + off +1 <= (short*) (curVoice->begPtr + curVoice->loopBeg) && curVoice->pingpong))
  346.                     {curVoice->pingpong = !curVoice->pingpong; aDD = -aDD; aCC += aDD; RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight; off = (long) (aCC>>BYTEDIV);}
  347.                     spreVal = *(SndBuffer + off);
  348.                 }
  349.                 else
  350.                 {
  351.                     spreVal = spreVal2;
  352.                     preOff = off;
  353.                     
  354.                     if( SndBuffer + off + 1 >= (short*) curVoice->maxPtr)
  355.                     {
  356.                         if( curVoice->loopSize > 0) 
  357.                         {
  358.                           aCC = aCC & ((1 << BYTEDIV) - 1);    
  359.                           RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight;
  360.                           off = (long) (aCC>>BYTEDIV);
  361.                           preOff = off;
  362.                           
  363.                           SndBuffer = (short*) (curVoice->begPtr + curVoice->loopBeg);
  364.                           SndBuffer--;
  365.                         }
  366.                         else    // If TICK remove
  367.                         {
  368.                             MADTickLoopFill8( curVoice, ASCBuffer1, ASCBuffer2, i, (tShort * chnVol) >> 8, (tShort * chnVol2) >> 8);
  369.                             killSample = true;
  370.                             break;
  371.                         }
  372.                     }
  373.                     spreVal2 = *(SndBuffer + off + 1);
  374.                 }
  375.             }
  376.             
  377.             tShort = (    LeftWeight *     spreVal + RightWeight *     *(SndBuffer + off + 1)) >> BYTEDIV;            aCC += aDD;
  378.             
  379.             *ASCBuffer1 += (tShort * chnVol) >> 8;        ASCBuffer1 += 2;
  380.             *ASCBuffer2 += (tShort * chnVol2) >> 8;        ASCBuffer2 += 2;
  381.         }
  382.         
  383.         if( killSample)
  384.         {
  385.             curVoice->samplePtr    = 0L;    curVoice->curPtr    = curVoice->maxPtr;
  386.         }
  387.         else
  388.         {
  389.             if( (aCC>>BYTEDIV) == preOff) curVoice->preOff = 0;
  390.             else curVoice->preOff = 0xFFFFFFFF;    
  391.             curVoice->spreVal = spreVal;
  392.             curVoice->spreVal2 = *(SndBuffer + off + 1);
  393.             curVoice->curPtr = (Ptr) (SndBuffer + (aCC>>BYTEDIV));
  394.         }
  395.         
  396.         curVoice->lAC = aCC & ((1 << BYTEDIV) - 1);
  397.         
  398.         curVoice->lastWordL = (tShort * chnVol) >> 8;
  399.         curVoice->lastWordR = (tShort * chnVol2) >> 8;
  400.     }
  401. }
  402.  
  403. void Sampler16Addin16DelayStereo( Channel *curVoice, long    *ASCBuffer, MADDriverRec *intDriver)
  404. {
  405.     long                i = intDriver->ASCBUFFER;
  406.     long                chnVol, chnVol2;
  407.     long                off, tShortL = 0, tShortR = 0;
  408.     long                *ASCBuffer1, *ASCBuffer2;
  409.     Boolean            killSample = false;
  410.     ///
  411.     long                aDD, aCC = curVoice->lAC;
  412.     
  413.     aDD = (AMIGA_CLOCKFREQ2 << BYTEDIV) / ( curVoice->period * (intDriver->DriverSettings.outPutRate>>16));
  414.     if( curVoice->pingpong == true && curVoice->loopType == ePingPongLoop) aDD = -aDD;    // PINGPONG
  415.     ///
  416.     
  417.     chnVol2        = DoVolPanning256( 0, curVoice, intDriver);
  418.     chnVol         = DoVolPanning256( 1, curVoice, intDriver);
  419.     
  420.     if( (curVoice->ID % 2) == 0)
  421.     {
  422.         ASCBuffer1 = ASCBuffer;
  423.         ASCBuffer2 = ASCBuffer +1L + intDriver->MDelay*2L;
  424.     }
  425.     else
  426.     {
  427.         ASCBuffer2 = ASCBuffer +1L;
  428.         ASCBuffer1 = ASCBuffer + intDriver->MDelay*2L;
  429.     }
  430.     
  431.     //*****************************************
  432.     if( intDriver->DriverSettings.TickRemover) MADTickRemoverStart8( curVoice, ASCBuffer1, ASCBuffer2, intDriver);
  433.     //*****************************************
  434.  
  435.     if( curVoice->curPtr >= curVoice->maxPtr && curVoice->loopSize == 0) return;
  436.     
  437.     {
  438.         short    *SndBuffer = (short*)    curVoice->curPtr;
  439.         long    RightWeight, LeftWeight, preOff = curVoice->preOff;
  440.       short    spreVal = curVoice->spreVal, spreValR = curVoice->spreValR, spreVal2 = curVoice->spreVal2, spreVal2R = curVoice->spreVal2R;
  441.         
  442.         while( i-- > 0)
  443.         {
  444.             RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight;        off = 2*(aCC>>BYTEDIV);
  445.             
  446.             if( preOff != off)
  447.             {
  448.                 if( curVoice->loopType == ePingPongLoop && curVoice->loopSize > 0)        // PINGPONG
  449.                 {
  450.                     preOff = off;
  451.                     if( (SndBuffer + off +3 >= (short*) curVoice->maxPtr && !curVoice->pingpong) ||
  452.                             (SndBuffer + off +2 <= (short*) (curVoice->begPtr + curVoice->loopBeg) && curVoice->pingpong))
  453.                     {curVoice->pingpong = !curVoice->pingpong; aDD = -aDD; aCC += aDD; RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight; off = (long) 2*(aCC>>BYTEDIV);}
  454.                     spreVal = *(SndBuffer + off);
  455.                     spreValR = *(SndBuffer + off + 1);
  456.                 }
  457.                 else
  458.                 {
  459.                     spreVal = spreVal2;
  460.                     spreValR = spreVal2R;
  461.                     preOff = off;
  462.                     
  463.                     if( SndBuffer + off + 3 >= (short*) curVoice->maxPtr)
  464.                     {
  465.                         if( curVoice->loopSize > 0) 
  466.                         {
  467.                           aCC = aCC & ((1 << BYTEDIV) - 1);    
  468.                           RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight;        off = (long) 2*(aCC>>BYTEDIV);
  469.                           preOff = off;
  470.                           
  471.                           SndBuffer = (short*) (curVoice->begPtr + curVoice->loopBeg);
  472.                           SndBuffer-=2;
  473.                         }
  474.                         else    // If TICK remove
  475.                         {
  476.                             MADTickLoopFill8( curVoice, ASCBuffer1, ASCBuffer2, i, (tShortL * chnVol) >> 8, (tShortR * chnVol2) >> 8);
  477.                             killSample = true;
  478.                             break;
  479.                         }
  480.                     }
  481.                     spreVal2 = *(SndBuffer + off + 2);
  482.                     spreVal2R = *(SndBuffer + off + 3);
  483.                 }
  484.             }
  485.             
  486.             tShortL = (    LeftWeight *     spreVal + RightWeight *     *(SndBuffer + off + 2)) >> BYTEDIV;        *ASCBuffer1 += (tShortL * chnVol) >> 8;        ASCBuffer1 += 2;
  487.             tShortR = (    LeftWeight *     spreValR + RightWeight *     *(SndBuffer + off + 3)) >> BYTEDIV;        *ASCBuffer2 += (tShortR * chnVol2) >> 8;        ASCBuffer2 += 2;
  488.             
  489.             aCC += aDD;
  490.         }
  491.         
  492.         if( killSample)
  493.         {
  494.             curVoice->samplePtr    = 0L;    curVoice->curPtr    = curVoice->maxPtr;
  495.         }
  496.         else
  497.         {
  498.             if( 2*(aCC>>BYTEDIV) == preOff) curVoice->preOff = 0;
  499.             else curVoice->preOff = 0xFFFFFFFF;
  500.             curVoice->spreVal = spreVal;
  501.             curVoice->spreValR = spreValR;
  502.             curVoice->spreVal2 = *(SndBuffer + off + 2);
  503.             curVoice->spreVal2R = *(SndBuffer + off + 3);
  504.             curVoice->curPtr = (Ptr) (SndBuffer + 2*(aCC>>BYTEDIV));
  505.         }
  506.         
  507.         curVoice->lAC = aCC & ((1 << BYTEDIV) - 1);
  508.         
  509.         aCC -= aDD;
  510.         curVoice->lastWordL = (tShortL * chnVol) >> 8;
  511.         curVoice->lastWordR = (tShortR * chnVol2) >> 8;
  512.     }
  513. }
  514.  
  515. void Sample16BufferAddDelay( Channel *curVoice, register long    *ASCBuffer, MADDriverRec *intDriver)
  516. {
  517.     if( curVoice->amp == 16)
  518.     {
  519.         if( curVoice->stereo) Sampler16Addin16DelayStereo( curVoice, ASCBuffer, intDriver);
  520.         else Sampler16Addin16Delay( curVoice, ASCBuffer, intDriver);
  521.     }
  522.     else if( curVoice->amp == 8)
  523.     {
  524.         if( curVoice->stereo) Sampler16AddDelayStereo( curVoice, ASCBuffer, intDriver);
  525.         else Sampler16AddDelay( curVoice, ASCBuffer, intDriver);
  526.     }
  527. }
  528.  
  529. void Play16StereoDelay( MADDriverRec *intDriver)
  530. {
  531. short        *ASCBuffer, valP = 0x7FFFL, valN = -0x7FFFL;
  532. long        *ttt, i;
  533.  
  534.     for( i = 0 ; i < intDriver->DriverSettings.numChn; i++) Sample16BufferAddDelay( &intDriver->chan[ i], intDriver->DASCBuffer, intDriver);
  535.     
  536.     ttt = intDriver->DASCBuffer;
  537.     ASCBuffer = (short*) intDriver->IntDataPtr;
  538.     
  539.     i = intDriver->ASCBUFFER*2;
  540.     
  541.     while( i-- > 0)
  542.     {
  543.         if( *ttt > valP) *ASCBuffer++ = valP;
  544.         else if( *ttt < valN) *ASCBuffer++ = valN;
  545.         else *ASCBuffer++ = *ttt;
  546.         
  547.         *ttt++ = 0;
  548.     }
  549. }
  550.  
  551. void Sampler8in8AddDelay( Channel *curVoice, short    *ASCBuffer, MADDriverRec *intDriver)
  552. {
  553.     char            tByte;
  554.     long             i = intDriver->ASCBUFFER;
  555.     long            chnVol, chnVol2, off;
  556.     short            *ASCBuffer1, *ASCBuffer2;
  557.     Boolean        killSample = false;
  558.     
  559.     ///
  560.     long                aDD, aCC = curVoice->lAC;
  561.     
  562.     aDD = (AMIGA_CLOCKFREQ2 << BYTEDIV) / ( curVoice->period * (intDriver->DriverSettings.outPutRate>>16));
  563.     if( curVoice->pingpong == true && curVoice->loopType == ePingPongLoop) aDD = -aDD;    // PINGPONG
  564.     ///
  565.     
  566.     if( curVoice->curPtr >= curVoice->maxPtr && curVoice->loopSize == 0) return;
  567.     
  568.     chnVol2    = DoVolPanning256( 0, curVoice, intDriver);
  569.     chnVol    = DoVolPanning256( 1, curVoice, intDriver);
  570.     
  571.     if( (curVoice->ID % 2) == 0)
  572.     {
  573.         ASCBuffer1 = ASCBuffer;
  574.         ASCBuffer2 = ASCBuffer +1L + intDriver->MDelay*2L;
  575.     }
  576.     else
  577.     {
  578.         ASCBuffer2 = ASCBuffer +1L;
  579.         ASCBuffer1 = ASCBuffer + intDriver->MDelay*2L;
  580.     }
  581.     
  582.     {
  583.         Ptr            SndBuffer = curVoice->curPtr;
  584.         long        RightWeight, LeftWeight, preOff = curVoice->preOff;
  585.       char      preVal = curVoice->preVal, preVal2 = curVoice->preVal2;
  586.         
  587.         while( i-- > 0)
  588.         {
  589.             RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight;        off = aCC>>BYTEDIV;
  590.             
  591.             if( preOff != off)
  592.             {
  593.                 if( curVoice->loopType == ePingPongLoop && curVoice->loopSize > 0)        // PINGPONG
  594.                 {
  595.                     preOff = off;
  596.                     if( (SndBuffer + off +1 >= curVoice->maxPtr && !curVoice->pingpong) ||
  597.                             (SndBuffer + off +1 <= curVoice->begPtr + curVoice->loopBeg && curVoice->pingpong))
  598.                     {curVoice->pingpong = !curVoice->pingpong; aDD = -aDD; aCC += aDD; RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight; off = (long) (aCC>>BYTEDIV);}
  599.                     preVal = *(SndBuffer + off);
  600.                 }
  601.                 else
  602.                 {
  603.                     preVal = preVal2;
  604.                     preOff = off;
  605.                     
  606.                     if( SndBuffer + off + 1 >= curVoice->maxPtr)
  607.                     {
  608.                         if( curVoice->loopSize > 0) 
  609.                         {
  610.                           aCC = aCC & ((1 << BYTEDIV) - 1);    
  611.                           RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight;
  612.                           off = (long) (aCC>>BYTEDIV);
  613.                           preOff = off;
  614.                           
  615.                           SndBuffer = curVoice->begPtr + curVoice->loopBeg;
  616.                           SndBuffer--;
  617.                         }
  618.                         else    // If TICK remove
  619.                         {
  620.                             killSample = true;
  621.                             break;
  622.                         }
  623.                     }
  624.                     preVal2 = *(SndBuffer + off + 1);
  625.                 }
  626.             }
  627.             
  628.             tByte = (    LeftWeight *     preVal + RightWeight *     *(SndBuffer + off + 1)) >> BYTEDIV;            aCC += aDD;
  629.             
  630.             *ASCBuffer1 += (chnVol * tByte) >> 8;        ASCBuffer1 += 2;
  631.             *ASCBuffer2 += (chnVol2 * tByte) >> 8;        ASCBuffer2 += 2;
  632.         }
  633.         
  634.         
  635.         if( killSample)
  636.         {
  637.             curVoice->samplePtr    = 0L;    curVoice->curPtr    = curVoice->maxPtr;
  638.         }
  639.         else
  640.         {
  641.             if( (aCC>>BYTEDIV) == preOff) curVoice->preOff = 0;
  642.             else curVoice->preOff = 0xFFFFFFFF;    //(long) (aCC>>BYTEDIV);
  643.             curVoice->preVal = preVal;
  644.             curVoice->preVal2 = *(SndBuffer + off + 1);
  645.             curVoice->curPtr = SndBuffer + (aCC>>BYTEDIV);
  646.         }
  647.     }
  648.     
  649.     curVoice->lAC = aCC & ((1 << BYTEDIV) - 1);
  650. }
  651.  
  652. void Sampler8in16AddDelay( Channel *curVoice, short    *ASCBuffer, MADDriverRec *intDriver)
  653. {
  654.     char                tByte;
  655.     long                chnVol, chnVol2;
  656.     long                i = intDriver->ASCBUFFER, off;
  657.     short                *ASCBuffer1, *ASCBuffer2;
  658.     Boolean            killSample = false;
  659.     
  660.     ///
  661.     long                aDD, aCC = curVoice->lAC;
  662.     
  663.     aDD = (AMIGA_CLOCKFREQ2 << BYTEDIV) / ( curVoice->period * (intDriver->DriverSettings.outPutRate>>16));
  664.     if( curVoice->pingpong == true && curVoice->loopType == ePingPongLoop) aDD = -aDD;    // PINGPONG
  665.     ///
  666.     
  667.     if( curVoice->curPtr >= curVoice->maxPtr && curVoice->loopSize == 0) return;
  668.     
  669.     chnVol2    = DoVolPanning256( 0, curVoice, intDriver);
  670.     chnVol    = DoVolPanning256( 1, curVoice, intDriver);
  671.     
  672.     if( (curVoice->ID % 2) == 0)
  673.     {
  674.         ASCBuffer1 = ASCBuffer;
  675.         ASCBuffer2 = ASCBuffer +1L + intDriver->MDelay*2L;
  676.     }
  677.     else
  678.     {
  679.         ASCBuffer2 = ASCBuffer +1L;
  680.         ASCBuffer1 = ASCBuffer + intDriver->MDelay*2L;
  681.     }
  682.     
  683.     {
  684.         Ptr            SndBuffer = curVoice->curPtr;
  685.         long        RightWeight, LeftWeight, preOff = curVoice->preOff;
  686.         char        preVal = curVoice->preVal, preVal2 = curVoice->preVal2;
  687.         
  688.         #ifdef _INTEL_H
  689.         SndBuffer++;
  690.         #endif
  691.         
  692.         while( i-- > 0)
  693.         {
  694.             RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight;        off = aCC>>BYTEDIV;
  695.             
  696.             if( preOff != off)
  697.             {
  698.                 if( curVoice->loopType == ePingPongLoop && curVoice->loopSize > 0)        // PINGPONG
  699.                 {
  700.                     preOff = off;
  701.                     if( (SndBuffer + 2*off +2 >= curVoice->maxPtr && !curVoice->pingpong) ||
  702.                             (SndBuffer + 2*off +2 <= (curVoice->begPtr + curVoice->loopBeg) && curVoice->pingpong))
  703.                     {curVoice->pingpong = !curVoice->pingpong; aDD = -aDD; aCC += aDD; RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight; off = (long) (aCC>>BYTEDIV);}
  704.                     preVal = *(SndBuffer + 2*off);
  705.                 }
  706.                 else
  707.                 {
  708.                     preVal = preVal2;
  709.                     preOff = off;
  710.                     
  711.                     if( SndBuffer + 2*off +2 >= curVoice->maxPtr)
  712.                     {
  713.                         if( curVoice->loopSize > 0) 
  714.                         {
  715.                           aCC = aCC & ((1 << BYTEDIV) - 1);    
  716.                           RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight;
  717.                           off = (long) (aCC>>BYTEDIV);
  718.                           preOff = off;
  719.                           
  720.                           SndBuffer = (curVoice->begPtr + curVoice->loopBeg);
  721.                           SndBuffer -= 2;
  722.                         }
  723.                         else    // If TICK remove
  724.                         {
  725.                             killSample = true;
  726.                             break;
  727.                         }
  728.                     }
  729.                     preVal2 = *(SndBuffer + 2*off + 2);
  730.                 }
  731.             }
  732.             
  733.             tByte = (    LeftWeight * preVal + RightWeight *     *(SndBuffer + 2*off + 2)) >> BYTEDIV;            aCC += aDD;
  734.             
  735.             *ASCBuffer1 += (chnVol * tByte) >> 8;        ASCBuffer1 += 2;
  736.             *ASCBuffer2 += (chnVol2 * tByte) >> 8;        ASCBuffer2 += 2;
  737.         }
  738.         
  739.         if( killSample)
  740.         {
  741.             curVoice->samplePtr    = 0L;    curVoice->curPtr    = curVoice->maxPtr;
  742.         }
  743.         else
  744.         {
  745.             if( (aCC>>BYTEDIV) == preOff) curVoice->preOff = 0;
  746.             else curVoice->preOff = 0xFFFFFFFF;    
  747.             curVoice->preVal = preVal;
  748.             curVoice->preVal2 = *(SndBuffer + 2*off + 2);
  749.             curVoice->curPtr = (Ptr) (SndBuffer + 2*(aCC>>BYTEDIV));
  750.         }
  751.     }
  752.     
  753.     curVoice->lAC = aCC & ((1 << BYTEDIV) - 1);
  754. }
  755.  
  756. void Sampler8in8AddDelayStereo( Channel *curVoice, short    *ASCBuffer, MADDriverRec *intDriver)
  757. {
  758.     char            tByteL, tByteR;
  759.     long             i = intDriver->ASCBUFFER;
  760.     long            chnVol, chnVol2;
  761.     long            off;
  762.     short            *ASCBuffer1, *ASCBuffer2;
  763.     Boolean        killSample = false;
  764.     
  765.     ///
  766.     long                aDD, aCC = curVoice->lAC;
  767.     
  768.     aDD = (AMIGA_CLOCKFREQ2 << BYTEDIV) / ( curVoice->period * (intDriver->DriverSettings.outPutRate>>16));
  769.     if( curVoice->pingpong == true && curVoice->loopType == ePingPongLoop) aDD = -aDD;    // PINGPONG
  770.     ///
  771.     
  772.     if( curVoice->curPtr >= curVoice->maxPtr && curVoice->loopSize == 0) return;
  773.     
  774.     chnVol2    = DoVolPanning256( 0, curVoice, intDriver);
  775.     chnVol    = DoVolPanning256( 1, curVoice, intDriver);
  776.     
  777.     if( (curVoice->ID % 2) == 0)
  778.     {
  779.         ASCBuffer1 = ASCBuffer;
  780.         ASCBuffer2 = ASCBuffer +1L + intDriver->MDelay*2L;
  781.     }
  782.     else
  783.     {
  784.         ASCBuffer2 = ASCBuffer +1L;
  785.         ASCBuffer1 = ASCBuffer + intDriver->MDelay*2L;
  786.     }
  787.     
  788.     {
  789.         Ptr        SndBuffer = curVoice->curPtr;
  790.         long    RightWeight, LeftWeight, preOff = curVoice->preOff;
  791.       char    preVal = curVoice->preVal, preValR = curVoice->preValR, preVal2 = curVoice->preVal2, preVal2R = curVoice->preVal2R;
  792.         
  793.         while( i-- > 0)
  794.         {
  795.             RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight;        off = 2*(aCC>>BYTEDIV);
  796.             
  797.             if( preOff != off)
  798.             {
  799.                 if( curVoice->loopType == ePingPongLoop && curVoice->loopSize > 0)        // PINGPONG
  800.                 {
  801.                     preOff = off;
  802.                     if( (SndBuffer + off +3 >= curVoice->maxPtr && !curVoice->pingpong) ||
  803.                             (SndBuffer + off +2 <= curVoice->begPtr + curVoice->loopBeg && curVoice->pingpong))
  804.                     {curVoice->pingpong = !curVoice->pingpong; aDD = -aDD; aCC += aDD; RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight; off = (long) 2*(aCC>>BYTEDIV);}
  805.                     preVal = *(SndBuffer + off);
  806.                     preValR = *(SndBuffer + off + 1);
  807.                 }
  808.                 else
  809.                 {
  810.                     preVal = preVal2;
  811.                     preValR = preVal2R;
  812.                     preOff = off;
  813.                     
  814.                     if( SndBuffer + off + 3 >= curVoice->maxPtr)
  815.                     {
  816.                         if( curVoice->loopSize > 0) 
  817.                         {
  818.                           aCC = aCC & ((1 << BYTEDIV) - 1);    
  819.                           RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight;        off = (long) 2*(aCC>>BYTEDIV);
  820.                           preOff = off;
  821.                           
  822.                           SndBuffer = curVoice->begPtr + curVoice->loopBeg;
  823.                           SndBuffer-=2;
  824.                         }
  825.                         else    // If TICK remove
  826.                         {
  827.                             killSample = true;
  828.                             break;
  829.                         }
  830.                     }
  831.                     preVal2 = *(SndBuffer + off + 2);
  832.                     preVal2R = *(SndBuffer + off + 3);
  833.                 }
  834.             }
  835.             
  836.             tByteL = ( LeftWeight *     preVal + RightWeight *     *(SndBuffer + off + 2)) >> BYTEDIV;        *ASCBuffer1 += (chnVol * tByteL) >> 8;        ASCBuffer1 += 2;
  837.             tByteR = ( LeftWeight *     preValR + RightWeight *     *(SndBuffer + off + 3)) >> BYTEDIV;        *ASCBuffer2 += (chnVol2 * tByteR) >> 8;        ASCBuffer2 += 2;
  838.             
  839.             aCC += aDD;
  840.         }
  841.         
  842.         if( killSample)
  843.         {
  844.             curVoice->samplePtr    = 0L;    curVoice->curPtr    = curVoice->maxPtr;
  845.         }
  846.         else
  847.         {
  848.             if( 2*(aCC>>BYTEDIV) == preOff) curVoice->preOff = 0;
  849.             else curVoice->preOff = 0xFFFFFFFF;
  850.             curVoice->preVal = preVal;
  851.             curVoice->preValR = preValR;
  852.             curVoice->preVal2 = *(SndBuffer + off + 2);
  853.             curVoice->preVal2R = *(SndBuffer + off + 3);
  854.             curVoice->curPtr = SndBuffer + 2*(aCC>>BYTEDIV);
  855.         }
  856.     }
  857.     
  858.     curVoice->lAC = aCC & ((1 << BYTEDIV) - 1);
  859. }
  860.  
  861. void Sampler8in16AddDelayStereo( Channel *curVoice, short    *ASCBuffer, MADDriverRec *intDriver)
  862. {
  863.     char                tByteL = 0, tByteR = 0;
  864.     long                chnVol, chnVol2;
  865.     long                i = intDriver->ASCBUFFER;
  866.     long                off;
  867.     short                *ASCBuffer1, *ASCBuffer2;
  868.     Boolean            killSample = false;
  869.     
  870.     ///
  871.     long                aDD, aCC = curVoice->lAC;
  872.     
  873.     aDD = (AMIGA_CLOCKFREQ2 << BYTEDIV) / ( curVoice->period * (intDriver->DriverSettings.outPutRate>>16));
  874.     if( curVoice->pingpong == true && curVoice->loopType == ePingPongLoop) aDD = -aDD;    // PINGPONG
  875.     ///
  876.     
  877.     if( curVoice->curPtr >= curVoice->maxPtr && curVoice->loopSize == 0) return;
  878.     
  879.     chnVol2    = DoVolPanning256( 0, curVoice, intDriver);
  880.     chnVol    = DoVolPanning256( 1, curVoice, intDriver);
  881.     
  882.     if( (curVoice->ID % 2) == 0)
  883.     {
  884.         ASCBuffer1 = ASCBuffer;
  885.         ASCBuffer2 = ASCBuffer +1L + intDriver->MDelay*2L;
  886.     }
  887.     else
  888.     {
  889.         ASCBuffer2 = ASCBuffer +1L;
  890.         ASCBuffer1 = ASCBuffer + intDriver->MDelay*2L;
  891.     }
  892.     
  893.     {
  894.         Ptr        SndBuffer = curVoice->curPtr;
  895.         long    RightWeight, LeftWeight, preOff = curVoice->preOff;
  896.         char    preVal = curVoice->preVal, preValR = curVoice->preValR, preVal2 = curVoice->preVal2, preVal2R = curVoice->preVal2R;
  897.         
  898.         #ifdef _INTEL_H
  899.         SndBuffer++;
  900.         #endif
  901.         
  902.         while( i-- > 0)
  903.         {
  904.             RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight;        off = 2*(aCC>>BYTEDIV);
  905.             
  906.             if( preOff != off)
  907.             {
  908.                 if( curVoice->loopType == ePingPongLoop && curVoice->loopSize > 0)        // PINGPONG
  909.                 {
  910.                     preOff = off;
  911.                     if( (SndBuffer + 2*off +6 >= curVoice->maxPtr && !curVoice->pingpong) ||
  912.                             (SndBuffer + 2*off +4 <= curVoice->begPtr + curVoice->loopBeg && curVoice->pingpong))
  913.                     {curVoice->pingpong = !curVoice->pingpong; aDD = -aDD; aCC += aDD; RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight; off = (long) 2*(aCC>>BYTEDIV);}
  914.                     preVal = *(SndBuffer + 2*off);
  915.                     preValR = *(SndBuffer + 2*off + 2);
  916.                 }
  917.                 else
  918.                 {
  919.                     preVal = preVal2;
  920.                     preValR = preVal2R;
  921.                     preOff = off;
  922.                     
  923.                     if( SndBuffer + 2*off + 6 >= curVoice->maxPtr)
  924.                     {
  925.                         if( curVoice->loopSize > 0) 
  926.                         {
  927.                           aCC = aCC & ((1 << BYTEDIV) - 1);    
  928.                           RightWeight = aCC & ((1 << BYTEDIV) - 1);        LeftWeight = (1 << BYTEDIV) - RightWeight;        off = (long) 2*(aCC>>BYTEDIV);
  929.                           preOff = off;
  930.                           
  931.                           SndBuffer = curVoice->begPtr + curVoice->loopBeg;
  932.                           SndBuffer-=4;
  933.                         }
  934.                         else    // If TICK remove
  935.                         {
  936.                             killSample = true;
  937.                             break;
  938.                         }
  939.                     }
  940.                     preVal2 = *(SndBuffer + 2*off + 4);
  941.                     preVal2R = *(SndBuffer + 2*off + 6);
  942.                 }
  943.             }
  944.             
  945.             tByteL = (    LeftWeight * preVal + RightWeight *     *(SndBuffer + 2*off + 4)) >> BYTEDIV;    *ASCBuffer1 += (chnVol * tByteL) >> 8;        ASCBuffer1 += 2;
  946.             tByteR = (    LeftWeight * preValR + RightWeight *     *(SndBuffer + 2*off + 6)) >> BYTEDIV;    *ASCBuffer2 += (chnVol2 * tByteR) >> 8;        ASCBuffer2 += 2;
  947.             aCC += aDD;
  948.         }
  949.         
  950.         if( killSample)
  951.         {
  952.             curVoice->samplePtr    = 0L;    curVoice->curPtr    = curVoice->maxPtr;
  953.         }
  954.         else
  955.         {
  956.             if( 2*(aCC>>BYTEDIV) == preOff) curVoice->preOff = 0;
  957.             else curVoice->preOff = 0xFFFFFFFF;
  958.             curVoice->preVal = preVal;
  959.             curVoice->preValR = preValR;
  960.             curVoice->preVal2 = *(SndBuffer + 2*off + 4);
  961.             curVoice->preVal2R = *(SndBuffer + 2*off + 6);
  962.             curVoice->curPtr = SndBuffer + 4*(aCC>>BYTEDIV);
  963.         }
  964.     }
  965.         
  966.     curVoice->lAC = aCC & ((1 << BYTEDIV) - 1);
  967. }
  968.  
  969. void Sample8BufferAddDelay( Channel *curVoice, register short *ASCBuffer, MADDriverRec *intDriver)
  970. {
  971.     if( curVoice->stereo)
  972.     {
  973.         if( curVoice->amp == 16) Sampler8in16AddDelayStereo( curVoice, ASCBuffer, intDriver);
  974.         else Sampler8in8AddDelayStereo( curVoice, ASCBuffer, intDriver);
  975.     }
  976.     else
  977.     {
  978.         if( curVoice->amp == 16) Sampler8in16AddDelay( curVoice, ASCBuffer, intDriver);
  979.         else Sampler8in8AddDelay( curVoice, ASCBuffer, intDriver);
  980.     }
  981. }
  982.  
  983. void Play8StereoDelay( MADDriverRec *intDriver)
  984. {
  985. long            i;
  986. short            *ttt;
  987. Ptr                ASCBuffer;
  988.  
  989.     for( i = 0 ; i < intDriver->DriverSettings.numChn; i++) Sample8BufferAddDelay    ( &intDriver->chan[i], intDriver->DASCBuffer8, intDriver);
  990.  
  991.     ttt = intDriver->DASCBuffer8;
  992.     ASCBuffer = intDriver->IntDataPtr;
  993.  
  994.     i = intDriver->ASCBUFFER*2;
  995.     while( i-- > 0)
  996.     {
  997.         *ASCBuffer++ = *(intDriver->OverShoot + *ttt);
  998.         *ttt++ = 0;
  999.     }
  1000. }