Skip to main content

format

format(
@sr -1
@duration -1
@timeunit 0
@numchannels -1
@resample 1
@resamplingfiltersize 11
@resamplingmode 'sinc'
@channelmodedown 3
@channelmodeup 3
) -> llll

Generates an audio process operation for basic buffer formatting, such as changing the number of channels, duration and sample rate.


Arguments

  • @sr [int]: Sample rate for the buffer. Use -1 to keep sample rate or 0 to use bellplay~'s global sample rate. (default: -1).
  • @duration [int/float]: Target duration, based on @timeunit. Use -1 to keep buffer duration. (default: -1).
  • @timeunit [int]: Time unit for @duration. (default: 0).
    • 0: Milliseconds
    • 1: Samples
    • 2: Duration ratio
    • 3: Milliseconds difference
    • 4: Samples difference
  • @numchannels [int/float]: Target duration, based on @timeunit. Use -1 to keep buffer duration. (default: -1).
  • @resample [int]: Resample buffer when @sr is different. (default: 1).
    • 0: Off
    • 1: On
  • @resamplingfiltersize [int]: Resampling filter size. (default: 11).
  • @resamplingmode [symbol]: Resampling mode. (default: 'sinc').
    • 'sinc'
    • 'nearest neighbor'
    • 'sample and hold'
    • 'linear'
    • 'quad'
    • 'cubic'
  • @channelmodedown [int]: Channel conversion mode while downmixing (default: 3).
    • 0: Delete all samples
    • 1: Only keep existing channels
    • 2: Pad last channel
    • 3: Cyclic repetition of channels while upmixing.
    • 4: Palindrome cycling of channels while upmixing.
    • 5: Pan channels to new configuration
  • @channelmodeup [int]: Channel conversion mode while upmixing (default: 3).
    • 0: Delete all samples
    • 1: Only keep existing channels
    • 2: Pad last channel
    • 3: Cyclic repetition of channels while upmixing.
    • 4: Palindrome cycling of channels while upmixing.
    • 5: Pan channels to new configuration

Output

Format operation [llll]


Usage

format is meant to be used with the process function:

$buffer = importaudio('singing.wav'); ## input buffer
$op = format(); ## processing operation
$buffer = $buffer.process($op); ## apply processing
$buffer.view('after format process')