cannam@162
|
1 # piper-vamp-js/examples/docker/Dockerfile
|
cannam@162
|
2 #
|
cannam@162
|
3 # Example of the whole process of taking an existing Vamp plugin
|
cannam@162
|
4 # and turning it into a Piper Javascript module.
|
cannam@162
|
5 #
|
cannam@162
|
6 # The process is not automatic: you have to create a C++ main file and
|
cannam@162
|
7 # adjust build properties in the Makefile.
|
cannam@162
|
8 #
|
cannam@162
|
9 # Normally you would create a repo for your converted module and keep
|
cannam@162
|
10 # your newly-created files in that. (The other examples in this repo,
|
cannam@162
|
11 # examples/vamp-example-plugins and examples/vamp-test-plugin,
|
cannam@162
|
12 # illustrate that.)
|
cannam@162
|
13 #
|
cannam@162
|
14 # However in this example we will start with a Vamp plugin that we
|
cannam@162
|
15 # have not yet written any of these files for, and illustrate creating
|
cannam@162
|
16 # those -- although using batch processing tools rather than an
|
cannam@162
|
17 # interactive editor.
|
cannam@162
|
18 #
|
cannam@162
|
19 # This is provided as a Docker file in order to ensure it can be
|
cannam@162
|
20 # reproducibly run, and illustrate all the steps from a clean
|
cannam@162
|
21 # environment.
|
cannam@162
|
22 #
|
cannam@162
|
23 # There are four phases to this:
|
cannam@162
|
24 #
|
cannam@162
|
25 # 1. Install prerequisite packages, download all needed repos, and
|
cannam@162
|
26 # build dependencies and required tools.
|
cannam@162
|
27 #
|
cannam@162
|
28 # 2. Obtain the Vamp plugin that we are actually intending to convert,
|
cannam@162
|
29 # and compile it in the normal way (i.e. as a C++ plugin) so that
|
cannam@162
|
30 # the generator can load and examine it.
|
cannam@162
|
31 #
|
cannam@162
|
32 # 3. Make a new working folder for our conversion, generate an
|
cannam@162
|
33 # initial version of the C++ main entry point for the module, and
|
cannam@162
|
34 # edit anything that the generator got wrong.
|
cannam@162
|
35 #
|
cannam@162
|
36 # 4. Create a Makefile and run the JS module build.
|
cannam@162
|
37 #
|
cannam@162
|
38 # Let's go...
|
cannam@162
|
39 #
|
cannam@162
|
40 # (Using Arch Linux base: installing Emscripten on Ubuntu is a right
|
cannam@162
|
41 # mess unless you want to recompile the whole thing)
|
cannam@162
|
42 #
|
cannam@162
|
43 FROM base/archlinux:2017.06.01
|
cannam@162
|
44 MAINTAINER Chris Cannam <cannam@all-day-breakfast.com>
|
cannam@162
|
45
|
cannam@162
|
46
|
cannam@162
|
47 # Phase 1. Install prerequisite packages...
|
cannam@162
|
48 #
|
cannam@162
|
49 RUN echo 'Server = http://archlinux.mirrors.uk2.net/$repo/os/$arch' > /etc/pacman.d/mirrorlist
|
cannam@162
|
50 RUN pacman --noconfirm -Syu && \
|
cannam@162
|
51 pacman --noconfirm -Sy \
|
cannam@162
|
52 gcc \
|
cannam@162
|
53 make \
|
cannam@162
|
54 boost \
|
cannam@162
|
55 pkg-config \
|
cannam@162
|
56 emscripten \
|
cannam@162
|
57 python \
|
cannam@162
|
58 jre8-openjdk-headless \
|
cannam@162
|
59 nodejs \
|
cannam@162
|
60 libsndfile \
|
cannam@162
|
61 curl \
|
cannam@162
|
62 git \
|
cannam@162
|
63 mercurial
|
cannam@162
|
64 RUN rm -rf /var/cache/pacman/pkg/*
|
cannam@162
|
65 ENV PATH $PATH:/usr/lib/emscripten
|
cannam@162
|
66 RUN locale-gen en_US.UTF-8
|
cannam@162
|
67 ENV LANG en_US.UTF-8
|
cannam@162
|
68 #
|
cannam@162
|
69 # ... download all needed repos, including this one! ...
|
cannam@162
|
70 #
|
cannam@162
|
71 RUN git clone https://github.com/piper-audio/piper
|
cannam@162
|
72 RUN git clone https://github.com/piper-audio/piper-vamp-js
|
cannam@162
|
73 RUN git clone https://github.com/piper-audio/piper-vamp-cpp
|
cannam@162
|
74 RUN git clone https://github.com/c4dm/vamp-plugin-sdk
|
cannam@162
|
75 RUN git clone https://github.com/c4dm/vamp-test-plugin
|
cannam@162
|
76 #
|
cannam@162
|
77 # ... and build the dependencies and required tools
|
cannam@162
|
78 #
|
cannam@162
|
79 WORKDIR vamp-plugin-sdk
|
cannam@162
|
80 RUN ./configure && make && make install
|
cannam@162
|
81 ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/local/lib
|
cannam@162
|
82 WORKDIR ..
|
cannam@162
|
83 WORKDIR piper-vamp-js
|
cannam@162
|
84 # (Get the first run of Emscripten, which sets it up, out of the way)
|
cannam@162
|
85 RUN em++ --version
|
cannam@162
|
86 RUN make
|
cannam@162
|
87 WORKDIR ..
|
cannam@162
|
88
|
cannam@162
|
89
|
cannam@162
|
90 # Phase 2. Obtain the Vamp plugin that we are actually intending to
|
cannam@162
|
91 # convert, and compile it in the normal way (i.e. as a C++ plugin)
|
cannam@162
|
92 # so that the generator can load and examine it.
|
cannam@162
|
93 # For this example we are going to convert the Simple Cepstral Pitch
|
cannam@162
|
94 # Tracker plugin, see
|
cannam@162
|
95 # https://code.soundsoftware.ac.uk/projects/cepstral-pitchtracker
|
cannam@162
|
96 #
|
cannam@162
|
97 RUN git clone https://github.com/cannam/cepstral-pitchtracker
|
cannam@162
|
98 WORKDIR cepstral-pitchtracker
|
cannam@162
|
99 RUN make -f Makefile.linux64
|
cannam@162
|
100 WORKDIR ..
|
cannam@162
|
101
|
cannam@162
|
102
|
cannam@162
|
103 # Phase 3. Make a new working folder for our conversion...
|
cannam@162
|
104 #
|
cannam@162
|
105 RUN mkdir js-cepstral-pitchtracker
|
cannam@162
|
106 WORKDIR js-cepstral-pitchtracker
|
cannam@162
|
107 #
|
cannam@162
|
108 # ... generate an initial version of the C++ main entry point for
|
cannam@162
|
109 # the module...
|
cannam@162
|
110 #
|
cannam@162
|
111 RUN VAMP_PATH=../cepstral-pitchtracker \
|
cannam@162
|
112 ../piper-vamp-js/bin/piper-vamp-stub-generator cepstral-pitchtracker \
|
cannam@162
|
113 | tee cepstral-pitchtracker.cpp
|
cannam@162
|
114 #
|
cannam@162
|
115 # ... and edit anything that the generator got wrong. In this case,
|
cannam@162
|
116 # the only problem is that it has written [cC]epstralPitchtracker where
|
cannam@162
|
117 # the original code has [cC]epstralPitchTracker. Let's also remove the
|
cannam@162
|
118 # prompt comments the generator included.
|
cannam@162
|
119 #
|
cannam@162
|
120 RUN perl -i -p -e 's/Pitchtracker/PitchTracker/g' cepstral-pitchtracker.cpp
|
cannam@162
|
121 RUN perl -i -p -e 's,^//.*\n,,' cepstral-pitchtracker.cpp
|
cannam@162
|
122 RUN cat cepstral-pitchtracker.cpp
|
cannam@162
|
123
|
cannam@162
|
124
|
cannam@163
|
125 # Phase 4. Create a Makefile and run the JS module build. This is a
|
cannam@163
|
126 # bit ugly because we're trying to stuff the whole content of the
|
cannam@163
|
127 # Makefile into our Docker script!
|
cannam@162
|
128 #
|
cannam@162
|
129 RUN echo \
|
cannam@162
|
130 'PIPER_VAMP_JS_DIR := ../piper-vamp-js\n\n\
|
cannam@162
|
131 PLUGIN_DIR := ../cepstral-pitchtracker\n\
|
cannam@162
|
132 SRC_DIR := $(PLUGIN_DIR)\n\n\
|
cannam@162
|
133 MODULE_NAME := CepstralPitchTracker\n\
|
cannam@162
|
134 MODULE_SOURCE := cepstral-pitchtracker.cpp\n\n\
|
cannam@162
|
135 PLUGIN_SOURCES := $(SRC_DIR)/AgentFeeder.cpp $(SRC_DIR)/CepstralPitchTracker.cpp $(SRC_DIR)/NoteHypothesis.cpp $(SRC_DIR)/PeakInterpolator.cpp\n\n\
|
cannam@162
|
136 INCLUDES := -I$(SRC_DIR)\n\n\
|
cannam@162
|
137 include $(PIPER_VAMP_JS_DIR)/Makefile.inc' | sed 's/\\n/\n/g' > Makefile
|
cannam@162
|
138 RUN cat Makefile
|
cannam@162
|
139 RUN make em
|
cannam@162
|
140 RUN ls -l
|
cannam@162
|
141 RUN make test
|
cannam@162
|
142
|