Options
All
  • Public
  • Public/Protected
  • All
Menu

Insert an audio sample into a track.

Note that base class FluidAudioFile has many useful methods and properties for trimming, fading, reversing, etc.

Hierarchy

Implements

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

finalize

  • Techniques may have a finalize method, which will be invoked in when calling session.finalize() for each unique finalize function that was inserted via session.insertScore(...) since the last call to session.finalize. Note that the when finalize methods are not associated with any particular technique instance, so .this will be undefined inside the finalize method invocation.

    The order that finalizers will be called in is undefined. It's a good idea to make finalizers idempotent because a finalizer may be called more than one if the user does the following:

    1. `session.insertScore(scoreContainingFinalizerTechnique)
    2. `session.finalize()
    3. `session.insertScore(scoreContainingFinalizerTechnique)
    4. session.finalize() // finalizer invoked a second time

    Parameters

    Returns void

getEndInSourceSeconds

  • getEndInSourceSeconds(): 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

getSourcePlaybackSeconds

  • getSourcePlaybackSeconds(): 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

  • growLeftEdgeBySeconds(seconds: number): AudioFile
  • 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 AudioFile

growLeftEdgeBySecondsSafe

  • growLeftEdgeBySecondsSafe(seconds: number): AudioFile

growRightEdgeBySeconds

  • growRightEdgeBySeconds(seconds: number): AudioFile
  • 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 AudioFile

growRightEdgeBySecondsSafe

  • growRightEdgeBySecondsSafe(seconds: number): AudioFile

isReversed

  • isReversed(): boolean

playToEnd

reverse

setMarkers

  • setMarkers(markers: Map<string, number> | {}): void

setPlaybackRate

  • setPlaybackRate(playbackRate?: number): AudioFile
  • 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 AudioFile

use

Static copy

  • Create a copy of an AudioFile technique, optionally applying changes to the copy before returning it. This is useful in situations when you want variations of an audioFile with different properties.

    Note that the value returned will be an AudioFile even if the first argument is an instance of a class derived from AudioFile. As a result, the output object will not be an exact copy if audioFileTechnique is derived from techniques.AudioFile.

    const newAudioFile = AudioFile.copy(someAudioFile)

    Parameters

    • audioFileTechnique: AudioFileOptions | AudioFile

      The input AudioFile technique to copy

    • change: AudioFileConfig = {}

      The resulting AudioFile will

    Returns AudioFile

    A copied version of the input audio file technique