summaryrefslogtreecommitdiff
path: root/src/d/snd/d_snd_control_player.cpp
blob: fe0d9e4b1740558c8fcf2110f1df2640bc5aa05d (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 "d/snd/d_snd_control_player.h"

#include "common.h"
#include "d/snd/d_snd_control_player_mgr.h"
#include "d/snd/d_snd_player_mgr.h"
#include "d/snd/d_snd_sound.h"
#include "nw4r/snd/snd_SoundPlayer.h"
#include "nw4r/snd/snd_global.h"

dSndControlPlayerVolumeBase_c::dSndControlPlayerVolumeBase_c() : dSndControlPlayer_c(1.0f, 0.0f, 1.0f) {
    mpPlayer = nullptr;
    mIndex = 0;
}

void dSndControlPlayer_c::reset() {
    dSndControl_c::reset();
    apply();
}

void dSndControlPlayer_c::setIndex1(u32 idx) {
    mpPlayer = dSndControlPlayerMgr_c::GetInstance()->getPlayer1(idx);
    mIndex = idx;
}

void dSndControlPlayer_c::setIndex2(u32 idx) {
    mpPlayer = dSndControlPlayerMgr_c::GetInstance()->getPlayer2(idx);
    mIndex = idx;
}

void dSndControlPlayer_c::stop() {
    mCurrValue = getAppliedValue();
    dSndControl_c::stop();
}

void dSndControlPlayerVolume_c::apply() {
    mpPlayer->SetVolume(mCurrValue);
}

f32 dSndControlPlayerVolume_c::getAppliedValue() {
    return mpPlayer->GetVolume();
}

void dSndControlPlayerLpfFreq_c::apply() {
    mpPlayer->SetLpfFreq(mCurrValue);
}

f32 dSndControlPlayerLpfFreq_c::getAppliedValue() {
    return mpPlayer->GetLpfFreq();
}

void dSndControlPlayerFxSend_c::apply() {
    if (mCurrValue < mMin) {
        mCurrValue = mMin;
    }
    if (mCurrValue >= mMax) {
        mCurrValue = mMax;
    }
    mpPlayer->SetFxSend(nw4r::snd::AUX_B, mCurrValue);
}

f32 dSndControlPlayerFxSend_c::getAppliedValue() {
    int auxBus = nw4r::snd::AUX_A;
    if (dSndPlayerMgr_c::isBgmPlayerId(mIndex)) {
        auxBus = nw4r::snd::AUX_B;
    }
    return mpPlayer->GetFxSend(auxBus);
}