Skip to main content

trim

trim(
@threshold 0.01
@ampunit 0
@start 1
@end 1
) -> llll

Generates an audio process operation for applying silence-based trimming to a buffer. When the entire buffer is considered silent, the resulting buffer's duration will be a single audio sample.


Arguments

  • @threshold [int/float]: amplitude threshold at/below which samples are considered silence. (default: 0.01).
  • @ampunit [int]: amplitude unit for @threshold. (default: 0).
    • 0: linear
    • 1: decibels
  • @start [int/float]: trim the beginning of the buffer. (default: 1).
    • 0: off
    • 1: on
  • @end [int/float]: trim the end of the buffer. (default: 1).
    • 0: off
    • 1: on

Output

join operation [llll]


Usage

trim is meant to be used with the process function:

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