Skip to content

Commit

Permalink
feat: new WrapperEvent fields via #93
Browse files Browse the repository at this point in the history
  • Loading branch information
demberto committed Oct 27, 2022
1 parent 807a17e commit 1166779
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Time.gate`, `Time.shift` and `Time.full_porta` [#89].
- *Experimental* Python 3.11 support is back.
- A shit ton of flags in `VSTPlugin` and refactoring [#95].
- `WrapperEvent.page`, `WrapperEvent.height`, `WrapperEvent.width` [#93].

### Changed

Expand All @@ -50,6 +51,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#88]: https://github.com/demberto/PyFLP/issues/88
[#89]: https://github.com/demberto/PyFLP/issues/89
[#90]: https://github.com/demberto/PyFLP/issues/90
[#93]: https://github.com/demberto/PyFLP/issues/93
[#95]: https://github.com/demberto/PyFLP/issues/95

## [2.0.0a4] - 2022-10-22

Expand Down
Binary file added docs/img/plugin/wrapper/page.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 50 additions & 9 deletions pyflp/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ class _WrapperFlags(enum.IntFlag):
Visible = 1 << 0
_Disabled = 1 << 1
Detached = 1 << 2
Maximized = 1 << 3
# _U3 = 1 << 3
Generator = 1 << 4
SmartDisable = 1 << 5
ThreadedProcessing = 1 << 6
DemoMode = 1 << 7 # saved with a demo version
HideSettings = 1 << 8
Captionized = 1 << 9 # TODO find meaning
Minimized = 1 << 9
_DirectX = 1 << 16 # indicates the plugin is a DirectX plugin
_EditorSize = 2 << 16

Expand Down Expand Up @@ -150,11 +150,33 @@ class SoundgoodizerEvent(StructEventBase):
).compile()


class WrapperPage(ct.EnumBase):
Editor = 0
""":guilabel:`Plugin editor`."""

Settings = 1
""":guilabel:`VST wrapper settings`."""

Sample = 3
""":guilabel:`Sample settings`."""

Envelope = 4
""":guilabel:`Envelope / instrument settings`."""

Miscellaneous = 5
""":guilabel:`Miscallenous functions`."""


class WrapperEvent(StructEventBase):
STRUCT = c.Struct(
"_u1" / c.Bytes(16), # 16
"flags" / StdEnum[_WrapperFlags](c.Int16ul), # 18
"_u2" / c.Bytes(34), # 52
"_u1" / c.Optional(c.Bytes(16)), # 16
"flags" / c.Optional(StdEnum[_WrapperFlags](c.Int16ul)), # 18
"_u2" / c.Optional(c.Bytes(2)), # 20
"page" / c.Optional(StdEnum[WrapperPage](c.Int8ul)), # 21
"_u3" / c.Optional(c.Bytes(23)), # 44
"width" / c.Optional(c.Int32ul), # 48
"height" / c.Optional(c.Int32ul), # 52
"_extra" / c.GreedyBytes, # None as of 20.9.2
).compile()


Expand Down Expand Up @@ -324,23 +346,33 @@ def __init__(self, events: EventTree, **kw: Any):
super().__init__(events, **kw)

compact = _WrapperProp(_WrapperFlags.HideSettings)
"""Whether plugin page toolbar is hidden or not.
"""Whether plugin page toolbar (:guilabel:`Detailed settings`) is hidden.
![](https://bit.ly/3qzOMoO)
"""

demo_mode = _WrapperProp(_WrapperFlags.DemoMode)
"""Whether the plugin state was saved in a demo / trial version of the plugin."""
demo_mode = _WrapperProp(_WrapperFlags.DemoMode) # TODO Verify if this works
"""Whether the plugin state was saved in a demo / trial version."""

detached = _WrapperProp(_WrapperFlags.Detached)
"""Plugin editor can be moved between different monitors when detached."""

disabled = _WrapperProp(_WrapperFlags._Disabled)
"""This is a legacy property; DON'T use it.
Check :attr:`Channel.enabled` or :attr:`Slot.enabled` instead.
"""

directx = _WrapperProp(_WrapperFlags._DirectX)
"""Whether the plugin is a DirectX plugin or not."""

generator = _WrapperProp(_WrapperFlags.Generator)
"""Whether the plugin is a generator or an effect."""

maximized = _WrapperProp(_WrapperFlags.Maximized)
height = StructProp[int](PluginID.Wrapper)
"""Height of the plugin editor (in pixels)."""

minimized = _WrapperProp(_WrapperFlags.Minimized)
"""Whether the plugin editor is maximized or minimized.
![](https://bit.ly/3QDMWO3)
Expand All @@ -349,12 +381,21 @@ def __init__(self, events: EventTree, **kw: Any):
multithreaded = _WrapperProp(_WrapperFlags.ThreadedProcessing)
"""Whether threaded processing is enabled or not."""

page = StructProp[WrapperPage](PluginID.Wrapper)
"""Active / selected / current page.
![](https://bit.ly/3ffJKM3)
"""

smart_disable = _WrapperProp(_WrapperFlags.SmartDisable)
"""Whether smart disable is enabled or not."""

visible = _WrapperProp(_WrapperFlags.Visible)
"""Whether the editor of the plugin is visible or closed."""

width = StructProp[int](PluginID.Wrapper)
"""Width of the plugin editor (in pixels)."""


AnyPlugin = _PluginBase[AnyEvent] # TODO alias to _IPlugin + _PluginBase (both)

Expand Down
16 changes: 16 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
PluginID,
Soundgoodizer,
VSTPlugin,
WrapperPage,
)

from .conftest import ModelFixture
Expand Down Expand Up @@ -95,6 +96,21 @@ def test_vst_plugin(plugin: PluginFixture[VSTPlugin]):
def test_fruity_wrapper(plugin: PluginFixture[VSTPlugin]):
wrapper = plugin("fruity-wrapper.fst", VSTPlugin)

# WrapperEvent properties
assert not wrapper.compact
assert not wrapper.demo_mode
assert not wrapper.detached
assert not wrapper.directx
assert not wrapper.disabled
assert wrapper.generator
assert wrapper.height == 410
assert not wrapper.minimized
assert wrapper.multithreaded
assert wrapper.page == WrapperPage.Settings
assert not wrapper.smart_disable
assert wrapper.visible
assert wrapper.width == 561

# VSTPluginEvent properties
assert wrapper.automation.notify_changes
assert wrapper.compatibility.buffers_maxsize
Expand Down

0 comments on commit 1166779

Please sign in to comment.