Audio: go back to 32 khz to fix issues with portamento.

This commit is contained in:
Sonic Dreamcaster 2024-12-31 05:27:37 -03:00
parent 28e31cfe3d
commit bc1443d624
2 changed files with 46 additions and 44 deletions

View File

@ -144,91 +144,91 @@ ReverbSettings D_800C76A8[] = {
{ 1, 0x30, 0x4FFF, 0, 0 }, { 1, 0x30, 0x4FFF, 0, 0 },
}; };
AudioSpec gAudioSpecs[] = { AudioSpec gAudioSpecs[] = {
/* 0 */ { 44100, 2, 22, ARRAY_COUNT(D_800C74D0), D_800C74D0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, /* 0 */ { 32000, 2, 22, ARRAY_COUNT(D_800C74D0), D_800C74D0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 1 */ /* 1 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C74E0), D_800C74E0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C74E0), D_800C74E0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 2 */ /* 2 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C74F0), D_800C74F0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C74F0), D_800C74F0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 3 */ /* 3 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C7500), D_800C7500, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C7500), D_800C7500, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 4 */ /* 4 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C7510), D_800C7510, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C7510), D_800C7510, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 5 */ /* 5 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C7520), D_800C7520, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C7520), D_800C7520, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 6 */ /* 6 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C7530), D_800C7530, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C7530), D_800C7530, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 7 */ /* 7 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C7540), D_800C7540, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C7540), D_800C7540, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 8 */ /* 8 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C7550), D_800C7550, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C7550), D_800C7550, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 9 */ /* 9 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C7560), D_800C7560, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C7560), D_800C7560, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 10 */ /* 10 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C7570), D_800C7570, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C7570), D_800C7570, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 11 */ /* 11 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C7580), D_800C7580, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C7580), D_800C7580, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 12 */ /* 12 */
{ 44100, 1, 22, ARRAY_COUNT(D_800C7590), D_800C7590, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x2B000, { 32000, 1, 22, ARRAY_COUNT(D_800C7590), D_800C7590, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x2B000,
0x35000 }, 0x35000 },
/* 13 */ /* 13 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C75A0), D_800C75A0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C75A0), D_800C75A0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 14 */ /* 14 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C75B0), D_800C75B0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C75B0), D_800C75B0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 15 */ /* 15 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C75C0), D_800C75C0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C75C0), D_800C75C0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x34000 }, 0x34000 },
/* 16 */ /* 16 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C75D8), D_800C75D8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C75D8), D_800C75D8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 17 */ /* 17 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C75E8), D_800C75E8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C75E8), D_800C75E8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 18 */ /* 18 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C75F8), D_800C75F8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C75F8), D_800C75F8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 19 */ /* 19 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C7608), D_800C7608, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C7608), D_800C7608, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 20 */ /* 20 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C7618), D_800C7618, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C7618), D_800C7618, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
/* 21 */ /* 21 */
{ 44100, 2, 32, ARRAY_COUNT(D_800C7628), D_800C7628, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 32, ARRAY_COUNT(D_800C7628), D_800C7628, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x00000 }, 0x00000 },
/* 22 TITLE */ /* 22 TITLE */
{ 44100, 1, 32, ARRAY_COUNT(D_800C7638), D_800C7638, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 1, 32, ARRAY_COUNT(D_800C7638), D_800C7638, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x00000 }, 0x00000 },
/* 23 OPTION */ /* 23 OPTION */
{ 44100, 1, 32, ARRAY_COUNT(D_800C7648), D_800C7648, 0x7FFF, 0x1200, 0xA000, 0, 0x5B00, 0x1D00, 0, 0x00000, { 32000, 1, 32, ARRAY_COUNT(D_800C7648), D_800C7648, 0x7FFF, 0x1200, 0xA000, 0, 0x5B00, 0x1D00, 0, 0x00000,
0x00000 }, 0x00000 },
/* 24 */ /* 24 */
{ 44100, 1, 22, ARRAY_COUNT(D_800C7658), D_800C7658, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x00000, { 32000, 1, 22, ARRAY_COUNT(D_800C7658), D_800C7658, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x00000,
0x60000 }, 0x60000 },
/* 25 */ /* 25 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C7668), D_800C7668, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C7668), D_800C7668, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x00000 }, 0x00000 },
/* 26 */ /* 26 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C7678), D_800C7678, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C7678), D_800C7678, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x00000 }, 0x00000 },
/* 27 */ /* 27 */
{ 44100, 2, 32, ARRAY_COUNT(D_800C7688), D_800C7688, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 32, ARRAY_COUNT(D_800C7688), D_800C7688, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x00000 }, 0x00000 },
/* 28 */ /* 28 */
{ 44100, 2, 22, ARRAY_COUNT(D_800C74D0), D_800C74D0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, { 32000, 2, 22, ARRAY_COUNT(D_800C74D0), D_800C74D0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 }, 0x35000 },
}; };
s32 D_800C7C28 = 0x20000000; // unused? s32 D_800C7C28 = 0x20000000; // unused?

View File

@ -1,6 +1,7 @@
#include "Engine.h" #include "Engine.h"
#include "ui/ImguiUI.h" #include "ui/ImguiUI.h"
#include "StringHelper.h" #include "StringHelper.h"
#include "libultraship/src/Context.h" #include "libultraship/src/Context.h"
#include "resource/type/ResourceType.h" #include "resource/type/ResourceType.h"
#include "resource/importers/AnimFactory.h" #include "resource/importers/AnimFactory.h"
@ -54,6 +55,7 @@ extern "C" {
float gInterpolationStep = 0.0f; float gInterpolationStep = 0.0f;
#include <sf64thread.h> #include <sf64thread.h>
#include <macros.h> #include <macros.h>
#include "sf64audio_provisional.h"
void AudioThread_CreateNextAudioBuffer(int16_t* samples, uint32_t num_samples); void AudioThread_CreateNextAudioBuffer(int16_t* samples, uint32_t num_samples);
} }
@ -82,11 +84,11 @@ GameEngine::GameEngine() {
} }
} }
this->context = this->context = Ship::Context::CreateUninitializedInstance("Starship", "ship", "starship.cfg.json");
Ship::Context::CreateUninitializedInstance("Starship", "ship", "starship.cfg.json");
this->context->InitConfiguration(); // without this line InitConsoleVariables fails at Config::Reload() this->context->InitConfiguration(); // without this line InitConsoleVariables fails at Config::Reload()
this->context->InitConsoleVariables(); // without this line the controldeck constructor failes in ShipDeviceIndexMappingManager::UpdateControllerNamesFromConfig() this->context->InitConsoleVariables(); // without this line the controldeck constructor failes in
// ShipDeviceIndexMappingManager::UpdateControllerNamesFromConfig()
auto controlDeck = std::make_shared<LUS::ControlDeck>(); auto controlDeck = std::make_shared<LUS::ControlDeck>();
@ -95,9 +97,10 @@ GameEngine::GameEngine() {
auto window = std::make_shared<Fast::Fast3dWindow>(std::vector<std::shared_ptr<Ship::GuiWindow>>({})); auto window = std::make_shared<Fast::Fast3dWindow>(std::vector<std::shared_ptr<Ship::GuiWindow>>({}));
this->context->Init(OTRFiles, {}, 3, { 44100, 1024*2, 2480*2 }, window, controlDeck); this->context->Init(OTRFiles, {}, 3, { 32000, 1024 , 2480 }, window, controlDeck);
Ship::Context::GetInstance()->GetLogger()->set_level((spdlog::level::level_enum)CVarGetInteger("gDeveloperTools.LogLevel", 1)); Ship::Context::GetInstance()->GetLogger()->set_level(
(spdlog::level::level_enum) CVarGetInteger("gDeveloperTools.LogLevel", 1));
Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v"); Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v");
auto loader = context->GetResourceManager()->GetResourceLoader(); auto loader = context->GetResourceManager()->GetResourceLoader();
@ -139,11 +142,12 @@ GameEngine::GameEngine() {
loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryBinaryVertexV0>(), RESOURCE_FORMAT_BINARY, loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryBinaryVertexV0>(), RESOURCE_FORMAT_BINARY,
"Vertex", static_cast<uint32_t>(Fast::ResourceType::Vertex), 0); "Vertex", static_cast<uint32_t>(Fast::ResourceType::Vertex), 0);
loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryXMLVertexV0>(), RESOURCE_FORMAT_XML, loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryXMLVertexV0>(), RESOURCE_FORMAT_XML, "Vertex",
"Vertex", static_cast<uint32_t>(Fast::ResourceType::Vertex), 0); static_cast<uint32_t>(Fast::ResourceType::Vertex), 0);
loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryBinaryDisplayListV0>(), RESOURCE_FORMAT_BINARY, loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryBinaryDisplayListV0>(),
"DisplayList", static_cast<uint32_t>(Fast::ResourceType::DisplayList), 0); RESOURCE_FORMAT_BINARY, "DisplayList",
static_cast<uint32_t>(Fast::ResourceType::DisplayList), 0);
loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryXMLDisplayListV0>(), RESOURCE_FORMAT_XML, loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryXMLDisplayListV0>(), RESOURCE_FORMAT_XML,
"DisplayList", static_cast<uint32_t>(Fast::ResourceType::DisplayList), 0); "DisplayList", static_cast<uint32_t>(Fast::ResourceType::DisplayList), 0);
@ -215,14 +219,14 @@ void GameEngine::StartFrame() const {
this->context->GetWindow()->StartFrame(); this->context->GetWindow()->StartFrame();
} }
#if 1 #if 0
// Values for 44100 hz // Values for 44100 hz
#define SAMPLES_HIGH 752 #define SAMPLES_HIGH 752
#define SAMPLES_LOW 720 #define SAMPLES_LOW 720
#else #else
// Values for 32000 hz // Values for 32000 hz
#define SAMPLES_HIGH 560 #define SAMPLES_HIGH 560
#define SAMPLES_LOW 544 #define SAMPLES_LOW 528
#endif #endif
@ -259,9 +263,7 @@ void GameEngine::HandleAudioThread() {
std::unique_lock<std::mutex> Lock(audio.mutex); std::unique_lock<std::mutex> Lock(audio.mutex);
int samples_left = AudioPlayerBuffered(); int samples_left = AudioPlayerBuffered();
u32 num_audio_samples = samples_left < AudioPlayerGetDesiredBuffered() u32 num_audio_samples = samples_left < AudioPlayerGetDesiredBuffered() ? (((samples_high))) : (((samples_low)));
? (((samples_high ) ) )
: (((samples_low)) );
frames++; frames++;