Skip to content

Commit

Permalink
patch -> pedalboard
Browse files Browse the repository at this point in the history
  • Loading branch information
SrMouraSilva committed Nov 29, 2016
1 parent 6c5bdfb commit 6375545
Show file tree
Hide file tree
Showing 21 changed files with 395 additions and 388 deletions.
58 changes: 29 additions & 29 deletions Readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Play!
from pluginsmanager.mod_host.mod_host import ModHost
from pluginsmanager.model.bank import Bank
from pluginsmanager.model.patch import Patch
from pluginsmanager.model.pedalboard import Pedalboard
from pluginsmanager.model.connection import Connection
from pluginsmanager.model.lv2.lv2_effect_builder import Lv2EffectBuilder
Expand All @@ -80,22 +80,22 @@ Connecting with mod_host. Is necessary that the mod_host process already running
mod_host.connect()
manager.register(mod_host)
Creating patch
Creating pedalboard

.. code-block:: python
patch = Patch('Rocksmith')
bank.append(patch)
pedalboard = Pedalboard('Rocksmith')
bank.append(pedalboard)
# or
# bank.patches.append(patch)
# bank.pedalboards.append(pedalboard)
Loads patch. All changes in patch are reproduced in mod_host
Loads pedalboard. All changes in pedalboard are reproduced in mod_host

.. code-block:: python
mod_host.patch = patch
mod_host.pedalboard = pedalboard
Add effects in the patch
Add effects in the pedalboard

.. code-block:: python
Expand All @@ -105,11 +105,11 @@ Add effects in the patch
fuzz = builder.build('http://guitarix.sourceforge.net/plugins/gx_fuzzfacefm_#_fuzzfacefm_')
reverb2 = builder.build('http://calf.sourceforge.net/plugins/Reverb')
patch.append(reverb)
patch.append(fuzz)
patch.append(reverb2)
pedalboard.append(reverb)
pedalboard.append(fuzz)
pedalboard.append(reverb2)
# or
# patch.effects.append(reverb2)
# pedalboard.effects.append(reverb2)
For obtains automatically the sound card inputs and outputs, use :class:`SystemEffectBuilder`. It requires `JACK-Client`_.

Expand Down Expand Up @@ -147,13 +147,13 @@ Connecting *mode two*:

.. code-block:: python
patch.connect(Connection(reverb.outputs[0], fuzz.inputs[0]))
patch.connect(Connection(reverb.outputs[1], fuzz.inputs[0]))
patch.connect(Connection(fuzz.outputs[0], reverb2.inputs[0]))
patch.connect(Connection(reverb.outputs[0], reverb2.inputs[0]))
pedalboard.connect(Connection(reverb.outputs[0], fuzz.inputs[0]))
pedalboard.connect(Connection(reverb.outputs[1], fuzz.inputs[0]))
pedalboard.connect(Connection(fuzz.outputs[0], reverb2.inputs[0]))
pedalboard.connect(Connection(reverb.outputs[0], reverb2.inputs[0]))
patch.connect(reverb2.outputs[0].connect(sys_effect.inputs[0]))
patch.connect(reverb2.outputs[0].connect(sys_effect.inputs[1]))
pedalboard.connect(reverb2.outputs[0].connect(sys_effect.inputs[0]))
pedalboard.connect(reverb2.outputs[0].connect(sys_effect.inputs[1]))
Set effect status (enable/disable bypass) and param value

Expand All @@ -167,10 +167,10 @@ Set effect status (enable/disable bypass) and param value
fuzz.outputs[0].disconnect(reverb2.inputs[0])
# or
# patch.connections.remove(Connection(fuzz.outputs[0], reverb2.inputs[0]))
# pedalboard.connections.remove(Connection(fuzz.outputs[0], reverb2.inputs[0]))
# or
# index = patch.connections.index(Connection(fuzz.outputs[0], reverb2.inputs[0]))
# del patch.connections[index]
# index = pedalboard.connections.index(Connection(fuzz.outputs[0], reverb2.inputs[0]))
# del pedalboard.connections[index]
reverb.toggle()
Expand All @@ -180,16 +180,16 @@ Removing effects and connections:

.. code-block:: python
patch.effects.remove(fuzz)
pedalboard.effects.remove(fuzz)
for connection in list(patch.connections):
patch.connections.remove(connection)
for connection in list(pedalboard.connections):
pedalboard.connections.remove(connection)
for effect in list(patch.effects):
patch.effects.remove(effect)
for effect in list(pedalboard.effects):
pedalboard.effects.remove(effect)
# or
# for index in reversed(range(len(patch.effects))):
# del patch.effects[index]
# for index in reversed(range(len(pedalboard.effects))):
# del pedalboard.effects[index]
Maintenance
-----------
Expand Down Expand Up @@ -224,4 +224,4 @@ You can generate the documentation in your local machine:
firefox build/html/index.html
.. _Sphinx: http://www.sphinx-doc.org/
.. _Read the Docs: http://readthedocs.org
.. _Read the Docs: http://readthedocs.org
12 changes: 6 additions & 6 deletions docs/source/model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ This page contains the model classes.
graph [rankdir=TB];
node [shape=rect, style=filled, color="#298029", fontname=Sans, fontcolor="#ffffff", fontsize=10];

Bank->Patch [dir="forward", arrowhead="odiamond", arrowtail="normal"];
Patch->Connection [dir="forward", arrowhead="odiamond", arrowtail="normal"];
Patch->Effect [dir="forward", arrowhead="odiamond", arrowtail="normal"];
Bank->Pedalboard [dir="forward", arrowhead="odiamond", arrowtail="normal"];
Pedalboard->Connection [dir="forward", arrowhead="odiamond", arrowtail="normal"];
Pedalboard->Effect [dir="forward", arrowhead="odiamond", arrowtail="normal"];
Param->Effect [dir="backward", arrowhead="diamond", arrowtail="normal"];
Input->Effect [dir="backward", arrowhead="diamond", arrowtail="normal"];
Output->Effect [dir="backward", arrowhead="diamond", arrowtail="normal"];
Expand Down Expand Up @@ -91,10 +91,10 @@ Param
:members:
:special-members:

Patch
-----
Pedalboard
----------

.. autoclass:: pluginsmanager.model.patch.Patch
.. autoclass:: pluginsmanager.model.pedalboard.Pedalboard
:members:
:special-members:

Expand Down
8 changes: 4 additions & 4 deletions pluginsmanager/banks_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ def __init__(self):
def append(self, observer):
self.observers.append(observer)

def on_current_patch_change(self, patch, token=None):
def on_current_pedalboard_change(self, pedalboard, token=None):
for observer in self.observers:
observer.on_current_patch_change(patch, token)
observer.on_current_pedalboard_change(pedalboard, token)

def on_bank_updated(self, bank, update_type, token=None, **kwargs):
for observer in self.observers:
observer.on_bank_updated(bank, update_type, token, **kwargs)

def on_patch_updated(self, patch, update_type, token=None, **kwargs):
def on_pedalboard_updated(self, pedalboard, update_type, token=None, **kwargs):
for observer in self.observers:
observer.on_patch_updated(patch, update_type, token, **kwargs)
observer.on_pedalboard_updated(pedalboard, update_type, token, **kwargs)

def on_effect_updated(self, effect, update_type, token=None, **kwargs):
for observer in self.observers:
Expand Down
64 changes: 32 additions & 32 deletions pluginsmanager/mod_host/mod_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ class ModHost(UpdatesObserver):
mod_host.connect()
banks_manager.register(mod_host)
# Set the mod_host patch for a patch that the bank
# Set the mod_host pedalboard for a pedalboard that the bank
# has added in banks_manager
mod_host.patch = my_awesome_patch
mod_host.pedalboard = my_awesome_pedalboard
The changes in current patch (``mod_host.patch``) will also result in mod-host::
The changes in current pedalboard (``mod_host.pedalboard``) will also result in mod-host::
driver = my_awesome_patch.effects[0]
driver = my_awesome_pedalboard.effects[0]
driver.active = False
.. note::
Expand Down Expand Up @@ -70,7 +70,7 @@ def __init__(self, address='localhost'):
self.address = address

self.host = None
self._patch = None
self._pedalboard = None

def connect(self):
"""
Expand All @@ -80,64 +80,64 @@ def connect(self):
self.host = Host(self.address)

def auto_connect(self):
if self.patch is None or len(self.patch.effects) == 0:
if self.pedalboard is None or len(self.pedalboard.effects) == 0:
return

first = self.patch.effects[0]
last = self.patch.effects[-1]
first = self.pedalboard.effects[0]
last = self.pedalboard.effects[-1]

self.host.connect_input_in(first.inputs[0])

before = first
for effect in self.patch.effects[1:]:
for effect in self.pedalboard.effects[1:]:
self.host.connect(Connection(before.outputs[0], effect.inputs[0]))
before = effect

self.host.connect_on_output(last.outputs[0], 1)
self.host.connect_on_output(last.outputs[0], 2)

@property
def patch(self):
def pedalboard(self):
"""
Currently managed patch (current patch)
Currently managed pedalboard (current pedalboard)
:getter: Current patch - Patch loaded by mod-host
:setter: Set the patch that will be loaded by mod-host
:type: Patch
:getter: Current pedalboard - Pedalboard loaded by mod-host
:setter: Set the pedalboard that will be loaded by mod-host
:type: Pedalboard
"""
return self._patch
return self._pedalboard

@patch.setter
def patch(self, patch):
self.on_current_patch_change(patch)
@pedalboard.setter
def pedalboard(self, pedalboard):
self.on_current_pedalboard_change(pedalboard)

####################################
# Observer
####################################
def on_current_patch_change(self, patch, token=None):
if self.patch is not None:
for effect in self.patch.effects:
def on_current_pedalboard_change(self, pedalboard, token=None):
if self.pedalboard is not None:
for effect in self.pedalboard.effects:
self.on_effect_updated(effect, UpdateType.DELETED)

self._patch = patch
self._pedalboard = pedalboard

for effect in patch.effects:
for effect in pedalboard.effects:
self.on_effect_updated(effect, UpdateType.CREATED)

def on_bank_updated(self, bank, update_type, token=None, **kwargs):
if self.patch is not None \
and bank != self.patch.bank:
if self.pedalboard is not None \
and bank != self.pedalboard.bank:
return
pass

def on_patch_updated(self, patch, update_type, token=None, **kwargs):
if patch != self.patch:
def on_pedalboard_updated(self, pedalboard, update_type, token=None, **kwargs):
if pedalboard != self.pedalboard:
return

self.on_current_patch_change(patch)
self.on_current_pedalboard_change(pedalboard)

def on_effect_updated(self, effect, update_type, token=None, **kwargs):
if effect.patch != self.patch:
if effect.pedalboard != self.pedalboard:
return

if update_type == UpdateType.CREATED:
Expand All @@ -153,19 +153,19 @@ def _load_params_of(self, effect):
self.on_param_value_changed(param)

def on_effect_status_toggled(self, effect, token=None):
if effect.patch != self.patch:
if effect.pedalboard != self.pedalboard:
return

self.host.set_status(effect)

def on_param_value_changed(self, param, token=None):
if param.effect.patch != self.patch:
if param.effect.pedalboard != self.pedalboard:
return

self.host.set_param_value(param)

def on_connection_updated(self, connection, update_type, token=None):
if connection.input.effect.patch != self.patch:
if connection.input.effect.pedalboard != self.pedalboard:
return

if update_type == UpdateType.CREATED:
Expand Down

1 comment on commit 6375545

@SrMouraSilva
Copy link
Member Author

Choose a reason for hiding this comment

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

Fix #4

Please sign in to comment.