Options
All
  • Public
  • Public/Protected
  • All
Menu

FluidAudioFile is a non-destructive reference to static audio asset. Think of it like an "Item" in Reaper or an "Audio Clip" in Tracktion Waveform.

It is unusual that you use FluidAudioFile directly. More often you will create and interact with the fluid.techniques.AudioFile derived class. Note that unlike the technique version, FluidAudioFile does not have a .use method so a FluidAudioFile instance is not a Technique, and cannot be used in a technique library.

However, most of the methods for manipulating audio files on the timeline are defined in this class, so the documentation here is likely to be informative.

Hierarchy

Index

Constructors

constructor

Properties

durationSeconds

durationSeconds: number = 1

durationSeconds specifies the length of the playback event measured on the main timeline. To calculate where in the source audio file playback ends, use .getEndInSourceSeconds().

fadeInSeconds

fadeInSeconds: number = 0

Fade in time in seconds

fadeOutSeconds

fadeOutSeconds: number = 0

Fade out time in seconds

gainDb

gainDb: number = 0

Gain in dBFS applied to the sample. 0 is unity gain

info

info: AudioFileInfo = {}

Information and metadata pertaining to the source audio file

markers

markers: Map<string, number> = ...

Named events within the source file

mode

mode: AudioFileMode = ...

Audio file playback mode. See AudioFileMode

pan

pan: number = 0

Stereo pan as bipolar number form -1 to 1

path

path: string = ''

path to the underlying audio file

pitchSemitones

pitchSemitones: number = 0

Adjust the pitch of the sample in semitones.cents

playbackRate

playbackRate: number = 1

startInSourceSeconds

startInSourceSeconds: number = 0

startInSourceSeconds specifies the beginning of the region of interest within the audio source file. Set this to zero to play from the beginning. This measures the start point within the source material, assuming a 1x .playbackRate (even when this.playbackRate != 1). Notice that you cannot use startInSourceSeconds + durationSeconds to calculate the "endInSourceSeconds".

To calculate the position in the source audio file that playback ends, use .getEndInSourceSeconds(), which correctly accounts for the value of .playbackRate.

startTimeSeconds

startTimeSeconds: number = 0

The time within the parent (track) that this sample will be triggered

Static Modes

Modes: typeof AudioFileMode = ...

Methods

check

  • check(): null | string
  • Check the AudioFile for potential problems. If problems are found, return an error message string. Otherwise, return null

    Returns null | string

getEndInSourceSeconds

  • getEndInSourceSeconds(): number
  • Identify where within the source file playback will end, given the values of .startInSourceSeconds, .durationSeconds, and .playbackRate.

    Returns number

getMaxDurationSeconds

  • getMaxDurationSeconds(): number
  • Calculate and return the maximum valid value for .durationSeconds.

    Setting the .durationSeconds value to the value returned by this function will result in the underlying audio file being played to the end of the underlying audio source object (or to the beginning, if .playbackRate is negative.

    audioFile.durationSeconds = audioFile.getMaxDurationSeconds()
    

    When the file is NOT reversed, the source file length is used, so make sure that audioFile.info.duration exists.

    Returns number

getSourceDurationSeconds

  • getSourceDurationSeconds(): number
  • Return the length of the source audio file in seconds. If the length is not included in .info, print a WARNING message, and return an arbitrary value.

    Returns number

getSourcePlaybackSeconds

  • getSourcePlaybackSeconds(): number
  • Return the length of the source audio file given the current .playbackRate. This will be the maximum length of the event, assuming the value of .startInSource does not trim the fileEvent.

    Returns number

getTailLeftSeconds

  • getTailLeftSeconds(): number
  • The "left tail" is the source content that gets trimmed during playback when (for example), the .startInSourceSeconds offsets the beginning of the playback within the underlying source audio file.

    If the .startInSourceSeconds property is 1, then the "left tail" will also be 1 (assuming .playbackRate == 1).

    This method will calculate the duration of the lead-in tail correctly even when audio is playing in reverse (because of a negative .playbackRate)

    Note that there is an inverse relationship between the absolute value of .playbackRate and the tail length, because slowing the playback rate of the source file effectively increases the length of the underlying sample.

    Returns number

    A duration (measured in seconds on the timeline) of the lead-in tail of this audio item.

getTailRightSeconds

  • getTailRightSeconds(): number
  • The "right tail" is the source content that gets truncated during playback when (for example), the .durationSeconds ends playback before the end of the underlying source audio file.

    If source audio file duration is 5 seconds, and the .durationSeconds property is 4 seconds, then the "right tail" will be 1 second (assuming .playbackRate == 1 and .startInSourceSeconds == 0).

    This method will calculate the duration of the trailing tail even when audio is playing in reverse (because of a negative .playbackRate or when .startInSourceSeconds != 0).

    Note that there is an inverse relationship between the absolute value of .playbackRate and the tail length, because slowing the playback rate of the source file effectively increases the length of the underlying sample.

    Returns number

    A duration (measured in seconds on the timeline) of the trailing tail of this audio item.

growLeftEdgeBySeconds

  • Move the left edge of the item without moving the contents of the item on the timeline.

    Parameters

    • seconds: number

      Positive values make the item longer by moving the left edge to the left. Negative values make the item shorter by moving the left edge to the right. This value is be measured on the timeline, and not in the audiofile source (an important distinction when this.playbackRate != 1).

    Returns FluidAudioFile

growLeftEdgeBySecondsSafe

growRightEdgeBySeconds

  • Move the right edge of the item without moving the contents of the item on the timeline.

    Parameters

    • seconds: number

      Positive values make the item longer by moving the right edge to the right. Negative values make the item shorter by moving the right edge to the left. This value is be measured on the timeline, and not in the audiofile source (an important distinction when this.playbackRate != 1).

    Returns FluidAudioFile

growRightEdgeBySecondsSafe

isReversed

  • isReversed(): boolean

playToEnd

  • Set the event's .durationSeconds so that it plays right up to the end of the source. This takes into account .playbackRate, .isReversed(), and .startInSourceSeconds.

    Returns FluidAudioFile

reverse

setMarkers

  • setMarkers(markers: Map<string, number> | {}): void
  • Convenience method for setting audio file markers

    Parameters

    • markers: Map<string, number> | {}

    Returns void

setPlaybackRate

  • Set playbackRate for the clip, stretching the duration proportionally. A negative value will result in a reversed clip, where a positive value will result in a non-reversed clip. If playbackRate causes the playback direction to change, .startInSource will also be updated so as to maintain the playback region within the source audio file.

    Note that cybr only accepts values in [-10, -0.02] and [0.02 to 10].

    Parameters

    • playbackRate: number = 1

    Returns FluidAudioFile