summaryrefslogtreecommitdiff
path: root/include/nw4r/snd/snd_SoundHandle.h
blob: 4dd83232962fca20a2f725e5cd4566a36555a040 (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
116
117
118
#ifndef NW4R_SND_SOUND_HANDLE_H
#define NW4R_SND_SOUND_HANDLE_H

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

#include "common.h"

#include "nw4r/snd/snd_BasicSound.h"

#include "nw4r/ut/ut_algorithm.h" // ut::NonCopyable

/*******************************************************************************
 * classes and functions
 */

namespace nw4r { namespace snd
{
	// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2894f
	class SoundHandle : private ut::NonCopyable
	{
	// methods
	public:
		// cdtors
		SoundHandle() : mSound() {}
		~SoundHandle() { DetachSound(); }

		// methods
		void detail_AttachSoundAsTempHandle(detail::BasicSound* pSound);
		void detail_AttachSound(detail::BasicSound *sound);
		bool IsAttachedSound() const { return mSound != nullptr; }
		detail::BasicSound *detail_GetAttachedSound() { return mSound; }
		const detail::BasicSound *detail_GetAttachedSound() const { return mSound; }
		void DetachSound();

		void SetOutputLineFlag(int outputLineFlag) {
			if (IsAttachedSound())
				mSound->SetOutputLineFlag(outputLineFlag);
		}

		void FadeIn(int fadeFrames) {
			if (IsAttachedSound())
				mSound->FadeIn(fadeFrames);
		}

		void SetVolume(f32 volume, int frames) {
			if (IsAttachedSound())
				mSound->SetVolume(volume, frames);
		}

		void SetPitch(f32 pitch) {
			if (IsAttachedSound())
				mSound->SetPitch(pitch);
		}

		void Stop(int fadeFrames) {
			if (IsAttachedSound())
				mSound->Stop(fadeFrames);
		}

		void Pause(bool flag, int fadeFrames) {
			if (IsAttachedSound())
				mSound->Pause(flag, fadeFrames);
		}

		void SetPan(f32 pan) {
			if (IsAttachedSound())
				mSound->SetPan(pan);
		}

		void SetFxSend(AuxBus bus, f32 send) {
			if (IsAttachedSound())
				mSound->SetFxSend(bus, send);
		}

		void SetLpfFreq(f32 lpfFreq) {
			if (IsAttachedSound())
				mSound->SetLpfFreq(lpfFreq);
		}

		bool IsPause() const {
			return IsAttachedSound() && mSound->IsPause();
		}

		bool IsPrepared() const {
			return IsAttachedSound() && mSound->IsPrepared();
		}

		int GetRemainingFadeFrames() const {
			if (IsAttachedSound())
				return mSound->GetRemainingFadeFrames();

			return 0;
		}

		u32 GetId() const
		{
			if (IsAttachedSound())
				return mSound->GetId();

			return detail::BasicSound::INVALID_ID;
		}

		void StartPrepared()
		{
			if (IsAttachedSound())
				mSound->StartPrepared();
		}

	// members
	private:
		/* base NonCopyable */			// size 0x00, offset 0x00
		detail::BasicSound	*mSound;	// size 0x04, offset 0x00
	}; // size 0x04
}} // namespace nw4r::snd

#endif // NW4R_SND_SOUND_HANDLE_H