Doubts about handling different sample rates in audio plugin

Hello guys, If I understand correctly, when playing a sound file (like in the AudioSampleBuffer tutorial) I should be sure to resample the file to match the output sample rate for correct playback.

What is the standard way of doing this sample rate conversion? I thought about resampling the data(linear interp maybe) off-line but if the output sample rate changes while the plugin is running, the buffer should be resampled again.
How do audio players handle this kind of stuff? Real-time resampling with linear interpolation?

Really interested to know what is the common aproach when, for example, playing 44100Hz audio with a device output of 48000hz, or what resampling methods are used, etc.
Thanks in advance! And sorry if this is pretty much common knowledge, just don’t want to get into bad practices.

Edit: In case it’s confusing, Im asking about playing audio from a sound file inside the plugin, not taking the input from the host for processing like an audio effect. I guess it’s more like what a sampler plugin would do.

Your thread title talks about plugins. Usually, if your hardware runs at 48kHz and you drop a 44.1kHz audio file onto your daws track, then put a plug-in on that track and start playback, your plugin will receive samples at 48kHz. It‘s the daw‘s responsibility to convert your imported 44.1kHz file to 48kHz if your project settings are at 48kHz and it will most likely render a converted version of it offline in a background process right when you import your audio file.

So your plugin never needs to handle the conversion from a certain input samplerate to a certain output samplerate. That being said there are of course algorithms that upsample the input signal of the plugin, so some processing at higher samplerate and then again do some downsampling to send out a out signal at the same rate as the input rate. Distortion effects do this for an example. But this is done because the DSP algorithm needs it to work but not to match source material samplerate to Hardware samplerate.

As you asked about what algorithms are used for this. The Lagrange interpolator which also comes with juce is a possible algorithm for this. But there might be people out here that can tell you more about resampling algorithms :wink:

You might want to check out this:

Hey thanks for taking the time.
I was talking about audio playback inside of a plugin, like what a classic sampler would do but without having to change the pitch or anything, just audio playback functionality. I supose it’s basically the same procedure as a normal music player but I specify plugin in the title because it may be implemented differently (probably since output sample rate can be changed while the plugin is running or something else I might not know about).
Im going to edit the post to make it more clear!