Playing tone sequences

To play a tone sequence, you must use ToneControl. Create a Player using a special locator, get the ToneControl, set its command sequence, and then start the player:

Player player = Manager.createPlayer(Manager.TONE_DEVICE_LOCATOR);
player.realize();
ToneControl tc = (ToneControl)(player.getControl("ToneControl"));
tc.setSequence(new byte[] { ToneControl.VERSION, 1,
                            ToneControl.C4, 8
                            ToneControl.C4 + 2, 8 });  // D4
player.start();

Note that you must call player.realize() before getting the tone control. You cannot get any type of control from a player before you have realized it.

ToneControl has byte commands for playing notes, creating and playing repeatable blocks of notes, and changing tempo, volume, and so on (see the Mobile Media API specification for details).

None of the example code fragments presented in this section includes the necessary try/catch blocks for the various exceptions which can be thrown by the method calls.

A player for tone sequence from .JTS file (as well as other media file types) can be also created using protocols (http://, file://, https://).