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 |
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 |
dictionaries: * |
|
public |
dictionary: {...undefined: Object, ...dict: Object} |
|
public |
morse2textD: {} |
|
public |
options: * |
|
public |
text2morseD: {} |
|
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 |
Tidies text (upper case, trim, squash multiple spaces) |
|
public |
tokeniseMorse(morse: *): * |
|
public |
tokeniseRawText(text: String): * Splits text into words and letters |
|
public |
tokeniseText(text: String): * Tidies and then tokenises text |
|
private |
_addDictionary(dict: Object) Load in a dictionary. |
|
private |
_input2output(tokens: *, dict: *): * |
|
private |
|
From class MorseCW | ||
public get |
baseLength: number: * 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 |
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 |
_baseElement: * The element of the dictionary that the ratios are based off |
|
private |
_baseLength: * |
|
private |
_ditsInParis: * |
|
private |
_fwpm: * |
|
private |
_lengths: * |
|
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 |
Set the Farnsworth WPM speed. |
|
public |
setFWPMfromRatio(ratio: number) Set the Farnsworth WPM given ratio of fditlength / ditlength |
|
public |
setLength(element: *, length: *) |
|
public |
setRatio(element: *, ratio: *) |
|
public |
Set the WPM speed. |
|
public |
setWPMfromDitLen(ditLen: number) Set the WPM given dit length in ms |
|
public |
testFWPMmatchesRatio(): * |
|
public |
testWPMmatchesRatio(): * |
|
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#constructorParams:
Name | Type | Attribute | Description |
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 |
|
frequency of wave in Hz |
params.sampleRate | number |
|
sample rate for the waveform in Hz |
Public Methods
public getSample(timings: number[], endPadding: number): number[] source
Get a sample waveform, not using Web Audio API (synchronous).
Params:
Name | Type | Attribute | Description |
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 |
|
how much silence in ms to add to the end of the waveform. |
public getWAASample(timings: number[], endPadding: number): Promise(number[]) source
Get a sample waveform using Web Audio API (asynchronous).
Params:
Name | Type | Attribute | Description |
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 |
|
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. |