mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-28 14:33:37 +00:00
TU19: merge Minecraft.Client/Platform/Common/Audio
This commit is contained in:
parent
da3d403b29
commit
d6bdbb39ae
|
|
@ -23,3 +23,41 @@ void ConsoleSoundEngine::SetIsPlayingEndMusic(bool bVal) {
|
|||
void ConsoleSoundEngine::SetIsPlayingNetherMusic(bool bVal) {
|
||||
m_bIsPlayingNetherMusic = bVal;
|
||||
}
|
||||
|
||||
void ConsoleSoundEngine::tick() {
|
||||
if (scheduledSounds.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (AUTO_VAR(it, scheduledSounds.begin()); it != scheduledSounds.end();) {
|
||||
SoundEngine::ScheduledSound* next = *it;
|
||||
next->delay--;
|
||||
|
||||
if (next->delay <= 0) {
|
||||
play(next->iSound, next->x, next->y, next->z, next->volume,
|
||||
next->pitch);
|
||||
it = scheduledSounds.erase(it);
|
||||
delete next;
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleSoundEngine::schedule(int iSound, float x, float y, float z,
|
||||
float volume, float pitch, int delayTicks) {
|
||||
scheduledSounds.push_back(new SoundEngine::ScheduledSound(
|
||||
iSound, x, y, z, volume, pitch, delayTicks));
|
||||
}
|
||||
|
||||
ConsoleSoundEngine::ScheduledSound::ScheduledSound(int iSound, float x, float y,
|
||||
float z, float volume,
|
||||
float pitch, int delay) {
|
||||
this->iSound = iSound;
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->z = z;
|
||||
this->volume = volume;
|
||||
this->pitch = pitch;
|
||||
this->delay = delay;
|
||||
}
|
||||
|
|
@ -77,6 +77,26 @@ public:
|
|||
static const WCHAR* wchSoundNames[eSoundType_MAX];
|
||||
static const WCHAR* wchUISoundNames[eSFX_MAX];
|
||||
|
||||
public:
|
||||
void tick();
|
||||
void schedule(int iSound, float x, float y, float z, float volume,
|
||||
float pitch, int delayTicks);
|
||||
|
||||
private:
|
||||
class ScheduledSound {
|
||||
public:
|
||||
int iSound;
|
||||
float x, y, z;
|
||||
float volume, pitch;
|
||||
int delay;
|
||||
|
||||
public:
|
||||
ScheduledSound(int iSound, float x, float y, float z, float volume,
|
||||
float pitch, int delay);
|
||||
};
|
||||
|
||||
std::vector<ScheduledSound*> scheduledSounds;
|
||||
|
||||
private:
|
||||
// platform specific functions
|
||||
|
||||
|
|
|
|||
|
|
@ -202,8 +202,8 @@ void SoundEngine::init(Options* pOptions) {
|
|||
// Create a driver to render our audio - 44khz, 16 bit,
|
||||
#ifdef __PS3__
|
||||
// On the Sony PS3, the driver is always opened in 48 kHz, 32-bit floating
|
||||
//point. The only meaningful configurations are MSS_MC_STEREO,
|
||||
//MSS_MC_51_DISCRETE, and MSS_MC_71_DISCRETE.
|
||||
// point. The only meaningful configurations are MSS_MC_STEREO,
|
||||
// MSS_MC_51_DISCRETE, and MSS_MC_71_DISCRETE.
|
||||
m_hDriver = AIL_open_digital_driver(48000, 16, iNumberOfChannels,
|
||||
AIL_OPEN_DIGITAL_USE_SPU0);
|
||||
#elif defined __PSVITA__
|
||||
|
|
@ -479,6 +479,12 @@ void SoundEngine::updateMiles() {
|
|||
case eSoundType_MOB_ENDERDRAGON_HIT:
|
||||
distanceScaler = 100.0f;
|
||||
break;
|
||||
case eSoundType_FIREWORKS_BLAST:
|
||||
case eSoundType_FIREWORKS_BLAST_FAR:
|
||||
case eSoundType_FIREWORKS_LARGE_BLAST:
|
||||
case eSoundType_FIREWORKS_LARGE_BLAST_FAR:
|
||||
distanceScaler = 100.0f;
|
||||
break;
|
||||
case eSoundType_MOB_GHAST_MOAN:
|
||||
case eSoundType_MOB_GHAST_SCREAM:
|
||||
case eSoundType_MOB_GHAST_DEATH:
|
||||
|
|
@ -631,6 +637,7 @@ static S32 running = AIL_ms_count();
|
|||
#endif
|
||||
|
||||
void SoundEngine::tick(std::shared_ptr<Mob>* players, float a) {
|
||||
ConsoleSoundEngine::tick();
|
||||
#ifdef __DISABLE_MILES__
|
||||
return;
|
||||
#endif
|
||||
|
|
@ -1103,6 +1110,12 @@ int SoundEngine::OpenStreamThreadProc(void* lpParameter) {
|
|||
SoundEngine* soundEngine = (SoundEngine*)lpParameter;
|
||||
soundEngine->m_hStream =
|
||||
AIL_open_stream(soundEngine->m_hDriver, soundEngine->m_szStreamName, 0);
|
||||
|
||||
if (soundEngine->m_hStream == 0) {
|
||||
app.DebugPrintf(
|
||||
"SoundEngine::OpenStreamThreadProc - Could not open - %s\n",
|
||||
soundEngine->m_szStreamName);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1204,8 +1217,13 @@ void SoundEngine::playMusicUpdate() {
|
|||
char szName[255];
|
||||
wcstombs(szName, wstrSoundName.c_str(), 255);
|
||||
|
||||
#if defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
std::string strFile =
|
||||
"TPACK:\\Data\\" + string(szName) + ".binka";
|
||||
"TPACK:/Data/" + std::string(szName) + ".binka";
|
||||
#else
|
||||
std::string strFile =
|
||||
"TPACK:\\Data\\" + std::string(szName) + ".binka";
|
||||
#endif
|
||||
std::string mountedPath =
|
||||
StorageManager.GetMountedPath(strFile);
|
||||
strcpy(m_szStreamName, mountedPath.c_str());
|
||||
|
|
@ -1296,8 +1314,10 @@ void SoundEngine::playMusicUpdate() {
|
|||
}
|
||||
|
||||
// std::wstring name =
|
||||
// m_szStreamFileA[m_musicID]; char *SoundName = (char
|
||||
// *)ConvertSoundPathToName(name); strcat((char
|
||||
// m_szStreamFileA[m_musicID]; char *SoundName
|
||||
// = (char
|
||||
// *)ConvertSoundPathToName(name);
|
||||
// strcat((char
|
||||
// *)szStreamName,SoundName);
|
||||
|
||||
app.DebugPrintf("Starting streaming - %s\n", m_szStreamName);
|
||||
|
|
|
|||
|
|
@ -150,6 +150,82 @@ const WCHAR* ConsoleSoundEngine::wchSoundNames[eSoundType_MAX] = {
|
|||
L"dig.snow", // eSoundType_DIG_SNOW
|
||||
L"dig.stone", // eSoundType_DIG_STONE
|
||||
L"dig.wood", // eSoundType_DIG_WOOD
|
||||
|
||||
// 1.6.4
|
||||
L"fireworks.launch", // eSoundType_FIREWORKS_LAUNCH,
|
||||
L"fireworks.blast", // eSoundType_FIREWORKS_BLAST,
|
||||
L"fireworks.blast_far", // eSoundType_FIREWORKS_BLAST_FAR,
|
||||
L"fireworks.large_blast", // eSoundType_FIREWORKS_LARGE_BLAST,
|
||||
L"fireworks.large_blast_far", // eSoundType_FIREWORKS_LARGE_BLAST_FAR,
|
||||
L"fireworks.twinkle", // eSoundType_FIREWORKS_TWINKLE,
|
||||
L"fireworks.twinkle_far", // eSoundType_FIREWORKS_TWINKLE_FAR,
|
||||
|
||||
L"mob.bat.idle", // eSoundType_MOB_BAT_IDLE,
|
||||
L"mob.bat.hurt", // eSoundType_MOB_BAT_HURT,
|
||||
L"mob.bat.death", // eSoundType_MOB_BAT_DEATH,
|
||||
L"mob.bat.takeoff", // eSoundType_MOB_BAT_TAKEOFF,
|
||||
|
||||
L"mob.wither.spawn", // eSoundType_MOB_WITHER_SPAWN,
|
||||
L"mob.wither.idle", // eSoundType_MOB_WITHER_IDLE,
|
||||
L"mob.wither.hurt", // eSoundType_MOB_WITHER_HURT,
|
||||
L"mob.wither.death", // eSoundType_MOB_WITHER_DEATH,
|
||||
L"mob.wither.shoot", // eSoundType_MOB_WITHER_SHOOT,
|
||||
|
||||
L"mob.cow.step", // eSoundType_MOB_COW_STEP,
|
||||
L"mob.chicken.step", // eSoundType_MOB_CHICKEN_STEP,
|
||||
L"mob.pig.step", // eSoundType_MOB_PIG_STEP,
|
||||
L"mob.enderman.stare", // eSoundType_MOB_ENDERMAN_STARE,
|
||||
L"mob.enderman.scream", // eSoundType_MOB_ENDERMAN_SCREAM,
|
||||
L"mob.sheep.shear", // eSoundType_MOB_SHEEP_SHEAR,
|
||||
L"mob.sheep.step", // eSoundType_MOB_SHEEP_STEP,
|
||||
L"mob.skeleton.death", // eSoundType_MOB_SKELETON_DEATH,
|
||||
L"mob.skeleton.step", // eSoundType_MOB_SKELETON_STEP,
|
||||
L"mob.spider.step", // eSoundType_MOB_SPIDER_STEP,
|
||||
L"mob.wolf.step", // eSoundType_MOB_WOLF_STEP,
|
||||
L"mob.zombie.step", // eSoundType_MOB_ZOMBIE_STEP,
|
||||
|
||||
L"liquid.swim", // eSoundType_LIQUID_SWIM,
|
||||
|
||||
L"mob.horse.land", // eSoundType_MOB_HORSE_LAND,
|
||||
L"mob.horse.armor", // eSoundType_MOB_HORSE_ARMOR,
|
||||
L"mob.horse.leather", // eSoundType_MOB_HORSE_LEATHER,
|
||||
L"mob.horse.zombie.death", // eSoundType_MOB_HORSE_ZOMBIE_DEATH,
|
||||
L"mob.horse.skeleton.death", // eSoundType_MOB_HORSE_SKELETON_DEATH,
|
||||
L"mob.horse.donkey.death", // eSoundType_MOB_HORSE_DONKEY_DEATH,
|
||||
L"mob.horse.death", // eSoundType_MOB_HORSE_DEATH,
|
||||
L"mob.horse.zombie.hit", // eSoundType_MOB_HORSE_ZOMBIE_HIT,
|
||||
L"mob.horse.skeleton.hit", // eSoundType_MOB_HORSE_SKELETON_HIT,
|
||||
L"mob.horse.donkey.hit", // eSoundType_MOB_HORSE_DONKEY_HIT,
|
||||
L"mob.horse.hit", // eSoundType_MOB_HORSE_HIT,
|
||||
L"mob.horse.zombie.idle", // eSoundType_MOB_HORSE_ZOMBIE_IDLE,
|
||||
L"mob.horse.skeleton.idle", // eSoundType_MOB_HORSE_SKELETON_IDLE,
|
||||
L"mob.horse.donkey.idle", // eSoundType_MOB_HORSE_DONKEY_IDLE,
|
||||
L"mob.horse.idle", // eSoundType_MOB_HORSE_IDLE,
|
||||
L"mob.horse.donkey.angry", // eSoundType_MOB_HORSE_DONKEY_ANGRY,
|
||||
L"mob.horse.angry", // eSoundType_MOB_HORSE_ANGRY,
|
||||
L"mob.horse.gallop", // eSoundType_MOB_HORSE_GALLOP,
|
||||
L"mob.horse.breathe", // eSoundType_MOB_HORSE_BREATHE,
|
||||
L"mob.horse.wood", // eSoundType_MOB_HORSE_WOOD,
|
||||
L"mob.horse.soft", // eSoundType_MOB_HORSE_SOFT,
|
||||
L"mob.horse.jump", // eSoundType_MOB_HORSE_JUMP,
|
||||
|
||||
L"mob.witch.idle", // eSoundType_MOB_WITCH_IDLE, <---
|
||||
// missing
|
||||
L"mob.witch.hurt", // eSoundType_MOB_WITCH_HURT, <---
|
||||
// missing
|
||||
L"mob.witch.death", // eSoundType_MOB_WITCH_DEATH, <---
|
||||
// missing
|
||||
|
||||
L"mob.slime.big", // eSoundType_MOB_SLIME_BIG,
|
||||
L"mob.slime.small", // eSoundType_MOB_SLIME_SMALL,
|
||||
|
||||
L"eating", // eSoundType_EATING <--- missing
|
||||
L"random.levelup", // eSoundType_RANDOM_LEVELUP
|
||||
|
||||
// 4J-PB - Some sounds were updated, but we can't do that for the 360 or we
|
||||
// have to do a new sound bank instead, we'll add the sounds as new ones and
|
||||
// change the code to reference them
|
||||
L"fire.new_ignite",
|
||||
};
|
||||
|
||||
const WCHAR* ConsoleSoundEngine::wchUISoundNames[eSFX_MAX] = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue