MorsePlayerWAA
Direct Subclass:
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 |
bandpassNode: * |
|
public |
endPadding: * |
|
public |
|
|
public set |
|
|
public get |
frequency: * |
|
public get |
|
|
public |
isNote: *[] |
|
public get |
|
|
public get |
|
|
public |
|
|
public |
|
|
public get |
Return the index of the next note in the sequence to be scheduled. |
|
public |
onOffNode: * |
|
public |
|
|
public set |
Set the play mode (one of 'sine' and 'sample'). |
|
public get |
playMode: * |
|
public |
|
|
public |
splitterNode: * |
|
public |
startPadding: * |
|
public set |
Set the volume for the player. |
|
public get |
|
|
public |
volumeNode: * |
Private Members | ||
private |
_cTimings: *[] |
|
private |
_endTimer: * |
|
private |
_frequency: * |
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
_playMode: * |
|
private |
_queue: *[] |
|
private |
|
|
private |
_startTimer: * |
|
private |
_stopTimer: * |
|
private |
_tZero: * |
|
private |
_timer: * |
|
private |
|
|
private |
_volume: * |
Method Summary
Public Methods | ||
public |
|
|
public |
Load timing sequence, replacing any existing sequence. |
|
public |
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 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:
Name | Type | Attribute | Description |
params | Object | lots of optional parameters. |
|
params.defaultFrequency | number |
|
fallback frequency (Hz) to use if the loaded sequence does not define any. |
params.startPadding | number |
|
number of ms to wait before playing first note after play is pressed |
params.endPadding | number |
|
number of ms to wait at the end of a sequence before playing the next one (or looping). |
params.volume | number |
|
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 |
|
play mode, either "sine" or "sample". |
Public Members
public bandpassNode: * source
public endPadding: * source
public fallbackFrequency: * source
public set frequency source
public get frequency: * source
public isNote: *[] source
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 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.
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 volumeNode: * source
Private Members
private _cTimings: *[] source
private _endTimer: * source
private _frequency: * source
private _playMode: * source
private _queue: *[] source
private _soundEndTime: * source
private _startTimer: * source
private _stopTimer: * source
private _tZero: * source
private _timer: * source
private _volume: * source
Public Methods
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:
Name | Type | Attribute | Description |
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
Load timing sequence which will be played when the current sequence is completed (current queue is deleted).
Params:
Name | Type | Attribute | Description |
sequence | Object | see load() method for object description |
public muteAudio(mute: Boolean) source
Mutes or unmutes the audio (leaving the volume setting alone)
Params:
Name | Type | Attribute | Description |
mute | Boolean | true to mute, false to unmute |
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:
Name | Type | Attribute | Description |
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.