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

Lv2 core implementation #4899

Closed
wants to merge 155 commits into from
Closed

Conversation

JohannesLorenz
Copy link
Contributor

@JohannesLorenz JohannesLorenz commented Mar 17, 2019

This is a first minimal Lv2 plugin, supporting the whole core, except for CV ports.
No features or extensions are supported yet.

What should work:

  • Generate sound using Lv2 plugins and effects
  • Any kind of automation
  • Correct stereo linking behavior
  • Instrument window's "Plugin" tab resizes to fit all knobs
  • Loading/Saving

What does not work yet:

  • After linking models, values are swapped instead of being the same #4904 Unlinking one stereo model, changing its values, then changing
    values of a linked one, then clicking "Link Channels" does not really link
    the first stereo model (bug imported from Ladspa) -> Will be fixed with next master merge.
  • Known Bug: Triple Oscillator has an orange stripe on its "Plugin" tab
  • Known Bug: Many old instruments windows are resized wrong
  • Known Bug: Instrument windows are resized wrong in some cases when using the arrows to switch instruments in the instrument window. This bug does only affect projects with at least one "variable sized instrument".
  • Known Bug: VST/Vestige cannot be instantiated

Code Reviewers:

Feel free to split the review or just look at everything you're interested in.

Review hints:

  • Lv2Manger.h provides a full overview of the new Lv2 classes. It may be easier
    to first look there.
  • Possible things to check may include memory issues or deviations from the Lv2 specs.

Testers:

Testing hints:

  • Most CALF and some MDA effects work.
  • For testing an instrument, you can use the x42 testsignal generator (Instruments with piano are unsupported in the Lv2 core).
  • You can test scale points/combo boxes using the "MDA combo" effect.
  • Many plugins will not be recognized. The console logs them and shows reasons.

On advance, many thanks for reviewing and testing!

Add labeled controls for different types with a common base class
Implement a container for multiple equal groups of linked models and
suiting views. Such groups are suited for representing mono effects where each
Model occurs twice. A group provides Models for one mono processor and is
visually represented with a group box.

This concept is common for LADSPA and Lv2, and useful for any mono effect.
For an explenation about the new Lv2 classes, see Lv2Manager.h
@JohannesLorenz JohannesLorenz added this to the 1.3.0 milestone Mar 17, 2019
@JohannesLorenz
Copy link
Contributor Author

Sorry for the CI failure. It seems like it only requires replacing two assert calls with Q_ASSERT. I'll fix this ASAP.

@JohannesLorenz
Copy link
Contributor Author

CI is working again (the left CI errors don't look code related) and I removed a lot of dead code so the code should get more readable.

Copy link
Member

@Spekular Spekular left a comment

Choose a reason for hiding this comment

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

First pass cosmetic review, checked for rule Add a space after if, else if, else, for, do, while and switch.

plugins/Lv2Effect/Lv2Effect.cpp Outdated Show resolved Hide resolved
plugins/Lv2Effect/Lv2Effect.cpp Outdated Show resolved Hide resolved
plugins/Lv2Effect/Lv2FxControlDialog.cpp Outdated Show resolved Hide resolved
plugins/Lv2Effect/Lv2FxControlDialog.cpp Outdated Show resolved Hide resolved
plugins/Lv2Effect/Lv2FxControlDialog.cpp Outdated Show resolved Hide resolved
src/gui/Lv2ViewBase.cpp Outdated Show resolved Hide resolved
src/gui/Lv2ViewBase.cpp Outdated Show resolved Hide resolved
src/gui/Lv2ViewBase.cpp Outdated Show resolved Hide resolved
src/gui/Lv2ViewBase.cpp Outdated Show resolved Hide resolved
src/gui/Lv2ViewBase.cpp Outdated Show resolved Hide resolved
@Spekular
Copy link
Member

Spekular commented Apr 4, 2019

There are some violations of the rule:

Do not add a space after opening brackets or a space before closing brackets.

If you interpret it strictly. Another rule in the conventions gives this example:
if (m_sample > 0) {--m_sample;}

Whereas your code occasionally uses this style:
if (m_sample > 0) { --m_sample; }

However, I can't bring myself to "correct" the latter in review as it looks far more readable to me and I question the original rule. When using explicitly blocked brackets, there should obviously not be spaces before/after. However, for one liners I feel the opposite is true, there should obviously be spaces between the brackets and the code itself.

Copy link
Member

@Spekular Spekular left a comment

Choose a reason for hiding this comment

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

Finished my style review. A fair amount of places that don't use explicit blocking, so I added comments for that. Don't necessarily agree with that change either, feels like vertical space will balloon in some places if it's "fixed".

plugins/Lv2Effect/Lv2Effect.cpp Outdated Show resolved Hide resolved
plugins/Lv2Effect/Lv2Effect.cpp Outdated Show resolved Hide resolved
src/core/lv2/Lv2Ports.cpp Outdated Show resolved Hide resolved
src/core/lv2/Lv2Ports.cpp Outdated Show resolved Hide resolved
src/core/lv2/Lv2Ports.cpp Outdated Show resolved Hide resolved
src/core/lv2/Lv2Ports.cpp Outdated Show resolved Hide resolved
src/gui/Lv2ViewBase.cpp Outdated Show resolved Hide resolved
Spekular and others added 2 commits April 4, 2019 18:33
Apply fixes according to coding conventions, thanks to @Spekular

Co-Authored-By: JohannesLorenz <[email protected]>
@JohannesLorenz
Copy link
Contributor Author

All comments solved again. I think the only one that might require a second look is the D/W fix 4c2a52a, but even that should be correct.

@DomClark @PhysSong Please let me know if there are more things to change or whether you are OK with the PR now.

@JohannesLorenz
Copy link
Contributor Author

Thanks. This means all mandatory reviews are passed now.

After there have been so many changes and merges, I'd like to still ask someone to test it through again before we're going to master. Especially loading/saving.

I invited you, @douglasdgi , for now. Some testing hints are in the top post.

@JohannesLorenz
Copy link
Contributor Author

JohannesLorenz commented May 7, 2020

One issue is that there's currently hundreds of lines of debug output coming when you start LMMS, like:

Lv2 plugin "LSP Spektrumanalysator x1" (URI: http://lsp-plug.in/plugins/lv2/spectrum_analyzer_x1 ) can not be loaded:
  -  unknown port type for mandatory port : UI Input
  -  unknown port type for mandatory port : UI Output
  -  required feature not supported : http://lv2plug.in/ns/ext/urid#map

I think I'll disable this unless the user sets an environment variable, like LMMS_LV2_DEBUG.

-> EDIT: Solved in bca38f0.

@JohannesLorenz
Copy link
Contributor Author

Thanks to @douglasdgi for reporting: If you have installed lv2, but not lilv, you get

CMake Error at CMakeLists.txt:191 (IF):
  if given arguments:

    "1" "AND"

  Unknown arguments specified

The code line is IF(${LV2_FOUND} AND ${LILV_FOUND}) . Anyone an idea how to fix this?

@LostRobotMusic
Copy link
Contributor

It would be good if the search bar in the effects was unselected upon clicking the top bar of the window (or really just anywhere in the window other than the search bar), so that the user can use their keyboard to play whatever instrument they have open without needing to switch windows.

Copy link
Member

@PhysSong PhysSong left a comment

Choose a reason for hiding this comment

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

@JohannesLorenz This will fix the reported issue.

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
JohannesLorenz and others added 2 commits May 17, 2020 08:11
@JohannesLorenz
Copy link
Contributor Author

JohannesLorenz commented May 17, 2020

@douglasdgi I fixed it in 867973c . Can you please check if it's fixed well?

Do you plan to test more or are you finished with testing? (If you're done, you can approve by submitting a PR review)

CMakeLists.txt Outdated Show resolved Hide resolved
@JohannesLorenz
Copy link
Contributor Author

All reviews successful. I'll try to merge it tomorrow.

@JohannesLorenz
Copy link
Contributor Author

I did some git tricks to get the branch content with a single commit into master (2a66e83) while leaving this branch as it is, so I'm closing this branch now.


private:
Lv2FxControls m_controls;
std::vector<sampleFrame> m_tmpOutputSmps;
Copy link
Member

Choose a reason for hiding this comment

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

This is invalid because sampleFrame is an array type. For some reason, libstdc++ allows it. This fails to build on macOS(reported on Discord), but the CI was not spotting this because you didn't add LV2 packages to macOS CI builds.

Copy link
Member

Choose a reason for hiding this comment

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

Can we redefine sampleFrame from sample_t[DEFAULT_CHANNELS] to std::array<sample_t, DEFAULT_CHANNELS>? The latter is generally recommended over plain arrays in modern C++ as it is much better behaved.

Copy link
Member

Choose a reason for hiding this comment

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

@DomClark That's what's done in #4994.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be fixed now in a new PR #5536 .

@Reflexe you will need to merge this branch (or rebase to master) - If you do, watch out for merge conflicts in lines marked "@recording".

JohannesLorenz added a commit that referenced this pull request Sep 21, 2020
... in order to make standard containers be able to store it. Required for
#5532 (#4899) and the recording PR.

This includes:

* removing the `LocklessRingBuffer<sampleFrame>` specialization
* passing samplerame in `StereoDelay::tick` as a reference

Additional cleanups:

* removing already unused typedef `sampleFrameA`
* add some `const_cast` to make code more readable
sdasda7777 pushed a commit to sdasda7777/lmms that referenced this pull request Jun 28, 2022
... in order to make standard containers be able to store it. Required for
LMMS#5532 (LMMS#4899) and the recording PR.

This includes:

* removing the `LocklessRingBuffer<sampleFrame>` specialization
* passing samplerame in `StereoDelay::tick` as a reference

Additional cleanups:

* removing already unused typedef `sampleFrameA`
* add some `const_cast` to make code more readable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

8 participants