Options
All
  • Public
  • Public/Protected
  • All
Menu

Waveform graphic draw widget.

Hierarchy

  • WaveformGraph

Index

Constructors

constructor

  • Constructor.

    Parameters

    • audioElement: HTMLMediaElement

      Input HTML element with source audio (HTML audio tag).

    • viewElement: HTMLElement

      The HTML element to render the widget.

    • Optional options: IWaveFormGraphOptions

      The widget options.

    Returns WaveformGraph

Properties

Protected Optional audioContext

audioContext: AudioContext

Protected audioElement

audioElement: HTMLMediaElement

Protected canvasContext

canvasContext: CanvasRenderingContext2D

Protected canvasElement

canvasElement: HTMLCanvasElement

Protected colorNegative

colorNegative: string

Protected colorPositive

colorPositive: string

Protected Optional dataSampling

dataSampling: number[]

Protected Optional decodedBuffer

decodedBuffer: AudioBuffer

Protected height

height: number

Protected loadedAudioSource

loadedAudioSource: string = ''

Protected Optional options

Protected Optional sourceChannel

sourceChannel: number

Protected viewElement

viewElement: HTMLElement

Protected width

width: number

Methods

Protected createWaveForm

  • createWaveForm(): number[]
  • Returns number[]

Protected drawSegment

  • drawSegment(x: number, y: number, width: number, isEven: boolean): void
  • Parameters

    • x: number
    • y: number
    • width: number
    • isEven: boolean

    Returns void

Protected drawWaveForm

  • drawWaveForm(data: number[], maxWidth: number, maxHeight: number): void
  • Parameters

    • data: number[]
    • maxWidth: number
    • maxHeight: number

    Returns void

Protected filterData

  • filterData(samples: number, primaryData: number[], secondaryData?: number[]): number[]
  • Parameters

    • samples: number
    • primaryData: number[]
    • Optional secondaryData: number[]

    Returns number[]

getAudioBuffer

  • getAudioBuffer(): AudioBuffer
  • Returns the current audio buffer.

    Returns AudioBuffer

Protected getAudioContext

  • getAudioContext(): AudioContext
  • Returns AudioContext

getDataSampling

  • getDataSampling(sampleCount: number, sourceChannel?: number, sourceAudioBuffer?: AudioBuffer): number[]
  • Returns an array of a specified number of data samples, taken at regular intervals. The minimum amount of data to construct a wave form graphic of a given width (defined by number of samples).

    Parameters

    • sampleCount: number

      Number of samples.

    • Optional sourceChannel: number

      Optional source channel (0 - Left or 1 - Right). If omitted the max of both channels for stereo audio will be taken.

    • Optional sourceAudioBuffer: AudioBuffer

      Optional instance of a source audio buffer. If omitted the current audio buffer will be taken.

    Returns number[]

Protected init

  • init(): void
  • Returns void

loadAudio

  • loadAudio(src?: string): Promise<AudioBuffer>
  • Loads audio from source URL and sets current audio buffer.

    Parameters

    • Optional src: string

      Source URL of audio.

    Returns Promise<AudioBuffer>

    Promise that resolves the current audio buffer.

render

  • render(): Promise<number[]>
  • Draws waveform graphic.

    Returns Promise<number[]>

    Promise that resolves an array of data samples used to construct a wave form graphic.

reset

  • reset(): void
  • Resets the graphic.

    Returns void

resize

  • resize(): void
  • Updates the canvas size depended on element size.

    Returns void

setAudioBuffer

setDataSampling

Protected setOptions

Protected setSize

  • setSize(): void
  • Returns void

Generated using TypeDoc