jw-audio
v0.1.5
Published
A class which controls and manages the audio context.
Downloads
9
Readme
jw-audio
A class which controls and manages the audio context.
Install
Props
| Prop | Description |
| ------------- | ------------------------------------------ |
| destination
| the destination node of the audio context. |
Methods
| Method | Parameters | Description |
| -------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| createMediaSource
| url
: string | creates a media element source from a given url. The returned source node allows playback controls such as play, pause, set playback time, etc... |
| createBufferSource
| url
: string | creates a buffer source from a given url. |
| createLiveSource
| | creates a live stream source by requesting user audio media. |
| createGain
| | creates a gain node. |
| createAnalyser
| | creates an analyser node. |
| createOscillator
| | creates an oscillator node. |
| getFrequencyData
| analyser
: analyser node | generates an array of frequency data from a given analyser node. |
Usage
import * as Audio from "jw-audio";
/** Retrieves the destination node from the audio context. */
let destination = Audio.destination;
/** Creates a media source from a url. */
let source = await Audio.createMediaSource("<url>");
/** Create an analyser node from the audio context. */
let analyser = Audio.createAnalyser();
/** Create an gain node from the audio context. */
let gain = Audio.createGain();
/** Create an live stream source node from the audio context. */
let liveSource = await Audio.createLiveSource();
/** Generates an array of frequency data from a given analyser node. */
let frequencyData = Audio.getFrequencyData(analyser);