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

MorseCWWave

Extends:

MorseMorseCW → MorseCWWave

Class to create sine-wave samples of standard CW Morse.

Example:

import MorseCWWave from 'morse-pro-cw-wave';
var morseCW = new MorseCW();
var tokens = morseCW.text2morse("abc");
var timings = morseCW.morseTokens2timing(tokens);
var sample = morseCWWave.getSample(timings);

Constructor Summary

Public Constructor
public

constructor(params: Object)

Member Summary

Public Members
public
public

Method Summary

Public Methods
public

getSample(timings: number[], endPadding: number): number[]

Get a sample waveform, not using Web Audio API (synchronous).

public

getWAASample(timings: number[], endPadding: number): Promise(number[])

Get a sample waveform using Web Audio API (asynchronous).

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
From class MorseCW
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

The element of the dictionary that the ratios are based off

private
private
private

_fwpm: *

private
private
private

_ratios: *

private
private

_wpm: *

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

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

Public Constructors

public constructor(params: Object) source

Override:

MorseCW#constructor

Params:

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

params.frequency number
  • optional
  • default: 550

frequency of wave in Hz

params.sampleRate number
  • optional
  • default: 8000

sample rate for the waveform in Hz

Public Members

public frequency: number source

public sampleRate: number source

Public Methods

public getSample(timings: number[], endPadding: number): number[] source

Get a sample waveform, not using Web Audio API (synchronous).

Params:

NameTypeAttributeDescription
timings number[]

millisecond timings, +ve numbers representing sound, -ve for no sound (+ve/-ve can be in any order) // TODO @param {number[]} frequencies - frequencies of elements in Hz. // TODO @param {number[]} volumes - volumes of elements in Hz. // TODO: remove endpadding?

endPadding number
  • optional
  • default: 0

how much silence in ms to add to the end of the waveform.

Return:

number[]

an array of floats in range [-1, 1] representing the wave-form.

public getWAASample(timings: number[], endPadding: number): Promise(number[]) source

Get a sample waveform using Web Audio API (asynchronous).

Params:

NameTypeAttributeDescription
timings number[]

millisecond timings, +ve numbers representing sound, -ve for no sound (+ve/-ve can be in any order) // TODO @param {number[]} frequencies - frequencies of elements in Hz. // TODO @param {number[]} volumes - volumes of elements in Hz. // TODO: remove endpadding?

endPadding number
  • optional
  • default: 0

how much silence in ms to add to the end of the waveform.

Return:

Promise(number[])

a Promise resolving to an array of floats in range [-1, 1] representing the wave-form.