Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Sample Rate to 32000 hz #4780

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

sonicdcer
Copy link

@sonicdcer sonicdcer commented Jan 1, 2025

This change fixes Vibrato and Portamento issues with the port.

Build Artifacts

Comment on lines 536 to 545
#if 0
// Values for 44100 hz
#define SAMPLES_HIGH 752
#define SAMPLES_LOW 720
#else
// Values for 32000 hz
#define SAMPLES_HIGH 560
#define SAMPLES_LOW 528

#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of this can we just change

        //AudioMgr_ThreadEntry(&gAudioMgr);
        // 528 and 544 relate to 60 fps at 32 kHz 32000/60 = 533.333..
        // in an ideal world, one third of the calls should use num_samples=544 and two thirds num_samples=528
        //#define SAMPLES_HIGH 560
        //#define SAMPLES_LOW 528
        // PAL values
        //#define SAMPLES_HIGH 656
        //#define SAMPLES_LOW 624

        // 44KHZ values
        #if 0
        // Values for 44100 hz
        #define SAMPLES_HIGH 752
        #define SAMPLES_LOW 720
        #else
        // Values for 32000 hz
        #define SAMPLES_HIGH 560
        #define SAMPLES_LOW 528

        #endif

to

        //AudioMgr_ThreadEntry(&gAudioMgr);
        // 528 and 544 relate to 60 fps at 32 kHz 32000/60 = 533.333..
        // in an ideal world, one third of the calls should use num_samples=544 and two thirds num_samples=528
        #define SAMPLES_HIGH 560
        #define SAMPLES_LOW 528

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you willing to lose values for 44100? You don't rather have this for quick change and testing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the experience we've had so far with 44k, I doubt we'll go back, but if we do, we can look for this PR to see the differences.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree with @Malkierian. if someone wants to try to get 44.1k working again they can check the git blame and find them

@@ -354,7 +354,7 @@ OTRGlobals::OTRGlobals() {
overlay->LoadFont("Fipps", 32.0f, "fonts/Fipps-Regular.otf");
overlay->SetCurrentFont(CVarGetString(CVAR_GAME_OVERLAY_FONT, "Press Start 2P"));

context->InitAudio({ .SampleRate = 44100, .SampleLength = 1024, .DesiredBuffered = 2480 });
context->InitAudio({ .SampleRate = 32000, .SampleLength = 1024, .DesiredBuffered = 2480 });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like DesiredBuffered was changed for 44.1k here

		int SDLAudioPlayer::GetDesiredBuffered(void) {
-            return 1680;
+            return 2480;
		}

interestingly, it seems SampleLength was already 1024 before the switch to 44.1k

i also am not sure where these values are coming from:
32000/1680 = 19.047619048
44100/2480 = 17.782258065

@Kenix3 @NEstelami any ideas?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find that. Where is it?

Copy link
Contributor

@briaguya-ai briaguya-ai Jan 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int SDLAudioPlayer::GetDesiredBuffered(void) {
return 1680;
}

vs

int SDLAudioPlayer::GetDesiredBuffered(void) {
return 2480;
}

and

int WasapiAudioPlayer::GetDesiredBuffered(void) {
return 1680;
}

vs

int WasapiAudioPlayer::GetDesiredBuffered(void) {
return 2480;
}

Copy link
Contributor

@briaguya-ai briaguya-ai Jan 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for sample length, it's used here in LUS (but i don't see it being used in wasapi)

but it was hardcoded to 1024 at the beginning of the repo being public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants