Skip to content

Commit

Permalink
Issue #77 - Fix SystemMidi connection support in ProtocolParser. Not …
Browse files Browse the repository at this point in the history
…finish
  • Loading branch information
SrMouraSilva committed Oct 29, 2017
1 parent c8a3d19 commit 0b9b6a9
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 11 deletions.
14 changes: 14 additions & 0 deletions pluginsmanager/model/effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,20 @@ def is_unique_for_all_pedalboards(self):
"""
return False

@property
def use_real_identifier(self):
"""
Instances of audio plugins are dynamically created, so the effect identifier for the jack can be set.
However, SystemEffect correspond (mostly) to the audio interfaces already present in the computational system.
The identifier for their jack has already been set.
return bool: For this audio plugin, is necessary use the real effect identifier?
Example: :class:`.Lv2Effect` is False
Example: :class:`.SystemEffect` is True
"""
return False

def __repr__(self):
return "<{} object as '{}' at 0x{:x}>".format(
self.__class__.__name__,
Expand Down
7 changes: 7 additions & 0 deletions pluginsmanager/model/system/system_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,10 @@ def is_unique_for_all_pedalboards(self):
Example: :class:`.SystemEffect` is unique for all pedalboards
"""
return True

@property
def use_real_identifier(self):
"""
return bool: For this audio plugin, is necessary use the real effect identifier?
"""
return True
20 changes: 10 additions & 10 deletions pluginsmanager/observer/mod_host/protocol_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,22 @@ def _connect_message(origin_port, destination_port):
return 'connect {} {}'.format(origin_port, destination_port)

@staticmethod
def _get_out_name_of(effect_output):
effect = effect_output.effect
def _get_out_name_of(output_of_effect):
effect = output_of_effect.effect

if isinstance(effect_output, SystemOutput):
return '{}:{}'.format(effect, effect_output)
if effect.use_real_identifier:
return '{}:{}'.format(effect, output_of_effect)

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

@staticmethod
def _get_in_name_of(effect_input):
effect = effect_input.effect
def _get_in_name_of(input_of_effect):
effect = input_of_effect.effect

if isinstance(effect_input, SystemInput):
return '{}:{}'.format(effect, effect_input)
if effect.use_real_identifier:
return '{}:{}'.format(effect, input_of_effect)

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

@staticmethod
def disconnect(connection):
Expand Down
43 changes: 43 additions & 0 deletions test/mod_host/mod_host_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,46 @@ def test_connection_not_current_pedalboard(self):
mod_host.pedalboard = pedalboard

pedalboard2.connect(pedalboard2.effects[0].outputs[0], pedalboard2.effects[1].inputs[0])

#@unittest.skip
def test_system_midi_port(self):
from pluginsmanager.observer.mod_host.mod_host import ModHost
from pluginsmanager.model.pedalboard import Pedalboard
from pluginsmanager.model.lv2.lv2_effect_builder import Lv2EffectBuilder
from pluginsmanager.model.system.system_effect import SystemEffect

jack_system = SystemEffect(
'system',
[], # audio inputs
['playback_1', 'playback_2'], # audio output
[], # midi inputs
[] # midi outputs
)
jack_ttymidi = SystemEffect(
'ttymidi',
[], # audio inputs
[], # audio output
['MIDI_in'], # midi inputs
['MIDI_out'] # midi outputs
)

modhost = ModHost('localhost')
modhost.connect()

pedalboard = Pedalboard('MDA-EP')
builder = Lv2EffectBuilder()
ep = builder.build('http://guitarix.sourceforge.net/plugins/gx_oc_2_#_oc_2_')

pedalboard.append(ep)

# REMEMBER: FIRST OUTPUT, SECOND INPUT
# EPiano contains two audio output ports and one midi input port
pedalboard.connect(ep.outputs[0], jack_system.inputs[0])
pedalboard.connect(jack_ttymidi.midi_outputs[0], ep.midi_inputs[0])

# If not using banks manager, the changes will not be applied automatically
# then, is necessary changes the pedalboard at the end
modhost.pedalboard = pedalboard

# Safe close
modhost.close()
1 change: 0 additions & 1 deletion test/model/midi_output_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import unittest
from unittest.mock import MagicMock

from pluginsmanager.model.connection import ConnectionError
from pluginsmanager.model.lv2.lv2_effect_builder import Lv2EffectBuilder
from pluginsmanager.model.pedalboard import Pedalboard
from pluginsmanager.model.system.system_effect import SystemEffect
Expand Down

0 comments on commit 0b9b6a9

Please sign in to comment.