-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d204b68
commit f0dabeb
Showing
2 changed files
with
129 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,74 @@ | ||
""" | ||
common > param | ||
Code for interacting with plugin parameters. | ||
Authors: | ||
* Miguel Guthridge [[email protected], HDSQ#2154] | ||
This code is licensed under the GPL v3 license. Refer to the LICENSE file for | ||
more details. | ||
""" | ||
import plugins | ||
|
||
from common.plug_indexes import PluginIndex | ||
from abc import abstractmethod | ||
|
||
|
||
class PluginParameter: | ||
""" | ||
This is an abstract class used to provide type safety when modifying plugin | ||
parameters. | ||
""" | ||
|
||
@abstractmethod | ||
def __init__(self, index: PluginIndex) -> None: | ||
""" | ||
Associate the parameter with a plugin instance. This allows the | ||
parameter properties to be modified. | ||
""" | ||
... | ||
|
||
@abstractmethod | ||
@property | ||
def value(self) -> float: | ||
""" | ||
The value of the parameter (read/write) | ||
""" | ||
... | ||
|
||
@value.setter | ||
@abstractmethod | ||
def value(self, newValue: float): | ||
... | ||
|
||
@abstractmethod | ||
@property | ||
def name(self) -> str: | ||
""" | ||
The name of the parameter | ||
""" | ||
... | ||
|
||
|
||
def Param(paramIndex: int) -> type[PluginParameter]: | ||
""" | ||
A `Param` represents a parameter for a plugin. This function generates a | ||
`PluginParameter` class that can be used to access the parameter given a | ||
plugin instance. | ||
```py | ||
# Create a parameter definition | ||
SustainParam = Param(5) | ||
# ... | ||
def Param(paramIndex: int): | ||
class PluginParameter: | ||
def eFader1(control: ControlShadowEvent, plugin: GeneratorIndex): | ||
# Associate the parameter with the given plugin, then set its value | ||
SustainParam(plugin).value = control.value | ||
``` | ||
""" | ||
class IndexedPluginParameter(PluginParameter): | ||
def __init__(self, index: PluginIndex) -> None: | ||
self.__plug = index | ||
|
||
|
@@ -36,4 +100,4 @@ def name(self) -> str: | |
True | ||
) | ||
|
||
return PluginParameter | ||
return IndexedPluginParameter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters