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

SasAudio: Implement linear interpolation #8950

Merged
merged 8 commits into from
Dec 20, 2016
Merged

Conversation

hrydgard
Copy link
Owner

@hrydgard hrydgard commented Sep 3, 2016

PPSSPP's audio has always been a little bit harsher and brighter than the real thing, because interpolation was missing in the mixer. This implements linear interpolation, which I believe is what the PSP also uses. Higher order interpolation could be implemented but I don't think it'll be very noticable, the big difference is from none to linear.

Currently this is a straightforward unoptimized implemenation. Not sure about the performance impact, but calling ReadSamples with 1 as an argument can't be terribly fast. So should probably restore the resampleBuffer but make sure the results are exactly the same as from this (the old calculation had issues which is why we needed the smoothness "hackery" which has now been removed).

@unknownbrackets
Copy link
Collaborator

unknownbrackets commented Sep 3, 2016

Just a reminder: a previous attempt by me caused pops in certain areas, as reported by some users. May be something to test here. #5509.

IIRC it seemed like the PSP used trilinear.

-[Unknown]

for (int i = delay; i < grainSize; i++) {
while (sampleFrac >= PSP_SAS_PITCH_BASE) {
voice.resampleHist[0] = voice.resampleHist[1];
voice.ReadSamples(&voice.resampleHist[1], 1);
Copy link
Collaborator

@unknownbrackets unknownbrackets Sep 3, 2016

Choose a reason for hiding this comment

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

Hmm, I wonder if this could have a significant impact to VAG decode speed (I know you mentioned this can't be terribly fast)? I guess would need to measure... a good thing it can be on a separate thread now...

-[Unknown]

Copy link
Owner Author

@hrydgard hrydgard Sep 4, 2016

Choose a reason for hiding this comment

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

Actually I think I want to go back to reading many samples at a time, but I wanted to switch to a known good algorithm first, before I try making it more efficient.

@VIRGINKLM
Copy link
Contributor

I've been requesting that feature a looong time ago. Thanx alot. I hope it can be applied to samples that PSP doesn't apply any interpolation either (like voice clips and sfx in GTA/Monster Hunter/KH games). But seriously, linear is the best, no aliasing so no extra metalic harmonics. Very happy.

@hrydgard hrydgard added this to the v1.4.0 milestone Dec 1, 2016
@hrydgard
Copy link
Owner Author

I removed the overhead one verifiable step at a time, and now it's really fast and correct :) Or at least should be. Merge time once the builds pass.

@hrydgard hrydgard merged commit 8222a66 into master Dec 20, 2016
@hrydgard hrydgard deleted the audio-linear-interpolation branch December 20, 2016 22:27
@hrydgard hrydgard changed the title WIP: SasAudio: Implement linear interpolation SasAudio: Implement linear interpolation Dec 20, 2016
@@ -38,6 +38,7 @@ enum {
PSP_SAS_PITCH_MAX = 0x4000,

PSP_SAS_VOL_MAX = 0x1000,
PSP_SAS_MAX_GRAIN = 1024, // VERY conservative! 256 is quite common but don't think I've ever seen bigger.
Copy link
Collaborator

@unknownbrackets unknownbrackets Mar 20, 2017

Choose a reason for hiding this comment

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

__sceSasInit allows grainSize of 2048 at most, any higher values fail with ERROR_SAS_INVALID_GRAIN. But 2048 is allowed.

-[Unknown]

Copy link
Owner Author

Choose a reason for hiding this comment

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

Oh right, that's a pretty compelling argument. I'll change it.

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