Class Index | File Index

Classes


Namespace weasel.Helper


Defined in: helpers.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Static class containing helper functions for dealing with binary data in Soundtracker Modules.
Method Summary
Method Attributes Method Name and Description
<static>  
weasel.Helper.addEasyMenu(oBrowserAudio, oMenuElement, bAdvancedMenu)
Add the Easy Audio Menu to the selected element on the page.
<static>  
weasel.Helper.base64Decode(sEncodedString)
Decode a base64 string into a binary array.
<static>  
weasel.Helper.checkForCompression(aModuleData)
Decompress the module if needed.
<static>  
weasel.Helper.convertStringToArray(sData)
Convert a String (containing binary data) into a byte array.
<static>  
weasel.Helper.easyPlay(xModuleData)
Initialise the Easy Audio player with a Ultimate Soundtracker Module.
<static>  
weasel.Helper.easyStart()
Start/unpause the Easy Audio player.
<static>  
weasel.Helper.easyStop()
Stop/Pause the Easy Audio player.
<static>  
weasel.Helper.getByte(aData, iOffset)
Read a byte from byte array.
<static>  
weasel.Helper.getFloat32Array(iSize)
Get a Typed Array if supported (as these are supposed to be much faster, use less memory and don't cause the Garbage Collector to go nuts).
<static>  
weasel.Helper.getHighRezTimer()
Get the value of the high resolution timer which has microsecond accuracy, if available.
<static>  
weasel.Helper.getLong(aData, iOffset)
Read a long (4 bytes in big endian format [thats 680x0 number format]) from byte array.
<static>  
weasel.Helper.getNullTerminatedString(aData, iOffset, iMaxLength)
Get a null terminated string from a byte array.
<static>  
weasel.Helper.getUnsignedByteArray(iSize)
Get a Typed Array if supported (as these are supposed to be much faster, use less memory and don't cause the Garbage Collector to go nuts).
<static>  
weasel.Helper.getWord(aData, iOffset)
Read a word (2 bytes in big endian format [thats 680x0 number format]) from byte array.
<static>  
weasel.Helper.searchArrayForString(aData, iStartOffset, iEndOffset, sString)
Search for a ASCII string in a byte array from a given offset, used to find IFF sample headers.
<static>  
weasel.Helper.twosComplement(iUsignedByte)
Convert a unsigned byte into a signed byte (ones complement into twos complement).
Namespace Detail
weasel.Helper
Static class containing helper functions for dealing with binary data in Soundtracker Modules.
Author: Warren Willmey 2011.
Method Detail
<static> weasel.Helper.addEasyMenu(oBrowserAudio, oMenuElement, bAdvancedMenu)
Add the Easy Audio Menu to the selected element on the page. The Easy Menu contains the minimum level of audio settings that are considered useful. The menu is CSS driven and is of the drop down variety so it not suitable for use in the bottom right of screen (top left is preferred).
Defined in: EasyMenu.js.
Parameters:
{weasel.BrowserAudio} oBrowserAudio
= BrowserAudio object that is to be attached to the Easy Menu.
{Element} oMenuElement
= The HTML Element that the Easy Menu will appear under.
{bool} bAdvancedMenu
= Create either the simple or advanced menu (currently un-implemented).

<static> {Array|Uint8Array} weasel.Helper.base64Decode(sEncodedString)
Decode a base64 string into a binary array. This is the preferred method to decode Base64 encoded data as unfortunately window.atob() is not supported by all browsers (looking at you IE). It does have the advantage of decoding directly to an array instead of a string.
Parameters:
{String} sEncodedString
= The Base64 encoded string.
Returns:
{Array|Uint8Array} = Array containing the decoded byte data.

<static> {Array|Uint8Array} weasel.Helper.checkForCompression(aModuleData)
Decompress the module if needed. Requires the JXG.Util.Unzip library, which is LGPL 3 and can be located here: http://jsxgraph.uni-bayreuth.de/wp/2009/09/29/jsxcompressor-zlib-compressed-javascript-code/
Parameters:
{Array|Uint8Array} aModuleData
= The un/compressed module data.
Returns:
{Array|Uint8Array} = The decompressed module if compressed. If not the data returned is that which was passed in.

<static> {Array|Uint8Array} weasel.Helper.convertStringToArray(sData)
Convert a String (containing binary data) into a byte array.
Author: Warren Willmey 2011.
Parameters:
{String} sData
= The String containing the bytes.
Throws:
{String}
'Wrong data type' = sData is expected to be a String.
Returns:
{Array|Uint8Array} = The String converted to an Array.

<static> {(String|weasel.BrowserAudio)} weasel.Helper.easyPlay(xModuleData)
Initialise the Easy Audio player with a Ultimate Soundtracker Module. This is the easiest and simplest way to play a module, if your not too concerned about performance or the finer points of controlling the playback. Use the Helper.easyStart() to start playing the module and Helper.easyStop() to stop/pause the module.
Parameters:
{Array|Uint8Array|Element|String} xModuleData
= The Ultimate Soundtracker Module is various different data formats, A) In binary as an Array of bytes; B) Contained within a HTML Element as a Base64 encoded string; C).As a Base64 encoded String. IF the 3rd Party (LGPL 3) JXG decompression library is available for use then .gz and .zip modules are allowed.
Returns:
{(String|weasel.BrowserAudio)} = A string is returned if an error occurred (containing the error message), or a weasel.BrowserAudio object ready for use upon success.

<static> weasel.Helper.easyStart()
Start/unpause the Easy Audio player.

<static> weasel.Helper.easyStop()
Stop/Pause the Easy Audio player.

<static> {int} weasel.Helper.getByte(aData, iOffset)
Read a byte from byte array.
Author: Warren Willmey 2011.
Parameters:
{Array|Uint8Array} aData
= The Array containing the byte to fetch.
{int} iOffset
= The offset of the byte to fetch (starting at 0, last byte = sData.length -1).
Throws:
{String}
'Index out of range' = the Offset is out of range of the provided data.
{String}
'Wrong data type' = aData is expected to be an Array.
Returns:
{int} = The byte at the given offset, or throws an exception if "Index out of range".

<static> {(Array|Float32Array)} weasel.Helper.getFloat32Array(iSize)
Get a Typed Array if supported (as these are supposed to be much faster, use less memory and don't cause the Garbage Collector to go nuts). Be aware that a Float is a 32bit data type and not a Number data type (IEEE-754 Double, which is 64 bits) and so mathematical results WILL be different when using them, due to precision.
Parameters:
{int} iSize
= The size of the array wanted.
Returns:
{(Array|Float32Array)} = Array of iSize or Float32Array of iSize if Float32Array data type is supported.

<static> {int|DOMHighResTimeStamp} weasel.Helper.getHighRezTimer()
Get the value of the high resolution timer which has microsecond accuracy, if available. Returns value in milliseconds if not.
Returns:
{int|DOMHighResTimeStamp} = Current value of timer in milliseconds.

<static> {int} weasel.Helper.getLong(aData, iOffset)
Read a long (4 bytes in big endian format [thats 680x0 number format]) from byte array.
Author: Warren Willmey 2011.
Parameters:
{Array|Uint8Array} aData
= The Array containing the word to fetch.
{int} iOffset
= The offset of the long to fetch (starting at 0, last byte = aData.length -1).
Throws:
{String}
'Index out of range' = the Offset is out of range of the provided data.
{String}
'Wrong data type' = sData is expected to be an Array.
Returns:
{int} = The long at the given offset, or throws an exception if "Index out of range".

<static> {String} weasel.Helper.getNullTerminatedString(aData, iOffset, iMaxLength)
Get a null terminated string from a byte array.
Parameters:
{Array|Uint8Array} aData
= Array of bytes containing string.
{int} iOffset
= The offset into the data to the beginning of the string.
{int} iMaxLength
= The maximum length the string can be.
Returns:
{String} = The null terminated string converted to accepted ASCII range.

<static> {(Array|Uint8Array)} weasel.Helper.getUnsignedByteArray(iSize)
Get a Typed Array if supported (as these are supposed to be much faster, use less memory and don't cause the Garbage Collector to go nuts).
Parameters:
{int} iSize
= The size of the array wanted.
Returns:
{(Array|Uint8Array)} = Array of iSize or Uint8Array of iSize if Uint8Array data type is supported.

<static> {int} weasel.Helper.getWord(aData, iOffset)
Read a word (2 bytes in big endian format [thats 680x0 number format]) from byte array.
Author: Warren Willmey 2011.
Parameters:
{Array|Uint8Array} aData
= The Array containing the word to fetch.
{int} iOffset
= The offset of the word to fetch (starting at 0, last byte = aData.length -1).
Throws:
{String}
'Index out of range' = the Offset is out of range of the provided data.
{String}
'Wrong data type' = sData is expected to be an Array.
Returns:
{int} = The word at the given offset, or throws an exception if "Index out of range".

<static> {int} weasel.Helper.searchArrayForString(aData, iStartOffset, iEndOffset, sString)
Search for a ASCII string in a byte array from a given offset, used to find IFF sample headers.
Parameters:
{Array} aData
= The array of bytes to search.
{int} iStartOffset
= The starting offset to search from.
{int} iEndOffset
= The ending offset to search too.
{string} sString
= The string to look for (case sensitive).
Returns:
{int} = The offset of the match, or -1 if not found.

<static> {int} weasel.Helper.twosComplement(iUsignedByte)
Convert a unsigned byte into a signed byte (ones complement into twos complement).
Author: Warren Willmey 2011.
Parameters:
{int} iUsignedByte
= the Ones complement (or unsigned byte) to convert,
Returns:
{int} = The Twos complement (signed byte).

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