Class Index | File Index

Classes


Class weasel.BrowserAudio


Defined in: BrowserAudio.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
weasel.BrowserAudio(iPlaybackFrequency, iIntervalMsRate)
Object to abstract the different methods for playing audio in different browsers.
Field Summary
Field Attributes Field Name and Description
 
Constants of the different browser audio sub systems.
 
 
 
 
Method Summary
Method Attributes Method Name and Description
 
changeReplayFrequency(iNewReplayFrequency)
Change the replay frequency, if possible (not all audio subsystems allow this) and any additional modules (other than the one currently playing) will need to have their playback frequency changed with: oModule.changePlaybackFrequency( oBrowserAudio.getPlaybackFrequency() );.
 
Feed the Audio subsytems.
 
Get the current AudioBuffer object.
 
Get the *estimated* Audio sub system lag (not all sub systems support this) the value returned may not include the time take to work its way through the operating system to the sound card and out the speakers, different O/S and drivers return different values Pulse+Alsa is different from Alsa alone which is different from Windows XP.
 
The active browser audio that is/will be used for output.
 
Get the state of HTML5 Audio playback fidelity (8-bit, mono vs 16bit, stereo).
 
Is the Amiga filter command being ignored?.
 
Get the expected interval rate between audio updates in Milliseconds.
 
Get the current module playing.
 
Get the number of sound channels used for playback (not the number of channels in the mod)
 
Get the current replay frequency.
 
Get the current amount of pre buffering used on the audio sub system (Mozilla, AudioContext is request based).
 
Get the number of milliseconds it took to create the audio data for this interval (its like measuring in ice ages!!), be aware that the system clock may not be that accurate either.
 
Get the number of samples per interval (this is the number of samples that need to be created per interval).
 
Get list of supported browser audio types.
 
Get the state of Low Latency vs Speed setting (currently only applies to Firefox).
 
init()
Create the required feeder for the discovered browser audio system, you only need to call this function once to start the browser audio sub system, after that use stop() and start() to stop/pause/un-pause.
 
Is Browser Audio currently playing?
 
Set HTML5 Audio to low fidelity mode, 8 bit mono, which is needed as all sample data has to be encoded into a wav file, base64 encoded and stuck into a DataURI for the browser to play.
 
setIgnoreFilter(bIgnoreFilter)
Turn On/Off ability to ignore the Amiga Filter, almost all modules written without filter which was not present in the original Amiga being introduced with the Amiga 2000 and Amiga 500.
 
setInterpolation(iInterpolationType)
Set interpolation for ALL channels in the current module (you can also manually set the interpolation for each channel to be different).
 
setModule(oModule)
Set the module to play.
 
setPreBufferingInMS(fPreBufferingInMS)
Set the current pre buffering used on the audio sub system.
 
Start/restart/un-pause stopped audio.
 
stop()
Stop audio (can be used as a pause).
 
On some audio subsystems (Firefox) use a audio buffer the size of a single interval in order to reduce the number of write calls to the browser audio api.
Class Detail
weasel.BrowserAudio(iPlaybackFrequency, iIntervalMsRate)
Object to abstract the different methods for playing audio in different browsers.
Author: Warren Willmey 2011.
Parameters:
{int} iPlaybackFrequency
= The playback frequency in hertz to use.
{int} iIntervalMsRate
= The expected interval rate between feeds.
Field Detail
AudioType
Constants of the different browser audio sub systems.

oAudioBuffer

oAudioNode

oBase64Stream

oModule
Method Detail
changeReplayFrequency(iNewReplayFrequency)
Change the replay frequency, if possible (not all audio subsystems allow this) and any additional modules (other than the one currently playing) will need to have their playback frequency changed with: oModule.changePlaybackFrequency( oBrowserAudio.getPlaybackFrequency() );.
Parameters:
{int} iNewReplayFrequency
= The new replay frequency in Hz (e.g. 48000).

{int} feedAudio()
Feed the Audio subsytems.
Returns:
{int} = The number of samples written to the audio sub system.

{weasel.AudioBuffer} getAudioBuffer()
Get the current AudioBuffer object.
Returns:
{weasel.AudioBuffer} = The AudioBuffer object.

{int} getAudioSubSystemLag()
Get the *estimated* Audio sub system lag (not all sub systems support this) the value returned may not include the time take to work its way through the operating system to the sound card and out the speakers, different O/S and drivers return different values Pulse+Alsa is different from Alsa alone which is different from Windows XP. So it is best to give the USER control over how much pre-buffering they should have.
Returns:
{int} = The lag in samples between written and played.

{int} getAudioType()
The active browser audio that is/will be used for output.
Returns:
{int} weasel.BrowserAudio.AudioType = The active browser audio.

{bool} getHTML5LowFidelityMode()
Get the state of HTML5 Audio playback fidelity (8-bit, mono vs 16bit, stereo).
Returns:
{bool} = true : Low fidelity mode is enabled (8 bit, mono), false : high fidelity mode (16 bit, stereo).

{bool} getIgnoreFilter()
Is the Amiga filter command being ignored?.
Returns:
{bool} = true : Ignore the Amiga Filter, false : Enable use of Amiga Filter.

{int} getIntervalRate()
Get the expected interval rate between audio updates in Milliseconds.
Returns:
{int} = The expect interval rate between audio updates in Milliseconds.

{weasel.UltimateSoundTracker121|weasel.UltimateSoundTracker18|weasel.DOCSoundTracker9|weasel.DOCSoundTracker22|weasel.TJCSoundTracker2|weasel.DefJamSoundTracker3|weasel.SpreadpointSoundTracker23|weasel.SpreadpointSoundTracker25|weasel.NoiseTracker11|weasel.NoiseTracker20|weasel.ProTrackerMK|weasel.FSTModule} getModule()
Get the current module playing.
Returns:
{weasel.UltimateSoundTracker121|weasel.UltimateSoundTracker18|weasel.DOCSoundTracker9|weasel.DOCSoundTracker22|weasel.TJCSoundTracker2|weasel.DefJamSoundTracker3|weasel.SpreadpointSoundTracker23|weasel.SpreadpointSoundTracker25|weasel.NoiseTracker11|weasel.NoiseTracker20|weasel.ProTrackerMK|weasel.FSTModule} = The current module set to play.

{int} getNumberOfSoundChannels()
Get the number of sound channels used for playback (not the number of channels in the mod)
Returns:
{int} = The number of sound channels ( 1= mono, 2 = stereo).

{int} getPlaybackFrequency()
Get the current replay frequency.
Returns:
{int} = The currently used replay frequency in Hz (e.g. 44100, 48000 etc).

{float} getPreBufferingInMS()
Get the current amount of pre buffering used on the audio sub system (Mozilla, AudioContext is request based).
Returns:
{float} = The target pre buffering in milliseconds.

{int} getProfileInMS()
Get the number of milliseconds it took to create the audio data for this interval (its like measuring in ice ages!!), be aware that the system clock may not be that accurate either.
Returns:
{int} = Profile time in Milliseconds taken to create audio.

{int} getSamplesPerInterval()
Get the number of samples per interval (this is the number of samples that need to be created per interval).
Returns:
{int} = The number of samples per interval.

{weasel.BrowserAudio.AudioType} getSupportedBrowserAudioTypes()
Get list of supported browser audio types.
Returns:
{weasel.BrowserAudio.AudioType} = The list of supported browser audio types.

{bool} getTradeLowerLatencyForSpeed()
Get the state of Low Latency vs Speed setting (currently only applies to Firefox).
Returns:
{bool} = True : Lower the latency is used at the cost of some speed, False : faster is used at the cost of lower latency.

init()
Create the required feeder for the discovered browser audio system, you only need to call this function once to start the browser audio sub system, after that use stop() and start() to stop/pause/un-pause.

{bool} playing()
Is Browser Audio currently playing?
Returns:
{bool} = true : Browser Audio is currently playing, false : Browser Audio is not currently playing.

setHTML5LowFidelityMode(bLowFidelity)
Set HTML5 Audio to low fidelity mode, 8 bit mono, which is needed as all sample data has to be encoded into a wav file, base64 encoded and stuck into a DataURI for the browser to play. Unfortunately the browser takes a long time decoding the DataURI and start playing it, causing annoying pauses (unless you have a really fast machine) on the JavaScript side (a new audio clip is created every 2 seconds, which is when you'll see the pause).
Parameters:
{bool} bLowFidelity
= true : Low fidelity mode is enabled (8 bit, mono), false : high fidelity mode (16 bit, stereo).

setIgnoreFilter(bIgnoreFilter)
Turn On/Off ability to ignore the Amiga Filter, almost all modules written without filter which was not present in the original Amiga being introduced with the Amiga 2000 and Amiga 500. It should be noted that this does not turn On the actual filter, the filter gets turned On/Off from within the module using the correct Effect Command (typically E-00 and E-01).
Parameters:
{bool} bIgnoreFilter
= true : Ignore the Amiga Filter, false : Enable use of Amiga Filter, if module uses filter command.

setInterpolation(iInterpolationType)
Set interpolation for ALL channels in the current module (you can also manually set the interpolation for each channel to be different).
Parameters:
{weasel.Channel.SupportedInterpolationTypes} iInterpolationType
= The interpolation type to use.

setModule(oModule)
Set the module to play.
Parameters:
{weasel.UltimateSoundTracker121|weasel.UltimateSoundTracker18|weasel.DOCSoundTracker9|weasel.DOCSoundTracker22|weasel.TJCSoundTracker2|weasel.DefJamSoundTracker3|weasel.SpreadpointSoundTracker23|weasel.SpreadpointSoundTracker25|weasel.NoiseTracker11|weasel.NoiseTracker20|weasel.ProTrackerMK|weasel.FSTModule} oModule
= The Ultimate Soundtracker module to play.

setPreBufferingInMS(fPreBufferingInMS)
Set the current pre buffering used on the audio sub system.
Parameters:
{float} fPreBufferingInMS
= The target amount of pre buffering to use in the audio sub system (although anything more than 500ms-intervalMSRate is asking for trouble, expect "weird" behavour!).

start()
Start/restart/un-pause stopped audio.

stop()
Stop audio (can be used as a pause).

tradeLowerLatencyForSpeed(bLowerLatency)
On some audio subsystems (Firefox) use a audio buffer the size of a single interval in order to reduce the number of write calls to the browser audio api. This has the disadvantage of poor latency response (because the audio buffer always has to be full before passing to the browser, when we might actually need slightly more or slightly less), but is quicker.
Parameters:
{bool} bLowerLatency
= True : Lower the latency at the cost of some speed, False : Make things run a bit faster at the cost of lower latency.

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Mar 05 2018 18:46:31 GMT-0000 (GMT)