Showing posts with label Audio. Show all posts
Showing posts with label Audio. Show all posts

Tuesday, February 28, 2017

WildMidi for Android: Compiling WildMidi using Android NDK rev 13

Android had no standard midi protocol before Marshmallow. Even after a standard MIDI event API for a developer to build android app which does midi synthesis by itself is a great feature!. In 2016 i compiled FluidSynth 1.6 for Android and created a SoundFont Midi Player with USB keyboard support. This app can play midi, rmi files and can send midi events via USB MIDI Keyboard, Normal USB keyboard to fluidsynth to synthesize sound. Due to latency and high CPU consumption issues i decided to look at other options. One good option was WildMidi.

WildMidi -

It says -

"The WildMIDI library uses Gravis Ultrasound patch files to convert MIDI files into audio which is then passed back to the calling application for further processing or output

Library Features

  • RIFF MIDI file support
  • MIDI format 0, 1 and 2 support
  • MIDI-like formats: KAR, HMI, HMP, MUS and XMI
  • Cross Platform: Linux, Windows, OSX, FreeBSD and etc.
  • Thread safe
  • host-Endian native streaming
  • WAV file output
  • Linear and gauss re-sampling
  • Final output reverb engine
  • Timidity.cfg compatibility
Player Features

  • OSS and Alsa Output (Linux/FreeBSD)
  • Windows Sound System support (Windows)
  • OpenAL (OSX/Others)
  • SoundBlaster 16 (DOS)"

In Player features Android sound system is not mentioned and that doesn't mean it cannot be used in Android. I compiled WildMidi for Android and the link to download the binary package is mentioned later in this page. I tested WildMidi on Ubuntu-Studio which had inbuilt "FreePats". The Gravis Ultrasound Patch files are used by WildMidi to synthesize sound. We can use WildMidi player to play midi files on Android by modifying its player code by sending PCM buffer to Android OpenSLES or AudioTrack.

Can wildmidi be used for sending MIDI events to build piano like app with fast response? Currently NO as per wildmidi source!

Looking at source code of wildmidi inside wildmidi_lib.h. It says "Not Yet Implemented". That "latency" thing! everywhere.

/* NOTE: Not Yet Implemented Or Tested Properly */
/* Due to delay in audio output in the player, this is not being developed
   futher at the moment. Further Development will occur when output latency
   has been reduced enough to "appear" instant.
WM_SYMBOL int WildMidi_Live (midi * handle, uint32_t midi_event);

/* reserved for future coding
 * need to change these to use a time for cmd_pos and new_cmd_pos

WM_SYMBOL int WildMidi_InsertMidiEvent (midi * handle, uint8_t char midi_cmd, *char midi_cmd_data, unsigned long int midi_cmd_data_size, unsigned long int *cmd_pos);
WM_SYMBOL int WildMidi_DeleteMidiEvent (midi * handle, uint8_t char midi_cmd, unsigned long int *cmd_pos);
WM_SYMBOL int WildMidi_MoveMidiEvent (midi * handle, , uint8_t char midi_cmd, unsigned long int *cmd_pos, unsigned long int *new_cmd_pos);

This can be used to build a midi player for android using wildmidi synthesizer. The build script is same as libpng build script mentioned on my other article.

Download wildmidi arm binary from here:

Tuesday, February 7, 2017

Useful Collection of Public Domain, Creative Commons, Free sounds and graphics for commercial use

As an Indie developer i required lot of free sound, music and game art for commercial use. Internet is huge but it still lacks resources with permissible license. Looking for free stuff is not bad but also not great because every work has value and in real life there is no free meal. There are very helping people who offer their work for free to ease development work of indie workers. Below are links to such useful assets.

A website with lots of free multimedia resources. Contains 2D, 3D, music, sound etc stuff with search and page wise browsing. It includes resources with multiple types of open licenses.

Kenney Vleugels website:

"We've created over 35,000 images, audio files and 3D models for you to use in your projects. Thanks to our public domain license you're even allowed to use them in commercial projects!"

220+MB of arts and sounds.

Glitch Game Art

"The collaborative, web-based, massively multiplayer game Glitch began its initial private testing in 2009, opened to the public in 2010, and was shut down in 2012. It was played by more than 150,000 people and was widely hailed for its original and highly creative visual style.

The entire library of art assets from the game, has been made freely available, dedicated to the public domain. Code from the game client is included to help developers work with the assets. All of it can be downloaded and used by anyone, for any purpose. (But: use it for good.)"

Huge collection of arts. Don't miss it!

The Last Door Game Assets

"Hey pals! We have a special gift for you! Today, in commemoration of Alan Turing, father of modern computing, all of Season One's assets will become open source! Also, we want to commemorate you, as the great community we proudly have. Thank you so much! Now you can create your own 'The Last Door' content by using the original graphics and sounds! Create videos, animate gifs or develop your won 'The Last Door' game! The assets are under Creative Commons Attribution 4.0 license, so you can spread your passion in all formats and ways."

"Hi! I'm Davit Masia, I create a lot of graphics for fun, mockups,etc... that usually ends lost on my folders. So i decided upload and share with everybody all that stuff so people can use in their projects. Assets are free but any donation will be welcomed and motivate me to add more and more"

Around 30MB of free arts.

"The assets in this repository are created at Sparklin Labs by Pixel-boy.
They are released under the Creative Commons Zero (CC0) license.

You can use the assets found in this repository in your own games, even commercial ones. Attribution is not required but appreciated. Placing a link to somewhere would be awesome :)"

" is a place to buy royalty free 2D game art assets. It contains more than 50 items, from platformer & top down tileset, side scrolling & top down character spritesheet, game GUI, space shooter asset, and many more.

Who's the guy behind this site?
I'm Zuhria Alfitra a.k.a pzUH. A lone wolf indie-gamedev-wannabe from Yogyakarta, Indonesia."

Huge collection of cliparts, images of animals, plants, education, shapes etc. It can be very helpful to make a derivative art. Get a simple shape and enhance it to something more beautiful. ~1GB of images. Public Domain.

"Unlimited Commercial Use

We try to make it clear that you may use all clipart from Openclipart even for unlimited commercial use. ... We use the Creative Commons Zero 1.0 Public Domain License every time an artist uploads a piece of clipart to Openclipart to make it clear the artist is releasing the creative work for anyone to use for any reason, even commercially."

Very good collection of collections!. This is a MUST visit page. However the repository is big and sometimes you might want to download only few folders from github. For example we want to download a CC0 or non GPL licensed assets. If you know how to use command line then a single folder can be exported from github. GUI based software can also do that.

For example you want to download folder but there is no option on that page. Start command shell like bash on Linux or cmd.exe on Windows. Install SVN subversion software and run this command -

Firstly copy the link

Then replace tree/master by trunk. It becomes like this -

Now run

svn export

This will download only the DCGames_stuff folder. If you don't like command line then try a GUI software like TortoiseSVN and export the url above as example.

Freebies license:

"You are permitted to use the resources in any number of personal and commercial projects for yourself or a client.
You can modify the resources according to your requirements and include them into works such as websites, applications, printed materials and others."


Blender Texture Disc

Public domain textures pack in a CD.

Sweet home 3D texture packs

Contains some useful texture packs.

Owned by Sujit Yadav. He has shared some useful vector arts.

To get more images and textures one can use public domain or CC0 like licensed photos or videos.

3D models:

"Hi there. 'Free the models' is a site dedicated to provide free content for 3d applications and 3d/game engines. The license of the content is that what you download from here is one step away from public domain. So, everything you download from here is free for any use EXCEPT it cannot be included in another free web or cd collection and it cannot be sold separately. Otherwise you can use it in your commercial game, 3d application or render work. You don't have to provide credit but It would be nice if you do. Thank you. Elias Tsiantas /Herakleion/Greece."

Lots of 3D models in sh3f format. Its like zip file and can be extracted.

Free Sounds:

A very useful and huge collection of high quality audios. Below are some sound files i downloaded from this website.

[99Sounds] 99 Drum Samples
[99Sounds] Atmospherik Mekanisms
[99Sounds] Cinematic Sound Effects
99Sounds Drones
[99Sounds] InterSpace
[99Sounds] Magnetic Fields
[99Sounds] Percussa Toolbox by Richard Gould
[99Sounds] Project Exodus
[99Sounds] Project Pegasus
[99Sounds] Punching Percussion
99Sounds Radiophonic Atmospheres by Red Sky Lullaby
[99Sounds] Rain And Thunder
[99Sounds] Sound Design Tools
[99Sounds] The Warehouse

The files are very big and i have compressed them to very low size still maintaining quality. Due to their license restriction i cannot share those compressed ogg files. Please visit their site and download them all. Many of these audio have 96KHz sample rate. Do read the download resume technique at end of this article to download from this site because the big files many times stop resuming.

Various licenses and huge collection of user submitted sounds.

Another good site i used.
Search "free sounds" on Google. There are many sites like this.

Get sound samples from sound pack formats

One best way to get sounds is packed, synth sound formats. Sound formats like SoundFont SF2, Downloadable Sound DLS, Patch (pat files). There are many sites which offer these files. Below are some valuable sound collections or packs.


Big collection of sound sample. Uncompressed size 844 MB

DrumKits from Hydrogen DrumMachine app

The drumkit files are zip files with sample configuration. Extract audio files from them and use in any DAW. Drumkits names:

3355606kit, ColomboAcousticDrumkit, HardElectro1, Synthie-1, BJA_Pacific, DeathMetal, HipHop-1, TD-7kit, Boss_DR-110, EasternHop-1, HipHop-2, Techno-1, circAfrique v4, ElectricEmpireKit, K-27_Trash_Kit, TR808909, Classic-626, ErnysPercussion, Millo-Drums_v.1, VariBreaks, Classic-808, ForzeeStereo, Millo_MultiLayered2, YamahaVintageKit

Many free sound samples.

Download some free Digital Audio making software and many of them offer free sound packs inside them. Linux Multimedia Studio is among them. Download tracker music software and their XI instruments which can be converted to wav or flac.

List of CC0 websites for images, wallpapers, photos

"The Metropolitan Museum of Art makes 375,000 images of public domain art freely available under Creative Commons Zero"

As it says huge collection of museum art can be used for even commercial purpose. Deriving these arts to make new things can be very useful.

How to get more multimedia assets with lesser effort?

I spent lot time in learning programming, music, sound effects, digital arts and some more skills. Now i can make games alone. However i realized one must rather invest time in one skill they love most and Master that skill ( I love all but music is at top :) ). What about those technologies where skill is not enough to complete a work faster? There are many ways to do it. You can pay to a freelancer and get your work done. What if you don't have much money?. This is where free stuff comes to help. Some very useful links have been shared above. But now i will share techniques to get free stuff with little effort.

A video is a sequence of pictures. Therefore an open licensed movie is also bundle of same license image assets. With this idea i downloaded open source videos like BigBuckBunny. ElephantsDream, Sintel etc. There are lots of effects, textures, sounds etc in these videos. Extract data from these videos and use them wherever needed. But don't forget to follow the license honestly!.

Here are links of some public domain, Creative Commons videos:

Blender Movies:



There are many resources which are public domain but can still cause copyright issues. For example old SuperMan cartoons are public domain but the SuperMan himself is not!. Please be careful for these type of things.

How to resume downloads which expires if stopped?

Many websites generate download links which expire after some time or fail if multiple connections are created. I use UGET on linux. Windows version of this software is also available. Simply add a URL and start downloading. When a new url is created go to properties of the download item and replace the old url by new url. Another way is to use KGET. Its also a Linux app. It can add mirror links. Add whenever a new link is created.

Download link: 

The links shared here can be very helpful to many indie and non-indie developers. Please submit links in comments i will add here.

Friday, October 14, 2016

Audio Visualizer using libGDX for multiple platforms

This article & project is about visualizing audio as waveforms on screen. Before starting let's understand few terms and minimum requirements related to the project. Most of details about app is inside the source code. This article is only about audio section.

  • A device supported by libGDX library. 
  • Device must support microphone. 

Sample Rate:
Total number of samples of audio to be captured per second. We will use standard 44100 samples per second i.e. 44.1KHz.

Audio Sample:
Size of 1 sample. 1 sample is signed 16 bits in size and therefore can represent total 65536 volume levels. Negative samples have value from -1 to -32768 and +ve samples have value from 0 to 32767. We will use Mono samples only. Please refer to Audio documentation on Wikipedia, website or a book for further information on samplerate etc.

This project uses libGDX audio recorder interface to capture audio from MIC. Code is extremely simple to understand and implement on multiple platforms. Functions to create & delete recorder.

public final void make_recorder() {
        if( m_rec == null ) {
            m_rec =, true);
            m_samples = new short[ (int)(44100f / FPS)];            
    public void destroy_recorder() {
        if( m_rec != null ) {
            m_rec = null;

Below code is used for capturing audio samples in a buffer for drawing purpose., 0, m_samples.length);
// plot samples by moving from left middle of screen to right middle. Delta is how
// high the resolution of plotting is.
for( float i = 0; i <= 100f; i += delta ) {

m_sample is a short buffer of size 44100/FPS. This is because in this project we draw screen at 25FPS and every frame plots audio data. So we divide 1 second of audio into 25 parts and sync with screen. Total samples we need per frame is 44100/FPS.

Pseudo code of drawing audio data:
  • Capture 44100/FPS number of samples into SAMPLES buffer. 
  • Loop from left middle of screen i.e. x=0 to x=100% of screen width plotting audio sample related to the % value. Means x=0% means 0% position of sample in SAMPLES. x=35% = 35/100 x SAMPLES's SIZE. Formula: Audio Sample = PERCENT_POS/100 * SAMPLES's SIZE. 
  • Take amplitude of sample as per your choice and plot audio using pixel. Plot line between current and last sample. 

Visualizer snapshot:

Download link for java only source code of project.


With same logic i built my Sound Visualizer which renders beautiful design using voices. It can be called Rangoli Maker or simple Mandalas or Cymatics kind of plotter. Cymatics needs lots of calculation in 3D but this app is good for flower like designs.

Download link for Android app: