summaryrefslogtreecommitdiff
path: root/libs/revolution/src/homebuttonLib/nw4hbm/snd/SoundHandle.h
blob: baeba5dbdff11b04c7668ad45d8f3a0bee676e63 (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
#ifndef NW4HBM_SND_SOUND_HANDLE_H
#define NW4HBM_SND_SOUND_HANDLE_H

#include <revolution/types.h>

#include "BasicSound.h"

#include "../ut/inlines.h"

namespace nw4hbm {
    namespace snd {
        class SoundHandle : private ut::NonCopyable {
        public:
            SoundHandle() : mSound(NULL) {}
            ~SoundHandle() { DetachSound(); }

            void detail_AttachSound(detail::BasicSound* sound);
            void detail_AttachSoundAsTempHandle(detail::BasicSound* sound);

            bool IsAttachedSound() const { return mSound != NULL; }

            detail::BasicSound* detail_GetAttachedSound() { return mSound; }

            void DetachSound();

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

                return false;
            }

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

                return -1;
            }

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

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

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

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

            void SetOutputLine(int flag) {
                if (IsAttachedSound()) {
                    mSound->SetOutputLine(flag);
                }
            }

            void SetMainOutVolume(f32 volume) {
                if (IsAttachedSound()) {
                    mSound->SetMainOutVolume(volume);
                }
            }
            void SetRemoteOutVolume(int remote, f32 volume) {
                if (IsAttachedSound()) {
                    mSound->SetRemoteOutVolume(remote, volume);
                }
            }

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

        private:
            /* 0x00 */ detail::BasicSound* mSound;
        };
    }  // namespace snd
}  // namespace nw4hbm

#endif