Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctlra v1 #203

Closed
wants to merge 7 commits into from
Closed

Ctlra v1 #203

wants to merge 7 commits into from

Conversation

harryhaaren
Copy link
Member

Initial implementation of Ctlra support for Luppp. This is based on POC code from ~2016, when the Ctlra library was being designed. Since then the API has seen lots of updates, and these commits hack those changes into Luppp.

Note that the actual architecture of the current implementation is not correct, as the ctlra_idle_poll() function is called from the real-time audio context. This means that these patches are NOT ready for use on stage, as they WILL cause glitches and Xruns when Ctlra enabled devices are plugged into your system.

This PR is here to show the workings of Ctlra and Luppp - and to allow alpha testers etc to get access to the codebase. More commits will be pushed as time permits! -H

This is an import and rework of previous POC of the Ctlra
library and Luppp. The initial code had many rebase conflicts
with Luppp (it was done during Nov 2016, and as a POC for the
TCC scripting components, hence was not good quality and each
commit wasn't well split - hence this single bulk commit).

Signed-off-by: Harry van Haaren <[email protected]>
Signed-off-by: Harry van Haaren <[email protected]>
Ctlra devices now being accepted by Luppp :)

Signed-off-by: Harry van Haaren <[email protected]>
This enables initial prototyping

Signed-off-by: Harry van Haaren <[email protected]>
Signed-off-by: Harry van Haaren <[email protected]>
@harryhaaren harryhaaren self-assigned this Mar 25, 2018
@coderkun
Copy link
Contributor

coderkun commented Mar 29, 2018

Hi @harryhaaren, I am trying to compile this branch but am failing to tell Luppp about Ctlra.

Is it correct to compile Ctlra separately (with meson build && cd build && ninja)? How do I link Ctlra so that Luppp’s compile.sh finds it? Or does meson (for Luppp) replace running compile.sh? Sorry if this might be obvious …

@harryhaaren
Copy link
Member Author

Hey @coderkun ; good question! You must install Ctlra to make Luppp pick it up:

$ cd /path/to/ctlra/
meson configure -Dprefix=/usr
ninja install # note this installs to your system-wide location

Then in Luppp

meson build
cd build
ninja

Make sure that you have "libtcc" installed too, the Luppp implementation depends on it.

Good luck, and post back if you're having issues. Cheers! -H

@coderkun
Copy link
Contributor

coderkun commented Mar 31, 2018

@harryhaaren, I would really like to avoid installing Ctlra system-wide. Therefore I tried to install it in ~/.local with the following steps:

Cltra

meson --prefix ~/.local build
ninja -C build
ninja -C build install

Luppp

PKG_CONFIG_PATH=~/.local/lib/pkgconfig/ meson build

So the meson build for Luppp finds the Ctlra dependency but fails with this error:

meson.build:38:2: ERROR: Could not generate cargs for openav_ctlra:

Investigating further reveals that I might be missing the AVTK library:

$ PKG_CONFIG_PATH=~/.local/lib/pkgconfig/ pkg-config --cflags --libs openav_ctlra
Package openav_avtka was not found in the pkg-config search path.
Perhaps you should add the directory containing `openav_avtka.pc'
to the PKG_CONFIG_PATH environment variable
Package 'openav_avtka', required by 'openav_ctlra', not found

Unfortunately OpenAV-AVTK does not ship with a PKG-Config file and also does not provide an “install” target, does it?

Sorry for bothering you with these environmental issues …

@harryhaaren
Copy link
Member Author

@coderkun - nice work - you're making good progress!

Note that there are now two (very similarly named) UI toolkits, AVTK (the old C++ one) and AVTKA (which Ctlra uses, and is a simpler plain-C re-write).

Ctlra is looking for AVTKA. You can install it using the same method as you did for using Ctlra, by prefixing the PKG_CONFIG_PATH env var, and then building Ctlra, and after that Luppp.

There are ways to make Luppp download / compile Ctlra / Avtka directly (using Meson), which would remove this issue for you. I'll consider adding it ASAP after merging this - to make it easier to test / deploy.

Thanks for your work on this - let me know if the above helps enough, or if I should prioritize adding the "automated" download / compile of Ctlra/Avtka for Luppp.

@coderkun
Copy link
Contributor

coderkun commented Apr 1, 2018

Some progress here. First, thanks for the hint re “Avtka”, @harryhaaren, I had the wrong one. To summarize first, I am able to build all three libraries/application but have issues with ctlra_test.c. Here is how I compile now:

Fix Avtka dep

First I had to fix Avtka’s “gd” dependency to be lowercase (“GD” does not find it for me)

Compile Avtka, Cltra and Luppp

Then I build all three libraries/applications with the same commands (though install does not do anything for Luppp):

PKG_CONFIG_PATH=~/.local/lib/pkgconfig/ meson --prefix ~/.local build
ninja -C build
ninja -C build install

Run Luppp

Finally I run Luppp with the following

cd /path/to/luppp/gcc
$ LD_LIBRARY_PATH=~/.local/lib/ ../build/luppp

ctlra_test.c

The last commad starts Luppp properly but complains about ctlra_test.c. One issue seems to be that stdio.h is missing – though I am not certain about tcc here. If I fix that tcc complains about additional issues but does not give any useful error message.

I am not sure if these additional issues are due to my environment or due to one of these steps. But it some progress which I want to document. Let me know, if this is not the right place for that.

@harryhaaren
Copy link
Member Author

@coderkun - great progress! The last steps are to copy a few files to the "build" folder. Again this step should be made automatic - or somehow easier for testing, alpha quality code here.

From Ctlra, copy event.h to the build directory

From the build dir, copy the "luppp_script_api.h" file:

cp ../src/controller/luppp_script_api.h .

Finally a header called "pstdint.h" is required,

wget https://raw.githubusercontent.com/mongodb/mongo-perl-driver/master/pstdint.h

At the end, there should be beside the luppp binary, the event.h file from Ctlra, pstdint.h and luppp_script_api.h for the Luppp control itself. The ctlra_test.c file is the TCC enabled "script" that you can modify at runtime and remap controllers.

Note: the <luppp>/gcc directory has the pstdint.h and ctlra_test.c files already present.

meson gcc  # that should be enough to build Luppp in the gcc directory :)

Let me know how that goes - its the last step I think... -H

@coderkun
Copy link
Contributor

coderkun commented Apr 5, 2018

The build etc. all works fine now (using gcc as the build folder) but starting Luppp still complains about the Ctlra script:

$ cd gcc
$ LD_LIBRARY_PATH=~/.local/lib/ ./luppp
[…]
[Luppp] Gui:475: Add Ctlra Controller in GUI()
[Luppp] CtlraScript:311: CtlraScript() got file ctlra_test.c
TCC ERROR: ctlra_test.c:27: warning: implicit declaration of function 'printf'
TCC ERROR: /usr/lib/tcc/libtcc1.a:1: error: declaration expected
failed to alloc mem for program

TCC ERROR: /usr/lib/tcc/libtcc1.a:1: error: declaration expected
failed to relocate code to program memory

compile failed
[Luppp] Gui:482: Ctlra Controller initialization failed!

@harryhaaren, I am not sure what I am doing wrong. Do you have any clue or any hint how to proceed?

@georgkrause
Copy link
Contributor

I have the same issue. Obviously compiling the ctlra_test.c fails for any reason. the first error could be fixed by

#include <stdio.h>

remains the memory allocation error without any further information.

@coderkun
Copy link
Contributor

coderkun commented Apr 8, 2018

Do you think the version of tcc could cause a difference? I am using 0.9.27, @harryhaaren, which one are you using?

@georgkrause
Copy link
Contributor

Here is the Howto build the branch: https://github.com/openAVproductions/openAV-Luppp/wiki/Building-ctlra_v1-branch
Will keep it updated, maybe a good tool so simplify the progress.

@georgkrause
Copy link
Contributor

gcc/ should be added to .gitignore

@coderkun
Copy link
Contributor

coderkun commented Apr 8, 2018

Finally success: It works for me using tcc 0.9.26! I created an issue for Cltra for this: openAVproductions/openAV-Ctlra#79.

Now I can start testing the actual functionality. Sorry for all the noise.

@harryhaaren
Copy link
Member Author

@coderkun thanks for your perseverence! Lets see how you go from here :)

@georgkrause This is a WIP branch - and the gcc/ directory contains useful files for testing. You're right in that it shouldn't be merged as is - and that's also not the intention.

@georgkrause
Copy link
Contributor

@harryhaaren sorry because of this gcc folder, i thought all stuff in there is generated, but now i know its in the repository. my fault, nevermind and sorry!

@harryhaaren
Copy link
Member Author

I'm closing this PR. The Ctlra codebase could still be used directly by Luppp, but there is not a huge advantage to doing so. The Mappa PR (#241) is a much smaller code-change, and provides better runtime user-experience as well as easier integration for users.

Cancelling this PR doesn not mean that there will not be Ctlra support in Luppp. The hardware device IO will still use Ctlra library, but the Mappa API is used (instead of raw ctlra) to also fix the mapping of hw->sw problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants