Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1.  
  2. void mixer::mix(sample::ptr a_Sample, sample::ptr *a_Result){
  3.         sample::value_type *l_Left   = a_Sample->buffer();
  4.         sample::value_type *l_Right  = a_Sample->buffer();
  5.         sample::value_type *l_Output = (*a_Result)->buffer();
  6.  
  7.         float l_PanValue = std::min(1.f, std::max(-1.f, a_Sample->pan()));
  8.  
  9.         sample::value_type l_PanLeft  = 1 - ((l_PanValue + 1) / 2);
  10.         sample::value_type l_PanRight =      (l_PanValue + 1) / 2;
  11.        
  12.         float l_MagicValue = 5.f;
  13.  
  14.         // correct right channel for interleaved format
  15.         l_Right += a_Sample->channels() - 1;
  16.  
  17.         for(int i = 0; i < a_Sample->count() / a_Sample->channels(); i++){
  18.                 float l_Volume = a_Sample->volume() * m_MasterVolume / l_MagicValue;
  19.  
  20.                 *l_Output++ += *l_Left * l_PanLeft * l_Volume;
  21.                 *l_Output++ += *l_Right * l_PanRight * l_Volume;
  22.  
  23.                 l_Left  += a_Sample->channels();
  24.                 l_Right += a_Sample->channels();
  25.         }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement