Skip to content

Commit

Permalink
Add doc effect, input, output, update_type, updates_observer, param, …
Browse files Browse the repository at this point in the history
…observable_list. Add symbol attribute: input, output, param. Param now is indexed by symbol (like input, output)
  • Loading branch information
SrMouraSilva committed Nov 28, 2016
1 parent 76e13f5 commit 6c5bdfb
Show file tree
Hide file tree
Showing 20 changed files with 271 additions and 77 deletions.
13 changes: 13 additions & 0 deletions docs/source/model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,22 @@ This page contains the model classes.
SystemOutput->Output;

Lv2Param->Param;

BanksManager->Bank [dir="forward", arrowhead="odiamond", arrowtail="normal"];
BanksManager->ObserverManager [dir="forward", arrowhead="none", arrowtail="normal"];
ObserverManager->UpdatesObserver [dir="forward", arrowhead="odiamond", arrowtail="normal"];
ModHost->UpdatesObserver
}


BanksManager
------------

.. autoclass:: pluginsmanager.banks_manager.BanksManager
:members:
:special-members:


Bank
----

Expand Down
2 changes: 1 addition & 1 deletion docs/source/model_system.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PedalPi - PluginsManager - Model - System
=========================================

SystemEffectBuilder
----------------
-------------------

.. autoclass:: pluginsmanager.model.system.system_effect_builder.SystemEffectBuilder
:members:
Expand Down
2 changes: 1 addition & 1 deletion pluginsmanager/mod_host/mod_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ModHost(UpdatesObserver):
"""
Python port for mod-host::
**Python port for mod-host**
`Mod-host`_ is a `LV2`_ host for Jack controllable via socket or command line.
This class offers the mod-host control in a python API::
Expand Down
14 changes: 4 additions & 10 deletions pluginsmanager/mod_host/protocol_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ def _get_out_name_of(effect_output):
if isinstance(effect_output, SystemOutput):
return '{}:{}'.format(effect, effect_output)

symbol = effect_output._output['symbol']
return 'effect_{}:{}'.format(effect.instance, symbol)
return 'effect_{}:{}'.format(effect.instance, effect_output.symbol)

@staticmethod
def _get_in_name_of(effect_input):
Expand All @@ -110,9 +109,7 @@ def _get_in_name_of(effect_input):
if isinstance(effect_input, SystemInput):
return '{}:{}'.format(effect, effect_input)

symbol = effect_input._input['symbol']

return 'effect_{}:{}'.format(effect.instance, symbol)
return 'effect_{}:{}'.format(effect.instance, effect_input.symbol)

@staticmethod
def disconnect(connection):
Expand Down Expand Up @@ -198,10 +195,8 @@ def param_set(param):
:param Lv2Param param: Parameter that will be updated your value
"""
instance = param.effect
symbol = param._param['symbol']
value = param.value

return 'param_set {} {} {}'.format(instance, symbol, value)
return 'param_set {} {} {}'.format(instance, param.symbol, param.value)

@staticmethod
def param_get(param):
Expand All @@ -217,9 +212,8 @@ def param_get(param):
:param Lv2Param param: Parameter that will be get your current value
"""
instance = param.effect
symbol = param._param['symbol']

return 'param_get {} {}'.format(instance, symbol)
return 'param_get {} {}'.format(instance, param.symbol)

@staticmethod
def param_monitor():
Expand Down
2 changes: 1 addition & 1 deletion pluginsmanager/model/bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Bank(object):
True
>>> del bank.patches[0]
>>> bank.patches[0] == californication
>>> bank.patches[0] == californication # Patch Can't stop rermoved, first is now the californication
True
You can also toggle patches into different banks::
Expand Down
2 changes: 2 additions & 0 deletions pluginsmanager/model/effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class Effect(metaclass=ABCMeta):
Effect contains a `active` status (off=bypass), a list of :class:`Param`,
a list of :class:`Input` and a list of :class:`Connection`
:param Patch patch: Patch where the effect lies.
"""

def __init__(self, patch=None):
Expand Down
43 changes: 42 additions & 1 deletion pluginsmanager/model/input.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,38 @@
from abc import ABCMeta
from abc import ABCMeta, abstractmethod

from unittest.mock import MagicMock


class Input(metaclass=ABCMeta):
"""
Input is the medium in which the audio will go into effect to be processed.
Effects usually have a one (mono) or two inputs (stereo L + stereo R). But this
isn't a rule: Some have only class:`Output`, like audio frequency generators,
others have more than two.
For obtains the inputs::
>>> my_awesome_effect
<Lv2Effect object as 'Calf Reverb' active at 0x7fd58d874ba8>
>>> my_awesome_effect.inputs
(<Lv2Input object as In L at 0x7fd58c583208>, <Lv2Input object as In R at 0x7fd58c587320>)
>>> effect_input = my_awesome_effect.inputs[0]
>>> effect_input
<Lv2Input object as In L at 0x7fd58c583208>
>>> symbol = effect_input.symbol
>>> symbol
'in_l'
>>> my_awesome_effect.inputs[symbol] == effect_input
True
For connections between effects, view :class:`Connections`.
:param Effect effect: Effect of input
"""

def __init__(self, effect):
self._effect = effect
Expand All @@ -12,8 +41,19 @@ def __init__(self, effect):

@property
def effect(self):
"""
:return: Effect of input
"""
return self._effect

@property
@abstractmethod
def symbol(self):
"""
:return: Input identifier
"""
pass

@property
def json(self):
"""
Expand All @@ -27,5 +67,6 @@ def json(self):
def __dict__(self):
return {
'effect': self.effect.patch.effects.index(self.effect),
'symbol': self.symbol,
'index': self.effect.inputs.index(self),
}
7 changes: 4 additions & 3 deletions pluginsmanager/model/lv2/lv2_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ def __init__(self, plugin):

self.plugin = plugin

self._params = tuple([Lv2Param(self, param) for param in plugin["ports"]["control"]["input"]])
params = [Lv2Param(self, param) for param in plugin["ports"]["control"]["input"]]
self._params = DictTuple(params, lambda param: param.symbol)

inputs = [Lv2Input(self, effect_input) for effect_input in plugin['ports']['audio']['input']]
self._inputs = DictTuple(inputs, lambda _input: _input._input['symbol'])
self._inputs = DictTuple(inputs, lambda _input: _input.symbol)

outputs = [Lv2Output(self, effect_output) for effect_output in plugin['ports']['audio']['output']]
self._outputs = DictTuple(outputs, lambda _output: _output._output['symbol'])
self._outputs = DictTuple(outputs, lambda _output: _output.symbol)

self.instance = None

Expand Down
5 changes: 4 additions & 1 deletion pluginsmanager/model/lv2/lv2_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ def __repr__(self):
id(self)
)

@property
def symbol(self):
return self._input['symbol']

@property
def __dict__(self):
dictionary = super(Lv2Input, self).__dict__
dictionary['index'] = self._input['index']
dictionary['symbol'] = self._input['symbol']

return dictionary
5 changes: 4 additions & 1 deletion pluginsmanager/model/lv2/lv2_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ def __repr__(self):
id(self)
)

@property
def symbol(self):
return self._output['symbol']

@property
def __dict__(self):
dictionary = super(Lv2Output, self).__dict__
dictionary['index'] = self._output['index']
dictionary['symbol'] = self._output['symbol']

return dictionary
19 changes: 3 additions & 16 deletions pluginsmanager/model/lv2/lv2_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Lv2Param(Param):
:class:`Param` is an object representation of an Lv2 Audio Plugin
Parameter
:param value: Param value
:param param: Param value
"""

def __init__(self, effect, param):
Expand All @@ -22,18 +22,5 @@ def minimum(self):
return self._param['ranges']['minimum']

@property
def json(self):
"""
Get a json decodable representation of this param
:return dict: json representation
"""
return self.__dict__

@property
def __dict__(self):
return {
'index': self._param['index'],
'symbol': self._param['symbol'],
'value': self.value,
}
def symbol(self):
return self._param['symbol']
67 changes: 66 additions & 1 deletion pluginsmanager/model/output.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
from abc import ABCMeta
from abc import ABCMeta, abstractmethod

from pluginsmanager.model.connection import Connection

from unittest.mock import MagicMock


class Output(metaclass=ABCMeta):
"""
Output is the medium in which the audio processed by the effect is returned.
Effects usually have a one (mono) or two outputs (stereo L + stereo R). .
For obtains the outputs::
>>> my_awesome_effect
<Lv2Effect object as 'Calf Reverb' active at 0x7fd58d874ba8>
>>> my_awesome_effect.outputs
(<Lv2Output object as Out L at 0x7fd58c58a438>, <Lv2Output object as Out R at 0x7fd58c58d550>)
>>> output = my_awesome_effect.outputs[0]
>>> output
<Lv2Output object as Out L at 0x7fd58c58a438>
>>> symbol = my_awesome_effect.outputs[0].symbol
>>> symbol
'output_l'
>>> my_awesome_effect.outputs[symbol] == output
True
For connections between effects, view :class:`Connections`.
:param Effect effect: Effect of output
"""

def __init__(self, effect):
self._effect = effect
Expand All @@ -14,14 +41,51 @@ def __init__(self, effect):

@property
def effect(self):
"""
:return: Effect of output
"""
return self._effect

def connect(self, effect_input):
"""
Connect it with effect_input::
>>> driver_output = driver.outputs[0]
>>> reverb_input = reverb.inputs[0]
>>> Connection(driver_output, reverb_input) in driver.effect.connections
False
>>> driver_output.connect(reverb_input)
>>> Connection(driver_output, reverb_input) in driver.effect.connections
True
:param Input effect_input: Input that will be connected with it
"""
self.effect.patch.connections.append(Connection(self, effect_input))

def disconnect(self, effect_input):
"""
Disconnect it with effect_input
>>> driver_output = driver.outputs[0]
>>> reverb_input = reverb.inputs[0]
>>> Connection(driver_output, reverb_input) in driver.effect.connections
True
>>> driver_output.disconnect(reverb_input)
>>> Connection(driver_output, reverb_input) in driver.effect.connections
False
:param Input effect_input: Input that will be disconnected with it
"""
self.effect.patch.connections.remove(Connection(self, effect_input))

@property
@abstractmethod
def symbol(self):
"""
:return: Output identifier
"""
pass

@property
def json(self):
"""
Expand All @@ -35,5 +99,6 @@ def json(self):
def __dict__(self):
return {
'effect': self.effect.patch.effects.index(self.effect),
'symbol': self.symbol,
'index': self.effect.outputs.index(self),
}

0 comments on commit 6c5bdfb

Please sign in to comment.