summaryrefslogtreecommitdiff
path: root/include/nw4r/snd/snd_SeqSoundHandle.h
blob: 764bbec300a7047861b04c273c3306791175a7ed (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
#ifndef NW4R_SND_SEQ_SOUND_HANDLE_H
#define NW4R_SND_SEQ_SOUND_HANDLE_H

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

#include "common.h" // nullptr

#include "nw4r/snd/snd_SeqSound.h"
#include "nw4r/snd/snd_SeqTrack.h"
#include "nw4r/ut/ut_NonCopyable.h" // ut::NonCopyable

/*******************************************************************************
 * types
 */

// forward declarations
namespace nw4r { namespace snd { namespace detail { class SeqSound; }}}

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

namespace nw4r { namespace snd
{
	// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2e9b6
	class SeqSoundHandle : private ut::NonCopyable
	{
	// methods
	public:
		SeqSoundHandle(SoundHandle*);
		~SeqSoundHandle() { DetachSound(); }
		// methods
		bool IsAttachedSound() const { return mSound != nullptr; }

		void DetachSound();

		u32 GetTick() const {
			if (IsAttachedSound())
				return mSound->GetTick();
			return 0;
		}

		void WriteVariable(int varNo, s16 value) {
			if (IsAttachedSound())
				mSound->WriteVariable(varNo, value);
		}

		void ReadVariable(int varNo, s16 *value) {
			if (IsAttachedSound())
				mSound->ReadVariable(varNo, value);
		}

		static bool WriteGlobalVariable(int varNo, s16 value) {
			return detail::SeqSound::WriteGlobalVariable(varNo, value);
		}

		void SetTrackMute(u32 trackFlags, SeqMute mute) {
			if (IsAttachedSound())
				mSound->SetTrackMute(trackFlags, mute);
		}

		void SetTempoRatio(f32 tempoRatio) {
			if (IsAttachedSound())
				mSound->SetTempoRatio(tempoRatio);
		}

		void SetVolume(u32 trackFlags, f32 volume) {
			if (IsAttachedSound())
				mSound->SetTrackVolume(trackFlags, volume);
		}

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

#endif // NW4R_SND_SEQ_SOUND_HANDLE_H