Skip to content

antonvasin/juce_libsamplerate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

juce_libsamplerate

JUCE wrapper for libsamplerate aka Secret Rabbit Code. Provides SRCAudioSource class as an alternative for juce::ResamplingAudioSource.

Usage

#include "juce_libsamplerate/juce_libsamplerate.h"

auto resampler = std::make_unique<SRCAudioSource> (
    inputSource,
    /* deleteInputWhenDeleted = */ true,
    /* numChannels            = */ 2,
    /* quality                = */ SRCQuality::MediumSinc);

// samplesInPerOutputSample: 1.0 = passthrough, >1.0 = speed up, <1.0 = slow down
resampler->setResamplingRatio (2.0);

resampler->prepareToPlay (512, 48000.0);
// ... use it as a normal juce::AudioSource  ...

Internal buffer is preallocated and its size is capped by MaxRatio = 32.0 which avoids resizing during playback but may limit some use cases.

Quality presets

SRCQuality libsamplerate converter
BestSinc SRC_SINC_BEST_QUALITY
MediumSinc SRC_SINC_MEDIUM_QUALITY
FastestSinc SRC_SINC_FASTEST
ZeroOrder SRC_ZERO_ORDER_HOLD
Linear SRC_LINEAR

See the libsamplerate docs for more info.

Installation

libsamplerate is not bundled with the module and must be added by the user.

Git Submodule

git submodule add https://github.com/libsndfile/libsamplerate.git vendor/libsamplerate
git submodule add https://github.com/antonvasin/juce_libsamplerate.git modules/libsamplerate
git submodule update --init

Then add libsamplerate and juce_libsamplerate to your CMake project:

add_subdirectory(vendor/libsamplerate)
juce_add_module(modules/juce_libsamplerate)
target_link_libraries(juce_libsamplerate INTERFACE SampleRate::samplerate)
target_link_libraries(MyPlugin PRIVATE juce_libsamplerate)

CPM

include(CPM)
CPMAddPackage(
    NAME libsamplerate
    GITHUB_REPOSITORY libsndfile/libsamplerate
    GIT_TAG 0.2.2
)

CPMAddPackage(
    NAME juce_libsamplerate
    GITHUB_REPOSITORY antonvasin/juce_libsamplerate
    SOURCE_DIR modules/juce_libsamplerate
)

juce_add_module(modules/juce_libsamplerate)
target_link_libraries(juce_libsamplerate INTERFACE SampleRate::samplerate)
target_link_libraries(MyPlugin PRIVATE juce_libsamplerate)

Requirements

  • JUCE 7 or newer (depends on juce_audio_formats).
  • libsamplerate 0.2.x.
  • A C++20 compiler

About

JUCE wrapper for libsamplerate

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages