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

#include <revolution/types.h>

namespace nw4hbm {
    namespace snd {
        class SoundHandle;

        namespace detail {
            class ExternalSoundPlayer;
        }

        class SoundStartable {
        public:
            typedef enum StartResult {
                START_SUCCESS = 0,
                START_ERR_LOW_PRIORITY,
                START_ERR_INVALID_LABEL_STRING,
                START_ERR_INVALID_SOUNDID,
                START_ERR_NOT_DATA_LOADED,
                START_ERR_NOT_ENOUGH_PLAYER_HEAP,
                START_ERR_CANNOT_OPEN_FILE,
                START_ERR_NOT_AVAILABLE,
                START_ERR_CANNOT_ALLOCATE_TRACK,
                START_ERR_NOT_ENOUGH_INSTANCE,
                START_ERR_INVALID_PARAMETER,
                START_ERR_INVALID_SEQ_START_LOCATION_LABEL,

                START_ERR_USER = 128,
                START_ERR_UNKNOWN = 255,
            } StartResult;

            typedef struct StartInfo {
                typedef enum EnableFlag {
                    ENABLE_START_OFFSET = (1 << 0),
                    ENABLE_PLAYER_ID = (1 << 1),
                    ENABLE_PLAYER_PRIORITY = (1 << 2)
                } EnableFlag;

                typedef enum StartOffsetType {
                    START_OFFSET_TYPE_SAMPLE = 0,
                    START_OFFSET_TYPE_MILLISEC,
                } StartOffsetType;

                /* 0x00 */ StartOffsetType startOffsetType;
                /* 0x04 */ int startOffset;
                /* 0x08 */ u32 playerId;
                /* 0x0C */ int playerPriority;
                /* 0x10 */ int voiceOutCount;
            } StartInfo;

        public:
            /* 0x08 */ virtual ~SoundStartable() {}
            /* 0x0C */ virtual StartResult
            detail_SetupSound(SoundHandle* soundHandle, u32 id,
                              detail::BasicSound::AmbientArgInfo* ambientArgInfo,
                              detail::ExternalSoundPlayer* extPlayer, bool hold,
                              const StartInfo* startInfo) = 0;
            /* 0x10 */ virtual u32 detail_ConvertLabelStringToSoundId(const char* label) = 0;

            bool StartSound(SoundHandle* soundHandle, u32 id) {
                return detail_StartSound(soundHandle, id, NULL, NULL, NULL) == START_SUCCESS;
            }
            bool StartSound(SoundHandle* soundHandle, unsigned int id) {
                return detail_StartSound(soundHandle, id, NULL, NULL, NULL) == START_SUCCESS;
            }
            bool StartSound(SoundHandle* soundHandle, int id) {
                return detail_StartSound(soundHandle, id, NULL, NULL, NULL) == START_SUCCESS;
            }

            bool HoldSound(SoundHandle* soundHandle, u32 id) {
                return detail_HoldSound(soundHandle, id, NULL, NULL, NULL) == START_SUCCESS;
            }
            bool HoldSound(SoundHandle* soundHandle, unsigned int id) {
                return detail_HoldSound(soundHandle, id, NULL, NULL, NULL) == START_SUCCESS;
            }
            bool HoldSound(SoundHandle* soundHandle, int id) {
                return detail_HoldSound(soundHandle, id, NULL, NULL, NULL) == START_SUCCESS;
            }

            bool PrepareSound(SoundHandle* soundHandle, u32 id) {
                return detail_PrepareSound(soundHandle, id, NULL, NULL, NULL) == START_SUCCESS;
            }
            bool PrepareSound(SoundHandle* soundHandle, unsigned int id) {
                return detail_PrepareSound(soundHandle, id, NULL, NULL, NULL) == START_SUCCESS;
            }
            bool PrepareSound(SoundHandle* soundHandle, int id) {
                return detail_PrepareSound(soundHandle, id, NULL, NULL, NULL) == START_SUCCESS;
            }

        private:
            StartResult detail_StartSound(SoundHandle* soundHandle, u32 id,
                                          detail::BasicSound::AmbientArgInfo* ambientArgInfo,
                                          detail::ExternalSoundPlayer* extPlayer,
                                          const StartInfo* startInfo);

            StartResult detail_HoldSound(SoundHandle* soundHandle, u32 id,
                                         detail::BasicSound::AmbientArgInfo* ambientArgInfo,
                                         detail::ExternalSoundPlayer* extPlayer,
                                         const StartInfo* startInfo);

            StartResult detail_PrepareSound(SoundHandle* soundHandle, u32 id,
                                            detail::BasicSound::AmbientArgInfo* ambientArgInfo,
                                            detail::ExternalSoundPlayer* extPlayer,
                                            const StartInfo* startInfo);
        };

    }  // namespace snd
}  // namespace nw4hbm

#endif