MIDS music in your application

The music synthesizer

The MIDS music player features:

  • The music can use up to 8 tracks, one instrument per track.
  • Thus the music can use up to 8 different instruments.
  • The synthesizer internally uses 16 independant voices for playing notes.
  • The virtual instruments uses samples which size is limited to about 64kb.
  • The music size is only limited by the amount of free RAM.
  • Editable parameters: tempo, master volume, instruments volume, status flags: track mute, looped mode, pause mode, and more.

The synthesizer is based on wavetable synthesis. It is implemented as an ARM callback routine that is asynchronously called to fill the sound buffer (audio stream).

This ARM routine includes the MIDI sequencer that decodes the MIDI events and sets the first free available voice with the reference of the corresponding virtual instrument and the associated settings. Then the synthesizer uses instruments samples to produce the waveform of the currently being played note by the use of linear interpolation.

I've written some classes to easily use the synthesizer . The main class is clsMidiPlayer that initializes the sound buffer, loads the ARM routine in a memory chunk and sets flags and pointers. It also supplies methods to load music. The other classes are used for virtual instruments management. The global scheme is the one bellow:

Using Midsiku player

The downloadable project examples let you see how to include and use these codes and thus to ensure your application is able to play music.

Converting and including music

Some part of the process steps bellow are more detailed in other sections, the main steps to convert and include MIDS music in your applications are:

MIDI to MIDS conversion

First you must have playable music, the job is done by using the MIDI to MIDS converter tool running on Windows ©. Remember that with the current version no instruments are exported within the music, you will need to assign virtual instruments for all tracks by using the MIDS Editor tool that runs on Palm OS.

Creating soundfont

If you don't find the instruments you need in the download section (or if you want create your own instrument) you have to create the corresponding soundfont by using the same software used for MIDS conversion , the soundfonts creator tool can be launched from the main menu.

Assigning instruments to tracks

Now that you've got a MIDS music, you must assign instruments for all tracks by using the MIDS Editor tool running on Palm OS ©. the soundfont files corresponding to the virtual instruments must be installed on your device (as databases) or on a media card (as ".mhi" files).

When the job is done, that the produced music is the one you wanted, save the music. At this step of the process you will have to save your music file or database on your computer as it is a part of your Palm OS application. I think the simpliest way is to save your music on a media card as a MIDS file (as ".mhm" file) and then to transfer it on your computer. The Midsiku software also includes a usefull tool that converts MIDS files to Palm OS databases.

Embedding the player in your application

You must use the provided classes and the compiled ARM code:

  • clsMidiPlayer: the main class that manages the synthesizer.
  • clsSoundFont, clsSoundFontSample: classes used to manage virtual instruments.
  • clsVoice: class used by the synthesizer to play notes.
  • midiplayer.bin: the synthesizer ARM routine.
  • The clsDeviceCaps class is optional, it allows checking some device capacities to ensure that your application can run the player.
  • The modsound module including sound api declarations.

Define a global instance of the clsMidiPlayer class in a module, all other classes are internally used by this main class and thus you do not matter to know how to use them.

Here a part of code from a class used in one of the sample projects:

And now the way the music is easily loaded and played:

As you can see, quite simple to use!