MorsePlayerWAALight
Extends:
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 |
_timings: * |
|
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 |
audioContext: * |
|
public |
|
|
public |
|
|
public |
frequency: * |
|
public |
gainNode: * |
|
public |
isNote: *[] |
|
public |
|
|
public |
lowPassNode: * |
|
public |
|
|
public |
|
|
public |
splitterNode: * |
|
public |
|
|
public |
upNext: * |
|
private |
_cTimings: *[] |
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
_startTimer: * |
|
private |
_stopTimer: * |
|
private |
_tZero: * |
|
private |
_timer: * |
|
private |
|
|
private |
|
|
public |
|
|
public |
Load timing sequence, replacing any existing sequence. |
|
public |
loadCWWave(cwWave: Object) Convenience method to help playing directly from a MorseCWWave instance. |
|
public |
Load timing sequence which will be played when the current sequence is completed (only one sequence is queued). |
|
public |
loadNextCWWave(cwWave: Object) 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#constructorParams:
Name | Type | Attribute | Description |
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 jsNode: * source
Private Members
private _timings: * 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#loadParams:
Name | Type | Attribute | Description |
timings | * |
public soundOffCallback(noteNumber: *) source
Params:
Name | Type | Attribute | Description |
noteNumber | * |
public soundOnCallback(noteNumber: *) source
Params:
Name | Type | Attribute | Description |
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#_initialiseAudioNodesprivate _processSound(event: *) source
@access: private
Params:
Name | Type | Attribute | Description |
event | * |