A Makefile for UTAU Projects

2019/04/17

C: Tutorials

Edit 2019-05-24: Updated Makefile to generate file list automatically (line 2).

I'm currently making a new cover using UTAU, after having broken the last streak of covers. This time, I thought I'd try using make to help with rendering.

My biggest obstacle is automating the rendering itself: I don't know if UTAU has a command line interface, and using xdotool proved to be too unreliable when I tried. (It was frustrating.)

As it turned out, automating the rest of the rendering process is still really helpful. Here is the Makefile for UTAU projects[1]:

1
2
3
4
5
6
7
8
UTAU = env WINEPREFIX=/home/kisaragi-hiu/.wineprefix/UTAU wine "C:\\Program Files (x86)\\UTAU\\utau.exe"
WAV = $(patsubst %.ust,%.wav,$(wildcard *.ust))

render: $(WAV)
.PHONY: render

$(WAV): %.wav: %.ust
        $(UTAU) "$(realpath $<)"

Which simply runs $(UTAU) <ust full path> for each UST that's newer than its corresponding output file. The caveat here is that the UST needs to share its name with its output, which has to be set manually.

Now when I run make render, UTAU windows will pop up one by one for me to manually do the render[2]. This may not be quite automatic, but it's at least better than manually opening every UST in the project and rendering them.

[1] References used: Learn X in Y minutes, Use `make`! by freeCodeCamp, and File Name Functions in the manual.

[2] Alt-p g RET if the output file name has been set.