Giter Site home page Giter Site logo

morse-player's Introduction

Morse Player

This is a browser based morse code audio player that implements audio scheduling to accurately synchronize morse code audio playback with browser callback events for correlating UI and audio rendering. It also implements options inheritance, a rich scripting engine, glitchless pausing, and word-level rewind. It doesn't include any external dependencies and is very lightweight (just a few kilobytes uncompressed).


Getting Started

Initialize the player with system default options.

const player = new Player({
  volume: 0.7,
  gain: 0.5,
  freq: 600,
  q: 10,
  wpm: 25,
  eff: 25,
  color: '#fff'
});

Bind to events to capture player behavior.

const cancel = player.on('options', console.log);
const cancel = player.on('play:start', console.log);
const cancel = player.on('play:stop', console.log);
const cancel = player.on('play:resume', console.log);
const cancel = player.on('play:pause', console.log);
const cancel = player.on('play:rewind', console.log);

Setter for user options, and getter for aggregated options objects.

player.setOptions({ volume: 0.6 });
const options = player.getOptions();

Play a script, with optional script scoped options. This needs to happen within the context of a click-event within the browser for the audio to start playing.

player.play("Hello World", { wpm: 30 });
player.stop();
player.pause();
player.replay();
player.rewind(wordCount = 1);

Player

The core application

Options

The options system consists of four layers:

  1. System Options (defined on player creation)
  2. User Options (set at any time with setOptions())
  3. Script Options (set at playtime and optionally within the play script)
  4. Comined Options (the combined system->user->script options)

Emitter

Capture audio events to trigger UI changes.

Audio

The core audio driver the plays the characters.

Schedule

The schedule is how the player schedules events to coincide with the playing audio.

Script

The script renders the raw player text into playable characters. This expands any programatic directives within the script to set options or dynamically render text with actions.

Actions

Programatic directives within a player script to set options or dynamically render text.

[set wpm:25 [+ ]

Inspirations

Class Structure

  • Player
    • Options
    • Emitter
    • Audio
    • Schedule
    • Script
      • Render
        • Parse
          • Tokenize
        • Actions

morse-player's People

Contributors

numinos1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.