Exemplo n.º 1
0
        //////////////////////////////////////////////////////////////////////
        //
        //////////////////////////////////////////////////////////////////////
        private float GetCurrentVolume(WaveProvider32.eChannel channel)
        {
            int masterVol = 0;

            if (channel == eChannel.eChannel_Left)
            {
                if (!m_leftChannel)
                {
                    return(0.0f);
                }
                else
                {
                    masterVol = m_leftVolume;
                }
            }
            else
            {
                if (!m_rightChannel)
                {
                    return(0.0f);
                }
                else
                {
                    masterVol = m_rightVolume;
                }
            }
            float outVol = 0;

            switch (m_outputLevel)
            {
            case 0:
                outVol = 0.0f;
                break;

            case 1:
                outVol = 1.0f;
                break;

            case 2:
                outVol = 0.5f;
                break;

            case 3:
                outVol = 0.25f;
                break;

            default:
                outVol = 0.0f;
                break;
            }
            return((outVol * masterVol) / 7.0f);
        }
        //////////////////////////////////////////////////////////////////////
        //
        //vol is between 0 and 15
        //
        //////////////////////////////////////////////////////////////////////
        private float GetCurrentVol(double time, WaveProvider32.eChannel channel)
        {
            int masterVol = 0;

            if (channel == eChannel.eChannel_Left)
            {
                if (!m_leftChannel)
                {
                    return(0.0f);
                }
                else
                {
                    masterVol = m_leftVolume;
                }
            }
            else
            {
                if (!m_rightChannel)
                {
                    return(0.0f);
                }
                else
                {
                    masterVol = m_rightVolume;
                }
            }
            if (m_numberVolumeSweep != 0 && m_enveloppeClockCnt % m_numberVolumeSweep == 0)
            {
                if (m_bAttenuate)
                {
                    m_curVol--;
                }
                else
                {
                    m_curVol++;
                }
            }
            float volOut = Math.Min(15, Math.Max(m_curVol, 0));

            volOut /= 15.0f;
            volOut *= 7.0f;
            volOut /= masterVol;
            return(volOut);
        }