Skip to content
Morse code translator and decoder which can also play audio.
Branch: master
Clone or download
Latest commit 37b9496 Oct 4, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
src
test updated test file for node 4 Oct 2, 2018
.babelrc v1.0, using es6, fixed errors on safari Oct 2, 2018
.editorconfig Initial commit, v0.1.0 Jun 13, 2017
.gitignore
.jshintrc
.npmignore Added yarn instructions, Updated README.md Jun 14, 2017
.travis.yml Initial commit, v0.1.0 Jun 13, 2017
LICENSE
README.md Updated README.md Oct 4, 2018
gulpfile.js
package.json

README.md

Morsify - Morse Code Translator with Audio

npm-version npm-downloads travis-ci

Morse code encoder and decoder with no dependencies supports Latin, Cyrillic, Greek, Hebrew, Arabic, Persian, Japanese, Korean, Thai, and Unicode (Chinese and the others) characters with audio generation functionality using the Web Audio API.

Live Demo: https://morsify.net

Installation

npm

$ npm install morsify --save

yarn

$ yarn add morsify

Usage

const morsify = require('morsify');
const encoded = morsify.encode('SOS'); // .../---/... 
const decoded = morsify.decode('.../---/...'); // S O S
const characters = morsify.characters(); // {'1': {'A': '.-', ...}, ..., '11': {'ㄱ': '.-..', ...}}
const audio = morsify.audio('SOS');
audio.play(); // play audio
audio.stop(); // stop audio

Or alternatively, you can also use the library directly with including the source file.

<script src="https://rawgit.com/ozdemirburak/morsify/master/dist/morsify.min.js"></script>
<script>
    var encoded = morsify.encode('SOS'); // .../---/... 
    var decoded = morsify.decode('.../---/...'); // S O S
    var characters = morsify.characters(); // {'1': {'A': '.-', ...}, ..., '11': {'ㄱ': '.-..', ...}}
    var audio = morsify.audio('SOS');
    var oscillator = audio.oscillator; // OscillatorNode
    var context = audio.context; // AudioContext
    var gainNode = audio.gainNode; // GainNode
    audio.play(); // play audio
    audio.stop(); // stop audio
</script>

Options and Localization

You can customize the dash, dot or space characters and specify the alphabet with the priority option for an accurate encoding and decoding.

What priority option does is, gives direction to the plugin to start to searching for the given character set first.

Set the priority option according to the list below.

  • 1 => ASCII (Default)
  • 2 => Numbers
  • 3 => Punctuation
  • 4 => Latin Extended (Turkish, Polish etc.)
  • 5 => Cyrillic
  • 6 => Greek
  • 7 => Hebrew
  • 8 => Arabic
  • 9 => Persian
  • 10 => Japanese
  • 11 => Korean
  • 12 => Thai
  • 13 => Unicode (Chinese and the others)
const cyrillic = morsify.encode('Ленинград', { priority: 5 }); // .-.././-./../-./--./.-./.-/-..
const greek = morsify.decode('.../.-/--./.-/.--./.--', { priority: 6 }); // Σ Α Γ Α Π Ω
const hebrew = morsify.decode('––– –... ––– –. ––. .. .–.. –––', { dash: '', dot: '.', space: ' ', priority: 7 }); // ה ב ה נ ג י ל ה
const chinese = morsify.encode('你好', { priority: 13 }); // -..----.--...../-.--..-.-----.-
const characters = morsify.characters({ dash: '', dot: '' }); // {'1': {'A': '•–', ...}, ..., '11': {'ㄱ': '•–••', ...}}
const arabicAudio = morsify.audio('البُراق‎‎', { // generates the morse .-/.-../-.../.-./.-/--.- then generates the audio from it
  unit: 0.1, // period of one unit, in seconds, 1.2 / c where c is speed of transmission, in words per minute
  oscillator: {
    type: 'sine', // sine, square, sawtooth, triangle
    frequency: 500,  // value in hertz
    onended: function () { // event that fires when the tone has stopped playing
      console.log('ended');
    }
  }
}); 
const oscillator = arabicAudio.oscillator; // OscillatorNode 
const context = arabicAudio.context; // AudioContext; 
const gainNode = audio.gainNode; // GainNode
arabicAudio.play(); // will start playing morse audio
arabicAudio.stop(); // will stop playing morse audio

Contributing and Known Issues

Contributions are welcome.

Generating Minified Files

Install node and npm following one of the techniques explained within this link and run the commands below.

$ npm install --global gulp-cli
$ npm install
$ gulp

License

The MIT License (MIT). Please see License File for more information.

You can’t perform that action at this time.