Home Reference Source
import MorseAdaptiveDecoder from 'morse-pro/src/morse-pro-decoder-adaptive.js'
public class | source

MorseAdaptiveDecoder

Extends:

MorseDecoder → MorseAdaptiveDecoder

Class to convert from timings to Morse code. Adapts to changing speed.

Example:

var messageCallback = function(data) {
    console.log(data);
};
var speedCallback = function(s) {
    console.log('Speed is now: ' + s.wpm + ' WPM');
};
var decoder = new MorseAdaptiveDecoder(10);
decoder.messageCallback = messageCallback;
decoder.speedCallback = speedCallback;
var t;
while (decoder_is_operating) {
    // get some timing "t" from a sensor, make it +ve for noise and -ve for silence
    decoder.addTiming(t);
}
decoder.flush();  // make sure all the data is pushed through the decoder

Constructor Summary

Public Constructor
public

constructor(bufferSize: number)

Member Summary

Public Members
public
public

ditLen: *

public

ditLengths: *[]

public

fditLen: *

public
public

Method Summary

Private Methods
private

addDecode(duration: *, character: *)

Inherited Summary

From class MorseDecoder
public get

Get the millisecond timings of all durations determined to be dah-spaces

public get

dahs: number[]: *

Get the millisecond timings of all durations determined to be dahs

public get

ditLen: *

public set

ditLen(dit: number)

Set the length of a dit the decoder will look for.

public get

Get the millisecond timings of all durations determined to be dit-spaces

public get

dits: number[]: *

Get the millisecond timings of all durations determined to be dits

public get

fditLen: *

public set

fditLen(dit: number)

Set the length of a Farnsworth dit the decoder will look for.

public get

fwpm: *

public set

fwpm(fwpm: number)

Should be set to the Farnsworth WPM speed of the input sound.

public get

spaces: number[]: *

Get the millisecond timings of all durations determined to be spaces

public get

wpm: *

public set

wpm(wpm: number)

Should be set to the WPM speed of the input sound.

public

characters: *[]

public

defaults: {"wpm": number, "fwpm": number}

public
public
public
public

timings: *[]

public
private
private
private

_ditLen: *

private
private

_fwpm: *

private

_wpm: *

public

addTiming(duration: number)

Add a timing in ms to the list of recorded timings.

public

flush()

Process the buffer of unused timings, converting them into Morse and converting the generated Morse into a message.

public

messageCallback(jsonData: *)

public

speedCallback(jsonData: *)

private

addDecode(duration: number, character: string)

Store the timing and the corresponding decoded character element.

private

getTimings(character: *): *

private

Convert from millisecond timings to dots and dashes.

private

Public Constructors

public constructor(bufferSize: number) source

Override:

MorseDecoder#constructor

Params:

NameTypeAttributeDescription
bufferSize number
  • optional
  • default: 30

Size of the buffer to average over

Public Members

public bufferSize: * source

public ditLen: * source

Set the length of a dit the decoder will look for. The private _wpm, _fwpm, and _fditLen variables are also updated.

Override:

MorseDecoder#ditLen

public ditLengths: *[] source

public fditLen: * source

Set the length of a Farnsworth dit the decoder will look for. The private _wpm, _fwpm, and _ditLen variables are also updated.

Override:

MorseDecoder#fditLen

public fditLengths: *[] source

public lockSpeed: boolean source

Private Methods

private addDecode(duration: *, character: *) source

Store the timing and the corresponding decoded character element.

Override:

MorseDecoder#addDecode

Params:

NameTypeAttributeDescription
duration *
character *