Skip to content

Commit

Permalink
Fix model set observer. Fix #1 (jack client). Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SrMouraSilva committed Nov 18, 2016
1 parent 0ea14c5 commit 646c5bf
Show file tree
Hide file tree
Showing 16 changed files with 435 additions and 147 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ python:

install:
- pip3 install coverage
- pip3 install cffi
- pip3 install JACK-Client

script:
- coverage3 run --source=pluginsmanager setup.py test
Expand Down
14 changes: 12 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@

Pythonic management of LV2 audio plugins with [mod-host](https://github.com/moddevices/mod-host).

For API documentation, see [Application Documentation](http://pedalpi-pluginsmanager.readthedocs.io/?badge=latest).
**Documentation:**
http://pedalpi-pluginsmanager.readthedocs.io/

**Code:**
https://github.com/PedalPi/PluginsManager

**Python Package Index:**
https://github.com/PedalPi/PluginsManager/tarball/master#egg=PedalPi-PluginsManager

**License:**
Not yet

```python
manager = BanksManager()
Expand Down Expand Up @@ -66,7 +76,7 @@ This project uses [Sphinx](http://www.sphinx-doc.org/) + [Read the Docs](readthe
You can generate the documentation in your local machine:

```bash
pip3 install coverage3
pip3 install sphinx

cd docs
make html
Expand Down
2 changes: 1 addition & 1 deletion pluginsmanager/mod_host/host.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pluginsmanager.model.connection import Connection
from pluginsmanager.mod_host.connection import Connection
from pluginsmanager.mod_host.protocol_parser import ProtocolParser


Expand Down
31 changes: 27 additions & 4 deletions pluginsmanager/mod_host/mod_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ class ModHost(UpdatesObserver):
TOKEN = 'ModHost'

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

self.host = None
self.patch = None
self._patch = None

def connect(self):
""" Connect the object with mod-host """
Expand All @@ -37,8 +38,13 @@ def auto_connect(self):
self.host.connect_on_output(last.outputs[0], 1)
self.host.connect_on_output(last.outputs[0], 2)

def append(self, observer):
self.observers.append(observer)
@property
def patch(self):
return self._patch

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

####################################
# Observer
Expand All @@ -48,18 +54,26 @@ def on_current_patch_change(self, patch, token=None):
for effect in self.patch.effects:
self.on_effect_updated(effect, UpdateType.DELETED)

self.patch = patch
self._patch = patch

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

def on_bank_update(self, bank, update_type, token=None):
if bank != self.patch.bank:
return
pass

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

self.on_current_patch_change(patch)

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

if update_type == UpdateType.CREATED:
self.host.add(effect)
self._load_params_of(effect)
Expand All @@ -73,12 +87,21 @@ 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:
return

self.host.set_status(effect)

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

self.host.set_param_value(param)

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

if update_type == UpdateType.CREATED:
self.host.connect(connection)
elif update_type == UpdateType.DELETED:
Expand Down
12 changes: 11 additions & 1 deletion pluginsmanager/model/bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,17 @@ def __init__(self, name):
self.patches = ObservableList()
self.patches.observer = self._patches_observer

self.observer = MagicMock()
self._observer = MagicMock()

@property
def observer(self):
return self._observer

@observer.setter
def observer(self, observer):
self._observer = observer
for patch in self.patches:
patch.observer = observer

def _patches_observer(self, update_type, patch, index):
if update_type == UpdateType.CREATED \
Expand Down
2 changes: 1 addition & 1 deletion pluginsmanager/model/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Connection(object):

def __init__(self, effect_output, effect_input):
if effect_output.effect == effect_input.effect:
ConnectionError('Effect of output and effect of input are equals')
raise ConnectionError('Effect of output and effect of input are equals')

self._output = effect_output
self._input = effect_input
Expand Down
4 changes: 2 additions & 2 deletions pluginsmanager/model/lv2/lv2_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

class Lv2Input(Input):

def __init__(self, effect, input):
def __init__(self, effect, effect_input):
super(Lv2Input, self).__init__(effect)
self._input = input
self._input = effect_input

def __str__(self):
return self._input['name']
Expand Down
4 changes: 2 additions & 2 deletions pluginsmanager/model/lv2/lv2_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

class Lv2Output(Output):

def __init__(self, effect, output):
def __init__(self, effect, effect_output):
super(Lv2Output, self).__init__(effect)
self._output = output
self._output = effect_output

def __str__(self):
return self._output['name']
Expand Down
13 changes: 12 additions & 1 deletion pluginsmanager/model/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ def __init__(self, name):
self.effects.observer = self._effects_observer
self.connections.observer = self._connections_observer

self.observer = MagicMock()
self._observer = MagicMock()

@property
def observer(self):
return self._observer

@observer.setter
def observer(self, observer):
self._observer = observer

for effect in self.effects:
effect.observer = observer

def _effects_observer(self, update_type, effect, index):
if update_type == UpdateType.CREATED \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
from pluginsmanager.model.lv2.lv2_effect_builder import Lv2EffectBuilder


class Persistance(object):
class PersistenceError(Exception):
pass


class Persistence(object):

def __init__(self, system_effect):
self.system_effect = system_effect
Expand All @@ -23,6 +27,7 @@ def __init__(self, system_effect):
def read(self, json):
pass


class BankReader(Reader):

def read(self, json):
Expand All @@ -35,6 +40,7 @@ def read(self, json):

return bank


class PatchReader(Reader):

def read(self, json):
Expand All @@ -50,6 +56,7 @@ def read(self, json):

return patch


class EffectReader(Reader):

def __init__(self, system_effect):
Expand All @@ -60,7 +67,7 @@ def read(self, json):
if json['technology'] == 'lv2':
return self.read_lv2(json)

raise Exception('Unkown effect technology: ' + json['technology'])
raise PersistenceError('Unkown effect technology: ' + json['technology'])

def read_lv2(self, json):
effect = self.builder.build(json['plugin'])
Expand All @@ -72,6 +79,7 @@ def read_lv2(self, json):

return effect


class ConnectionReader(Reader):

def __init__(self, patch, system_effect):
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from setuptools import setup, find_packages
from setuptools import setup

def readme():
with open('Readme.md') as f:
return f.read()

setup(
name='PedalPi - PluginsManager',
name='PedalPi-PluginsManager',
version='0.0.1',
long_description=readme(),
#packages=find_packages('pluginsmanager'),
packages=[
'pluginsmanager',

Expand Down
58 changes: 0 additions & 58 deletions test/mod_host/mod_host_manual_test.py

This file was deleted.

0 comments on commit 646c5bf

Please sign in to comment.