import MorseAdaptiveDecoder from 'morse-pro/src/morse-pro-decoder-adaptive.js'
MorseAdaptiveDecoder
Extends:
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 |
bufferSize: * |
|
public |
ditLen: * |
|
public |
ditLengths: *[] |
|
public |
fditLen: * |
|
public |
fditLengths: *[] |
|
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 |
Get the millisecond timings of all durations determined to be dahs |
|
public get |
ditLen: * |
|
public set |
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 |
Get the millisecond timings of all durations determined to be dits |
|
public get |
fditLen: * |
|
public set |
Set the length of a Farnsworth dit the decoder will look for. |
|
public get |
fwpm: * |
|
public set |
Should be set to the Farnsworth WPM speed of the input sound. |
|
public get |
Get the millisecond timings of all durations determined to be spaces |
|
public get |
wpm: * |
|
public set |
Should be set to the WPM speed of the input sound. |
|
public |
characters: *[] |
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
timings: *[] |
|
public |
unusedTimes: *[] |
|
private |
|
|
private |
|
|
private |
_ditLen: * |
|
private |
_fditLen: * |
|
private |
_fwpm: * |
|
private |
_wpm: * |
|
public |
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 |
Store the timing and the corresponding decoded character element. |
|
private |
getTimings(character: *): * |
|
private |
timings2morse(times: number[]): string Convert from millisecond timings to dots and dashes. |
|
private |
|
Public Constructors
public constructor(bufferSize: number) source
Override:
MorseDecoder#constructorParams:
Name | Type | Attribute | Description |
bufferSize | number |
|
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#ditLenpublic 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#fditLenpublic fditLengths: *[] source
Private Methods
private addDecode(duration: *, character: *) source
Store the timing and the corresponding decoded character element.
Override:
MorseDecoder#addDecodeParams:
Name | Type | Attribute | Description |
duration | * | ||
character | * |