Advertisement
junh1024

MDA DITHER

Jan 1st, 2015
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. void mdaDither::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames)
  2. {
  3.     float o = offs, w = wlen, wi = 1.0f / wlen;                     //DC offset, word length & inverse
  4.    
  5.     float *inarray[NUM_CHANS];
  6.     float temparray[NUM_CHANS];
  7.     float *outarray[NUM_CHANS];
  8.  
  9.     for (int i = 0; i < NUM_CHANS; i++)
  10.     {
  11.         inarray[i] = inputs[i];
  12.         outarray[i] = outputs[i];
  13.  
  14.         --inarray[i];
  15.         --outarray[i];
  16.     }
  17.  
  18.     while(--sampleFrames >= 0)
  19.     {
  20.         for (int i = 0; i < NUM_CHANS; i++)
  21.         {
  22.             temparray[i] = *++inarray[i] + o; //apply offset, somehow this is needed
  23.  
  24.             if (temparray[i]<0.0f) temparray[i] -= wi; //(VstInt32) truncates towards zero!
  25.             temparray[i] = wi * (float)(VstInt32)(w * temparray[i]); //truncate
  26.  
  27.             *++outarray[i] = temparray[i] * gain; //apply shift
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement