Home Reference Source Repository
import MorseCW from 'morse-pro/src/morse-pro-cw.js'
public class | source

MorseCW

Extends:

Morse → MorseCW

Direct Subclass:

MorseCWWave, MorseDecoder

Indirect Subclass:

MorseAdaptiveDecoder

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

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

ratios(r: Map)

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

The element of the dictionary that the ratios are based off

private
private
private

_fwpm: *

private
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

setFWPM(fwpm: number): *

Set the Farnsworth WPM speed.

public

Set the Farnsworth WPM given ratio of fditlength / ditlength

public

setLength(element: *, length: *)

public

setRatio(element: *, ratio: *)

public

setWPM(wpm: number): *

Set the WPM speed.

public

Set the WPM given dit length in ms

public
public
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
public

dictionary: {...undefined: Object, ...dict: Object}

public
public

options: *

public
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

tidyText(text: String): *

Tidies text (upper case, trim, squash multiple spaces)

public

tokeniseMorse(morse: *): *

public

Splits text into words and letters

public

tokeniseText(text: String): *

Tidies and then tokenises text

private

Load in a dictionary.

private

_input2output(tokens: *, dict: *): *

private

Public Constructors

public constructor(params: Object) source

Override:

Morse#constructor

Params:

NameTypeAttributeDescription
params Object

dictionary of optional parameters.

params.dictionary string
  • optional
  • default: 'international'

which dictionary to use, e.g. 'international' or 'american'.

params.dictionaryOptions string[]
  • optional
  • default: []

optional additional dictionaries such as 'prosigns'.

params.wpm number
  • optional
  • default: 20

speed in words per minute using "PARIS " as the standard word.

params.fwpm number
  • optional
  • default: wpm

farnsworth speed.

Public Members

public get baseLength: number: * source

Get the length of the base element (i.e. a dit) in milliseconds

Return:

number

public get farnsworthRatio: number: * source

Get the Farnsworth dit length to dit length ratio

Return:

number

public get fwpm: number source

public get lengths: *: * source

Calculate and return the millisecond duration of each element, using negative durations for spaces.

Return:

*

Map

public get maxLength: number: * source

Return the length of the longest beep in milliseconds.

Return:

number

public get ratios: number[] source

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.

public get wordSpace: number source

Get the absolute duration of the space between words in ms.

public get wpm: number source

Private Members

private _baseElement: * source

The element of the dictionary that the ratios are based off

private _baseLength: * source

private _ditsInParis: * source

private _fwpm: * source

private _lengths: * source

private _maxLength: number 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:

NameTypeAttributeDescription
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.

Params:

NameTypeAttributeDescription
morseTokens Array

array of morse tokens corresponding to the ratio element of the dictionary used, e.g. [['..', '.-'], ['--', '...']]

lengths Object
  • optional
  • default: this.lengths

dictionary mapping element to duration with negative duration for spaces

Return:

number[]

public setFWPM(fwpm: number): * source

Set the Farnsworth WPM speed. Ensures that WPM is no slower than Farnsworth WPM.

Params:

NameTypeAttributeDescription
fwpm number

Return:

*

public setFWPMfromRatio(ratio: number) source

Set the Farnsworth WPM given ratio of fditlength / ditlength

Params:

NameTypeAttributeDescription
ratio number

public setLength(element: *, length: *) source

Params:

NameTypeAttributeDescription
element *
length *

public setRatio(element: *, ratio: *) source

Params:

NameTypeAttributeDescription
element *
ratio *

public setWPM(wpm: number): * source

Set the WPM speed. Ensures that Farnsworth WPM is no faster than WPM.

Params:

NameTypeAttributeDescription
wpm number

Return:

*

public setWPMfromDitLen(ditLen: number) source

Set the WPM given dit length in ms

Params:

NameTypeAttributeDescription
ditLen number

public testFWPMmatchesRatio(): * source

Return:

*

public testWPMmatchesRatio(): * source

Return:

*

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