SoX (Sound eXchange) audio processing via Hot Box containers.

Provides format conversion, effects chains, normalization, trimming, and file introspection using sox / soxi in isolated containers.

Input files use hot:// storage URLs; outputs are written to hot://sox/<uuid>/....

Quick Start

info ::sox/info("hot://uploads/track.wav")
tap(info)

out ::sox/convert("hot://uploads/track.wav", {format: "mp3"})
tap(out.url)

// With explicit output path
out ::sox/normalize("hot://uploads/track.wav", {
    level: "-3",
    output: "hot://audio/normalized.wav",
})

Container Requirements

Minimum Size small

Values

DEFAULT_IMAGE

DEFAULT_IMAGE: Str "alpine:3.21"

INSTALL_CMD

INSTALL_CMD: Str "apk add --no-cache sox lame > /dev/null 2>&1"

Functions

audio-trim

fn (input: Str, opts: TrimOpts): Map

Trim audio between start and absolute end times (SoX trim effect).

Returns {url: Str, format: Str}.

Example

clip ::sox/audio-trim("hot://uploads/track.wav", {start: "0:05", end: "0:30"})
clip.url
Container: small

build-audio-trim-args

fn (input-path: Str, output-path: Str, opts: TrimOpts): Vec<Str>

Build sox CLI arguments for trimming with the trim effect.

Example

::sox/build-audio-trim-args("/data/in.wav", "/data/out.wav", ::sox/TrimOpts({start: "0:05", end: "0:30"}))
// ["/data/in.wav", "/data/out.wav", "trim", "0:05", "=0:30"]

build-convert-args

fn (input-path: Str, output-path: Str, opts: ConvertOpts): Vec<Str>

Build sox CLI arguments for format conversion (no effects).

Example

::sox/build-convert-args("/data/in.wav", "/data/out.mp3", ::sox/ConvertOpts({format: "mp3", sample-rate: 44100, channels: 2}))
// ["/data/in.wav", "-r", "44100", "-c", "2", "/data/out.mp3"]

build-effect-args

fn (input-path: Str, output-path: Str, opts: EffectOpts): Vec<Str>

Build sox CLI arguments for effects processing.

Example

::sox/build-effect-args("/data/in.wav", "/data/out.wav", ::sox/EffectOpts({effects: ["reverb", "50", "50"]}))
// ["/data/in.wav", "/data/out.wav", "reverb", "50", "50"]

build-info-args

fn (input-path: Str): Vec<Str>

Build soxi CLI arguments for info extraction.

Example

::sox/build-info-args("/data/in.wav")  // ["/data/in.wav"]

build-normalize-args

fn (input-path: Str, output-path: Str, level: Str?, extra-args: Vec<Str>?): Vec<Str>

Build sox CLI arguments for normalization using gain -n.

Example

::sox/build-normalize-args("/data/in.wav", "/data/out.wav", "-3", null)
// ["/data/in.wav", "/data/out.wav", "gain", "-n", "-3"]

convert

fn (input: Str): Map
fn (input: Str, opts: ConvertOpts): Map

Convert audio to another format (and optional rate / channels).

Returns {url: Str, format: Str} pointing at Hot storage.

Example

out ::sox/convert("hot://uploads/track.wav", {format: "mp3", sample-rate: 44100, channels: 2})
out.url

// With no options the output is WAV
::sox/convert("hot://uploads/track.flac")
Container: small

effect

fn (input: Str, opts: EffectOpts): Map

Run a SoX effects chain on an audio file.

effects is a flat list of tokens, e.g. ["reverb", "50", "50"].

Returns {url: Str, format: Str}.

Example

out ::sox/effect("hot://uploads/track.wav", {effects: ["reverb", "50", "50"], format: "flac"})
out.url

// Tokens chain, so this applies two effects
::sox/effect("hot://uploads/track.wav", {effects: ["highpass", "80", "fade", "t", "1"]})
Container: small

info

fn (input: Str): Map

Read audio file metadata using soxi.

Returns a Map with string keys matching SoX field names (e.g. Channels, Sample Rate, Duration).

Example

details ::sox/info("hot://uploads/track.wav")
details.Channels
get(details, "Sample Rate")
Container: nano

normalize

fn (input: Str): Map
fn (input: Str, opts: NormalizeOpts): Map

Normalize audio levels using SoX gain -n.

Optional level sets headroom (e.g. "-3" for −3 dB relative to full scale).

Returns {url: Str, format: Str}.

Example

out ::sox/normalize("hot://uploads/track.wav")
out.url

// Leave 3 dB of headroom and choose the destination
::sox/normalize("hot://uploads/track.wav", {level: "-3", output: "hot://audio/normalized.wav"})
Container: small

parse-info-output

fn (stdout: Str?): Map

Parse soxi human-readable output into a Map of field names to values.

Example

::sox/parse-info-output("Channels       : 2\nSample Rate    : 44100\nDuration       : 00:00:03.00")
// {Channels: "2", "Sample Rate": "44100", Duration: "00:00:03.00"}

start-audio-trim

fn (input: Str, opts: TrimOpts): Map

Start an audio trim task without awaiting. Returns TaskInfo for use with ::hot::task/await.

Example

task ::sox/start-audio-trim("hot://uploads/track.wav", {start: "0:05", end: "0:30"})
::hot::task/await(task.id)
task.data.output
Container: small

start-convert

fn (input: Str): Map
fn (input: Str, opts: ConvertOpts): Map

Start a convert task without awaiting. Returns TaskInfo for use with ::hot::task/await.

Example

task ::sox/start-convert("hot://uploads/track.wav", {format: "flac"})
task.data.output

done ::hot::task/await(task.id)
done.status
Container: small

start-effect

fn (input: Str, opts: EffectOpts): Map

Start an effect task without awaiting. Returns TaskInfo for use with ::hot::task/await.

Example

task ::sox/start-effect("hot://uploads/track.wav", {effects: ["reverb", "50", "50"]})
::hot::task/await(task.id)
task.data.output
Container: small

start-info

fn (input: Str): Map

Start an info task without awaiting. Returns TaskInfo for use with ::hot::task/await.

Example

task ::sox/start-info("hot://uploads/track.wav")
done ::hot::task/await(task.id)
::sox/parse-info-output(done.stdout)
Container: nano

start-normalize

fn (input: Str): Map
fn (input: Str, opts: NormalizeOpts): Map

Start a normalize task without awaiting. Returns TaskInfo for use with ::hot::task/await.

Example

task ::sox/start-normalize("hot://uploads/track.wav", {level: "-3"})
::hot::task/await(task.id)
task.data.output
Container: small

Types

ConvertOpts

ConvertOpts type {
    format: Str,
    sample-rate: Int?,
    channels: Int?,
    bitrate: Str?,
    extra-args: Vec<Str>?,
    output: Str?,
    image: Str?,
    size: Str?,
    timeout: Int?
}

Options for audio format conversion.

Fields

  • format — Output format / extension, e.g. "wav", "mp3", "flac"
  • sample-rate — Output sample rate in Hz
  • channels — Channel count (1 mono, 2 stereo)
  • bitrate — Passed to SoX -C when set (codec-dependent)
  • output — Output hot:// URL (default: auto-generated)
  • image — Custom Docker image with SoX pre-installed
  • size — Box size override (default: "small")

EffectOpts

EffectOpts type {
    effects: Vec<Str>,
    format: Str?,
    extra-args: Vec<Str>?,
    output: Str?,
    image: Str?,
    size: Str?,
    timeout: Int?
}

Options for SoX effects processing.

Fields

  • effects — Effect tokens, e.g. ["reverb", "50", "50"]
  • format — Output format / extension (default: "wav")
  • output — Output hot:// URL (default: auto-generated)
  • image — Custom Docker image with SoX
  • size — Box size override (default: "small")

NormalizeOpts

NormalizeOpts type {
    level: Str?,
    format: Str?,
    extra-args: Vec<Str>?,
    output: Str?,
    image: Str?,
    size: Str?,
    timeout: Int?
}

Options for peak normalization via the SoX gain effect.

Fields

  • level — Headroom after normalize, e.g. "-3" for −3 dB (with gain -n)
  • format — Output format / extension (default: "wav")
  • output — Output hot:// URL (default: auto-generated)
  • image — Custom Docker image with SoX
  • size — Box size override (default: "small")

TrimOpts

TrimOpts type {
    start: Str,
    end: Str,
    format: Str?,
    extra-args: Vec<Str>?,
    output: Str?,
    image: Str?,
    size: Str?,
    timeout: Int?
}

Options for trimming audio to a time range (trim effect).

Fields

  • start — Start time, e.g. "0:00"
  • end — Absolute stop time, e.g. "0:30" (passed as =end to SoX)
  • format — Output format / extension (default: "wav")
  • output — Output hot:// URL (default: auto-generated)
  • image — Custom Docker image with SoX
  • size — Box size override (default: "small")