Skip to content

greyscaled/cs-weekly-2-material-audio-player

Repository files navigation

forthebadge forthebadge

cs-weekly-2-material-audio-player

Implements Web Audio API to create a simple wave oscillator visualizer. Original designed classes and architecture heavily inspired by examples on MDN. See MDN example

Writeup

I wrote a blog article discussing the Web Audio API and explaining the program here.

This project is an iteration of an effort called Code Something Weekly. The article explaining how and why is found here

Demo

LIVE DEMO

screenshot of demo

AudioPlayer

Kind: global class

new AudioPlayer(opts)

Param Type Default Description
opts Object (required)
opts.ctx Object (required) The AudioContext Object
[opts.volume] number 0.5 the overall volume
[opts.f1] number 130.81 the frequency of wave 1
[opts.f2] number 164.81 the frequency of wave 2
[opts.f3] number 196.00 the frequency of wave 3

audioPlayer.changeGain(volume) ⇒ undefined

Adjusts the overall volume

Kind: instance method of AudioPlayer

Param Type Description
volume number between (0.0, 1.0)

audioPlayer.changeFrequency(f, df) ⇒ undefined

Adjusts the value of a frequency.

Kind: instance method of AudioPlayer

Param Type Description
f number (1, 3). The frequency to change.
df number the amount to change the frequency

audioPlayer.getAnalyzerBinCount(f) ⇒ number

Returns 1/2 the FFT value for a given source. Represents the number of data values for visualization in the frequency domain. Use to assign the length of an unsigned 8-bit array (ie: Uint8Array [binCount])

Kind: instance method of AudioPlayer

Param Type Description
f number The frequency (1, 3) to obtain the bin count

audioPlayer.getAnalyzerFFTSize(f) ⇒ number

Returns the fftSize which is an unsigned long value and represents the window size in samples that is used when performing a Fast Fourier Transform.

Kind: instance method of AudioPlayer
Returns: number - - an unsigned long

Param Type Description
f number The frequency (1, 3) for which to get the FFT size.

audioPlayer.getAnalyzerTimeBytes(f, dataArray) ⇒ undefined

Copies the current time domain data into the provided array. Must be of type Uint8Array.

Kind: instance method of AudioPlayer

Param Type Description
f number The frequency (1, 3) to get the time btyes
dataArray Uint8Array

audioPlayer.togglePlay() ⇒ undefined

Starts or stops the audio player.

Kind: instance method of AudioPlayer

About

Implements Web Audio API to create a simple wave oscillator visualizer.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •