get it to build for linux and add tts logging

This commit is contained in:
briaguya 2023-11-12 05:19:09 -05:00
commit c213e15751
8 changed files with 47 additions and 7 deletions

View file

@ -8,7 +8,7 @@
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#include <float.h> #include <float.h>
#include "overlays\actors\ovl_Boss_Goma\z_boss_goma.h" #include "overlays/actors/ovl_Boss_Goma/z_boss_goma.h"
//Declarations specific to chests. //Declarations specific to chests.
#include "overlays/actors/ovl_En_Box/z_en_box.h" #include "overlays/actors/ovl_En_Box/z_en_box.h"
extern "C" { extern "C" {
@ -22,7 +22,7 @@ extern "C" {
void EnKarebaba_DeadItemDrop(EnKarebaba*, PlayState*); void EnKarebaba_DeadItemDrop(EnKarebaba*, PlayState*);
} }
//Declarations specific to Torches //Declarations specific to Torches
#include "overlays\actors\ovl_Obj_Syokudai\z_obj_syokudai.h" #include "overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h"
//User data for the general helper VA. //User data for the general helper VA.
typedef struct typedef struct
{ {

View file

@ -39,7 +39,7 @@ typedef float f32;
typedef int8_t s8; typedef int8_t s8;
typedef uint8_t u8; typedef uint8_t u8;
//Processing for our custom audio positioning. //Processing for our custom audio positioning.
static float lerp(float x, float y, float z) { static float lerp_aae(float x, float y, float z) {
return (1.0 - z) * x + z * y; return (1.0 - z) * x + z * y;
} }
@ -48,9 +48,9 @@ static float lerp(float x, float y, float z) {
return 0; return 0;
float leftover = ma_volume_db_to_linear(AAE_MAX_DB_REDUCTION); float leftover = ma_volume_db_to_linear(AAE_MAX_DB_REDUCTION);
float normDist = fabs(extras->distToPlayer) / extras->maxDistance; float normDist = fabs(extras->distToPlayer) / extras->maxDistance;
float db = lerp(0, AAE_MAX_DB_REDUCTION, normDist); float db = lerp_aae(0, AAE_MAX_DB_REDUCTION, normDist);
float gain = ma_volume_db_to_linear(db); float gain = ma_volume_db_to_linear(db);
gain -= lerp(0, leftover, normDist); gain -= lerp_aae(0, leftover, normDist);
return gain; return gain;
} }
//Borrow the pan calculation from the game itself. Todo: this is technical debt, so copy/ revise it or something at some point. //Borrow the pan calculation from the game itself. Todo: this is technical debt, so copy/ revise it or something at some point.
@ -148,7 +148,7 @@ void AccessibleAudioEngine::doPrepare(SoundAction& action)
//This should not loop more than twice. //This should not loop more than twice.
uint32_t nextChunk = nFrames; uint32_t nextChunk = nFrames;
ma_pcm_rb_acquire_write(&preparedOutput, &nextChunk, (void**)&chunk);//Might reduce nextChunk if there isn't enough buffer space available to accommodate the request. ma_pcm_rb_acquire_write(&preparedOutput, &nextChunk, (void**)&chunk);//Might reduce nextChunk if there isn't enough buffer space available to accommodate the request.
uint64_t framesRead = 0; ma_uint64 framesRead = 0;
ma_engine_read_pcm_frames(&engine, chunk, nextChunk, &framesRead); ma_engine_read_pcm_frames(&engine, chunk, nextChunk, &framesRead);
//Even if we get fewer frames than expected, we should still submit a full buffer of silence. //Even if we get fewer frames than expected, we should still submit a full buffer of silence.
if (framesRead < nextChunk) if (framesRead < nextChunk)
@ -357,7 +357,7 @@ void AccessibleAudioEngine::postHighPrioritySoundAction(SoundAction& action) {
return; return;
slot->extras.cutoff = action.cutoff; slot->extras.cutoff = action.cutoff;
ma_lpf_config config = ma_lpf_config config =
ma_lpf_config_init(ma_format_f32, AAE_CHANNELS, AAE_SAMPLE_RATE, lerp(0.0, AAE_SAMPLE_RATE / 2, action.cutoff), AAE_LPF_ORDER); ma_lpf_config_init(ma_format_f32, AAE_CHANNELS, AAE_SAMPLE_RATE, lerp_aae(0.0, AAE_SAMPLE_RATE / 2, action.cutoff), AAE_LPF_ORDER);
ma_lpf_reinit(&config, &slot->extras.filter); ma_lpf_reinit(&config, &slot->extras.filter);
} }

View file

@ -5,6 +5,7 @@
#include <thread> #include <thread>
#include <mutex> #include <mutex>
#include <deque> #include <deque>
#include <condition_variable>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <array> #include <array>

View file

@ -2,6 +2,7 @@
#include "z64.h" #include "z64.h"
#include "macros.h" #include "macros.h"
#include "functions.h" #include "functions.h"
#include <cmath>
extern "C" { extern "C" {
s32 func_80839768(PlayState* play, Player* p, Vec3f* arg2, CollisionPoly** arg3, s32* arg4, Vec3f* arg5); s32 func_80839768(PlayState* play, Player* p, Vec3f* arg2, CollisionPoly** arg3, s32* arg4, Vec3f* arg5);
void func_8083E298(CollisionPoly* arg0, Vec3f* arg1, s16* arg2); void func_8083E298(CollisionPoly* arg0, Vec3f* arg1, s16* arg2);

View file

@ -0,0 +1,16 @@
#include "SpeechLogger.h"
#include <libultraship/libultraship.h>
SpeechLogger::SpeechLogger() {
}
void SpeechLogger::Speak(const char* text, const char* language) {
lusprintf(__FILE__, __LINE__, 2, "Spoken Text (%s): %s", language, text);
}
bool SpeechLogger::DoInit() {
return true;
}
void SpeechLogger::DoUninitialize() {
}

View file

@ -0,0 +1,17 @@
#ifndef SOHSpeechLogger_h
#define SOHSpeechLogger_h
#include "SpeechSynthesizer.h"
class SpeechLogger : public SpeechSynthesizer {
public:
SpeechLogger();
void Speak(const char* text, const char* language);
protected:
bool DoInit(void);
void DoUninitialize(void);
};
#endif

View file

@ -36,3 +36,5 @@ class SpeechSynthesizer {
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include "DarwinSpeechSynthesizer.h" #include "DarwinSpeechSynthesizer.h"
#endif #endif
#include "SpeechLogger.h"

View file

@ -1042,6 +1042,9 @@ extern "C" void InitOTR() {
#elif defined(_WIN32) #elif defined(_WIN32)
SpeechSynthesizer::Instance = new SAPISpeechSynthesizer(); SpeechSynthesizer::Instance = new SAPISpeechSynthesizer();
SpeechSynthesizer::Instance->Init(); SpeechSynthesizer::Instance->Init();
#else
SpeechSynthesizer::Instance = new SpeechLogger();
SpeechSynthesizer::Instance->Init();
#endif #endif
clearMtx = (uintptr_t)&gMtxClear; clearMtx = (uintptr_t)&gMtxClear;