OROCHI
 
Loading...
Searching...
No Matches
GxUnitSound.h
Go to the documentation of this file.
1//===========================================================================
9//===========================================================================
10#pragma once
11
12GX_SOUND_NAMESPACE_BEGIN()
13
14//===========================================================================
16//===========================================================================
18{
19 //-------------------------------------------------------------
21 //-------------------------------------------------------------
23public:
24#if defined(_WINDOWS) || defined(_XBOX_XS)
26 class GxVoiceCallback : public IXAudio2VoiceCallback
27 {
28 //-------------------------------------------------------------
30 //-------------------------------------------------------------
32 public:
34 GxVoiceCallback(GxUnitSound* pOwner)
35 : _pOwner(pOwner)
36 {
37 }
39 ~GxVoiceCallback(void) { }
40
42 //-----------------------------------------------------------
44 //-----------------------------------------------------------
46
48 GX_FORCE_INLINE void OnStreamEnd(void) { _pOwner->stop(); }
49
50 // Called just before this voice's processing pass begins.
51 void OnVoiceProcessingPassStart(u32 /*SamplesRequired*/) override {}
52 // Called just after this voice's processing pass ends.
53 void OnVoiceProcessingPassEnd(void) override {}
54 // Called when this voice is about to start processing a new buffer.
55 void OnBufferStart(void* /*pBufferContext*/) override {}
56 // Called when this voice has just finished processing a buffer.
57 // The buffer can now be reused or destroyed.
58 void OnBufferEnd(void* /*pBufferContext*/) override {}
59 // Called when this voice has just reached the end position of a loop.
60 void OnLoopEnd(void* /*pBufferContext*/) override {}
61 // Called in the event of a critical error during voice processing,
62 // such as a failing xAPO or an error from the hardware XMA decoder.
63 // The voice may have to be destroyed and re-created to recover from
64 // the error. The callback arguments report which buffer was being
65 // processed when the error occurred, and its HRESULT code.
66 void OnVoiceError(void* /*pBufferContext*/, HRESULT error) override { GX_ERROR(false, "GxUnitSound error(0x%x)", error); }
67
69 //-----------------------------------------------------------
71 //-----------------------------------------------------------
73 private:
74 GxUnitSound* _pOwner;
75
77 };
78#endif //_WINDOWS || _XBOX_XS
79
80 static constexpr u32 SRC_CHANNEL_MAX = static_cast<u32>(GxSysSoundBase::CHANNEL_COUNT::MAX);
81 static constexpr u32 DST_CHANNEL_MAX = SRC_CHANNEL_MAX;
82 static constexpr f32 PAN_INVALID_VALUE = -1.1f;
83
85 enum class EFFECT
86 {
87 ECHO,
88 EQ,
89 MASTERING_LIMITER,
90 REVERB,
91 MAX,
92 };
93
94 // RTTI宣言
96 // GxClassBaseReference継承クラス用禁止宣言
98
99
100 //-------------------------------------------------------------
102 //-------------------------------------------------------------
104public:
106 GxUnitSound(void);
108 void cleanup(void) override;
109private:
110#if defined(_WINDOWS) || defined(_XBOX_XS)
112 b32 initializeX3dAudio(u32 channelCount);
113#endif //_WINDOWS || _XBOX_XS
114
116 //-----------------------------------------------------------
118 //-----------------------------------------------------------
120public:
122 void asyncUpdate(void) override;
124 void render(void) override;
126 void play(s32 loopCount = GxSysSound::LOOP_DEFAULT, f32 volume = 1.0f, f32 pitch = 1.0f, b32 is3D = true, f32 fadeTime = 0.f);
128 void stop(f32 duration = 0);
129#if defined(_WINDOWS) || defined(_XBOX_XS)
131 void setEffect(const EFFECT* pEffects, void** ppEffectParameters, u32 count);
133 void setEffectEnable(u32 index, b32 enable) const;
135 FXECHO_PARAMETERS getDefaultEchoParameters(void) const;
137 FXEQ_PARAMETERS getDefaultEqParameters(void) const;
139 FXMASTERINGLIMITER_PARAMETERS getDefaultMasteringLimiterParameters(void) const;
141 FXREVERB_PARAMETERS getDefaultReverbParameters(void) const;
142#endif //_WINDOWS || _XBOX_XS
143
145 //-----------------------------------------------------------
147 //-----------------------------------------------------------
149public:
151 f32 getVolume(void) const;
153 void setVolume(f32 volume);
155 f32 getPitch(void) const;
157 void setPitch(f32 pitch);
159 void set3dConeParameter(f32 innerAngle, f32 outerAngle, f32 outerVolume);
161 void set3dMinMaxAttenuationDistance(f32 min, f32 max);
163 void setSoundResource(GxResSound* pResSound);
165 constexpr f32 getPan(void) const { return _pan; }
167 GX_FORCE_INLINE void setPan(f32 pan) { _is3D = (pan == PAN_INVALID_VALUE); _pan = pan; }
168
170 //-----------------------------------------------------------
172 //-----------------------------------------------------------
174private:
175 GxResSound* _pResSound;
176 GxVector3 _positionBefore;
177 f32 _matrixCoefficients[SRC_CHANNEL_MAX * DST_CHANNEL_MAX];
178 f32 _channelAzimuths[SRC_CHANNEL_MAX];
179 b32 _is3D;
180 u32 _streamingSetSize;
181 b32 _isStreaming;
182 b32 _isPlay;
183 f32 _pan;
184 f32 _fadeTime;
185 f32 _fadeTimeCount;
186#if defined(_WINDOWS) || defined(_XBOX_XS)
187 GxVoiceCallback _callback;
188 IXAudio2SourceVoice* _pXAudio2SourceVoice;
189 X3DAUDIO_EMITTER _x3dAudioEmitter;
190 X3DAUDIO_CONE _x3dAudioCone;
191 X3DAUDIO_DISTANCE_CURVE _x3dAudioDistanceCurve;
192 X3DAUDIO_DISTANCE_CURVE_POINT _x3dAudioDistanceCurvePoint[2];
193 X3DAUDIO_DSP_SETTINGS _x3dAudioDspSettings;
194#endif //_WINDOWS || _XBOX_XS
195
197};
198
199GX_SOUND_NAMESPACE_END()
#define GX_PROHIBIT_CLASS_BASE_REFERENCE(__CLASS__)
GxClassBaseReference継承の禁止宣言(new以外の生成禁止 + コピー禁止)
Definition GxBase.h:244
@ MAX
定義数
@ EFFECT
エフェクト
サウンドリソースクラス
Definition GxResSound.h:18
@ UNIT_SOUND
サウンドユニット
static const s32 LOOP_DEFAULT
デフォルトのループ回数の設定値
Definition GxSysSound.h:84
座標ユニット基礎クラス
Definition GxUnitLocate.h:23
サウンド再生ユニット
Definition GxUnitSound.h:18
GX_FORCE_INLINE void setPan(f32 pan)
パン値を設定
Definition GxUnitSound.h:167
constexpr f32 getPan(void) const
パン値を取得
Definition GxUnitSound.h:165
EFFECT
サウンドエフェクト定義
Definition GxUnitSound.h:86
3次元ベクトル
Definition GxVector.h:245
32bitブーリアン
Definition GxDefine.h:173