Skip to content

Commit

Permalink
Merge pull request #8 from PedalPi/issue-6 (issues 6 and 7)
Browse files Browse the repository at this point in the history
Removed token support. Added with support (#6). Added autosaver (#7)
  • Loading branch information
SrMouraSilva committed Feb 11, 2017
2 parents e2f6e1d + 9c8a867 commit 2af1a1c
Show file tree
Hide file tree
Showing 12 changed files with 361 additions and 143 deletions.
6 changes: 3 additions & 3 deletions Readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ For manual input and output sound card definition, use:
.. note::

**NOT ADD sys_effect** in PATCH
**NOT ADD sys_effect** in any Pedalboard

Connecting *mode one*:

Expand All @@ -152,8 +152,8 @@ Connecting *mode two*:
pedalboard.connections.append(Connection(fuzz.outputs[0], reverb2.inputs[0]))
pedalboard.connections.append(Connection(reverb.outputs[0], reverb2.inputs[0]))
pedalboard.connections.append(reverb2.outputs[0].connect(sys_effect.inputs[0]))
pedalboard.connections.append(reverb2.outputs[0].connect(sys_effect.inputs[1]))
pedalboard.connections.append(Connection(reverb2.outputs[0], sys_effect.inputs[0]))
pedalboard.connections.append(Connection(reverb2.outputs[0], sys_effect.inputs[1]))
Set effect status (enable/disable bypass) and param value

Expand Down
93 changes: 42 additions & 51 deletions docs/source/model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,46 @@ This page contains the model classes.

.. graphviz::

digraph classes {
graph [rankdir=TB, nodesep=1, ranksep=1];

node [shape=rect, style=filled, color="#298029", fontname=Sans, fontcolor="#ffffff", fontsize=10];

Bank->Pedalboard [
dir="forward", arrowhead="odiamond", arrowtail="normal"
headlabel= " 1..n", taillabel="1"
];
Pedalboard->Effect [
dir="forward", arrowhead="odiamond", arrowtail="normal",
headlabel= " 1..n", taillabel="1"
];
Param->Effect [
dir="backward", arrowhead="diamond", arrowtail="normal",
headlabel= " 1", taillabel="n"
];
Pedalboard->Connection [
dir="forward", arrowhead="odiamond", arrowtail="normal",
headlabel= " 1", taillabel="n"
];
Input->Effect [
dir="backward", arrowhead="diamond", arrowtail="normal",
headlabel= " 1", taillabel="n"
];
Output->Effect [
dir="backward", arrowhead="diamond", arrowtail="normal",
headlabel= " 1", taillabel="n"
];


Input->Connection [
dir="backward", arrowhead="diamond", arrowtail="normal",
headlabel= " n", taillabel="1",
];
Output->Connection [
dir="backward", arrowhead="diamond", arrowtail="normal",
headlabel= " n", taillabel="1"
];
digraph classes {
graph [rankdir=BT];

node [shape=rect, style=filled, color="#298029", fontname=Sans, fontcolor="#ffffff", fontsize=10];

Pedalboard->Bank [
dir="forward", arrowhead="odiamond", arrowtail="normal"
];
Effect->Pedalboard [
dir="forward", arrowhead="odiamond", arrowtail="normal"
];
Param->Effect [
dir="backward", arrowhead="diamond", arrowtail="normal"
];
Connection->Pedalboard [
dir="forward", arrowhead="odiamond", arrowtail="normal"
];
Input->Effect [
dir="backward", arrowhead="diamond", arrowtail="normal"
];
Output->Effect [
dir="backward", arrowhead="diamond", arrowtail="normal"
];

Input->Connection [
dir="backward", arrowhead="odiamond", arrowtail="normal"
];
Output->Connection [
dir="backward", arrowhead="odiamond", arrowtail="normal"
];
}

.. graphviz::

digraph classes {
graph [rankdir=TB];
graph [rankdir=BT];
node [shape=rect, style=filled, color="#298029", fontname=Sans, fontcolor="#ffffff", fontsize=10];

Lv2Plugin->Lv2Effect[
dir="backward", arrowhead="diamond", arrowtail="normal",
headlabel= " n", taillabel="1"
Lv2Effect->Lv2Plugin[
dir="backward", arrowhead="diamond", arrowtail="normal"
];
Lv2Effect->Effect;
SystemEffect->Effect;
Expand All @@ -70,15 +60,16 @@ This page contains the model classes.

.. graphviz::

digraph classes {
graph [rankdir=TB];
node [shape=rect, style=filled, color="#298029", fontname=Sans, fontcolor="#ffffff", fontsize=10];
digraph classes {
graph [rankdir=BT];
node [shape=rect, style=filled, color="#298029", fontname=Sans, fontcolor="#ffffff", fontsize=10];

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
}
Bank->BanksManager [dir="forward", arrowhead="odiamond", arrowtail="normal"];
BanksManager->ObserverManager [dir="forward", arrowhead="none", arrowtail="normal"];
UpdatesObserver->ObserverManager [dir="forward", arrowhead="odiamond", arrowtail="normal"];
ModHost->UpdatesObserver
AutoSaver->UpdatesObserver
}

BanksManager
------------
Expand Down
77 changes: 61 additions & 16 deletions pluginsmanager/banks_manager.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import collections

from pluginsmanager.model.updates_observer import UpdatesObserver
from pluginsmanager.model.update_type import UpdateType

Expand Down Expand Up @@ -39,6 +41,7 @@ def register(self, observer):
:param UpdatesObserver observer: Observer that will be notified then occurs changes
"""
self.observer_manager.append(observer)
observer.manager = self

def append(self, bank):
"""
Expand All @@ -60,39 +63,81 @@ def _banks_observer(self, update_type, bank, index):

self.observer_manager.on_bank_updated(bank, update_type, index=index, origin=self)

def enter_scope(self, observer):
"""
Informs that changes occurs by the ``observer`` and isn't necessary
informs the changes for observer
:param UpdatesObserver observer: Observer that causes changes
"""
self.observer_manager.enter_scope(observer)

def exit_scope(self):
"""
Closes the last observer scope added
"""
self.observer_manager.exit_scope()


class ObserverManager(UpdatesObserver):
def __init__(self):
super(ObserverManager, self).__init__()
self.observers = []
self._observers_scope = collections.deque()

def enter_scope(self, observer):
"""
Open a observer scope.
Informs that changes occurs by the ``observer`` and isn't necessary
informs the changes for observer
:param UpdatesObserver observer: Observer that causes changes
"""
self._observers_scope.append(observer)

def exit_scope(self):
"""
Closes the last observer scope added
"""
self._observers_scope.pop()

@property
def scope(self):
try:
return self._observers_scope[-1]
except IndexError:
return None

def append(self, observer):
self.observers.append(observer)

def on_current_pedalboard_changed(self, pedalboard, token=None):
for observer in self.observers:
observer.on_current_pedalboard_changed(pedalboard, token)

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

def on_pedalboard_updated(self, pedalboard, update_type, token=None, **kwargs):
def on_pedalboard_updated(self, pedalboard, update_type, **kwargs):
for observer in self.observers:
observer.on_pedalboard_updated(pedalboard, update_type, token, **kwargs)
if observer != self.scope:
observer.on_pedalboard_updated(pedalboard, update_type, **kwargs)

def on_effect_updated(self, effect, update_type, token=None, **kwargs):
def on_effect_updated(self, effect, update_type, **kwargs):
for observer in self.observers:
observer.on_effect_updated(effect, update_type, token)
if observer != self.scope:
observer.on_effect_updated(effect, update_type)

def on_effect_status_toggled(self, effect, token=None):
def on_effect_status_toggled(self, effect):
for observer in self.observers:
observer.on_effect_status_toggled(effect, token)
if observer != self.scope:
observer.on_effect_status_toggled(effect)

def on_param_value_changed(self, param, token=None):
def on_param_value_changed(self, param):
for observer in self.observers:
observer.on_param_value_changed(param, token)
if observer != self.scope:
observer.on_param_value_changed(param)

def on_connection_updated(self, connection, update_type, token=None):
def on_connection_updated(self, connection, update_type):
for observer in self.observers:
observer.on_connection_updated(connection, update_type, token)
if observer != self.scope:
observer.on_connection_updated(connection, update_type)
17 changes: 7 additions & 10 deletions pluginsmanager/mod_host/mod_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ class ModHost(UpdatesObserver):
.. _Demystifying JACK – A Beginners Guide to Getting Started with JACK: http://libremusicproduction.com/articles/demystifying-jack-%E2%80%93-beginners-guide-getting-started-jack
"""

TOKEN = 'ModHost'

def __init__(self, address='localhost'):
super(ModHost, self).__init__()
self.token = ModHost.TOKEN
self.address = address

self.host = None
Expand Down Expand Up @@ -114,7 +111,7 @@ def pedalboard(self, pedalboard):
####################################
# Observer
####################################
def on_current_pedalboard_changed(self, pedalboard, token=None):
def on_current_pedalboard_changed(self, pedalboard):
if self.pedalboard is not None:
for effect in self.pedalboard.effects:
self.on_effect_updated(effect, UpdateType.DELETED)
Expand All @@ -124,19 +121,19 @@ def on_current_pedalboard_changed(self, pedalboard, token=None):
for effect in pedalboard.effects:
self.on_effect_updated(effect, UpdateType.CREATED)

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

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

self.on_current_pedalboard_changed(pedalboard)

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

Expand All @@ -152,19 +149,19 @@ def _load_params_of(self, effect):
for param in effect.params:
self.on_param_value_changed(param)

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

self.host.set_status(effect)

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

self.host.set_param_value(param)

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

Expand Down
4 changes: 3 additions & 1 deletion pluginsmanager/model/bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pluginsmanager.model.update_type import UpdateType

from unittest.mock import MagicMock
import uuid


class Bank(object):
Expand Down Expand Up @@ -34,7 +35,7 @@ class Bank(object):
True
>>> # Set pedalboard
>>> bank.pedalboards[0] = Pedalboard('Can't Stop')
>>> bank.pedalboards[0] = Pedalboard("Can't Stop")
>>> bank.pedalboards[0].bank == bank
True
Expand All @@ -54,6 +55,7 @@ def __init__(self, name):
self.pedalboards.observer = self._pedalboards_observer

self.index = -1
self._uuid = str(uuid.uuid4())

self.manager = None

Expand Down

0 comments on commit 2af1a1c

Please sign in to comment.