Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MyBasicAudio.cpp « src - github.com/mpc-hc/sanear.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 74986517f6ee6cbf2236dcad4949e8ef3cd2e011 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "pch.h"
#include "MyBasicAudio.h"

#include "AudioRenderer.h"

namespace SaneAudioRenderer
{
    MyBasicAudio::MyBasicAudio(IUnknown* pUnknown, AudioRenderer& renderer)
        : CBasicAudio(L"SaneAudioRenderer::MyBasicAudio", pUnknown)
        , m_renderer(renderer)
    {
    }

    STDMETHODIMP MyBasicAudio::put_Volume(long volume)
    {
        if (volume < -10000 || volume > 0)
            return E_FAIL;

        float f = (volume == 0) ?
                      1.0f : pow(10.0f, (float)volume / 2000.0f);

        m_renderer.SetVolume(f);

        return S_OK;
    }

    STDMETHODIMP MyBasicAudio::get_Volume(long* pVolume)
    {
        CheckPointer(pVolume, E_POINTER);

        float f = m_renderer.GetVolume();

        *pVolume = (f == 1.0f) ?
                       0 : (long)(log10(f) * 2000.0f);

        assert(*pVolume <= 0 && *pVolume >= -10000);

        return S_OK;
    }

    STDMETHODIMP MyBasicAudio::put_Balance(long balance)
    {
        if (balance < -10000 || balance > 10000)
            return E_FAIL;

        float f = (balance == 0) ?
                      0.0f : pow(10.0f, (float)abs(balance) / -2000.0f);

        m_renderer.SetBalance(copysign(f, (float)balance));

        return S_OK;
    }

    STDMETHODIMP MyBasicAudio::get_Balance(long* pBalance)
    {
        CheckPointer(pBalance, E_POINTER);

        float f = m_renderer.GetBalance();

        *pBalance = (f == 0.0f) ?
                        0 : (long)(copysign(log10(abs(f)), f) * 2000.0f);

        assert(*pBalance >= -10000 && *pBalance <= 10000);

        return S_OK;
    }
}