Coder Social home page Coder Social logo

sile / ffmml Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 539 KB

Famicon Flavored Misic Macro Language

License: Apache License 2.0

Rust 84.58% HTML 4.92% JavaScript 4.46% TypeScript 4.26% CSS 1.78%
chiptune famicon mml music-macro-language nes rust

ffmml's Introduction

ffmml

ffmml Documentation Actions Status License

Parser and player of Famicon Flavored Music Macro Language (FFMML).

Famicon is also known as NES (Nintendo Entertainment System).

๐ŸŽต Web Player

๐Ÿ“ VSCode Extension

The language specification of FFMML is based on MCK. But there are (known) differences between FFMML and MCK as follows:

  • FFMML doesn't support the following features:
    • #INCLUDE directive
    • #OCTAVE-REV directive
    • @n command (direct frequency select)
    • n command (direct note select)
    • y command (direct memory entry)
    • DPCM channel
  • FFMML features #CHANNEL <CHANNEL_NAME> <OSCILLATOR> directive that defines custom channels:
    • <CHANNEL_NAME>: A..=Z
    • <OSCILLATOR>: 1 (pulse wave), 2 (triangle wave), or 3 (noise)

Examples

The following example parses an MML script and generates audio data:

let mml = r#"; From https://www.nesdev.org/mck_guide_v1.0.txt
#TITLE My First NES Chip
#COMPOSER Nullsleep
#PROGRAMER 2003 Jeremiah Johnson

@v0 = { 10 9 8 7 6 5 4 3 2 }
@v1 = { 15 15 14 14 13 13 12 12 11 11 10 10 9 9 8 8 7 7 6 6 }
@v2 = { 15 12 10 8 6 3 2 1 0 }
@v3 = { 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 }

ABCD t150

A l8 o4 @01 @v0
A [c d e f @v1 g4 @v0 a16 b16 >c c d e f @v1 g4 @v0 a16 b16 >c<<]2

C l4 o3 q6
C [c e g8 g8 a16 b16 >c8 c e g8 g8 a16 b16 >c8<<]4

D l4 @v2 @0
D [@v2 b @v3 e @v2 b @v3 e @v2 b @v3 e @v2 b @v3 e8 @v2 b8]4"#;

let music = mml.parse::<ffmml::Music>().unwrap_or_else(|e| panic!("{e}"));
let mut player = music.play(48000);
let audio_data = (&mut player).collect::<Vec<_>>();
player.take_last_error().map(|e| panic!("{e}"));

To play the music defined by the above MML script, run the following commands:

$ cargo install ffmmlc
$ cat examples/music01.mml | ffmmlc > music01.wav
$ play music01.wav

References

About MML

Abount Famicon sound

ffmml's People

Contributors

sile avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.