Speaker

The device speaker is used to produce music notes.

Once music is stored into the speaker, a call to its play() method will produce notes.

The following commands :

speaker = [69,60,73,32];
speaker.play();

Will play note 69 : A (440Htz) with a length of 1s (60/60s) and the note 73 : C# (554.4Htz) for half about a second (32/60s).

Full note code list is given in iRobot Create Open Interface Specification

The list given as a value of speaker or speaker.val is a succession of note / duration couples composing a song. Note durations are given in 60th of a second.

Songs can only be 16 note long.

The command speaker.play() returns immediatly. If you launch another song while the song is still playing, the command will be ignored.