GOOD NEWS EVERYBODY.
After a few weeks, I’ve finally gotten [ffplay~] to compile for the Organelle M. AND IT WORKS. It was comforting to hear the sounds of home – WFMU – coming through the lil speaker, while I’ve been with my family in San Diego during difficult times.
I’ll do my best to describe the process. It is unfortunately rather involved, but could be vastly simplified with a better Makefile.
Prerequisites:
- OS 4.2 (others may work, just noting it here)
- connect the organelle to the internet
- ssh or vnc in
- set the OS to read-write:
> sudo ./home/music/fw_dir/scripts/remount-rw.sh
- I did all of this in
/sdcard
but it doesn’t really matter
First of all, one needs to have the latest versions of Pure Data and FFmpeg:
> git clone https://github.com/pure-data/pure-data.git
> git clone https://github.com/FFmpeg/FFmpeg.git
The library that contains ffplay~
is called “pd-quilt”. Clone its repo (and submodules) too:
> git clone --recursive https://github.com/myQwil/pd-quilt.git
You don’t need to build or install Pure Data, we just need the latest header files for building ffplay~
.
We do need to build and install ffmpeg. As it’s a newer version than is provided by the official Organelle repository, let’s install and use checkinstall
to make sure we can easily remove/replace it if needed:
> sudo apt update && sudo apt install checkinstall
Now ffmpeg (in the FFmpeg repo):
> ./configure
> make
> sudo checkinstall
Be patient, the ffmpeg steps take the longest (about 15 minutes to compile, several minutes at least for building the package for checkinstall
).
The reason we have to install ffmpeg is because it’s rather large and the pd-quilt author wisely decided to dynamically link it to the pure data lib. Unfortunately, this means we have to fiddle with either where ffmpeg installs itself, or fiddle with the linker configuration (by telling it where the libraries it needs are located). I chose the latter because, from my non-expert perspective, it’s more explicit (that is, easier to poke at until things work).
OK! Now we have to build one of pd-quilt’s submodules, game-music-emu
. First, it requires cmake
.
> sudo apt install cmake
In the pd-quilt/game-music-emu
directory:
> mkdir build
> cd build
> cmake ../
> make -j4
As became clear to me once I figured out the secret sauce for the linking step, we need to install zlib:
> sudo apt install zlib1g zlib1g-dev
At this point we’re ready to actually compile ffplay~
Except that for reasons I’m not entirely clear on, the Makefile
will fail to properly link the external libraries. As best I have been able to gather, it’s because of the cc
invocation: the order of the libs to be linked is significant, and they all need to come before the object files; and the -l
statements need to directly follow their corresponding -L
statements. Needless to say, the Makefile doesn’t do this right.
The build command output by the Makefile is correct, so back up in the pd-quilt
repo: > PDINCLUDEDIR=/sdcard/pure-data/src make ffplay~.pd_linux -j4
For reference, this is what it’s running (it gets spit out into the console):
cc -DPD -I "/sdcard/pure-data/src" -DUNIX -fPIC -DBLUNT=1 -DDATE=\"2022-05-27\" -DTIME=\"11:49:07\" -I./game-music-emu/gme -Wall -Wextra -Wshadow -Winline -Wstrict-aliasing -O3 -ffast-math -funroll-loops -fomit-frame-pointer -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard -o /sdcard/repos/pd-quilt/src/ffplay~.o -c /sdcard/repos/pd-quilt/src/ffplay~.c
And now the corrected link command:
cc -rdynamic -shared -fPIC -Wl,-rpath,"\$ORIGIN",--enable-new-dtags /sdcard/repos/pd-quilt/src/ffplay~.o -L/usr/local/include/libswresample -lswresample -L/usr/local/include/libavformat -lavformat -L/usr/local/include/libavcodec -lavcodec -L/usr/local/include/libavutil -lavutil -L/usr/include -lsamplerate -L/lib/arm-linux-gnueabihf -lz -lc -lm -o ffplay~.pd_linux
There you go! You should see ffplay~.pd_linux
sitting in the directory. You can copy it to wherever you keep your pure data externs and it should work.
Lemme know if anything here isn’t clear or if I seem to have left something out or got it wrong. Obviously it’s quite a number of steps and I may have gotten something wrong writing it out. I could also post the compiled external, and it should work so long as you compile and install ffmpeg exact as I have.
If anybody is a make
expert or knows someone here who may be, we should try to update it to take care of all of these details more automatically.