[Moto G4 Play ROMs, Kernels, Recoveries, & Other De] facuarmo:
Hello guys and welcome to my latest little experiment. This time, I'm trying to figure out how to get Munt working properly in the harpia, also, talking directly to the souncard (something that I couldn't get done yet).

First of all, let me say that this is an updated version of this guide https://retropie.org.uk/forum/topic/12549/tutorial-installing-munt-mt-32-emulation-on-rpi-3 for the RPi 3, this time I'll also cover some broken dependencies in Ubuntu, even though the one that's missing doesn't appear to be necessary at all. Anyways, the point is that all credits for 80% or more of the command belong to that thread's owner.

Let's begin!

ON YOUR COMPUTER

Clone this kernel's repo to your computer (just customized HybridX).

git clone https://github.com/Akianonymus/kernel_moto_msm8916 -b hxo-harpia ~/midikernel

Patch it to enable MIDI kernel support.

cd ~/midikernel && wget 'https://gist.githubusercontent.com/FacuM/68615a2102923eb349fef053789acd8b/raw/f4fd7f1d41bdcb38160c41ae073fa2bb1345ccc1/0001-enable-virtual-MIDI-devices-and-expose-the-sequencer.patch' && patch -p1 < 0001-enable-virtual-MIDI-devices-and-expose-the-sequencer.patch

Install the required dependencies.

sudo apt-get update
sudo apt-get -y install build-essential bc

Now build it.

bash harpia.sh

Now push the zip inside of ~/midikernel/Anykernel2/harpia to your device and flash it through recovery.

NOW ON THE SMARTPHONE

Download Linux Deploy from the Play Store.

Install the distro, I suggest you using Ubuntu as it's easier to set up than any other.

Start by tapping on the "Properties" button.

Set it up as follows:

Just in case you can't see the pictures:

Containerization method: chroot

Distribution: Ubuntu

Architecture: armhf

Distribution suite: xenial

Installation type: File

Installation path: /sdcard/linux.img

Image size (MB): 1536

File system: ext4

Section "Mounts" -> Enable (ticked)

Mount points -> Add -> /sdcard

Section "SSH" -> Enable (tick)

Leave everything else as-is, then, go back.

Now hit menu and tap install.

Wait some time, it's likely to take a kinda big amount of time.

Okay, now that you're all set, let's move to the smartphone's just created distro container and connect us through SSH.

Spawn a terminal and connect as follows...

ssh android@yourLANip

I'll show you an example in my own case.

Boom, magic.

Then, after providing it your password, it'll look like this. The default is root.

Here comes the best part: install all the dependencies.

Type the next command:

sudo apt-get update && sudo apt-get install build-essential cmake portaudio19-dev libx11-dev libxt-dev libxpm-dev glib2.0 wget

Now, lets supply the system some packages that haven't been yet published for xenial but are likely required.

wget 'http://launchpadlibrarian.net/134644780/qtmobility-dev_1.2.0-3ubuntu5_armhf.deb' && sudo dpkg -i qtmobility-dev_1.2.0-3ubuntu5_armhf.deb && sudo apt-get -y install -f

All done! Lets get Munt code.

wget 'https://github.com/munt/munt/archive/munt_2_3_0.tar.gz' && tar -xzf munt_2_3_0.tar.gz

Alrighty, now create the directories where to build.

mkdir munt-build && cd munt-build

Setting the compiler flags. Well, this part is pretty hard to understand if you aren't used to software compilation. But lets say that it's how explains the build system what to build and for which software/hardware combos. After a little investigation, I've got to the conclusion that the Odroid-C1's are the right ones for this device.

export CCFLAGS="-Ofast -mcpu=cortex-a5 -mfpu=neon-vfpv4 -mfloat-abi=hard -ftree-vectorize -funsafe-math-optimizations"
export CXXFLAGS="-Ofast -mcpu=cortex-a5 -mfpu=neon-vfpv4 -mfloat-abi=hard -ftree-vectorize -funsafe-math-optimizations"

All done! Now we can go to the actual thing: build it.

Issue this command:

cmake -DCMAKE_BUILD_TYPE=Release -Dmunt_WITH_MT32EMU_QT:BOOL=OFF ../munt-munt_2_3_0/

You should see something like this:

If everything went as expected, build it!

make -j$(nproc --all)

Sample output:

Install it!

sudo make install

Sample output:

It's time to build the ALSA Midi driver.

cd ../munt-munt_2_3_0/mt32emu_alsadrv && make && sudo make install

Sample output:

Now download the MT-32 ROMs from https://docs.google.com/open?id=0B5j-_ZMS8_UoY2MxOWRmMzktZmZhOS00M2EwLWFkZGItODNmODY4ZjU5Y2Vi (thanks to this thread) and place them i.e. in /sdcard/Download.

Create the path for the ROMs and put them there:

sudo mkdir /usr/share/mt32-rom-data && sudo cp /sdcard/Download/*.ROM /usr/share/mt32-rom-data/

NOTE: The ROMs found in that GDrive folder aren't properly named. Rename them as follows:

cd /usr/share/mt32-rom-data && sudo mv CM32L_CONTROL.1989-12-05.v1.02.ROM CM32L_CONTROL.ROM && sudo mv MT32_CONTROL.1988-09-30.vX.XX-patched.ROM MT32_CONTROL.ROM

That's all! :cowboy:

From now on, there are two ways to use this. I still haven't figured out how to get one of them working, but I'll soon get you news.

First way (recommended):

sudo mt32d -o 2

This will spawn a process that you should be able to use with DOSBox or some other software supporting this MIDI device. Its hardware ID is 128:0.

or

You can just render a WAV lossless file outta your MID MT file. This is done through this command: (I'll be testing with Space Quest III's track, you can get it here)

sudo mt32emu-smf2wav /sdcard/Download/sq3mt/SQ3MT.MID -m /sdcard/Download/ -d 0 -r 1 --src-quality=3

NOTE: I provide you with the most useful arguments that I've found and improve the converter's behavior. Feel free to try on your own.

This will leave you with something like this:

The process will really likely take some time as the recording quality is REALLY high. Anyways, as this is uncompressed audio, with a supported player such as foobar2000 you can try and listen to it while it's being done. It'll just stop when it reaches the end of the render.

I hope you liked it, feel free to post any suggestion or improvements that can be made.

Credits:

+/- 80% of this thread: "David87" on Retropie forum.

Kernel source: to anyone involved, but mainly [MENTION=7598239]@ki[/MENTION] for such stable sources.

To me: for having such a huge free time and lonely life to bring something so useless to an Android device.