Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

morse-pro

scphillips105EUPL-1.23.0.1

Library for manipulating Morse code text and sound. Understands prosigns and Farnsworth speed. Can playback via web audio API, WAV files, vibration and light and can decode input from the microphone or audio files.

morse code, CW, decoder, wav file, microphone, sound file, adaptive, keyer, iambic, prosigns

readme

Version Downloads License

Introduction

This Javascript (ES6) library is for manipulating Morse code text and sound. It is the library used in the tools on Morse Code World.

The library can:

  • Translate to and from text and Morse code (in the form of '-- --- .-. ... . / -.-. --- -.. .').
  • Understand Morse code prosigns.
  • Translate and play International, American (railroad), Arabic, Cyrillic, Cyrillic-Ukraine, Hebrew variants.
  • Generate downloadable RIFF WAVE ('.wav') files of Morse code at given frequency and speed.
  • Make use of the "Farnsworth speed" concept of extending the gaps between characters and words.
  • Generate in-browser sounds using the Web Audio API and falling back to other methods such as Flash for older browsers.
  • Take Morse code input from a web-based keyer or iambic keyer.
  • Decode to text given 'on' and 'off' timings and a fixed speed.
  • Adaptively decode to text, adjusting to the most likely speed and Farnsworth speed.
  • Decode from listening to the microphone or an audio file, adapting to the most prominent frequency.

It has been written using ES6 (ECMA Script 6).

Copyright and Licence

Two files (morse-pro-util-riffwave.js and morse-pro-util-datauri.js) are Public Domain. The others are:

Copyright: Stephen C Phillips, 2013-2017; Licensed under the EUPL v1.2, with extension of article 5 (compatibility clause) to any licence for distributing derivative works that have been produced by the normal use of the Work as a library.

Please note, this is different to the Expat (MIT) licence often found in Javascript projects and places restrictions and obligations on the user of the software.

The full text of the licence can be found in the LICENSE file in this folder. Comments below do not constitute the licence, they are just my comments on the licence.

The EUPL is an 'open source' licence: one of many options and one in the 'weak-copyleft' category. My intention in using EUPL v1.2 is primarily to ensure that any modifications to this library are made available to the community as source code. In contrast to many open source licences, the EUPL v1.2 licence makes it clear that modifications must be made available even in the case of the library being used as part of a web service and not distributed to the user, covering the 'Application Service Provider loophole' (in this case it is similar to the AGPL licence). My intention is also that this library can be used as a library by other pieces of software but that the EUPL v1.2 licence does not have to be applied to the software that links to it (this is similar to the LGPL licence). Of course, if you want to open source software that links to this library then you are free to do so.

So basically, if you use the library as-is in some piece of software then that's just fine (though an acknowledgement would be nice) and you can even keep the software closed-source should you wish to. If you modify the library and use it in some software that you provide to others, even if the library is not distributed to the users, then you must provide your modifications to the library back to the community so that everyone can benefit.

More information on the EUPL v1.2:

If you would like to access this software under a different licence then please get in touch and ask.

Documentation

Documentation on how to use the library is embedded in the source code and can be found in the esdoc folder.

Some diagrams:

Library Overview

Basics:

  • morse-pro.js: Morse class, providing basic functions to translate Morse code and manage translation dictionaries.
  • morse-pro-message.js: MorseMessage class, for conveniently translating to and from Morse code and dealing with errors.
  • dictionary: mappings from characters to dots and dashes and configuration of timing and translation

Audio:

  • morse-pro-cw.js: MorseCW class, to create the on/off timings needed by e.g. sound generators. Understands speed and Farnsworth speed concepts. Extends Morse class.
  • morse-pro-cw-wave.js: MorseCWWave class, to create sine-wave samples of standard CW Morse. Extends MorseCW.
  • morse-pro-audiocontext.js: MorseAudioContext singleton class to reliably obtain the web audio API AudioContext instance and load sound samples.
  • morse-player-waa.js: MorsePlayerWAA class, to play sounds in a web browser using the Web Audio API.
  • morse-player-waa-light.js: MorsePlayerWAALight class. Extends MorsePlayerWAA to provide callbacks when the sound goes on or off and when the sound ends. Can be used to turn a light on or off in time with the Morse sound.
  • morse-player-xas.js: MorsePlayerXAS class, to play sounds in older web browsers (e.g. IE) using XAudioJS.

Decoders:

  • morse-pro-decoder.js: MorseDecoder class which converts from timings to Morse code. Extends MorseCW.
  • morse-pro-decoder-adaptive.js: MorseDecoderAdaptive class, converts from timings to Morse code and adapts to changing speed. Extends MorseDecoder.

Keyers:

  • morse-pro-keyer.js: MorseKeyer class, tests for input (e.g. from the keyboard) using a timer, plays the appropriate tone via a MorsePlayer instance and passes the data to a MorseDecoder instance.
  • morse-pro-keyer-iambic.js: MorseKeyerIambic class extends MorseKeyer, will alternate between dit and dah if both keys are pressed together.

Listeners:

  • morse-pro-listener.js: MorseListener class, analyses audio from the microphone or a sound file to pick out Morse code timings which are passed into a MorseDecoder instance.
  • morse-pro-listener-adaptive.js: MorseListenerAdaptive class extends MorseListener, adapts to changing frequency (pitch).

Utilities:

Deprecated and compatibility:

changelog

morse-pro Changelog

All notable changes to this project will be documented in this file.

[3.0.1] - 2022-08-08

Fixed

  • generated esdoc is now not deleted when publishing to npm

[3.0.0] - 2022-08-08

This release contains many breaking changes and bug fixes, mostly documented below. It has not reached a particular milestone, but a release is needed. Many classes now take their constructor parameters as a dictionary (object) with defaults, but this refactoring is not quite complete. Notable additions are the generalisation of the translation to support variants of Morse code other than International, and the addition of the playback of American (railroad) Morse via sound samples. Also, a single class to reliably obtain the AudioContext class required to use the Web Audio API has been added.

Added

  • dictionary files to translate between text and dots/dashes for international (moved from morse-pro), American (railroad), Arabic, Cyrillic, Cyrillic-Ukraine, and Hebrew
    • international
      • accented characters added
      • sexed quotes added
      • new lines treated the same as other whitespace
  • morse-pro
    • methods to load and unload dictionaries
  • morse-pro-audiocontext
    • new singleton class to obtain AudioContext object reliably and load samples, supporting multiple browser implementations
  • morse-pro-compat
    • new compatibility class to support v2 library code
  • morse-pro-cw-compat
    • new compatibility class to support v2 library code
  • morse-pro-message
    • loadMorse(), loadText(), cleanText(), getInputErrorString(), getOutputErrorString(), getTextErrorString(), getMorseErrorString() methods
  • morse-pro-player-waa
    • better volume control, using internal gain value
    • support for American (railroad) Morse via sound-on and sound-off audio samples
    • queue() method to queue up the next sequence
    • muteAudio() method to mute the audio but still continue playing (e.g. via vibration or light)
  • morse-pro-player-light
    • muteLight() method
  • morse-pro-player-xas
    • volume and gain control
    • load() method now takes a list of timings

Changed

  • morse-pro
    • text to morse dictionary removed from here and put into separate dictionary file
    • input is now not converted to upper case
  • morse-pro-cw
    • class constructor takes all parameters via a dictionary with defaults
    • now extends Morse class instead of MorseMessage
    • pretty much the whole class has changed in order to use dictionaries
  • morse-pro-cw-wave
    • class constructor takes all parameters via a dictionary with defaults
  • morse-pro-decoder
    • class constructor takes all parameters via a dictionary with defaults
    • wpm and fwpm properties are now setWPM() and setFWPM() methods
  • morse-pro-decoder-adaptive
    • class constructor takes all parameters via a dictionary with defaults
  • morse-pro-keyer
    • class constructor takes all parameters via a dictionary: now uses a configured decoder and player object
  • morse-pro-keyer-iambic
    • class constructor takes all parameters via a dictionary with defaults
  • morse-pro-player-waa
    • class constructor takes all parameters via a dictionary with defaults
    • audio graph has improved bandpass filter
    • volume changes happen over a few milliseconds to remove audio artifacts
    • stopping the sound happens over a few milliseconds to remove audio artifacts
  • morse-pro-player-waa-light
    • class constructor takes all parameters via a dictionary with defaults

Deprecated

  • morse-pro-wpm
    • calculations of sound durations are now handled via dictionary files

Removed

  • morse-pro-message
    • clearError() method
  • morse-pro-player-waa
    • loadCWWave() method
    • loadNextCWWave() method
  • morse-pro-player-xas
    • loadCWWave() method
  • tests
    • all tests removed as they were primarily testing only legacy code and getting them to run was difficult
  • Vagrantfile

Fixed

  • morse-pro-decoder
    • noise threshold increased (had been set too small)
  • morse-pro-message
    • 50ms of nothing is added to the end of a sound file to avoid the end being clipped on playback
  • morse-pro-player-waa
    • sequenceEndingCallback is called more reliably
    • 200ms start-up delay (minimum) is applied the very first time and then the user's confugured delay is used
  • morse-pro-player-waa-light
    • SMALL_AMPLITUDE constant added to ignore some noise

[2.0.0] - 2019-01-02

No particular reason to make a release now except that it's been too long coming and will never really be ready. Best to release it now in case it is useful to someone. It's version 2.0.0 because of breaking changes, not for any other reason. More breaking changes are likely as I am not happy with the architecture, but who knows when?!

Added

  • more in-line documentation in many files
  • some more tests of main classes
  • morse-pro
    • a few more punctuation characters
  • morse-pro-wpm
    • dahLength, ditSpace, charSpace and wordSpace methods
  • morse-pro-cw
    • wordSpace property
    • endPadding parameter (default 0) in getSample and getWAASample methods to allow a configurable pause at the end of the waveform
  • morse-pro-cw-wave
    • a lowpass bi-quad filter to the waveform generated by getSample
    • getWAASample asynchronous method to return sample generated using Web Audio API
  • morse-pro-keyer
    • optional fwpm 3rd argument in constructor
  • morse-pro-keyer-iambic
    • optional fwpm 3rd argument in constructor
    • optional iambicA 5th argument in constructor to switch between iambic A and B modes
  • morse-pro-player-waa
    • callback functions in constructor for sequenceStart, sequenceEnding and soundStopped (the last one was previously just in morse-pro-player-waa-light)
    • low-pass filter on waveform to remove clicks
    • loadTimings method
    • loadNext method to provide a single item queue of timings
    • pause method
    • isPaused read-only property
    • nextNote read-only property
    • startPadding field to insert a pause before playback begins (suggest 5ms to avoid sound artefacts in some browsers)
    • endPadding field to insert a pause after playback of a timing sequence completes
  • morse-pro-player-waa-light
    • additional callback functions in constructor to match morse-pro-player-waa
  • morse-pro-player-xas
    • volume now settable

Changed

  • updates node and npm to latest versions
  • updates all npm dependencies to latest versions (apart from babel which is latest v6, not v7)
  • Babel uses 'env' preset instead of 'es2015'
  • morse-pro
    • tidyMorse now trims whitespace
    • looksLikeMorse now returns false when the input string is just whitespace
  • morse-pro-wpm
    • millisecond timings are now rounded to the nearest integer
  • morse-pro-util-riffwave
    • getData arguments changed to take waveform data (so use morseCWWave.getSample() not morseCWWave instance directly), sampleRate and bitsPerSample
  • morse-pro-cw
    • makes useProsigns argument in constructor have true as the default
    • getTimingsGeneral is now a static method
  • morse-pro-keyer
    • refactoring to mark many functions and fields as private
    • _ditOrDah function is now the method required in class extensions
  • morse-pro-keyer-iambic
    • refactored from check to _ditOrDah function
  • morse-pro-player-xas
    • refactors isPlaying field into isPlaying read-only property
  • morse-pro-player-waa-light
    • return value of audioType property changed from 4 to 5

[1.0.2] - 2017-08-11

Added

  • Some tests
  • Integration with travis and coveralls

Changed

  • Imports now use relative paths
  • npm library now transpiled from ES6 and located in lib directory

[1.0.1] - 2017-07-28

Added

  • ESDoc inline documentation

Changed

  • Source Javascript moved into src directory

[1.0.0] - 2017-07-23

  • initial release