Monday, May 23, 2016

Play midi files without midi driver using soundfonts on Android

Audience: Normal user
Platform:  Android


After trying to setup midi in Linux i decided to use Software Synthesis based players with custom soundfonts. Before that i will give basics of midi. Skip to APPs section if you don't want to read about midi system below.


How MIDI works?
Suppose you have memorized a pattern on piano notes and playing it on piano. Unfortunately there is no synthesizer (synth) & speaker attached. So before setting it up with synth you wrote every piano key activity on a paper or a file. You saved it like "C4 C4 D4# ... PITCH_WHEEL ... VOLUME_UP etc". Now you know the pattern, raga or rhythm of your music. Midi file is exactly this saved record!. Means there is no SOUND DATA. You write on paper that you payed a sitar or guitar. But how does that sound? To save that we really need sound file itself. That is the reason midi files are very small because there is no sound data inside mid files.

Now we know what is MID file. Now comes Synthesizer. That missing sound is produced by synth that is why the name. Midi tells a synth to play an instrument named guitar. Therefore depending upon a synth midi sound different. The big problem is that we create a music with our instruments and assume mid file will play same but if instruments are of low quality or even different in timbre may give totally different music. There are many solutions to this. Easiest solution is to produce stream music like mp3 ogg. However what is there are 1000 midi musics but very less disk space?. Its always recommended to keep midi files with original set of instruments so that in future we can reuse them for editing, remixing or other work. What we do is collect all the instruments sounds recorded and save in a bundle called SoundFont. Just like a font which contains set of Alphabets of a language.



So we have a solution.
Midi + SoundFont = Low size & preserved quality of OST (original sound track). 
More details about the topics covered can be found on wiki or tutorials on web.



APPs:

For windows, Mac related midi can be found on this link http://adamrehn.com/articles/playing-midi-soundfonts/


Android Version:
There are some apps which play midi using soundfont viz -

DroindSound, Timidity AE Player, LiveMidi, Midi Voyager, SoundFont-Midi-Player


SoundFont-Midi-Player is my own player i developed to play midi files with different soundfonts fast. It can change soundfonts easily and fast!. Do try it here -

https://play.google.com/store/apps/details?id=org.greh.soundfontmidiplayer

  • Switches between SoundFonts fast
  • Test SoundFont instruments using piano & USB MIDI Keyboard
  • Play Piano together with Midi music. However it also changes the instrument being played in Midi music.
  • Supports USB MIDI keyboard. Supports PITCH BEND messages, Pedal, Volume, Key events. AFAIK not all android apps do this. Tested M-AUDIO KeyRig 49 on Moto-G phone. Doing pitch bend on Android phone using USB Midi keyboard needs good response. I tested this app on some low end phones and it works fine.
  • Samplerates from 22050 to 96000Hz
  • Reverb & Chorus effects
  • Crystalizer audio effect. (Currently disabled)
  • FluidSynth is powerful and i think my app is the only one using latest FluidSynth 1.1.6 with GLIB Android build. Powered by Unmodified FluidSynth 1.1.6 Android Version. If modified source is used i will make the source available here.
  • More features described in PlayStore page.


Features to add:
- Hack Soundfont instrument without altering soundfont files to test midi music


Pro version i am planning to build with more useful features:
- Export as streaming music to ogg- Export self contained midi music i.e. rmid, (mod?)