Home Reference Source
import MorsePlayerWAALight from 'morse-pro/src/morse-pro-player-waa-light.js'
public class | source

MorsePlayerWAALight

Extends:

MorsePlayerWAA → MorsePlayerWAALight

Web browser sound player using Web Audio API. Extends MorsePlayerWAA to provide callbacks when the sound goes on or off. Can be used to turn a light on or off in time with the Morse sound. The callbacks have an error of +/- 2.6ms

Example:

import MorseCWWave from 'morse-pro-cw-wave';
import MorsePlayerWAALight from 'morse-pro-player-waa-light';
var morseCWWave = new MorseCWWave();
morseCWWave.translate("abc");
var morsePlayerWAALight = new MorsePlayerWAALight();
morsePlayerWAALight.soundOnCallback = lightOn;
morsePlayerWAALight.soundOffCallback = lightOff;
morsePlayerWAALight.soundStoppedCallback = soundStopped;
morsePlayerWAALight.volume = 0;
morsePlayerWAALight.loadCWWave(morseCWWave);
morsePlayerWAA.playFromStart();

Constructor Summary

Public Constructor
public

constructor(sequenceStartCallback: function(), sequenceEndingCallback: function(), soundStoppedCallback: function(), soundOnCallback: function(), soundOffCallback: function())

Member Summary

Public Members
public get
public

jsNode: *

Private Members
private
private
private

Method Summary

Public Methods
public

load(timings: *)

public

soundOffCallback(noteNumber: *)

public

soundOnCallback(noteNumber: *)

Private Methods
private

Set up the audio graph, connecting the splitter node to a JSNode in order to analyse the waveform @access: private

private

_off()

@access: private

private

_on()

@access: private

private

_processSound(event: *)

@access: private

Inherited Summary

From class MorsePlayerWAA
public get
public get
public get
public get

Return the index of the next note in the sequence to be scheduled.

public get
public set

Set the volume for the player

public
public
public
public
public
public

isNote: *[]

public
public
public
public
public
public
public

upNext: *

private

_cTimings: *[]

private
private
private
private
private
private
private
private
private
private

_tZero: *

private

_timer: *

private
private
public
public

load(timings: number[])

Load timing sequence, replacing any existing sequence.

public

loadCWWave(cwWave: Object)

Convenience method to help playing directly from a MorseCWWave instance.

public

loadNext(timings: number[])

Load timing sequence which will be played when the current sequence is completed (only one sequence is queued).

public

Convenience method to help playing directly from a MorseCWWave instance.

public

pause()

Pause playback (resume with play())

public

play()

Starts or resumes playback of the loaded timing sequence.

public

Plays the loaded timing sequence from the start, regardless of whether playback is ongoing or paused.

public
public
public
public

stop()

Stop playback (calling play() afterwards will start from the beginning)

private

Set up the audio graph @access: private

private

Schedule notes that start before now + lookAheadTime.

Public Constructors

public constructor(sequenceStartCallback: function(), sequenceEndingCallback: function(), soundStoppedCallback: function(), soundOnCallback: function(), soundOffCallback: function()) source

Override:

MorsePlayerWAA#constructor

Params:

NameTypeAttributeDescription
sequenceStartCallback function()

function to call each time the sequence starts.

sequenceEndingCallback function()

function to call when the sequence is nearing the end.

soundStoppedCallback function()

function to call when the sequence stops.

soundOnCallback function()

function to call wth the note number as the argument when a beep starts.

soundOffCallback function()

function to call with the note number as the argument when a beep stops.

Public Members

public get audioType: number: number source

Override:

MorsePlayerWAA#audioType

Return:

number

representing this audio player type: 5

public jsNode: * source

Private Members

private _count: number source

private _timings: * source

private _wasOn: boolean source

Public Methods

public load(timings: *) source

Load timing sequence, replacing any existing sequence. If endPadding is non-zero then an appropriate pause is added to the end.

Override:

MorsePlayerWAA#load

Params:

NameTypeAttributeDescription
timings *

public soundOffCallback(noteNumber: *) source

Params:

NameTypeAttributeDescription
noteNumber *

public soundOnCallback(noteNumber: *) source

Params:

NameTypeAttributeDescription
noteNumber *

Private Methods

private _initialiseAudioNodes() source

Set up the audio graph, connecting the splitter node to a JSNode in order to analyse the waveform @access: private

Override:

MorsePlayerWAA#_initialiseAudioNodes

private _off() source

@access: private

private _on() source

@access: private

private _processSound(event: *) source

@access: private

Params:

NameTypeAttributeDescription
event *