Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void mixer::mix(sample::ptr a_Sample, sample::ptr *a_Result){
- sample::value_type *l_Left = a_Sample->buffer();
- sample::value_type *l_Right = a_Sample->buffer();
- sample::value_type *l_Output = (*a_Result)->buffer();
- float l_PanValue = std::min(1.f, std::max(-1.f, a_Sample->pan()));
- sample::value_type l_PanLeft = 1 - ((l_PanValue + 1) / 2);
- sample::value_type l_PanRight = (l_PanValue + 1) / 2;
- float l_MagicValue = 5.f;
- // correct right channel for interleaved format
- l_Right += a_Sample->channels() - 1;
- for(int i = 0; i < a_Sample->count() / a_Sample->channels(); i++){
- float l_Volume = a_Sample->volume() * m_MasterVolume / l_MagicValue;
- *l_Output++ += *l_Left * l_PanLeft * l_Volume;
- *l_Output++ += *l_Right * l_PanRight * l_Volume;
- l_Left += a_Sample->channels();
- l_Right += a_Sample->channels();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement