Home Reference Source

Function

Static Public Summary
public

charSpace(wpm: number, fwpm: number): integer

Get the character-space in ms

public

dahLength(wpm: number): integer

Get the dah length in ms

public

ditLength(wpm: number): integer

Get the dit length in ms

public

ditSpace(wpm: number): integer

Get the dit space in ms

public

fditLength(wpm: *, fwpm: *): integer

Get the Farnsworth dit length in ms for a given WPM and Farnsworth WPM.

public

fwpm(wpm: *, r: *): *

Get the Farnsworth WPM for a given WPM and ratio

public

getData(data: number[], sampleRate: number, bitsPerSample: number): number[]

Convert PCM data to WAV file data.

public

getDataURI(data: number[], type: string): string

public
public

Determine whether a string is most likely morse code.

public

morse2text(morse: string, useProsigns: boolean): {message: string, morse: string, hasError: boolean}

Translate morse to text.

public

ratio(wpm: number, fwpm: number): number

Get the dit length ratio for a given WPM and Farnsworth WPM

public

text2ditdah(text: string, useProsigns: boolean): string

Translate text to morse in 'Di-di-dah dah' form.

public

text2morse(text: string, useProsigns: boolean): {message: string, morse: string, hasError: boolean}

Translate text to morse in '..- .. / --' form.

public

wordSpace(wpm: number, fwpm: number): integer

Get the word-space in ms

public

wpm(ditLen: *): number

Get the WPM for a given dit length in ms

Static Public

public charSpace(wpm: number, fwpm: number): integer source

import {charSpace} from 'morse-pro/src/morse-pro-wpm.js'

Get the character-space in ms

Params:

NameTypeAttributeDescription
wpm number

speed in words per minute

fwpm number
  • optional
  • default: wpm

Farnsworth speed in words per minute

Return:

integer

public dahLength(wpm: number): integer source

import {dahLength} from 'morse-pro/src/morse-pro-wpm.js'

Get the dah length in ms

Params:

NameTypeAttributeDescription
wpm number

speed in words per minute

Return:

integer

public ditLength(wpm: number): integer source

import {ditLength} from 'morse-pro/src/morse-pro-wpm.js'

Get the dit length in ms

Params:

NameTypeAttributeDescription
wpm number

speed in words per minute

Return:

integer

public ditSpace(wpm: number): integer source

import {ditSpace} from 'morse-pro/src/morse-pro-wpm.js'

Get the dit space in ms

Params:

NameTypeAttributeDescription
wpm number

speed in words per minute

Return:

integer

public fditLength(wpm: *, fwpm: *): integer source

import {fditLength} from 'morse-pro/src/morse-pro-wpm.js'

Get the Farnsworth dit length in ms for a given WPM and Farnsworth WPM. Note, actual dit-spaces should not be slowed down

Params:

NameTypeAttributeDescription
wpm *
fwpm *

Return:

integer

public fwpm(wpm: *, r: *): * source

import {fwpm} from 'morse-pro/src/morse-pro-wpm.js'

Get the Farnsworth WPM for a given WPM and ratio

Params:

NameTypeAttributeDescription
wpm *
r *

Return:

*

public getData(data: number[], sampleRate: number, bitsPerSample: number): number[] source

Convert PCM data to WAV file data.

Params:

NameTypeAttributeDescription
data number[]

waveform data, expected to be in (and clamped to) range [-1,1]

sampleRate number
  • optional
  • default: 8000

the sample rate of the waveform in Hz

bitsPerSample number
  • optional
  • default: 8

number of bits to store each data point (8 or 16)

Return:

number[]

array of bytes representing the WAV file

public getDataURI(data: number[], type: string): string source

Params:

NameTypeAttributeDescription
data number[]

list of bytes to encode

type string

MIME-type of the data

Return:

string

public getMIMEType(): string source

import {getMIMEType} from 'morse-pro/src/morse-pro-util-riffwave.js'

Return:

string

public looksLikeMorse(input: string): boolean source

import {looksLikeMorse} from 'morse-pro/src/morse-pro.js'

Determine whether a string is most likely morse code.

Params:

NameTypeAttributeDescription
input string

the text

Return:

boolean

true if the string only has Morse characters in after executing tidyMorse

public morse2text(morse: string, useProsigns: boolean): {message: string, morse: string, hasError: boolean} source

import {morse2text} from 'morse-pro/src/morse-pro.js'

Translate morse to text. Canonicalise the morse first. If something in the morse is untranslatable then it is surrounded by hash-signs ('#') and a hash is placed in the text.

Params:

NameTypeAttributeDescription
morse string

morse message using [.-_/| ] characters

useProsigns boolean

true if prosigns are to be used (default is true)

Return:

{message: string, morse: string, hasError: boolean}

public ratio(wpm: number, fwpm: number): number source

import {ratio} from 'morse-pro/src/morse-pro-wpm.js'

Get the dit length ratio for a given WPM and Farnsworth WPM

Params:

NameTypeAttributeDescription
wpm number

speed in words per minute

fwpm number

Farnsworth speed in words per minute

Return:

number

public text2ditdah(text: string, useProsigns: boolean): string source

import {text2ditdah} from 'morse-pro/src/morse-pro.js'

Translate text to morse in 'Di-di-dah dah' form.

Params:

NameTypeAttributeDescription
text string

alphanumeric message

useProsigns boolean

true if prosigns are to be used (default is true)

Return:

string

public text2morse(text: string, useProsigns: boolean): {message: string, morse: string, hasError: boolean} source

import {text2morse} from 'morse-pro/src/morse-pro.js'

Translate text to morse in '..- .. / --' form. If something in the text is untranslatable then it is surrounded by hash-signs ('#') and a hash is placed in the morse.

Params:

NameTypeAttributeDescription
text string

alphanumeric message

useProsigns boolean

true if prosigns are to be used (default is true)

Return:

{message: string, morse: string, hasError: boolean}

public wordSpace(wpm: number, fwpm: number): integer source

import {wordSpace} from 'morse-pro/src/morse-pro-wpm.js'

Get the word-space in ms

Params:

NameTypeAttributeDescription
wpm number

speed in words per minute

fwpm number
  • optional
  • default: wpm

Farnsworth speed in words per minute

Return:

integer

public wpm(ditLen: *): number source

import {wpm} from 'morse-pro/src/morse-pro-wpm.js'

Get the WPM for a given dit length in ms

Params:

NameTypeAttributeDescription
ditLen *

Return:

number