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

MorsePlayerWAA

Direct Subclass:

MorsePlayerWAALight

Web browser sound player using Web Audio API.

Example:

import MorseCW from 'morse-pro-cw';
import MorsePlayerWAA from 'morse-pro-player-waa';
var morseCW = new MorseCW();
var tokens = morseCW.text2morse("abc");
var timings = morseCW.morseTokens2timing(tokens);
var morsePlayerWAA = new MorsePlayerWAA();
morsePlayerWAA.load({timings});
morsePlayerWAA.playFromStart();

Constructor Summary

Public Constructor
public

constructor(params: Object)

Member Summary

Public Members
public get
public
public
public
public set
public get
public get

gain: number: *

public

isNote: *[]

public get
public get
public
public
public get

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

public
public
public set

playMode(mode: String)

Set the play mode (one of 'sine' and 'sample').

public get
public
public
public
public set

Set the volume for the player.

public get
public
Private Members
private

_cTimings: *[]

private
private
private
private
private
private
private
private
private
private
private

_queue: *[]

private
private
private
private

_tZero: *

private

_timer: *

private
private

_volume: *

Method Summary

Public Methods
public
public

load(sequence: Object)

Load timing sequence, replacing any existing sequence.

public

loadNext(sequence: Object)

this method was deprecated. - use queue() instead

Load timing sequence which will be played when the current sequence is completed (current queue is deleted).

public

Mutes or unmutes the audio (leaving the volume setting alone)

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

queue(sequence: Object)

Queue up a timing sequence (add to the end of the queue)

public

Called at the end of the last beep of a sequence.

public

Called at the point of the last notes of a sequence being scheduled.

public

Called to coincide with the start of the first note in a sequence.

public

Called when all sounds have definitely stopped.

public

stop()

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

Private Methods
private

Set up the audio graph.

private

Schedule notes that start before now + lookAheadTime.

private

_stop()

Internal clean stop that doesn't destroy audiocontext

Public Constructors

public constructor(params: Object) source

Params:

NameTypeAttributeDescription
params Object

lots of optional parameters.

params.defaultFrequency number
  • optional
  • default: 550

fallback frequency (Hz) to use if the loaded sequence does not define any.

params.startPadding number
  • optional
  • default: 0

number of ms to wait before playing first note after play is pressed

params.endPadding number
  • optional
  • default: 0

number of ms to wait at the end of a sequence before playing the next one (or looping).

params.volume number
  • optional
  • default: 1

volume of Morse. Takes range [0,1].

params.sequenceStartCallback function()

function to call each time the sequence starts.

params.sequenceEndingCallback function()

function to call when the sequence is nearing the end.

params.sequenceEndCallback function()

function to call when the sequence has ended.

params.soundStoppedCallback function()

function to call when the sequence stops.

params.onSample string

URL of the sound file to play at the start of a note.

params.offSample string

URL of the sound file to play at the end of a note.

params.playMode string
  • optional
  • default: "sine"

play mode, either "sine" or "sample".

Public Members

public get audioType: number: number source

Return:

number

representing this audio player type: 4

public bandpassNode: * source

public endPadding: * source

public fallbackFrequency: * source

public set frequency source

public get frequency: * source

public get gain: number: * source

Return:

number

the current gain [0,1]

public isNote: *[] source

public get isPaused: boolean: * source

Return:

boolean

whether the playback is paused or not

public get isPlaying: boolean: * source

Return:

boolean

whether a sequence is being played or not (still true even when paused); becomes false when stop is used

public loop: boolean source

public muteAudioNode: * source

public get nextNote: number: * source

Return the index of the next note in the sequence to be scheduled. Useful if the sequence has been paused.

Return:

number

note index

public onOffNode: * source

public oscillatorNode: * source

public set playMode(mode: String) source

Set the play mode (one of 'sine' and 'sample'). Also corrects the volume and low-pass filter.

public get playMode: * source

public sequenceLength: * source

public splitterNode: * source

public startPadding: * source

public set volume(v: number) source

Set the volume for the player. Sets the gain as a side effect.

public get volume: number: * source

Return:

number

the current volume [0,1]

public volumeNode: * source

Private Members

private _cTimings: *[] source

private _endTimer: * source

private _frequency: * source

private _gain: number source

private _initialStartPadding: number source

private _isPaused: boolean source

private _isPlaying: boolean source

private _lookAheadTime: number source

private _nextNote: number source

private _noAudio: boolean source

private _playMode: * source

private _queue: *[] source

private _soundEndTime: * source

private _startTimer: * source

private _stopTimer: * source

private _tZero: * source

private _timer: * source

private _timerInterval: number source

private _volume: * source

Public Methods

public hasError(): boolean source

Return:

boolean

whether there was an error in initialisation

public load(sequence: Object) source

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

Params:

NameTypeAttributeDescription
sequence Object

the sequence to play.

sequence.timings number[]

list of millisecond timings; +ve numbers are beeps, -ve numbers are silence.

sequence.frequencies number

a single frequency to be used for all beeps. If not set, the fallback frequency defined in the constructor is used.

public loadNext(sequence: Object) source

this method was deprecated. - use queue() instead

Load timing sequence which will be played when the current sequence is completed (current queue is deleted).

Params:

NameTypeAttributeDescription
sequence Object

see load() method for object description

public muteAudio(mute: Boolean) source

Mutes or unmutes the audio (leaving the volume setting alone)

Params:

NameTypeAttributeDescription
mute Boolean

true to mute, false to unmute

public pause() source

Pause playback (resume with play())

public play() source

Starts or resumes playback of the loaded timing sequence.

public playFromStart() source

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

public queue(sequence: Object) source

Queue up a timing sequence (add to the end of the queue)

Params:

NameTypeAttributeDescription
sequence Object

see load() method for object description

public sequenceEndCallback() source

Called at the end of the last beep of a sequence. Does not wait for endPadding.

public sequenceEndingCallback() source

Called at the point of the last notes of a sequence being scheduled. Designed to provide the opportunity to schedule some more notes.

public sequenceStartCallback() source

Called to coincide with the start of the first note in a sequence.

public soundStoppedCallback() source

Called when all sounds have definitely stopped.

public stop() source

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

Private Methods

private _initialiseAudio() source

Set up the audio graph. Should only be called once.

private _scheduleNotes(): boolean source

Schedule notes that start before now + lookAheadTime.

Return:

boolean

true if there is more to schedule, false if sequence is complete

private _stop() source

Internal clean stop that doesn't destroy audiocontext