RebelTechnology / OwlServer

Web-based Client/Server application for the Open Ware Laboratory
GNU General Public License v2.0
2 stars 2 forks source link

Support Faust and PD patch compilation #80

Closed pingdynasty closed 9 years ago

pingdynasty commented 9 years ago

Faust patches (.dsp files) should be compiled with make ... faust sysex. PD patches (.pd files) should be compile with make ... heavy sysex. That is, to compile Faust and PD patches add faust and heavy respectively, as the first make target.

For PD patches there is another complication. make heavy invokes a script in Tools/Heavy which sends the PD file to the Enzien audio website for compilation. It asks the user for login credentials then stores a token in ~/.heavy/token. An additional parameter must be passed in: HEAVYFILE. This should be the name of the main PD file.

For the online compiler, we can use (for now) fixed credentials: just run the script once to generate the token. Username owl.

Example: copy HeavyOwl.pd to PathSource and run (as www-data!) make HEAVYFILE=HeavyOwl.pd heavy sysex

pingdynasty commented 9 years ago

Minor change in build procedure. To build FAUST, specify a FAUST option, there is no more faust target. To build PD, specify a HEAVY option, as well as the heavy target. See OwlProgram readme.

sam-artuso commented 9 years ago

I'm not clear with the full command needed to build faust and pd patches.

Could you give me a full example for each?

pingdynasty commented 9 years ago

for FAUST:

make BUILD=/tmp/build PATCHSOURCE=/tmp/src FAUST=Crybaby PATCHNAME='Faust/Crybaby' PATCHCLASS=CrybabyPatch PATCHFILE=CrybabyPatch.hpp sysex

http://hoxtonowl.com/patch-library/patch/Faust_Crybaby/

Note that the PATCHFILE, CrybabyPatch.hpp, is created by the build script from the faust source file which is Crybaby.dsp. So set the variables thus: given a .dsp file foo.dsp set FAUST=foo (filename minus .dsp), PATCHCLASS=fooPatch (FAUST plus Patch), PATCHFILE=fooPatch.hpp (PATCHCLASS plus .hpp)

pingdynasty commented 9 years ago

For PD there seems to be a problem... The command should be:

make BUILD=/tmp/build PATCHSOURCE=/tmp/src HEAVY=HeavyOwl PATCHNAME=HeavyOWL PATCHCLASS=HeavyPatch PATCHFILE=HeavyPatch.hpp heavy sysex

Note the additional heavy target. However with an empty build directory, this only works the second time it is invoked. There's a wildcard which misses some generated files first time. I don't currently have a fix for this. Is it easy enough to call the makefile twice for PD files? First with 'make heavy', then with 'make heavy sysex' - everything else identical.

pingdynasty commented 9 years ago

This is the issue http://stackoverflow.com/questions/15048091/gnu-make-wildcard-function-doesnt-find-runtime-generated-files No solution listed!

sam-artuso commented 9 years ago

i can't get Faust patches to build.

...and the build will miserably fail!

Output:

In file included from /opt/OwlProgram.online/LibSource/basicmaths.c:1:0:
/opt/OwlProgram.online/LibSource/basicmaths.h:54:5: warning: 'arm_sqrt_f32' is static but used in inline function 'arm_sqrt' which is not static
    arm_sqrt_f32(in, &out);
    ^
Building patch Faust/Crybaby
faust: unrecognized option "-i"
faust: unrecognized option "-inpl"
ERROR : can't open architecture file owl.cpp

        Instructions to add CrybabyPatch.hpp to your owl pedal

Copy file [[ CrybabyPatch.hpp ]] to OwlWare/Libraries/OwlPatches directory

Add line [[ #include "CrybabyPatch.hpp" ]] to OwlWare/Libraries/OwlPatches/includes.h file

Add line [[ REGISTER_PATCH(CrybabyPatch, "CrybabyPatch", 2, 2); ]] to OwlWare/Libraries/OwlPatches/patches.cpp file

Rebuild the firmware using the command make in OwlWare directory

Upload the resulting firmware OwlWare/build/OwlWare.bin to the pedal using the OwlNest software.

/tmp/build/patch.cpp: In function 'void setup()':
/tmp/build/patch.cpp:1:16: error: 'CrybabyPatch' does not name a type
REGISTER_PATCH(CrybabyPatch, "Faust/Crybaby", 2, 2);
                ^
/opt/OwlProgram.online/Source/PatchProgram.cpp:23:73: note: in definition of macro 'REGISTER_PATCH'
#define REGISTER_PATCH(T, STR, IN, OUT) registerPatch(STR, IN, OUT, new T)
                                                                        ^
Makefile:146: recipe for target '/tmp/build/PatchProgram.o' failed
make: *** [/tmp/build/PatchProgram.o] Error 1

Any clue about what I'm doing wrong?

P.S.: The ouput of make seems to be much less verbose than on nestor, even when compiling normal patches. Do you happen to know why?

pingdynasty commented 9 years ago

I'll try to install faust from source http://sourceforge.net/p/faudiostream/code/ci/master/tree/

The build is less verbose because I edited the Makefile (and common.mk) on nestor to be more verbose.

pingdynasty commented 9 years ago

Working now on nestor and ulrike

make BUILD=/tmp/b PATCHSOURCE=/tmp/s FAUST=AutoWah sysex
sam-artuso commented 9 years ago

Re PD patches, since I don't know the password, I copied your token from ~mars/.heavy/token (hope it's all right).

I don't currently have a fix for this. Is it easy enough to call the makefile twice for PD files? First with 'make heavy', then with 'make heavy sysex' - everything else identical.

Here's my shot at building tamagazzi's HeavyOwl:

cd /tmp
mkdir {src,build}
cd src
wget wget https://raw.githubusercontent.com/tamagazzi/OWL-Heavy_Pure-Data-patches/master/HeavyOwl.pd
cd /opt/OwlProgram.online
make BUILD=/tmp/build PATCHSOURCE=/tmp/src HEAVY=HeavyOwl PATCHNAME=HeavyOWL PATCHCLASS=HeavyPatch PATCHFILE=HeavyPatch.hpp heavy
make BUILD=/tmp/build PATCHSOURCE=/tmp/src HEAVY=HeavyOwl PATCHNAME=HeavyOWL PATCHCLASS=HeavyPatch PATCHFILE=HeavyPatch.hpp heavy sysex
# fails with error message:
# make[1]: Leaving directory '/opt/OwlProgram.online'
# make: *** No rule to make target 'sysx'.  Stop.

But if I do make heavy sysex twice the patch seems to build successfully (even though I can't be 100% sure it did).

Suggestions?

pingdynasty commented 9 years ago

make: *** No rule to make target 'sysx'. Stop. I don't know where this comes from - did you mistype sysex? make heavy sysex twice seems to be the way. If the second command finishes with 0 exit status then you're good to go.

sam-artuso commented 9 years ago

Re PD patches, I think there's another issue with these two environment variables:

PATCHFILE=HeavyPatch.hpp
PATCHCLASS=HeavyPatch

It's not clear to me how I can derive the values of PATCHFILE and PATCHCLASS. All I have is the name of the source code file, which is HeavyOwl.pd.

I looked into the Makefile and these names seem to be hardcoded? Should I hardcode them too then?

pingdynasty commented 9 years ago

yes, PATCHFILE and PATCHCLASS are fixed for PD patches.

pingdynasty commented 9 years ago

in fact you don't have to pass them in, as the Makefile sets them - it would be slightly better if you didn't: in case they need to change in the future I can change them in the Makefile.

sam-artuso commented 9 years ago

Heavy's uploader.py works on ulrike but it doesn't on nestor. Here's the error:

$ make BUILD='/tmp/build' PATCHSOURCE='/tmp/src' PATCHNAME='HeavyOWL' PATCHIN=0 PATCHOUT=2 HEAVY='HeavyOwl' heavy sysex
Enter username: owl
Enter password: 
Traceback (most recent call last):
  File "./Tools/Heavy/uploader.py", line 276, in <module>
    main()
  File "./Tools/Heavy/uploader.py", line 139, in main
    verify=False if args.noverify else True)
  File "/usr/lib/python2.7/dist-packages/requests/api.py", line 85, in post
    return request('post', url, data=data, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/api.py", line 40, in request
    return s.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 229, in request
    r.send(prefetch=prefetch)
  File "/usr/lib/python2.7/dist-packages/requests/models.py", line 523, in send
    (body, content_type) = self._encode_files(self.files)
  File "/usr/lib/python2.7/dist-packages/requests/models.py", line 374, in _encode_files
    fn, fp = v
ValueError: too many values to unpack
make: *** [/tmp/build/HeavySource/Heavy_owl.h] Error 1

I tried to dig in uploader.py's source code but can't get my head round the issue. Any clues?

pingdynasty commented 9 years ago

urgh - different python versions? I'll have a look.

pingdynasty commented 9 years ago

nestor has Python 2.7.3, ulrike has Python 2.7.9. Not sure that is the problem or not. The required 'requests' package is called python-requests-oauthlib in more recent installations, but not on wheezy. I've sent a query to Martin Roth and Joe White, will see what they say.

pingdynasty commented 9 years ago

Martin R says The original error that you sent me is coming from within the requests module, perhaps that needs to be updated on your python installation (pip install --upgrade requests).

pingdynasty commented 9 years ago

Heavy and Faust compilation fails instantly on staging with Patch compilation failed. Please check the logs for errors., though stdout and stderr both say Please wait... Tested http://staging.hoxtonowl.com/patch-library/patch/HeavyOWL/ and http://staging.hoxtonowl.com/patch-library/patch/Faust_Crybaby/

sam-artuso commented 9 years ago

Uninstalled the Debian-packaged version of the requests module and reinstalled the same version as on the staging server with the Python package manager.

Managed to build all PD patches on nestor (from command line only, for now).

sam-artuso commented 9 years ago

All C++ and Faust patches can now be built from the website (both in staging and production). All the patches I tried will build successfully if they can be built from command line.

Re PD patches, there is one last issue with the token (which took me a while to understand). For security reasons, the OWL API is running as the nobody user, who (being nobody) doesn't have a home directory: there's nowhere to store the token.

I think I can change uploader.py so that it accepts the token as a command line argument. Or alternatively, I can run the API as a normal system user (less safe). Opinion?

ghost commented 9 years ago

Yes pls hack the uploader - we'll push the changes back to @mhroth and @enzienaudio if they want them.

sam-artuso commented 9 years ago

What is the original repository of the uploader?

pingdynasty commented 9 years ago

afaik it's not public. Issues are here https://github.com/enzienaudio/heavy

On 21/08/15 12:46, Sam Artuso wrote:

What is the original repository of the uploader?

— Reply to this email directly or view it on GitHub https://github.com/pingdynasty/OwlServer/issues/80#issuecomment-133385688.

sam-artuso commented 9 years ago

Problem fixed. All 3 PureData patches will now build successfully on staging and production.

GuillaumeLeNost commented 9 years ago

Very cool ! I succesfully tested the PD compile on the production.

Cheers G

Le 24 août 2015 à 21:00, Sam Artuso notifications@github.com a écrit :

Problem fixed. All 3 PureData patches will now build successfully on staging and production.

— Reply to this email directly or view it on GitHub https://github.com/pingdynasty/OwlServer/issues/80#issuecomment-134340003.

sam-artuso commented 9 years ago

Can we close this off?

pingdynasty commented 9 years ago

good work!