rem: cd->cd_Samples = cd->cd_DelayedSamples;
add: cd->cd_Samples = CalcSamples( cd->cd_Add, cd->cd_Type, cd->cd_LastOffset, cd->cd_Offset );
context: SetFreq ( REG( d0, UWORD channel ),          REG( d1, ULONG freq ),          REG( a2, struct AHIPrivAudioCtrl *audioctrl ),          REG( d2, ULONG flags ),          REG( a6, struct AHIBase *AHIBase ) ){  struct AHIChannelData *cd;  struct Library        *AHIsubBase;  ULONG                  rc;  ULONG                  add;  if(AHIBase->ahib_DebugLevel >= AHI_DEBUG_ALL)  {    Debug_SetFreq(channel, freq, audioctrl, flags);  }  AHIsubBase = audioctrl->ahiac_SubLib;  rc = AHIsub_SetFreq(channel, freq, &audioctrl->ac, flags);  if(audioctrl->ac.ahiac_Flags & AHIACF_NOMIXING     || rc != AHIS_UNKNOWN)  {    return 0;   /* We're done! */  }  cd = &audioctrl->ahiac_ChannelDatas[channel];  if(freq == 0)  {    cd->cd_NextFreqOK = FALSE;    add = 0;  }  else  {    cd->cd_NextFreqOK = TRUE;    if(freq == AHI_MIXFREQ)    {      add = 0x10000;    }    else    {      int shift = 0;            while(freq >= 65536)      {        shift++;        freq >>= 1;      }      add = ((freq << 16) / audioctrl->ac.ahiac_MixFreq) << shift;    }  }  AHIsub_Disable(&audioctrl->ac);#ifdef VERSION68K  cd->cd_NextAdd.I = add >> 16;  cd->cd_NextAdd.F = (add & 0xffff) << 16;#else  cd->cd_NextAdd = (Fixed64) add << 16;#endif  if(flags & AHISF_IMM)  {#ifdef VERSION68K    cd->cd_Add.I   = cd->cd_NextAdd.I;    cd->cd_Add.F   = cd->cd_NextAdd.F;    cd->cd_FreqOK  = cd->cd_NextFreqOK;    cd->cd_Samples = CalcSamples( cd->cd_Add.I, cd->cd_Add.F,                                  cd->cd_Type,                                  cd->cd_LastOffset.I, cd->cd_LastOffset.F,                                  cd->cd_Offset.I, cd->cd_Offset.F );#else    cd->cd_DelayedAdd     = cd->cd_NextAdd;    cd->cd_DelayedFreqOK  = cd->cd_NextFreqOK;    // cd->cd_Samples is also calculated when it actually happens...    cd->cd_DelayedSamples = CalcSamples( cd->cd_DelayedAdd,                                         cd->cd_DelayedType,                                         cd->cd_DelayedLastOffset,                                         cd->cd_DelayedOffset );    /* Enable anti-click routine */    cd->cd_AntiClickCount = audioctrl->ac.ahiac_AntiClickSamples;    if( ( flags & AHISF_NODELAY ) ||         ( cd->cd_AntiClickCount == 0 ) ||         !cd->cd_FreqOK || !cd->cd_SoundOK )    {      cd->cd_Add     = cd->cd_DelayedAdd;      cd->cd_FreqOK  = cd->cd_DelayedFreqOK;      cd->cd_Samples = cd->cd_DelayedSamples;      cd->cd_AntiClickCount = 0;    }    else    {      cd->cd_FreqDelayed = TRUE;    }#endif  }  AHIsub_Enable(&audioctrl->ac);  return 0;}