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

MorseCWWave

Extends:

MorseMessageMorseCW → MorseCWWave

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

Example:

import MorseCWWave from 'morse-pro-cw-wave';
var morseCWWave = new MorseCWWave();
morseCWWave.translate("abc");
var sample = morseCWWave.getSample();

Static Method Summary

Static Public Methods
public static

getSampleGeneral(timings: number[], frequency: number, sampleRate: number, endPadding: number): number[]

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

Constructor Summary

Public Constructor
public

constructor(frequency: number, sampleRate: number)

Member Summary

Public Members
public
public

Method Summary

Public Methods
public

getSample(endPadding: number): number[]

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

public

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

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

Inherited Summary

From class MorseMessage
public
public
public
public
public
public
public
public

Clear all the errors from the morse and message.

public

translate(input: string, isMorse: boolean): *

From class MorseCW
public static

getTimingsGeneral(dit: number, dah: number, ditSpace: number, charSpace: number, wordSpace: number, morse: string): number[]

Return an array of millisecond timings.

public get
public set

Set the Farnsworth WPM speed.

public get

Get the length of the space between words in ms.

public get
public set

Set the WPM speed.

private

_fwpm: *

private

_wpm: *

public

Get the total duration of the message in ms 8 @return {number}

public

Return an array of millisecond timings.

Static Public Methods

public static getSampleGeneral(timings: number[], frequency: number, sampleRate: 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)

frequency number

frequency of sound in Hz.

sampleRate number

sample rate in Hz.

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 Constructors

public constructor(frequency: number, sampleRate: number) source

Override:

MorseCW#constructor

Params:

NameTypeAttributeDescription
frequency number
  • optional
  • default: 550

frequency of wave in Hz

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(endPadding: number): number[] source

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

Params:

NameTypeAttributeDescription
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(endPadding: number): Promise(number[]) source

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

Params:

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