the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2class Mob;
3class Options;
4using namespace std;
5#include "..\..\..\Minecraft.World\SoundTypes.h"
6
7#ifdef _XBOX
8extern IXAudio2* g_pXAudio2; // pointer to XAudio2 instance used by QNet and XACT
9extern IXAudio2MasteringVoice* g_pXAudio2MasteringVoice; // pointer to XAudio2 mastering voice
10#endif
11
12class SoundEngine : public ConsoleSoundEngine
13{
14#ifdef _XBOX
15 //static const unsigned char *ucSoundNames[eSoundType_MAX][32];
16 static const int MAX_POLYPHONY = 30; // 4J added
17 static const int MAX_SAME_SOUNDS_PLAYING = 8; // 4J added
18 static IXACT3Engine *m_pXACT3Engine;
19 static X3DAUDIO_HANDLE m_xact3dInstance;
20 static X3DAUDIO_DSP_SETTINGS m_DSPSettings;
21 static X3DAUDIO_EMITTER m_emitter;
22 static X3DAUDIO_LISTENER m_listeners[4];
23 static int m_validListenerCount;
24
25 static X3DAUDIO_DISTANCE_CURVE m_VolumeCurve;
26 static X3DAUDIO_DISTANCE_CURVE_POINT m_VolumeCurvePoints[2];
27
28 static X3DAUDIO_DISTANCE_CURVE m_DragonVolumeCurve;
29 static X3DAUDIO_DISTANCE_CURVE_POINT m_DragonVolumeCurvePoints[2];
30
31 static X3DAUDIO_DISTANCE_CURVE m_VolumeCurveNoDecay;
32 static X3DAUDIO_DISTANCE_CURVE_POINT m_VolumeCurvePointsNoDecay[2];
33
34 static IXACT3WaveBank *m_pWaveBank;
35 static IXACT3WaveBank *m_pWaveBank2;
36 static IXACT3WaveBank *m_pStreamedWaveBank;
37 static IXACT3WaveBank *m_pStreamedWaveBankAdditional;
38 static IXACT3SoundBank *m_pSoundBank;
39 static IXACT3SoundBank *m_pSoundBank2;
40
41 static CRITICAL_SECTION m_CS;
42
43 struct soundInfo
44 {
45 // 4J-PB - adding the cue index so we can limit the number of the same sounds playing (rain)
46 XACTINDEX idx;
47 int iSoundBank;
48 eSOUND_TYPE eSoundID;
49 float x, y, z;
50 float volume;
51 float pitch;
52 IXACT3Cue *pCue;
53 bool updatePos;
54 };
55
56 void update3DPosition( soundInfo *pInfo, bool bPlaceEmitterAtListener = false, bool bIsCDMusic = false);
57 static vector<soundInfo *>currentSounds;
58
59 int noMusicDelay;
60 Random *random;
61
62 // 4J Added
63#endif
64
65#ifdef _XBOX
66 char * m_chMusicName;
67 soundInfo m_MusicInfo;
68
69 XACTINDEX m_musicIDX;
70 bool m_bStreamingMusicReady;
71 bool m_bStreamingWaveBank1Ready;
72 bool m_bStreamingWaveBank2Ready;
73
74 // to handle volume changes
75 XACTCATEGORY m_xactSFX;
76 XACTCATEGORY m_xactMusic;
77#endif
78public:
79 SoundEngine();
80 virtual void destroy();
81 virtual void play(int iSound, float x, float y, float z, float volume, float pitch);
82 virtual void playStreaming(const wstring& name, float x, float y , float z, float volume, float pitch, bool bMusicDelay=true);
83 virtual void playUI(int iSound, float volume, float pitch);
84 virtual void playMusicTick();
85 virtual void updateMusicVolume(float fVal);
86 virtual void updateSystemMusicPlaying(bool isPlaying);
87 virtual void updateSoundEffectVolume(float fVal);
88 virtual void init(Options *);
89 virtual void tick(shared_ptr<Mob> *players, float a); // 4J - updated to take array of local players rather than single one
90 virtual void add(const wstring& name, File *file);
91 virtual void addMusic(const wstring& name, File *file);
92 virtual void addStreaming(const wstring& name, File *file);
93#ifndef __PS3__
94 static void setXACTEngine( IXACT3Engine *pXACT3Engine);
95 void CreateStreamingWavebank(const char *pchName, IXACT3WaveBank **ppStreamedWaveBank);
96 void CreateSoundbank(const char *pchName, IXACT3SoundBank **ppSoundBank);
97
98#endif // __PS3__
99 virtual char *ConvertSoundPathToName(const wstring& name, bool bConvertSpaces=false);
100 bool isStreamingWavebankReady(); // 4J Added
101#ifdef _XBOX
102 bool isStreamingWavebankReady(IXACT3WaveBank *pWaveBank);
103#endif
104 int initAudioHardware(int iMinSpeakers) { return iMinSpeakers;}
105
106private:
107#ifndef __PS3__
108 static void XACTNotificationCallback( const XACT_NOTIFICATION* pNotification );
109#endif // __PS3__
110};