The following steps will get you started with Music Synthesizer for Android code in a Unix-like environment. Read each step carefully. Also check out the notes section for further details on the project. The following environment variables are used:
SYNTH_PATH
- The folder which contains the Music Synthesizer source code.PROTO_PATH
- The folder which contains the Protocol Buffers.
The following is a list of IDEs, SDKs, libraries, other necessary software. Download and extract them.
-
The Java Development Kit. (JDK7 recommended)
-
One of the following IDEs running the newest Android API.
- Eclipse for Java Developers with the Android SDK Tools and Android Development Tools Plugin.
- Android Studio (Not yet fully supported by this project.)
-
The Android Native-Code Development Kit (NDK). Tip: If you extract it to
$HOME/android-ndk
(leaving out the version number) a future step will be easier. -
The Google Protocol Buffers. Tip: If you extract it to
$HOME/protobuf
(leaving out the version number) a future step will be easier. -
Debian (Ubuntu) Only
Run the following commands to download and install necessary software and libraries:
sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install git lib32z1 libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5 g++ maven default-jre default-jdk
Using Git, clone the Music Synthesizer for Android source code and set your SYNTH_PATH
variable:
cd $HOME
git clone https://github.com/matthewcordaro/music-synthesizer-for-android.git
export SYNTH_PATH=$HOME/music-synthesizer-for-android
-
Set your
PROTO_PATH
variable. Example:export PROTO_PATH=$HOME/protobuf
-
Build the protocol buffer binary by running the following commands:
cd $PROTO_PATH ./configure --prefix=$PROTO_PATH make make check make install
-
Build the protocol buffer runtime library by running the following commands:
cd $PROTO_PATH/java mvn test mvn install mvn package
Install the pre built Windows protoc
compiler in $SYNTH_PATH/core/bin
.
Copy the binary and runtime library to the project folder by running the following commands:
mkdir $SYNTH_PATH/core/bin $SYNTH_PATH/core/lib
cp $PROTO_PATH/bin/protoc $SYNTH_PATH/core/bin/
cp $PROTO_PATH/java/target/protobuf-java-*.jar $SYNTH_PATH/core/lib/libprotobuf.jar
To make sure everything is installed correctly so far, run the ant tests. If they do not all pass, verify that you have done the above steps properly.
cd $SYNTH_PATH
ant test
You will probably want to add the SYNTH_PATH
and PROTO_PATH
environment variables to the OS so life is a little easier. You may want to include both the NDK and SDK Tools on your PATH
as well.
- Goto Control Panel > System and Security > System.
- Click on "Advanced System Settings".
- Click on "Environment Variables".
- Add the variables by clicking on "New" under "User Variables" or "System Variables" depending on your preference.
Append the export X_PATH=path/to/something
to the end of your ~/.profile
, /etc/profile
, or /etc/environment
depending on your preference.
Now we use the NDK to build the shared libraries. (libsynth.so
files that will be found in $SYNTH_PATH/android/libs/*/
.) You can either manually run the NDK compile, or have your Eclipse project run it automatically.
-
For manual building, make sure that the NDK folder is in your
PATH
variable and run:cd $SYNTH_PATH/android ndk-build
-
For automatic Eclipse building, first run the manual build. Then, if your NDK is saved to
$HOME/android-ndk
, Eclipse should automatically work and you can skip this step. Otherwise, edit$SYNTH_PATH/android/.externalToolBuilders/NDK Builder.launch
to make sure thatATTR\_LOCATION
points to a valid location for the ndk-build binary, such as${HOME}/android-ndk/ndk-build
.
Tip: If you run into any errors, try ndk-build clean
then ndk-build
before searching for a fix.
- Make a new workspace.
- Import the project. File > Import > Android > Existing Android Code Into Workspace. Follow on-screen instructions.
Tip: If you receive many errors that state "X cannot be resolved to a type" then it is likely your NDK generated Java files are not linked properly. Go to Project > Properties > Resource > Linked Resources and click on Linked Resources tab. Finally edit the core-gen variable to point to PROJECT_LOC/core-gen
or similar. This may not solve the issue; you may need to manually build the NDK code.
- The synthesizer engine is written in C++ for performance, and uses OpenSL ES to output sound.
- A NDK build depends on the target architecture (unlike Java code). It can be changed by editing
APP\_ABI
in the$SYNTH_PATH/android/jni/Application.mk
file. We have defaultedAPP\_ABI
toall
so that it will run on all possible devices. However, this slows the compile cycle and increases the APK file size. If you are routinely editing code for a single device, you may want to change this to the proper architecture. See here for more information. Note: Code built forarmeabi
will run on ARM v7 devices, but more slowly. - The core, test, and j2se packages can be built using Ant. So the desktop tools in the j2se package can still be built without an IDE.
- In Eclipse you will probably get errors on import (duplicate entry 'src', empty ${project_loc}, and maybe others). You can ignore these (although it would be great to clean them up).