soundfiles.lib

Soundfiles library. Its official prefix is so.

This library provides functions and abstractions to read, write, and manage audio files in Faust. It supports interpolation and looping controls for integration of recorded or pre-rendered audio in synthesis, effects, and compositional contexts.

The Soundfiles library is organized into 1 section:

References

Functions Reference


(so.)loop

Play a soundfile in a loop taking into account its sampling rate. loop is a standard Faust function.

A soundfile sf with C channels has 2 + C outputs (the length and the sampling rate of the part, then the C channels): the player outputs the C channels, si.bus(outputs(sf) - 2).

Usage

loop(sf, part) : si.bus(outputs(sf) - 2)

Where:

  • sf: the soundfile
  • part: the part in the soundfile list of sounds

Test

so = library("soundfiles.lib");
os = library("oscillators.lib");
sf = soundfile("sound[url:{'tests/assets/silence.wav'}]", 1);
loop_test = so.loop(sf, 0) + os.tosc(110) * 0.001;

(so.)loop_speed

Play a soundfile in a loop taking into account its sampling rate, with speed control. loop_speed is a standard Faust function.

A soundfile sf with C channels has 2 + C outputs (the length and the sampling rate of the part, then the C channels): the player outputs the C channels, si.bus(outputs(sf) - 2).

Usage

loop_speed(sf, part, speed) : si.bus(outputs(sf) - 2)

Where:

  • sf: the soundfile
  • part: the part in the soundfile list of sounds
  • speed: the speed between 0 and n

Test

so = library("soundfiles.lib");
os = library("oscillators.lib");
sf = soundfile("sound[url:{'tests/assets/silence.wav'}]", 1);
loop_speed_test = so.loop_speed(sf, 0, hslider("loop_speed:speed", 1, 0, 2, 0.01)) + os.tosc(110) * 0.001;

(so.)loop_speed_level

Play a soundfile in a loop taking into account its sampling rate, with speed and level controls. loop_speed_level is a standard Faust function.

A soundfile sf with C channels has 2 + C outputs (the length and the sampling rate of the part, then the C channels): the player outputs the C channels, si.bus(outputs(sf) - 2).

Usage

loop_speed_level(sf, part, speed, level) : si.bus(outputs(sf) - 2)

Where:

  • sf: the soundfile
  • part: the part in the soundfile list of sounds
  • speed: the speed between 0 and n
  • level: the volume between 0 and n

Test

so = library("soundfiles.lib");
sf = soundfile("sound[url:{'tests/assets/silence.wav'}]", 1);
os = library("oscillators.lib");
loop_speed_level_test = so.loop_speed_level(
    sf,
    0,
    hslider("loop_speed_level:speed", 1, 0, 2, 0.01),
    hslider("loop_speed_level:level", 0.5, 0, 1, 0.01)
) + os.tosc(110) * 0.001;

(so.)sound

Environment to handle a given sound of a soundfile: binds a soundfile primitive and a part number once, and exposes the players as methods (.loop, .loop_speed(speed), .loop_speed_level(speed, level), .play(level, gate), .play_rev(level, gate), .play_interp(ref, freq, level, gate, selector), .play_alt(level, gate, ctrl)) — see the commented example at the end of this file. A soundfile sf with C channels has 2 + C outputs, the players output the C channels, si.bus(outputs(sf) - 2).

Usage

sf = soundfile("[url:{'foo.wav'}]", 2);
sound(sf, part).loop : si.bus(outputs(sf) - 2)

Where:

  • sf: a soundfile primitive
  • part: the part number in the soundfile list

Example

sample = so.sound(soundfile("[url:{'foo.wav'}]", 2), 0);
process = sample.loop;