mirror of
https://github.com/jmarshall23/CnC_Remastered_Collection.git
synced 2026-08-12 08:00:55 +02:00
OpenAL music works at latest.
This commit is contained in:
+3
-1
@@ -5,4 +5,6 @@
|
||||
#pragma once
|
||||
|
||||
void AudMix_Init(void);
|
||||
const char* GetEffectFileName(int index);
|
||||
const char* GetEffectFileName(int index);
|
||||
const char* GetThemeMusicFileName(int index);
|
||||
void AudMix_PlayMusic(int musicId);
|
||||
@@ -34,6 +34,9 @@ enum AudioBufferType_t {
|
||||
#define MAX_PRECACHE_AUDIO 512
|
||||
|
||||
AudioBuffer_t precacheAudioTable[AUDIO_BUFFER_NUMTYPES][MAX_PRECACHE_AUDIO];
|
||||
AudioBuffer_t musicPrecacheAudioTable[MAX_PRECACHE_AUDIO];
|
||||
|
||||
int currentMusicPlaying = -1;
|
||||
|
||||
struct RIFF_Header {
|
||||
char chunkID[4];
|
||||
@@ -154,6 +157,22 @@ bool AudMix_IsEnabled(void) {
|
||||
return device != NULL && context != NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
AudMix_PlayMusic
|
||||
=============
|
||||
*/
|
||||
void AudMix_PlayMusic(int musicId) {
|
||||
if (currentMusicPlaying != -1) {
|
||||
alSourcei(musicPrecacheAudioTable[currentMusicPlaying].sourceId, AL_LOOPING, 0);
|
||||
alSourceStop(musicPrecacheAudioTable[currentMusicPlaying].sourceId);
|
||||
}
|
||||
|
||||
alSourcei(musicPrecacheAudioTable[musicId].sourceId, AL_LOOPING, 1);
|
||||
alSourcePlay(musicPrecacheAudioTable[musicId].sourceId);
|
||||
currentMusicPlaying = musicId;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
AudMix_Init
|
||||
@@ -191,6 +210,16 @@ void AudMix_Init(void) {
|
||||
}
|
||||
}
|
||||
|
||||
// Precache the music.
|
||||
for (int i = 0; i < THEME_COUNT; i++) {
|
||||
char expandedFilePath[512];
|
||||
|
||||
sprintf(expandedFilePath, "sound/music/%s.wav", GetThemeMusicFileName(i));
|
||||
if (!loadWavFile(expandedFilePath, musicPrecacheAudioTable[i])) {
|
||||
//assert(!"failed to load music!");
|
||||
}
|
||||
}
|
||||
|
||||
alListener3f(AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
@@ -210,6 +239,10 @@ void On_Sound_Effect(int sound_index, int variation, COORDINATE coord, int house
|
||||
// void On_Speech(int speech_index) // MBL 02.06.2020
|
||||
void On_Speech(int speech_index, HouseClass* house)
|
||||
{
|
||||
if (house == NULL) {
|
||||
alSourcePlay(precacheAudioTable[AUDIO_BUFFER_HOUSE_NONE][speech_index].sourceId);
|
||||
}
|
||||
|
||||
// DLLExportClass::On_Speech(PlayerPtr, speech_index); // MBL 02.06.2020
|
||||
//if (house == NULL) {
|
||||
// DLLExportClass::On_Speech(PlayerPtr, speech_index);
|
||||
|
||||
+16
-30
@@ -49,6 +49,7 @@
|
||||
|
||||
#include "function.h"
|
||||
#include "theme.h"
|
||||
#include "AUDIOMIX.H"
|
||||
|
||||
#ifndef WIN32
|
||||
extern short StreamLowImpact;
|
||||
@@ -102,6 +103,9 @@ ThemeClass::ThemeControl ThemeClass::_themes[THEME_COUNT] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
const char* GetThemeMusicFileName(int index) {
|
||||
return ThemeClass::_themes[index].Name;
|
||||
}
|
||||
|
||||
/***********************************************************************************************
|
||||
* ThemeClass::Base_Name -- Fetches the base filename for the theme specified. *
|
||||
@@ -282,33 +286,13 @@ ThemeType ThemeClass::Next_Song(ThemeType theme) const
|
||||
*=============================================================================================*/
|
||||
void ThemeClass::Queue_Song(ThemeType theme)
|
||||
{
|
||||
/*
|
||||
** If there is no score file present, then abort.
|
||||
*/
|
||||
if (!ScoresPresent) return;
|
||||
|
||||
/*
|
||||
** If there is no sound driver or sounds have been specifically
|
||||
** turned off, then abort.
|
||||
*/
|
||||
if (SampleType == 0 || Debug_Quiet) return;
|
||||
|
||||
/*
|
||||
** If the current score volumne is set to silent, then there is no need to play the
|
||||
** specified theme.
|
||||
*/
|
||||
if (Options.ScoreVolume == 0) return;
|
||||
|
||||
/*
|
||||
** If the pending theme is available to be set and the specified theme is valid, then
|
||||
** set the queued theme accordingly.
|
||||
*/
|
||||
if (Pending == THEME_NONE || Pending == THEME_PICK_ANOTHER || theme == THEME_NONE || theme == THEME_QUIET) {
|
||||
Pending = theme;
|
||||
if (Still_Playing()) {
|
||||
Fade_Sample(Current, THEME_DELAY);
|
||||
}
|
||||
}
|
||||
AudMix_PlayMusic(theme);
|
||||
}
|
||||
|
||||
|
||||
@@ -330,15 +314,17 @@ void ThemeClass::Queue_Song(ThemeType theme)
|
||||
*=============================================================================================*/
|
||||
int ThemeClass::Play_Song(ThemeType theme)
|
||||
{
|
||||
if (ScoresPresent && SampleType && !Debug_Quiet && Options.ScoreVolume != 0) {
|
||||
Stop();
|
||||
Score = theme;
|
||||
if (theme != THEME_NONE && theme != THEME_QUIET) {
|
||||
//PG StreamLowImpact = true;
|
||||
Current = File_Stream_Sample_Vol(Theme_File_Name(theme), 0xFF, true);
|
||||
//PG StreamLowImpact = false;
|
||||
}
|
||||
}
|
||||
AudMix_PlayMusic(theme);
|
||||
|
||||
//if (ScoresPresent && SampleType && !Debug_Quiet && Options.ScoreVolume != 0) {
|
||||
// Stop();
|
||||
// Score = theme;
|
||||
// if (theme != THEME_NONE && theme != THEME_QUIET) {
|
||||
// //PG StreamLowImpact = true;
|
||||
// Current = File_Stream_Sample_Vol(Theme_File_Name(theme), 0xFF, true);
|
||||
// //PG StreamLowImpact = false;
|
||||
// }
|
||||
//}
|
||||
return(Current);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
|
||||
class ThemeClass
|
||||
{
|
||||
friend const char* GetThemeMusicFileName(int index);
|
||||
|
||||
private:
|
||||
static char const * Theme_File_Name(ThemeType theme);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user