From af127ca23b32aaf53df9cd177da0d5200a34e0ee Mon Sep 17 00:00:00 2001 From: Patrik Nilsson <113925545+pnn64@users.noreply.github.com> Date: Tue, 27 May 2025 09:47:25 +0200 Subject: [PATCH] Audio: Update default sample rate to 48kHz to mitigate sync issues --- src/RageSound.cpp | 2 +- src/RageSoundManager.cpp | 2 +- src/RageSoundReader_Chain.cpp | 2 +- src/arch/Sound/ALSA9Helpers.cpp | 4 ++-- src/arch/Sound/DSoundHelpers.cpp | 8 ++++---- src/arch/Sound/RageSoundDriver.h | 2 +- src/arch/Sound/RageSoundDriver_AU.mm | 2 +- src/arch/Sound/RageSoundDriver_DSound_Software.cpp | 2 +- src/arch/Sound/RageSoundDriver_Null.cpp | 2 +- src/arch/Sound/RageSoundDriver_OSS.cpp | 2 +- src/arch/Sound/RageSoundDriver_PulseAudio.cpp | 4 ++-- src/arch/Sound/RageSoundDriver_WaveOut.cpp | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/RageSound.cpp b/src/RageSound.cpp index 04d5dfe435..c5d887a9f7 100644 --- a/src/RageSound.cpp +++ b/src/RageSound.cpp @@ -147,7 +147,7 @@ public: int SetPosition( int iFrame ) { return 1; } int Read( float *pBuf, int iFrames ) { return RageSoundReader::END_OF_FILE; } RageSoundReader *Copy() const { return new RageSoundReader_Silence; } - int GetSampleRate() const { return 44100; } + int GetSampleRate() const { return 48000; } unsigned GetNumChannels() const { return 1; } int GetNextSourceFrame() const { return 0; } float GetStreamToSourceRatio() const { return 1.0f; } diff --git a/src/RageSoundManager.cpp b/src/RageSoundManager.cpp index 94ad0914df..331c644994 100644 --- a/src/RageSoundManager.cpp +++ b/src/RageSoundManager.cpp @@ -133,7 +133,7 @@ float RageSoundManager::GetPlayLatency() const int RageSoundManager::GetDriverSampleRate() const { if( m_pDriver == nullptr ) - return 44100; + return 48000; return m_pDriver->GetSampleRate(); } diff --git a/src/RageSoundReader_Chain.cpp b/src/RageSoundReader_Chain.cpp index 1933b30c70..cbbca4134b 100644 --- a/src/RageSoundReader_Chain.cpp +++ b/src/RageSoundReader_Chain.cpp @@ -23,7 +23,7 @@ */ RageSoundReader_Chain::RageSoundReader_Chain() { - m_iPreferredSampleRate = 44100; + m_iPreferredSampleRate = 48000; m_iActualSampleRate = -1; m_iChannels = 0; m_iCurrentFrame = 0; diff --git a/src/arch/Sound/ALSA9Helpers.cpp b/src/arch/Sound/ALSA9Helpers.cpp index 9fc6fc7c1e..007022b211 100644 --- a/src/arch/Sound/ALSA9Helpers.cpp +++ b/src/arch/Sound/ALSA9Helpers.cpp @@ -212,7 +212,7 @@ void Alsa9Buf::GetSoundCardDebugInfo() Alsa9Buf::Alsa9Buf() { - samplerate = 44100; + samplerate = 48000; samplebits = 16; last_cursor_pos = 0; preferred_writeahead = 8192; @@ -229,7 +229,7 @@ RString Alsa9Buf::Init( int channels_, preferred_writeahead = iWriteahead; preferred_chunksize = iChunkSize; if( iSampleRate == 0 ) - samplerate = 44100; + samplerate = 48000; else samplerate = iSampleRate; diff --git a/src/arch/Sound/DSoundHelpers.cpp b/src/arch/Sound/DSoundHelpers.cpp index d365be84f9..441e7d4ac5 100644 --- a/src/arch/Sound/DSoundHelpers.cpp +++ b/src/arch/Sound/DSoundHelpers.cpp @@ -62,7 +62,7 @@ void DSound::SetPrimaryBufferMode() waveformat.wFormatTag = WAVE_FORMAT_PCM; waveformat.wBitsPerSample = 16; waveformat.nChannels = 2; - waveformat.nSamplesPerSec = 44100; + waveformat.nSamplesPerSec = 48000; waveformat.nBlockAlign = 4; waveformat.nAvgBytesPerSec = waveformat.nSamplesPerSec * waveformat.nBlockAlign; @@ -75,8 +75,8 @@ void DSound::SetPrimaryBufferMode() hr = pBuffer->GetFormat( &waveformat, sizeof(waveformat), &got ); if( FAILED(hr) ) LOG->Warn( hr_ssprintf(hr, "GetFormat on primary buffer") ); - else if( waveformat.nSamplesPerSec != 44100 ) - LOG->Warn( "Primary buffer set to %i instead of 44100", waveformat.nSamplesPerSec ); + else if( waveformat.nSamplesPerSec != 48000 ) + LOG->Warn( "Primary buffer set to %i instead of 48000", waveformat.nSamplesPerSec ); /* * MS docs: @@ -197,7 +197,7 @@ RString DSoundBuf::Init( DSound &ds, DSoundBuf::hw hardware, bool bNeedCtrlFrequency = false; if( m_iSampleRate == DYNAMIC_SAMPLERATE ) { - m_iSampleRate = 44100; + m_iSampleRate = 48000; bNeedCtrlFrequency = true; } diff --git a/src/arch/Sound/RageSoundDriver.h b/src/arch/Sound/RageSoundDriver.h index 22309b5948..daa7a9d89c 100644 --- a/src/arch/Sound/RageSoundDriver.h +++ b/src/arch/Sound/RageSoundDriver.h @@ -66,7 +66,7 @@ public: * hearing it. (This isn't necessarily the same as the buffer latency.) */ virtual float GetPlayLatency() const { return 0.0f; } - virtual int GetSampleRate() const { return 44100; } + virtual int GetSampleRate() const { return 48000; } protected: /* Start the decoding. This should be called once the hardware is set up and diff --git a/src/arch/Sound/RageSoundDriver_AU.mm b/src/arch/Sound/RageSoundDriver_AU.mm index 28366266be..1c4d0f41a2 100644 --- a/src/arch/Sound/RageSoundDriver_AU.mm +++ b/src/arch/Sound/RageSoundDriver_AU.mm @@ -151,7 +151,7 @@ RString RageSoundDriver_AU::Init() streamFormat.mBitsPerChannel = kBitsPerChannel; if( streamFormat.mSampleRate <= 0.0 ) - streamFormat.mSampleRate = 44100.0; + streamFormat.mSampleRate = 48000.0; m_iSampleRate = int( streamFormat.mSampleRate ); m_TimeScale = streamFormat.mSampleRate / AudioGetHostClockFrequency(); diff --git a/src/arch/Sound/RageSoundDriver_DSound_Software.cpp b/src/arch/Sound/RageSoundDriver_DSound_Software.cpp index ff7e3cfb22..dbcffefd33 100644 --- a/src/arch/Sound/RageSoundDriver_DSound_Software.cpp +++ b/src/arch/Sound/RageSoundDriver_DSound_Software.cpp @@ -97,7 +97,7 @@ RString RageSoundDriver_DSound_Software::Init() m_pPCM = new DSoundBuf; m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate; if( m_iSampleRate == 0 ) - m_iSampleRate = 44100; + m_iSampleRate = 48000; sError = m_pPCM->Init( ds, DSoundBuf::HW_DONT_CARE, channels, m_iSampleRate, 16, g_iMaxWriteahead ); if( sError != "" ) return sError; diff --git a/src/arch/Sound/RageSoundDriver_Null.cpp b/src/arch/Sound/RageSoundDriver_Null.cpp index f8a7124a58..6c140fff06 100644 --- a/src/arch/Sound/RageSoundDriver_Null.cpp +++ b/src/arch/Sound/RageSoundDriver_Null.cpp @@ -32,7 +32,7 @@ RageSoundDriver_Null::RageSoundDriver_Null() { m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate; if( m_iSampleRate == 0 ) - m_iSampleRate = 44100; + m_iSampleRate = 48000; m_iLastCursorPos = GetPosition(); StartDecodeThread(); } diff --git a/src/arch/Sound/RageSoundDriver_OSS.cpp b/src/arch/Sound/RageSoundDriver_OSS.cpp index 0bec4a5958..95a39f7e90 100644 --- a/src/arch/Sound/RageSoundDriver_OSS.cpp +++ b/src/arch/Sound/RageSoundDriver_OSS.cpp @@ -193,7 +193,7 @@ RString RageSoundDriver_OSS::Init() if(i != channels) return ssprintf( "RageSoundDriver_OSS: Wanted %i channels, got %i instead", channels, i ); - i = 44100; + i = 48000; if(ioctl(fd, SNDCTL_DSP_SPEED, &i) == -1 ) return ssprintf( "RageSoundDriver_OSS: ioctl(SNDCTL_DSP_SPEED, %i): %s", i, strerror(errno) ); samplerate = i; diff --git a/src/arch/Sound/RageSoundDriver_PulseAudio.cpp b/src/arch/Sound/RageSoundDriver_PulseAudio.cpp index d171fae3ca..88d56850a5 100644 --- a/src/arch/Sound/RageSoundDriver_PulseAudio.cpp +++ b/src/arch/Sound/RageSoundDriver_PulseAudio.cpp @@ -29,7 +29,7 @@ m_PulseMainLoop(nullptr), m_PulseCtx(nullptr), m_PulseStream(nullptr) { m_ss.rate = PREFSMAN->m_iSoundPreferredSampleRate; if( m_ss.rate == 0 ) - m_ss.rate = 44100; + m_ss.rate = 48000; } RageSoundDriver_PulseAudio::~RageSoundDriver_PulseAudio() @@ -133,7 +133,7 @@ void RageSoundDriver_PulseAudio::m_InitStream(void) ss.rate = PREFSMAN->m_iSoundPreferredSampleRate; if(ss.rate == 0) { - ss.rate = 44100; + ss.rate = 48000; } /* init channel map */ diff --git a/src/arch/Sound/RageSoundDriver_WaveOut.cpp b/src/arch/Sound/RageSoundDriver_WaveOut.cpp index c40f7b7626..cb1195cc24 100644 --- a/src/arch/Sound/RageSoundDriver_WaveOut.cpp +++ b/src/arch/Sound/RageSoundDriver_WaveOut.cpp @@ -125,7 +125,7 @@ RString RageSoundDriver_WaveOut::Init() b_InitSuccess = false; m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate; if( m_iSampleRate == 0 ) - m_iSampleRate = 44100; + m_iSampleRate = 48000; WAVEFORMATEX fmt; fmt.wFormatTag = WAVE_FORMAT_PCM;