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

Initial Implementation of LV2 module #983

Merged
merged 6 commits into from
Jul 1, 2024

Conversation

joinlaw
Copy link
Contributor

@joinlaw joinlaw commented May 11, 2024

Can be tested with melt eg:

$ melt ~/path/to/audio/file.wav -attach "lv2.http<//kxstudio.sf.net/carla/plugins/audiogain_s" 5=0.3 -consumer avformat:processed.mp3 acodec=libmp3lame

(:) in http://kxstudio.sf.net/carla/plugins/audiogain_s replaced with (<) because melt and/or mlt doesn't accept (:) in plugin name and also uri should be prefiexed with "lv2."

currently only this extensions are supported:
http://lv2plug.in/ns/ext/buf-size#boundedBlockLength
http://lv2plug.in/ns/ext/urid#map
http://lv2plug.in/ns/ext/urid#unmap
http://lv2plug.in/ns/ext/options#options

https://lv2plug.in/pages/host-compatibility.html

Copy link
Member

@ddennedy ddennedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach of copying the jackrack module and modifying it is not acceptable. That brings in a lot of baggage. jackrack code base was chosen at a time when I needed to support a rack XML file made with its GUI tool for a customer. This was a time when there were only some toy GUI tools for MLT. As a bonus it added support for JACK. I later modified it to support a single named LADSPA plugin for Kdenlive and friends. This ought to be a cleaner implementation without all of that baggage. I guess you can get there by continuing to modify, but I am not in a situation where I want to go through many PR reviews to get there. Alternatively, can the existing jackrack module be extended to support LV2?

src/modules/lv2/factory.c Outdated Show resolved Hide resolved
src/modules/lv2/factory.c Outdated Show resolved Hide resolved
src/modules/lv2/factory.c Outdated Show resolved Hide resolved
src/modules/lv2/factory.c Outdated Show resolved Hide resolved
src/modules/lv2/filter_lv2.c Outdated Show resolved Hide resolved
src/modules/lv2/filter_lv2.yml Outdated Show resolved Hide resolved
src/modules/lv2/filter_lv2.yml Outdated Show resolved Hide resolved
src/modules/lv2/producer_lv2.yml Outdated Show resolved Hide resolved
@joinlaw
Copy link
Contributor Author

joinlaw commented May 13, 2024

The approach of copying the jackrack module and modifying it is not acceptable. That brings in a lot of baggage. jackrack code base was chosen at a time when I needed to support a rack XML file made with its GUI tool for a customer. This was a time when there were only some toy GUI tools for MLT. As a bonus it added support for JACK. I later modified it to support a single named LADSPA plugin for Kdenlive and friends. This ought to be a cleaner implementation without all of that baggage. I guess you can get there by continuing to modify, but I am not in a situation where I want to go through many PR reviews to get there. Alternatively, can the existing jackrack module be extended to support LV2?

At first I tried to extend the jackrack module and even put both LADSPA and LV2 plugins in the same plugin manager but I fail to get working code for months until I tried copying and I get here.

Actually I have to think about the approach and take time to be more familiar with filter design in mlt. The problem is it was hard for me to use same structure of plugin/process/manager so I have to heavily alter it and only lock_free_fifo.c, lock_free_fifo.h files copied without modification.

@joinlaw
Copy link
Contributor Author

joinlaw commented May 17, 2024

with this commit aba53e9 now parameters metadata is more accurate and not causing issues and be readonly

kdenwork

And still I don't get dropdown options (enumerations) to work.

I am investigating ways to integrate this module in jackrack.

@joinlaw joinlaw force-pushed the lv2-module branch 2 times, most recently from 9646013 to 189bbf4 Compare May 24, 2024 13:20
@joinlaw
Copy link
Contributor Author

joinlaw commented May 24, 2024

By now this feature is reimplemented as part of jackrack module and the old implementation moved to lv2-module-old-way https://github.com/joinlaw/mlt/tree/lv2-module-old-way branch.

@ddennedy

src/modules/jackrack/filter_lv2.c Outdated Show resolved Hide resolved
src/modules/jackrack/filter_lv2.c Outdated Show resolved Hide resolved
@joinlaw
Copy link
Contributor Author

joinlaw commented Jun 28, 2024

With commit 1de2a58 enumeration is supported and also I created MR in kdenlive project https://invent.kde.org/multimedia/kdenlive/-/merge_requests/520 to support it in the generic UI. In the case of Shotcut from what I see that shotcut does not generate generic effect UI there should be a manually created qt UI file and I don't look into other projects using mlt.

Screenshot from 2024-06-28 18-08-09

Comment on lines 277 to 287
char *lv2context_can_ui = mlt_environment ("lv2context_can_ui");
if (lv2context_can_ui != NULL)
{
/* Video editors and other hosts that support custom GUI should use mlt_environment_set ("lv2context_can_ui", "1")
to inform mlt lv2 plugin manager and set UI features and extensions if not set.
*/
if (lv2context_can_ui[0] == '1')
{
//WIP: if support UI
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For hosts (ie. Video Editors) that want to support LV2 Custom GUIs they should set the mlt environment variable "lv2context_can_ui" to "1" and the the lv2 plugin instance will be instantiated with LV2 UI features and extensions and then they can get "global_lv2_world" handle of LilvWorld* and and retrieve the UI URI and handles and create ui support with suil library (http://drobilla.net/software/suil.html).

This is the plan for supporting Custom GUIs.

@ddennedy
Copy link
Member

Do not force push to a PR that has a lot of changes and already had some review. When you force push I need to start over the review because I can not see what you changed from I left off. And when there is a lot of code, it makes the reviewer more reluctant to start over.

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved

if(USE_LV2 AND TARGET PkgConfig::lilv)
target_link_libraries(mltjackrack PRIVATE PkgConfig::lilv)
target_sources(mltjackrack PRIVATE filter_lv2.c producer_lv2.c lv2_context.c lv2_plugin.c lv2_process.c lv2_plugin_settings.c)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the new header files to this as well as my IDE uses this to show the project files. You can see all of our CMakeLists.txt do that including other target_sources in the same file.

@ddennedy
Copy link
Member

Build target clang-format-check fails with many errors. I noticed problems immediately when I start editing files, and git diff showed many unrelated changes because my IDE is setup to follow our clang-format rules and reformats some of the code. One of the biggest issues is using tab characters for indent. clang-format should be following our include .clang-format config file.

@ddennedy
Copy link
Member

Not wanting to be a total downer, I did run it (with my change to use ^), and it is working including things like melt -query and serializing to XML with melt -consumer xml my.mp4 -attach lv2.http^//calf.sourceforge.net/plugins/Crusher 20=100

...
    <filter id="filter0">
      <property name="mlt_service">lv2.http^//calf.sourceforge.net/plugins/Crusher</property>
      <property name="20">100</property>
    </filter>
...

I also ran the above for several frames through valgrind, and it did not complain about any memory problems in this new code. So, just these few things to tidy up, and it is ready!

@ddennedy ddennedy added this to the v7.26.0 milestone Jul 1, 2024
@ddennedy ddennedy merged commit 8c744a6 into mltframework:master Jul 1, 2024
6 checks passed
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

2 participants