MorseCW
Extends:
Direct Subclass:
Indirect Subclass:
Class to create the on/off timings needed by e.g. sound generators. Timings are in milliseconds; "off" timings are negative.
Example:
import MorseCW from 'morse-pro-cw';
var morseCW = new MorseCW();
var tokens = morseCW.text2morse("abc");
var timings = morseCW.morseTokens2timing(tokens);
Constructor Summary
Public Constructor | ||
public |
constructor(params: Object) |
Member Summary
Public Members | ||
public get |
baseLength: number: * Get the length of the base element (i.e. |
|
public get |
Get the Farnsworth dit length to dit length ratio |
|
public get |
|
|
public get |
lengths: *: * Calculate and return the millisecond duration of each element, using negative durations for spaces. |
|
public get |
Return the length of the longest beep in milliseconds. |
|
public get |
|
|
public set |
Set the ratio of each element and normalise to the base element/ For the space elements, the ratio is negative. |
|
public get |
Get the absolute duration of the space between words in ms. |
|
public get |
|
Private Members | ||
private |
_baseElement: * The element of the dictionary that the ratios are based off |
|
private |
_baseLength: * |
|
private |
_ditsInParis: * |
|
private |
_fwpm: * |
|
private |
_lengths: * |
|
private |
|
|
private |
_ratios: * |
|
private |
|
|
private |
_wpm: * |
Method Summary
Public Methods | ||
public |
getDuration(timings: Array): * Add up all the millisecond timings in a list |
|
public |
morseTokens2timing(morseTokens: Array, lengths: Object): number[] Return an array of millisecond timings. |
|
public |
Set the Farnsworth WPM speed. |
|
public |
setFWPMfromRatio(ratio: number) Set the Farnsworth WPM given ratio of fditlength / ditlength |
|
public |
setLength(element: *, length: *) |
|
public |
setRatio(element: *, ratio: *) |
|
public |
Set the WPM speed. |
|
public |
setWPMfromDitLen(ditLen: number) Set the WPM given dit length in ms |
|
public |
testFWPMmatchesRatio(): * |
|
public |
testWPMmatchesRatio(): * |
Private Methods | ||
private |
Force the FWPM to match the fditlen/ditlen ratio without changing anything else |
|
private |
Force the WPM to match the base length without changing anything else |
Inherited Summary
From class Morse | ||
public |
dictionaries: * |
|
public |
dictionary: {...undefined: Object, ...dict: Object} |
|
public |
morse2textD: {} |
|
public |
options: * |
|
public |
text2morseD: {} |
|
public |
display(tokens: Array, charSpace: String, wordSpace: String, map: Map, errors: Array, errorPrefix: String, errorSuffix: String): * General method for converting a set of tokens to a displayable string |
|
public |
displayMorse(morseTokens: *): * |
|
public |
displayMorseErrors(morseTokens: *, errorTokens: *, prefix: *, suffix: *): * |
|
public |
displayText(textTokens: Array, escapeMap: Map): * Convert from text tokens to displayable String |
|
public |
displayTextErrors(textTokens: *, escapeMap: *, errorTokens: *, prefix: *, suffix: *): * |
|
public |
looksLikeMorse(input: *): * |
|
public |
morse2text(morse: *): * |
|
public |
morseTokens2text(morseTokens: *): {"morse": *, "text": *, "error": *, "hasError": *} |
|
public |
setDictionaries(dictList: List) Set the list of dictionaries to use. |
|
public |
setDictionariesAndOptions(dictList: *, optionList: *) |
|
public |
setOptions(optionList: List) Set the list of dictionary options to use. |
|
public |
text2morse(text: *): * |
|
public |
text2morseClean(text: *): * |
|
public |
textTokens2morse(textTokens: Array): * |
|
public |
Tidies text (upper case, trim, squash multiple spaces) |
|
public |
tokeniseMorse(morse: *): * |
|
public |
tokeniseRawText(text: String): * Splits text into words and letters |
|
public |
tokeniseText(text: String): * Tidies and then tokenises text |
|
private |
_addDictionary(dict: Object) Load in a dictionary. |
|
private |
_input2output(tokens: *, dict: *): * |
|
private |
|
Public Constructors
public constructor(params: Object) source
Override:
Morse#constructorParams:
Name | Type | Attribute | Description |
params | Object | dictionary of optional parameters. |
|
params.dictionary | string |
|
which dictionary to use, e.g. 'international' or 'american'. |
params.dictionaryOptions | string[] |
|
optional additional dictionaries such as 'prosigns'. |
params.wpm | number |
|
speed in words per minute using "PARIS " as the standard word. |
params.fwpm | number |
|
farnsworth speed. |
Public Members
public get baseLength: number: * source
Get the length of the base element (i.e. a dit) in milliseconds
public get lengths: *: * source
Calculate and return the millisecond duration of each element, using negative durations for spaces.
Return:
* | Map |
public set ratios(r: Map) source
Set the ratio of each element and normalise to the base element/ For the space elements, the ratio is negative.
Private Members
private _baseLength: * source
private _ditsInParis: * source
private _fwpm: * source
private _lengths: * source
private _ratios: * source
private _spacesInParis: * source
private _wpm: * source
Public Methods
public getDuration(timings: Array): * source
Add up all the millisecond timings in a list
Params:
Name | Type | Attribute | Description |
timings | Array | list of millisecond timings (-ve for spaces) |
Return:
* |
public morseTokens2timing(morseTokens: Array, lengths: Object): number[] source
Return an array of millisecond timings. With the Farnsworth method, the morse characters are played at one speed and the spaces between characters at a slower speed.
public setFWPM(fwpm: number): * source
Set the Farnsworth WPM speed. Ensures that WPM is no slower than Farnsworth WPM.
Params:
Name | Type | Attribute | Description |
fwpm | number |
Return:
* |
public setFWPMfromRatio(ratio: number) source
Set the Farnsworth WPM given ratio of fditlength / ditlength
Params:
Name | Type | Attribute | Description |
ratio | number |
public setLength(element: *, length: *) source
Params:
Name | Type | Attribute | Description |
element | * | ||
length | * |
public setRatio(element: *, ratio: *) source
Params:
Name | Type | Attribute | Description |
element | * | ||
ratio | * |
public setWPM(wpm: number): * source
Set the WPM speed. Ensures that Farnsworth WPM is no faster than WPM.
Params:
Name | Type | Attribute | Description |
wpm | number |
Return:
* |
public setWPMfromDitLen(ditLen: number) source
Set the WPM given dit length in ms
Params:
Name | Type | Attribute | Description |
ditLen | number |
Private Methods
private _setFWPMfromRatio() source
Force the FWPM to match the fditlen/ditlen ratio without changing anything else
private _setWPMfromBaseLength() source
Force the WPM to match the base length without changing anything else