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

Degraded audio fidelity during pitch bends in default XSynth #77

Open
Basiliotornado opened this issue Jul 29, 2024 · 9 comments
Open

Comments

@Basiliotornado
Copy link

image

XSynth.mp4

None of the synth settings seem to help or change anything
The audio was recorded on the linux binary in releases, but it still does this with a freshly compiled one

@arduano
Copy link
Collaborator

arduano commented Jul 30, 2024

I'm not too sure what you mean, maybe @MyBlackMIDIScore understands this better?

Also, just to make sure, does this happen on all soundfonts you tested?

@MyBlackMIDIScore
Copy link
Member

@Basiliotornado Hi, thanks for reporting this.
Would you be able to provide the MIDI and soundfont used?

@Basiliotornado
Copy link
Author

Basiliotornado commented Jul 30, 2024

https://drive.google.com/file/d/1VjYpc6K0s2epxz9wqRsaQXCFU3QPi3aN/view?usp=sharing

I suspect it's something to do with the pitch shifter, based on which notes create the distortion, and it doesn't sound like it's happening with Amethyst Imperial Grand, which seems to have one sample for each key.

I should also mention that the soundfont is native sf2, I converted it to sfz with polyphone.

@arduano
Copy link
Collaborator

arduano commented Jul 31, 2024

Ah yep, depending on the scale of this, that's a known issue. XSynth doesn't do any interpolation when sampling, just nearest neighbor, because of the absolutely massive performance impact we've obeserved that interpolation causes

Instead, it expands the samples when loading the soundfont per key. So each key gets a sample, which is scaled to 4x the output sample rate.

The only thing that breaks here is pitch bends, which would emit a very faint hiss due to nearest neighbor sampling. I'm not sure if we can have a proper fix for this, but I'll wait for @MyBlackMIDIScore's input

@MyBlackMIDIScore
Copy link
Member

I suspect it's something to do with the pitch shifter

Yeah, I just did some testing and it turns out this is what is causing those artifacts. By default XSynth does nearest neighbor interpolation, which is fast but lowers the quality of the audio in cases like this. It does provide an option for linear interpolation though which fixes this issue, but it can be slower in some cases hence why it is not enabled in Wasabi.

Although in the future I do plan to add more settings for XSynth to Wasabi, one of which is the interpolation algorithm. Right now the only way to use linear interpolation in Wasabi is to add this line:

interpolator: xsynth_core::soundfont::Interpolator::Linear,

in src/audio_playback/xsynth.rs after line 105 and build the program yourself.
If you have any more questions, let me know.

@arduano
Copy link
Collaborator

arduano commented Jul 31, 2024

jinx

@arduano
Copy link
Collaborator

arduano commented Jul 31, 2024

I wouldn't necessarily close this issue as it's a real issue with xsynth, I'll rename the title though

And although we have Interpolator::Linear, I don't know how well it's actually hooked up to the voice picker and whether linear is even enough in this context for perfect sound quality, or if we need even smarter interpolation for people who want quality over performance

@arduano arduano changed the title Audio quantization(?) artifact in XSynth on Debian 12 Degraded audio fidelity during pitch bends in default XSynth Jul 31, 2024
@arduano arduano reopened this Jul 31, 2024
@MyBlackMIDIScore
Copy link
Member

In this case (at least in the tests I did) linear interpolation fixes the issue. A "fix" for this would be to use linear by default but this will have quite a performance hit. So I guess what needs to be worked on is the speed of the linear interpolator?

As far as having more interpolation algorithms, this could help in some niche cases, but I think a priority should be to figure out the performance hit of linear int. first

Btw I'll move this issue to XSynth because it's not related to Wasabi

@MyBlackMIDIScore MyBlackMIDIScore transferred this issue from BlackMIDIDevs/wasabi Jul 31, 2024
@Basiliotornado
Copy link
Author

Added the linear interpolation, sounds a ton better!

image

Though comparing performance on versions of septette for the dead princess, the lerp version starts stuttering on the end of 63 million, while no interpolation holds strong through the entirety of 92 million (I drop below 60fps first). So I can see why this is the default.
For Wasabi though, I feel it should be an option somewhere in synth settings. I can go make a feature request there.

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

No branches or pull requests

3 participants