remix()

audresample.remix(signal, channels=None, mixdown=False, *, upmix=None, always_copy=False)[source]

Remix a signal.

The channels arguments allows to select one or more channels and/or re-order them. Examples:

channels

result

None

all channels

0

first channel

1

second channel

-1

last channel

-2

second last channel

[0, 1]

first two channels

[1, 0]

first two channels in swapped order

[0, -1]

first and last channel

[1, 1]

twice the second channel

range(3)

first three channels

If the input signal has not enough channels to fulfill the channels selection you can select an upmix method to fill in the missing channels. The workflow of audresample.remix() is always upmix -> channel selection -> downmix.

The returned signal always of shape (channels, samples).

Parameters
  • signal (ndarray) – array with signal values

  • channels (Union[int, Sequence[int], None]) – channel selection, see description

  • mixdown (bool) – apply mono mix-down on selection

  • upmix (Optional[str]) – if 'zeros' it will pad missing channels with zeros, if 'repeat' it will pad by repeating the existing channels

  • always_copy (bool) – if True always returns a new object

Return type

ndarray

Returns

remixed signal with shape (number of channels, number of samples)

Raises
  • RuntimeError – if input signal has more than two dimensions

  • ValueError – if channel selection is invalid and upmix is None

  • ValueError – if specified upmix method is not known