summaryrefslogtreecommitdiff
path: root/src/nw4r/snd/snd_BasicPlayer.cpp
blob: 6b8cba05e51cdaea2a1c5db67c0c40d978a9ef13 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "nw4r/snd/snd_BasicPlayer.h"

/* Original source:
 * kiwi515/ogws
 * src/nw4r/snd/snd_BasicPlayer.cpp
 */

/*******************************************************************************
 * headers
 */

#include "common.h" // f32

#include "nw4r/snd/snd_BasicSound.h"
#include "nw4r/snd/snd_global.h"

#include "nw4r/NW4RAssert.hpp"

/*******************************************************************************
 * functions
 */

namespace nw4r { namespace snd { namespace detail {

void PlayerParamSet::Init()
{
	volume			= 1.0f;
	pitch			= 1.0f;
	pan				= 0.0f;
	surroundPan		= 0.0f;
	lpfFreq			= 0.0f;
	biquadType		= 0;
	biquadValue		= 0.0f;
	remoteFilter	= 0;
	outputLineFlag	= OUTPUT_LINE_MAIN;
	mainOutVolume	= 1.0f;
	mainSend		= 0.0f;
	panMode			= PAN_MODE_DUAL;
	panCurve		= PAN_CURVE_SQRT;

	for (int i = 0; i < AUX_BUS_NUM; i++)
		fxSend[i]	= 0.0f;

	for (int i = 0; i < 4; i++)
		remoteOutVolume[i]	= 1.0f;

	for (int i = 0; i < (int)ARRAY_LENGTH(voiceOutParam); i++)
	{
		VoiceOutParam *param = &voiceOutParam[i];

		param->volume		= 1.0f;
		param->pitch		= 1.0f;
		param->pan			= 0.0f;
		param->surroundPan	= 0.0f;
		param->fxSend		= 0.0f;
		param->lpf			= 0.0f;
	}
}

BasicPlayer::BasicPlayer() :
	mId	(BasicSound::INVALID_ID)
{
	InitParam();
}

void BasicPlayer::InitParam()
{
	mPlayerParamSet.Init();
}

void BasicPlayer::SetFxSend(AuxBus bus, f32 send)
{
	// specifically not the source variant
	NW4RAssertHeaderClampedLValue_Line(81, bus, AUX_A, AUX_BUS_NUM);

	mPlayerParamSet.fxSend[bus] = send;
}

f32 BasicPlayer::GetFxSend(AuxBus bus) const
{
	// specifically not the source variant
	NW4RAssertHeaderClampedLValue_Line(87, bus, AUX_A, AUX_BUS_NUM);

	return mPlayerParamSet.fxSend[bus];
}

void BasicPlayer::SetBiquadFilter(int type, f32 value)
{
	// specifically not the source variants
	NW4RAssertHeaderClampedLRValue_Line(93, type, 0, 127);
	NW4RAssertHeaderClampedLRValue_Line(94, value, 0.0f, 1.0f);

	mPlayerParamSet.biquadType	= type;
	mPlayerParamSet.biquadValue	= value;
}

void BasicPlayer::SetRemoteFilter(int filter)
{
	// specifically not the source variant
	NW4RAssertHeaderClampedLRValue_Line(102, filter, 0, 127);

	mPlayerParamSet.remoteFilter = filter;
}

void BasicPlayer::SetRemoteOutVolume(int remote, f32 volume)
{
	mPlayerParamSet.remoteOutVolume[remote] = volume;
}

f32 BasicPlayer::GetRemoteOutVolume(int remote) const
{
	return mPlayerParamSet.remoteOutVolume[remote];
}

}}} // namespace nw4r::snd::detail