Class reference

SoundSmith

Inherits RefCounted

Performs time-stretching and pitch-shifting on raw audio buffers using Soundsmith.

Description

SoundSmith is a low-level audio processing utility which wraps the Soundsmith time-stretching library. It operates on raw interleaved floating-point PCM audio buffers and allows independent control of playback tempo and pitch.

Methods

AudioStreamWAV change_tempo(String path, float tempo, float pitch = 1.0)

Loads an MP3 file, applies time-stretching and pitch-shifting using the Soundsmith engine, and returns a streamable AudioStreamWAV. The `tempo` parameter controls playback speed without affecting pitch. A value of `1.0` preserves the original speed. The `pitch` parameter is a transpose factor. A value of `1.0` preserves pitch, `2.0` raises pitch by one octave, and `0.5` lowers pitch by one octave.

int get_last_channels() const

int get_last_sample_rate() const

PackedFloat32Array process(PackedFloat32Array input)

Processes a block of interleaved audio samples and returns a new buffer containing the time-stretched and pitch-shifted result. The effective playback speed is determined by the ratio of input samples to output samples, as influenced by the current tempo setting. The input buffer must contain 32-bit floating-point PCM data and be interleaved according to the configured channel count.

void reset()

Resets the internal processing state. This should be called when restarting playback or discontinuously changing input streams.

void set_channels(int channels)

Sets the number of audio channels. Input and output buffers are expected to be interleaved according to this channel count.

void set_pitch(float pitch)

Sets the pitch transpose factor. A value of `1.0` leaves pitch unchanged. Values greater than `1.0` raise pitch, while values less than `1.0` lower pitch.

void set_sample_rate(int rate)

Sets the sample rate, in Hz, used by the internal processing engine. Changing the sample rate resets the internal state.

void set_tempo(float tempo)

Sets the tempo multiplier used during processing. This value influences the ratio between input and output buffer sizes during time-stretching. A value of `1.0` preserves the original tempo, values greater than `1.0` speed up playback, and values less than `1.0` slow it down.

Source revision 4f5b14abade2
Connection interrupted. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.