ef-audio

Plays an audio file. Renders no visual output.

Set fft-size if you want to pair the element with ef-waveform for visualization.

The playback-rate and fade APIs below require Elements 0.60.34 or later.

Playback speed

Set playback-rate to a number from 0.25 to 4. The default is 1. Audio keeps its pitch during preview and export.

html
<ef-audio
  src="https://assets.editframe.com/muted-guitar.mp3"
  sourcein="2s"
  sourceout="10s"
  playback-rate="2"
></ef-audio>

This plays eight source seconds in four composition seconds. Trims use source time; see the time model for explicit duration behavior.

In JavaScript or React, use the numeric playbackRate property. Invalid HTML attribute values fall back to 1; setting the property outside the finite 0.25–4 range throws a RangeError.

Volume and fades

volume sets the clip's base gain from 0 to 1. For a fade, assign a volumeAtTime function in JavaScript or as a React prop. Its argument is clip-local composition seconds, not source-file seconds. The callback starts at 0 regardless of the source trim or the clip's offset in its parent.

html
<ef-timegroup id="music" duration="8s">
  <ef-audio
    src="https://assets.editframe.com/muted-guitar.mp3"
    duration="8s"
    volume="0.6"
  ></ef-audio>
</ef-timegroup>

<script type="module">
  const root = document.getElementById("music");
  root.initializer = (instance) => {
    const audio = instance.querySelector("ef-audio");
    audio.volumeAtTime = (localTime) => Math.min(localTime, 8 - localTime);
  };
</script>

This fades in over the first second and out over the last second. The callback returns a multiplier applied to volume: results are clamped to 0–1, with nonfinite results treated as 1. Export evaluates the fade for every output audio sample; preview smooths gain changes. Use a deterministic function of local time so seeking and export produce the same fade.

volumeAtTime is a property, not an HTML attribute. ef-video supports the same audio controls.

Attributes

16 of 16

duration

React prop
duration
Type
string
Default
—
Description
How long this element is active (CSS time, e.g. "5s").

fft-decay

React prop
fftDecay
Type
number
Default
8
Description
Decay frames averaged into getFrequencyData (default 8).

fft-gain

React prop
fftGain
Type
number
Default
3
Description
Linear gain applied before frequency analysis (default 3.0).

fft-size

React prop
fftSize
Type
number
Default
128
Description
FFT window size for getFrequencyData/getTimeDomainData (rounded to a power of two, default 128).

file-id

React prop
fileId
Type
string | null
Default
—
Description
Cloud file identifier — resolves to ${apiHost}/api/v1/files/${fileId}, taking priority over src.

interpolate-frequencies

React prop
interpolateFrequencies
Type
boolean
Default
false
Description
Smooths getFrequencyData bins by interpolating between FFT bands instead of nearest-neighbor sampling.

loop

React prop
loop
Type
boolean
Default
false
Description
Loop attribute — when this temporal is a self-driving root under a PlaybackController, the controller wraps back to 0 instead of pausing at duration.

mute

React prop
muted
Type
boolean
Default
false
Description
Mutes this element's audio.

offset

React prop
offset
Type
number
Default
—
Description
Start offset (seconds) within a parallel (fixed/contain/fit) parent timegroup.

playback-rate

React prop
playbackRate
Type
number
Default
1
Description
Source playback rate with preserved audio pitch.

sourcein

React prop
sourcein
Type
string
Default
—
Description
Start time within the source file (CSS time, e.g. "1.5s").

sourceout

React prop
sourceout
Type
string
Default
—
Description
End time within the source file (CSS time, e.g. "1.5s").

src

React prop
src
Type
string
Default
—
Description
URL of the source audio file.

trimend

React prop
trimend
Type
string
Default
—
Description
Trims this much off the end of the source (CSS time).

trimstart

React prop
trimstart
Type
string
Default
—
Description
Trims this much off the start of the source (CSS time).

volume

React prop
volume
Type
number
Default
1
Description
Audio volume (0.0 to 1.0).

Events