After discovering the Dolby Audio developer program at a conference recently, I really wanted to try their new Dolby Audio Java Android API, but I didn’t want to learn Java programming to do it.
This seemed like a perfect opportunity to try out Xamarin’s Java Bindings Library project for Xamarin.Android applications.
Dolby as an audio company needs no introduction, but you may not know that are focusing on the mobile space and they have a developer program for app app developers. What this means is, if you have mobile device that includes Dolby hardware, you can make use of this hardware to greatly enhance the audio in your apps in games. There are quite a few Dolby enabled devices on the market, but probably most notably are the new Kindle Fire HD & HDX Amazon tablets.
Check out Dolby’s free developer program here and download their API:
If you’re a C# developer and you haven’t heard much about Xamarin yet; you will. But the quick summary is, they make really amazing tools for developers to create native iOS, Mac & Android applications, from either a Mac or PC, entirely written in .NET C#.
* Full disclosure – when I started this blog I was simply a mobile developer that preferred to write as much code as possible in C#. This naturally led me to Xamarin - and I love their products. However, at the time of writing, I am working as an instructor for Xamarin’s training & certification program: Xamarin University. But definitely download the free trial and check it out:
Installation / Setup:
I’m not going to walk through the Xamarin setup, simply because they already have great docs on how to do it:
For the Dolby Audio API, you’ll just need to register as a developer, login, and download the Android API (bottom of the page):
The Dolby Audio API is at version 1.1 at the time of writing
I’m using the Xamarin.Android Business edition with Visual Studio 2013 on Windows 8.1, but this should all work perfectly in Xamarin Studio on either a Mac or PC.
Creating the Project:
In either Visual Studio 2012/2013 or Xamarin Studio, start to create a new project, browse to the the Android templates, choose the “Java Bindings Library” project type, pick your location, and press the OK button.
Add the Dolby Audio API Jar:
If you haven’t already, unzip the Dolby API package – “Dolby_audio_plugin_api_v220.127.116.11.zip”. In the Library folder you should see “dolby_audio_processing.jar”. Simply drag this file into the “Jars” folder of your newly created DolbyAudioAPI Binding project.
Then change the build action of the Jar file to “Embedded Jar”.
* Note, if you’re binding an API that contains additional reference jars. You would also add them to the “Jars” folder in your project and set the build action to “EmbeddedReferenceJar”.
Build the Project:
Now we just need to build the project, which will create a Xamarin.Android compatible dll that we’ll be able to reference in our Xamarin.Android projects.
In some cases, when you create a binding project you may get build issues. You would then need to edit the mappings used to create the binding. Fortunately for us in this case, the Dolby Audio API is well formed and well structured, making binding a straight forward process.
If you run into difficulties I definitely recommend checking out Xamarin article on Binding a Java Library here:
Reference the new Binding Assembly:
Our last step is to simply reference our new library in a Xamarin.Android project.
We can do this in two ways:
If we create a Xamarin.Android project in the same solution as the binding project, we can simply add a reference in our new project to the binding project.
Or we can directly reference the created dll, which you can find in either the bin\release or bin\debug folders of your binding project. If you’re planning on copying the dll to another location you just need the library - “DolbyAudioAPI.dll”.
Using the Dolby Audio API:
We can now start interacting with the Dolby Audio API from within our Xamarin.Android project(s). Dolby has done a great job of documenting the API in the downloadable API package, check out the Quick Start guide in the “Documents” folder first: “QSGuide-DolbyAudioAndroidPlug-in.pdf”.
Additionally there is sample Java code on their developer portal:
I’ll be showing how to use the Dolby Audio API in C# with Xamarin.Android in a following post. But in the mean time, you can download the binding project along with two Xamarin.Android sample apps from GitHub here: