audio-cutter
Reactive icon

Audio Cutter

Stable version 1.0.0 (Compatible with OutSystems 11)
Uploaded
 on 2 Sep (14 hours ago)
 by 
0.0
 (0 ratings)
audio-cutter

Audio Cutter

Documentation
1.0.0

Audio Cutter

Overview

Audio Cutter is a reusable OutSystems component for trimming audio files directly in the browser.

The component allows applications to select a portion of an audio file by specifying the start and end positions and export the selected segment as MP3 or WAV.

Audio processing is performed on the client side using browser audio capabilities, without requiring server-side audio processing.


Features

  • Trim audio files using start and end positions.
  • Export trimmed audio as MP3 or WAV.
  • Configure MP3 encoding bitrate.
  • Return the processed audio as Binary Data.
  • Return the duration of the trimmed audio segment.
  • Provide success and error information.
  • Client-side audio processing.
  • Static entities for supported audio formats and MP3 bitrates.
  • Includes a demo application showing how to consume the component.

Getting Started

1. Install the Component

Install Audio Cutter from Forge into your OutSystems environment.

The component exposes the following public Client Action:

CutAudio

Use this action from your application whenever you need to trim an audio file.


2. Prepare the Audio File

The CutAudio action expects the source audio file as Binary Data.

For example, the binary data can come from:

  • An uploaded file
  • A database Binary Data attribute
  • Another OutSystems component
  • An API response
  • Another audio-processing operation

Pass the binary data to:

AudioBinary

CutAudio

The CutAudio Client Action trims the supplied audio file between the specified start and end positions and returns the resulting audio segment.

Inputs

ParameterTypeMandatoryDescription
AudioBinaryBinary DataYesAudio file to be trimmed.
StartSecondsDecimalYesStart position of the audio segment, in seconds.
EndSecondsDecimalYesEnd position of the audio segment, in seconds.
OutputFormatTextYesOutput audio format. Supported values are mp3 and wav.
AudioBitrateIntegerNoMP3 output bitrate in kbps. Defaults to 128 kbps when not specified or when an unsupported value is provided.

Outputs

ParameterTypeDescription
SuccessBooleanIndicates whether the audio processing completed successfully.
ErrorMessageTextContains the error message when processing fails.
CutAudioBinaryBinary DataContains the resulting trimmed audio file.
DurationDecimalDuration of the resulting audio segment in seconds.

Supported Output Formats

The component currently supports two output formats.

MP3

Use:

mp3

MP3 output is encoded using the included LameJS library.

WAV

Use:

wav

WAV output is generated as 16-bit PCM audio.

Recommended Configuration

The component provides the AudioFormat Static Entity containing the supported formats.

LabelValue
MP3mp3
WAVwav

When building a UI, you can use this Static Entity to populate an Output Format dropdown rather than manually creating the values.


MP3 Bitrates

When exporting to MP3, the following bitrates are supported:

LabelValue
64 kbps64
96 kbps96
128 kbps128
160 kbps160
192 kbps192
256 kbps256
320 kbps320

The AudioBitrate Static Entity provides these supported values.

If no bitrate is supplied, the component uses 128 kbps.

Note: Bitrate is applicable only to MP3 output. It does not affect WAV output.


Audio Trimming

The trimming range is defined using:

StartSeconds
EndSeconds

For example:

StartSeconds = 10
EndSeconds   = 30

produces a 20-second audio segment starting at the 10-second position.

The component validates the requested range before processing.

Validation rules

  • StartSeconds cannot be negative.
  • StartSeconds must be less than the source audio duration.
  • EndSeconds must be greater than StartSeconds.
  • If EndSeconds exceeds the source audio duration, it is limited to the audio duration.
  • The selected audio segment must be at least 0.05 seconds.
  • OutputFormat must be mp3 or wav.

If validation or processing fails:

Success = False

and the reason is returned through:

ErrorMessage

Basic Usage Example

A typical implementation can follow this flow:

User selects audio file
        ↓
Convert/Get Binary Data
        ↓
Set StartSeconds
        ↓
Set EndSeconds
        ↓
Select OutputFormat
        ↓
Select AudioBitrate
        ↓
Call CutAudio
        ↓
Check Success
        ↓
Use CutAudioBinary

For example:

AudioBinary   = UploadedAudio
StartSeconds  = 15
EndSeconds    = 45
OutputFormat  = "mp3"
AudioBitrate  = 128

The action returns the selected 30-second segment as Binary Data.


Handling the Result

Always check the Success output after calling CutAudio.

Successful processing

Success = True

The resulting audio is available in:

CutAudioBinary

The duration is available in:

Duration

Failed processing

Success = False

The reason for the failure is available in:

ErrorMessage

A typical implementation can display the error message to the user or use it for application logging.


Working With the Resulting Audio

CutAudioBinary can be used like any other Binary Data in OutSystems.

For example, the application can:

  • Save the file to a database.
  • Send it to another API.
  • Provide it as a download.
  • Use it as the source for an audio player.
  • Pass it to another processing component.

The Audio Cutter component itself does not impose a storage strategy on the consuming application.


Demo Application

The component includes an Audio Cutter Demo application demonstrating the recommended usage pattern.

The demo allows users to:

  1. Select an audio file.
  2. Specify the start time.
  3. Specify the end time.
  4. Select MP3 or WAV output.
  5. Select the MP3 bitrate when applicable.
  6. Trim the audio.
  7. Review the processing result.
  8. Play or download the resulting audio.

The Demo App is intended as a reference implementation for developers integrating the Audio Cutter component into their own applications.


Client-Side Processing

Audio processing is performed in the user's browser.

The component uses browser audio capabilities to:

  1. Decode the source audio.
  2. Extract the requested portion.
  3. Render the selected audio segment.
  4. Encode the result as MP3 or WAV.
  5. Return the resulting file as Binary Data.

Because processing occurs on the client side, the source audio does not need to be uploaded to a server specifically for the trimming operation.

Note: Processing time and memory consumption can vary depending on the source audio size, duration, format, browser, and device capabilities.


MP3 Encoding

MP3 encoding is performed using LameJS, which is included as a component resource and loaded when MP3 output is requested.

WAV output does not require the MP3 encoder.

Therefore:

OutputFormat = MP3
        ↓
LameJS encoder
        ↓
MP3 Binary Data

and:

OutputFormat = WAV
        ↓
WAV PCM encoding
        ↓
WAV Binary Data

Recommended UI Configuration

For applications exposing the component through a user interface, the following controls are recommended:

UI ControlComponent Parameter
File UploadAudioBinary
Number InputStartSeconds
Number InputEndSeconds
DropdownAudioFormat
DropdownAudioBitrate
ButtonCutAudio

For the output format and bitrate dropdowns, the provided Static Entities can be used to populate the available options.


Error Handling

The component does not throw user-facing errors as a substitute for the output parameters.

Instead, processing results can be handled through:

Success
ErrorMessage

Recommended pattern:

Call CutAudio
      ↓
Success?
   ┌──┴──┐
  Yes    No
   ↓      ↓
Use     Display/
result   handle
         ErrorMessage

Limitations

The current version is intentionally focused on core audio trimming functionality.

  • Supported output formats are MP3 and WAV.
  • MP3 bitrate configuration applies only to MP3 output.
  • Audio processing depends on the capabilities of the user's browser and device.
  • Large audio files may require significant browser memory and processing resources.
  • The component currently focuses on trimming rather than advanced audio editing features such as effects, mixing, fading, or multi-track editing.

Version

Version 1.0

The initial version provides core client-side audio trimming functionality with MP3 and WAV export.

Future versions may introduce additional capabilities while maintaining compatibility with the existing CutAudio API where possible.


Support

For issues, questions, feature requests, or improvements, use the Support section of the Audio Cutter Forge component.