Giter Site home page Giter Site logo

esp-musicengine's Introduction

ESP-MusicEngine

Credits/references

MusicEngine library ported from mBed to ESP8266 (tested in Arduino IDE v1.6.10)
MusicEngine class / Retro  Music Engine
Original author: Chris Taylor (taylorza). Open source license: Apache 2.0
see https://developer.mbed.org/users/taylorza/code/MusicEngine/
Ported from mBed to ESP8266/Arduino by MMOLE (maxint-rd), inherited Apache license.

MusicEngine provides a means to play Music Macro Language sequences asynchronously. Where the tone() API-function allows for playing one single note, the MusicEngine.play() method can play an entire music score.
The music is played using a ticker-interrupt routine that changes the PWM frequency according the specific notes being played. This means we can do other things while the music keeps playing.

Learn more about Music Macro Language (MML) on wikipedia:
http://en.wikipedia.org/wiki/Music_Macro_Language
For downloadable MML music see http://www.archeagemmllibrary.com/
Extensive MML reference guide (not all commands supported):
http://woolyss.com/chipmusic/chipmusic-mml/ppmck_guide.php
Info about using PWM and other methods to generate sound:
https://developer.mbed.org/users/4180_1/notebook/using-a-speaker-for-audio-output/

================================

Installation/Usage

The current version can be downloaded as an Arduino library using the Sketch|Library menu. Just add the zipfile library and the enclosed examples should appear in the menu automatically.

Initialisation outside of Setup():

  // define pin, include header and initialize class
  #include <MusicEngine.h>
  #define BUZ_PIN 14
  MusicEngine music(BUZ_PIN);

Then to play music, call the play method where you want:

music.play("T240 L16 O6 C D E F G");

Note: the music will keep on playing using a Ticker interrupt.

Supported MML Syntax

Short syntax overview:

Command Description
  Tnnn Set tempo [32-255]. Examples: T120, T240
  Vnnn Set volume [0-128]. Note: limited effect on PWM-volume. Examples: V1, T120
  Lnn Set default note length [1-64]. Examples: L8, L16
  Mx   Set timing. Mn=default, Ml=legato, Ms=staccato
  On   Set octave [0-7]. Examples: O6, O7
  A-G  Play whole note. Example: C
  Ann-Gnn  Play note of alternative length [1-64]. Example: C4, A16
  Nnn Play frequency [0-96]. Example: N48
   #   Play sharp note. Example: C#
  +   Alternative for #
  −   Play flat note. Example: D-
   R    Rest. Example:  CDEC r CDEC
  P   Alternative for R. Example: CDEC p CDEC
  .   Longer note. Example: CDEC. 
  > shift octave up. Example: CDE>CDE. 
   < shift octave down.  Example: CDE<CDE. 

The supported MML-commands are a subset that may not completely cover all available music scores. If notes seem missing, check your score against the syntax above and replace unknown commands by equivalent supported alternatives. The music notation is case-insensitive. Spaces are not required but can be used for readability.

esp-musicengine's People

Contributors

maxint-rd avatar

Stargazers

 avatar

Watchers

mojocorp avatar James Cloos avatar  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.