What library do you use in the Raspberry Pi example project?

See Wiring Pi page.

It doesn't work on Arduino!

Step by step

  • Copy 'A tiny MML parser' library files to Arduino library directory.
  • Open the Arduino example program.
  • Compile it.
  • Download it.

The version of your IDE

What's the version of Arduino IDE do you use?
Is it the latest version of it?
If it's no, please try it with the newest one because some old versions doesn't work correctly!

Location of your MML text

Where is your MML text?
You should understand these difference for your application because of the architecture is Harvard.
In the general implementation without special attributes such as const and PROGMEM, it will locate on SRAM.
However you can NOT locate large MML text string on SRAM because AVR doesn't have large SRAM on it.
If your MML text located on SRAM, you need to configure MML_USE_AVR_PROGMEM to (0) in mml.h.
If your MML text located on FLASH, you need to configure MML_USE_AVR_PROGMEM to (1) in mml.h.
The default value is (0) and that means 'locate MML text on SRAM'
Locate your MML text on FLASH is more comfortable for a long song. :)

How to wire a speaker to Arduino?

You can see also Arduino tutorials such as Play a Melody using the tone() function and Play Melody!

I want to use this library for a commercial product!

Feel free! :) Please see also the license.

How do I develop a sound system?

This library allows you only to parse MML text string.
There aren't any interfaces for making sounds.
You should design the sound system independently.

How do I support chords?

There are some ways of supporting chords with MML.
First of all, you should understand there are many schemes to support chords with this library.
As I wrote elsewhere, this library allows you only to parse MML text string, and it doesn't provide 'how to make a sound'.

For example, one of the ways is using 'C0E0G4' for C chord in C major.
The zero length notes are indicating the part of the chord.
Please see also my Super Mario example with Arduino!

What's the bticks value in MML_OPTION?

The bticks means ticks of a beat.
For example, 480 ticks in a beat if bticks is 480.
Your callback function receive a note length with the ticks value.

How do I calculate the frequency from a note number?

static int get_note_frequency(const int note)
  static const double BASEFREQ = 55.0;
  return (int)(BASEFREQ * pow((double)2.0, (double)((double)(note - 9) / 12.0)));

How do I calculate the note length from a tick count?

static int get_note_length_ms(const int bpm, const int bticks, const int note_ticks)
  return (60 * 1000) * note_ticks / bpm / bticks;