Skip to content

Module pippi.soundbuffer

None

None

Functions

rebuild_buffer

def rebuild_buffer(
    frames,
    channels,
    samplerate
)

Classes

SoundBuffer

class SoundBuffer(
    /,
    *args,
    **kwargs
)

Class variables

avg
channels
dur
frames
mag
samplerate

Methods

adsr

def adsr(
    self,
    a=0.0,
    d=0.0,
    s=1.0,
    r=0.0
)

blocks

def blocks(
    self,
    blocksize=2048
)

clear

def clear(
    self,
    length=-1
)

Writes zeros into the buffer, adjusting the

size if length > 0.

clip

def clip(
    self,
    minval=-1,
    maxval=1
)

cloud

def cloud(
    self,
    length=-1.0,
    *args,
    **kwargs
)

Create a new Cloud from this SoundBuffer

convolve

def convolve(
    self,
    impulse,
    norm=True
)

copy

def copy(
    self
)

Return a new copy of this SoundBuffer.

cut

def cut(
    self,
    start=0.0,
    length=1.0
)

Copy a portion of this soundbuffer, returning

a new soundbuffer with the selected slice.

This is called cut for historical reasons, but it might be better understood if renamed to slice as it doesn't modify the source SoundBuffer in any way.

The start param is a position in seconds to begin cutting, and the length param is the cut length in seconds.

Overflowing values that exceed the boundries of the source SoundBuffer will return a SoundBuffer padded with silence so that the length param is always respected.

dub

def dub(
    self,
    sounds,
    pos=-1.0,
    framepos=0
)

Dub a sound or iterable of sounds into this soundbuffer

starting at the given position in fractional seconds.

>>> snd.dub(snd2, 3.2)

To dub starting at a specific frame position use:

>>> snd.dub(snd3, framepos=111)

env

def env(
    self,
    window=None
)

Apply an amplitude envelope

to the sound of the given type.

To modulate a sound with an arbitrary iterable, simply do:

>>> snd * iterable

Where iterable is a list, array, or SoundBuffer with the same # of channels and of any length

fcut

def fcut(
    self,
    start=0,
    length=1
)

Copy a portion of this soundbuffer, returning

a new soundbuffer with the selected slice.

Identical to cut except start and length should be given in frames instead of seconds.

fill

def fill(
    self,
    length
)

Truncate the buffer to the given length or

loop the contents of the buffer up to the given length in frames.

grains

def grains(
    self,
    minlength,
    maxlength=-1.0
)

Iterate over the buffer in fixed-size grains.

If a second length is given, iterate in randomly-sized grains, given the minimum and maximum sizes.

graph

def graph(
    self,
    *args,
    **kwargs
)

max

def max(
    self
)

mix

def mix(
    self,
    sounds
)

Mix this sound in place with a sound or iterable of sounds

pad

def pad(
    self,
    start=0.0,
    end=0.0,
    samples=False
)

Pad this sound with silence at start or end

pan

def pan(
    self,
    pos=0.5,
    method=None
)

Pan a stereo sound from pos=0 (hard left) to pos=1 (hard right)

Different panning strategies can be chosen by passing a value to the method param.

  • method='constant' Constant (square) power panning. This is the default.
  • method='linear' Simple linear panning.
  • method='sine' Variation on constant power panning using sin() and cos() to shape the pan. Taken from the floss manuals csound manual.
  • method='gogins' Michael Gogins' variation on the above which uses a different part of the sinewave. Also taken from the floss csound manual!

rcut

def rcut(
    self,
    length=1.0
)

Copy a portion of this SoundBuffer of the

given length in seconds starting from a random position within it.

This will always return a complete SoundBuffer without overflows or added silence, and the entire sound will be returned without added silence if a length that exceeds the length of the source SoundBuffer is given -- unlike SoundBuffer.cut() which will pad results with silence to preserve the length param if an invalid or overflowing offset position is given.

remix

def remix(
    self,
    channels
)

repeat

def repeat(
    self,
    reps=2
)

reverse

def reverse(
    self
)

reversed

def reversed(
    self
)

softclip

def softclip(
    self
)

speed

def speed(
    self,
    speed,
    scheme=0
)

Change the speed of the sound

stretch

def stretch(
    self,
    length,
    position=None,
    amp=1.0
)

Change the length of the sound without changing the pitch.

Uses the csound mincer phase vocoder implementation from soundpipe.

taper

def taper(
    self,
    length
)

toenv

def toenv(
    self,
    window=0.015
)

towavetable

def towavetable(
    self,
    *args,
    **kwargs
)

transpose

def transpose(
    self,
    speed,
    length=None,
    position=None,
    amp=1.0
)

Change the pitch of the sound without changing the length.

Uses the csound mincer phase vocoder implementation from soundpipe.

trim

def trim(
    self,
    start=False,
    end=True,
    threshold=0.0,
    window=4
)

Trim silence below a given threshold from the end (and/or start) of the buffer

vspeed

def vspeed(
    self,
    speed
)

write

def write(
    self,
    filename=None
)

Write the contents of this buffer to disk

in the given audio file format. (WAV, AIFF, AU)