NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
snd_SoundHandle.h
1#ifndef NW4R_SND_SOUND_HANDLE_H
2#define NW4R_SND_SOUND_HANDLE_H
3
4/*******************************************************************************
5 * headers
6 */
7
8#include <types.h>
9
10#include "nw4r/snd/snd_BasicSound.h"
11
12#include "nw4r/ut/ut_algorithm.h" // ut::NonCopyable
13
14/*******************************************************************************
15 * classes and functions
16 */
17
18namespace nw4r { namespace snd
19{
20 // [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2894f
21 class SoundHandle : private ut::NonCopyable
22 {
23 // methods
24 public:
25 // cdtors
26 SoundHandle() : mSound() {}
27 ~SoundHandle() { DetachSound(); }
28
29 // methods
30 void detail_AttachSoundAsTempHandle(detail::BasicSound* pSound);
31 void detail_AttachSound(detail::BasicSound *sound);
32 bool IsAttachedSound() const { return mSound != nullptr; }
33 detail::BasicSound *detail_GetAttachedSound() { return mSound; }
34 const detail::BasicSound *detail_GetAttachedSound() const { return mSound; }
35 void DetachSound();
36
37
38 void FadeIn(int fadeFrames) {
39 if (IsAttachedSound())
40 mSound->FadeIn(fadeFrames);
41 }
42
43 void SetVolume(f32 volume, int frames) {
44 if (IsAttachedSound())
45 mSound->SetVolume(volume, frames);
46 }
47
48 void SetPitch(f32 volume) {
49 if (IsAttachedSound())
50 mSound->SetPitch(volume);
51 }
52
53 void Stop(int fadeFrames) {
54 if (IsAttachedSound())
55 mSound->Stop(fadeFrames);
56 }
57
58 void Pause(bool flag, int fadeFrames) {
59 if (IsAttachedSound())
60 mSound->Pause(flag, fadeFrames);
61 }
62
63 void SetPan(f32 pan) {
64 if (IsAttachedSound())
65 mSound->SetPan(pan);
66 }
67
68 bool IsPause() const {
69 return IsAttachedSound() && mSound->IsPause();
70 }
71
72 int GetRemainingFadeFrames() const {
73 if (IsAttachedSound())
74 return mSound->GetRemainingFadeFrames();
75
76 return 0;
77 }
78
79 ulong GetId() const
80 {
81 if (IsAttachedSound())
82 return mSound->GetId();
83
84 return detail::BasicSound::INVALID_ID;
85 }
86
87 void StartPrepared()
88 {
89 if (IsAttachedSound())
90 mSound->StartPrepared();
91 }
92
93 // members
94 private:
95 /* base NonCopyable */ // size 0x00, offset 0x00
96 detail::BasicSound *mSound; // size 0x04, offset 0x00
97 }; // size 0x04
98}} // namespace nw4r::snd
99
100#endif // NW4R_SND_SOUND_HANDLE_H