def bank(self, midi=True): sys_effect = self.system_effect bank = Bank('Bank 1') pedalboard = Pedalboard('Pedalboard 1') bank.append(pedalboard) bank.append(Pedalboard('Pedalboard is a Pedalboard?')) reverb = self.builder.build('http://calf.sourceforge.net/plugins/Reverb') filter = self.builder.build('http://calf.sourceforge.net/plugins/Filter') reverb2 = self.builder.build('http://calf.sourceforge.net/plugins/Reverb') pedalboard.append(reverb) pedalboard.append(filter) pedalboard.append(reverb2) pedalboard.connect(reverb.outputs[0], filter.inputs[0]) pedalboard.connect(reverb.outputs[1], filter.inputs[0]) pedalboard.connect(filter.outputs[0], reverb2.inputs[0]) pedalboard.connect(reverb.outputs[0], reverb2.inputs[0]) if midi: cctonode = self.builder.build('http://gareus.org/oss/lv2/midifilter#cctonote') pedalboard.append(cctonode) pedalboard.connect(cctonode.midi_outputs[0], sys_effect.midi_inputs[0]) pedalboard.connect(sys_effect.midi_outputs[0], cctonode.midi_inputs[0]) pedalboard.connections.append(Connection(sys_effect.outputs[0], reverb.inputs[0])) pedalboard.connections.append(Connection(reverb2.outputs[0], sys_effect.inputs[0])) filter.toggle() filter.params[0].value = (filter.params[0].maximum - filter.params[0].minimum) / 3 return bank
def test_json(self): bank = Bank('Bank 1') pedalboard = Pedalboard('Rocksmith') builder = Lv2EffectBuilder() system_effect = SystemEffect('system', ('capture_1', 'capture_2'), ('playback_1', 'playback_2')) reverb = builder.build('http://calf.sourceforge.net/plugins/Reverb') filter = builder.build('http://calf.sourceforge.net/plugins/Filter') reverb2 = builder.build('http://calf.sourceforge.net/plugins/Reverb') pedalboard.append(reverb) pedalboard.append(filter) pedalboard.append(reverb2) pedalboard.connect(system_effect.outputs[0], reverb.inputs[0]) pedalboard.connect(reverb.outputs[0], filter.inputs[0]) pedalboard.connect(reverb.outputs[1], filter.inputs[0]) pedalboard.connect(filter.outputs[0], reverb2.inputs[0]) pedalboard.connect(reverb.outputs[0], reverb2.inputs[0]) pedalboard.connect(reverb.outputs[0], system_effect.inputs[0]) bank.append(pedalboard) print(json.dumps(bank.json, sort_keys=True, indent=2))
def test_set_pedalboard(self): """Test only coverage""" manager = BanksManager() bank = Bank('Bank 1') manager.append(bank) mod_host = ModHost('localhost') mod_host.host = MagicMock() manager.register(mod_host) pedalboard = Pedalboard('test_set_pedalboard_1') bank.append(pedalboard) reverb = self.builder.build( 'http://calf.sourceforge.net/plugins/Reverb') pedalboard.append(reverb) pedalboard2 = Pedalboard('test_set_pedalboard_2') reverb2 = self.builder.build( 'http://calf.sourceforge.net/plugins/Reverb') bank.append(pedalboard) pedalboard2.append(reverb2) mod_host.pedalboard = pedalboard mod_host.pedalboard = pedalboard2
def test_connection_not_current_pedalboard(self): """Test only coverage""" manager = BanksManager() bank = Bank('Bank 1') manager.append(bank) mod_host = ModHost('localhost') mod_host.host = MagicMock() manager.register(mod_host) pedalboard = Pedalboard('test_set_pedalboard_1') pedalboard.append( self.builder.build('http://calf.sourceforge.net/plugins/Reverb')) pedalboard2 = Pedalboard('test_set_pedalboard_2') pedalboard2.append( self.builder.build('http://calf.sourceforge.net/plugins/Reverb')) pedalboard2.append( self.builder.build('http://calf.sourceforge.net/plugins/Reverb')) bank.append(pedalboard) bank.append(pedalboard2) mod_host.pedalboard = pedalboard pedalboard2.connect(pedalboard2.effects[0].outputs[0], pedalboard2.effects[1].inputs[0])
def read(self, json): bank = Bank(json['name']) pedalboard_reader = PedalboardReader(self.system_effect) for pedalboard_json in json['pedalboards']: bank.append(pedalboard_reader.read(pedalboard_json)) return bank
def generate_bank(self, name): # Configure bank = Bank(name) pedalboard1 = Pedalboard(name + ' pedalboard') pedalboard2 = Pedalboard(name + ' pedalboard2') bank.append(pedalboard1) bank.append(pedalboard2) return bank
def generate_bank(self, name): # Configure bank = Bank(name) pedalboard1 = Pedalboard(name + ' pedalboard') pedalboard2 = Pedalboard(name + ' pedalboard2') bank.append(pedalboard1) bank.append(pedalboard2) return bank
def test_observers(self): mock = MagicMock() observer = Autosaver('data/test/') observer.save = mock observer.delete = mock manager = BanksManager() manager.register(observer) bank = Bank('Bank 1') manager.append(bank) observer.save.assert_called_with(bank) pedalboard = Pedalboard('Rocksmith') bank.append(pedalboard) observer.save.assert_called_with(bank) builder = Lv2EffectBuilder() reverb = builder.build('http://calf.sourceforge.net/plugins/Reverb') filter = builder.build('http://calf.sourceforge.net/plugins/Filter') reverb2 = builder.build('http://calf.sourceforge.net/plugins/Reverb') pedalboard.append(reverb) observer.save.assert_called_with(bank) pedalboard.append(filter) observer.save.assert_called_with(bank) pedalboard.append(reverb2) observer.save.assert_called_with(bank) reverb.outputs[0].connect(filter.inputs[0]) observer.save.assert_called_with(bank) reverb.outputs[1].connect(filter.inputs[0]) observer.save.assert_called_with(bank) filter.outputs[0].connect(reverb2.inputs[0]) observer.save.assert_called_with(bank) reverb.outputs[0].connect(reverb2.inputs[0]) observer.save.assert_called_with(bank) filter.toggle() observer.save.assert_called_with(bank) filter.params[0].value = (filter.params[0].maximum - filter.params[0].minimum) / 2 observer.save.assert_called_with(bank) del bank.pedalboards[0] observer.save.assert_called_with(bank) bank2 = Bank('Bank 2') manager.banks[0] = bank2 observer.delete.assert_called_with(bank2) observer.save.assert_called_with(bank2) manager.banks.remove(bank2) observer.delete.assert_called_with(bank2)
def test_observers_mock(self): """Test only coverage""" sys_effect = SystemEffect('system', ('capture_1', 'capture_2'), ('playback_1', 'playback_2')) manager = BanksManager() bank = Bank('Bank 1') manager.append(bank) mod_host = ModHost('localhost') mod_host.host = MagicMock() manager.register(mod_host) pedalboard = Pedalboard('Rocksmith') mod_host.pedalboard = pedalboard bank.append(pedalboard) reverb = self.builder.build( 'http://calf.sourceforge.net/plugins/Reverb') filter = self.builder.build( 'http://calf.sourceforge.net/plugins/Filter') reverb2 = self.builder.build( 'http://calf.sourceforge.net/plugins/Reverb') pedalboard.append(reverb) pedalboard.append(filter) pedalboard.append(reverb2) pedalboard.connect(reverb.outputs[0], filter.inputs[0]) pedalboard.connect(reverb.outputs[1], filter.inputs[0]) pedalboard.connect(filter.outputs[0], reverb2.inputs[0]) pedalboard.connect(reverb.outputs[0], reverb2.inputs[0]) filter.toggle() filter.params[0].value = (filter.params[0].maximum - filter.params[0].minimum) / 2 pedalboard.disconnect(filter.outputs[0], reverb2.inputs[0]) filter.toggle() pedalboard.effects.remove(filter) pedalboard.connections.append( Connection(sys_effect.outputs[0], reverb.inputs[0])) pedalboard.connections.append( Connection(reverb2.outputs[0], sys_effect.inputs[0])) for connection in list(pedalboard.connections): pedalboard.connections.remove(connection) for effect in list(pedalboard.effects): pedalboard.effects.remove(effect)
def test_delete_pedalboard(self): bank = Bank('Bank 1') pedalboard = MagicMock() bank.append(pedalboard) bank.observer = MagicMock() del bank.pedalboards[0] self.assertEqual(pedalboard.bank, None) self.assertEqual(len(bank.pedalboards), 0) bank.observer.on_pedalboard_updated.assert_called_with(pedalboard, UpdateType.DELETED, index=0, origin=bank)
def test_update_pedalboard(self): bank = Bank('Bank 1') pedalboard1 = MagicMock() pedalboard2 = MagicMock() bank.append(pedalboard1) bank.observer = MagicMock() bank.pedalboards[0] = pedalboard2 self.assertEqual(pedalboard2.bank, bank) self.assertEqual(bank.pedalboards[0], pedalboard2) bank.observer.on_pedalboard_updated.assert_called_with(pedalboard2, UpdateType.UPDATED, index=0, origin=bank)
def test_replace_bank(self): observer = Autosaver('../data/test/') manager = BanksManager() manager.register(observer) bank1 = Bank('Bank 1') pedalboard = Pedalboard('Rocksmith') bank1.append(pedalboard) manager.append(bank1) manager.banks[0] = Bank('Bank 2') self.validate_persisted(manager) while manager.banks: del manager.banks[0]
def test_json(self): bank = Bank('Bank 1') pedalboard = Pedalboard('Rocksmith') builder = Lv2EffectBuilder() reverb = builder.build('http://calf.sourceforge.net/plugins/Reverb') filter = builder.build('http://calf.sourceforge.net/plugins/Filter') reverb2 = builder.build('http://calf.sourceforge.net/plugins/Reverb') pedalboard.append(reverb) pedalboard.append(filter) pedalboard.append(reverb2) reverb.outputs[0].connect(filter.inputs[0]) reverb.outputs[1].connect(filter.inputs[0]) filter.outputs[0].connect(reverb2.inputs[0]) reverb.outputs[0].connect(reverb2.inputs[0]) bank.append(pedalboard) print((json.dumps(bank.json, sort_keys=True, indent=2)))
def bank(self): sys_effect = SystemEffect('system', ('capture_1', 'capture_2'), ('playback_1', 'playback_2')) bank = Bank('Bank 1') pedalboard = Pedalboard('Pedalboard 1') bank.append(pedalboard) bank.append(Pedalboard('Pedalboard is a Pedalboard?')) reverb = self.builder.build( 'http://calf.sourceforge.net/plugins/Reverb') filter = self.builder.build( 'http://calf.sourceforge.net/plugins/Filter') reverb2 = self.builder.build( 'http://calf.sourceforge.net/plugins/Reverb') pedalboard.append(reverb) pedalboard.append(filter) pedalboard.append(reverb2) reverb.outputs[0].connect(filter.inputs[0]) reverb.outputs[1].connect(filter.inputs[0]) filter.outputs[0].connect(reverb2.inputs[0]) reverb.outputs[0].connect(reverb2.inputs[0]) pedalboard.connections.append( Connection(sys_effect.outputs[0], reverb.inputs[0])) pedalboard.connections.append( Connection(reverb2.outputs[0], sys_effect.inputs[0])) filter.toggle() filter.params[0].value = (filter.params[0].maximum - filter.params[0].minimum) / 3 return bank
def test_observers_calls(self): observer = MagicMock() manager = BanksManager() manager.register(observer) bank = Bank('Bank 1') manager.append(bank) observer.on_bank_updated.assert_called_with(bank, UpdateType.CREATED, index=0, origin=manager) pedalboard = Pedalboard('Rocksmith') bank.append(pedalboard) observer.on_pedalboard_updated.assert_called_with(pedalboard, UpdateType.CREATED, index=0, origin=bank) builder = Lv2EffectBuilder() reverb = builder.build('http://calf.sourceforge.net/plugins/Reverb') filter = builder.build('http://calf.sourceforge.net/plugins/Filter') reverb2 = builder.build('http://calf.sourceforge.net/plugins/Reverb') pedalboard.append(reverb) observer.on_effect_updated.assert_called_with(reverb, UpdateType.CREATED, index=reverb.index, origin=pedalboard) pedalboard.append(filter) observer.on_effect_updated.assert_called_with(filter, UpdateType.CREATED, index=filter.index, origin=pedalboard) pedalboard.append(reverb2) observer.on_effect_updated.assert_called_with(reverb2, UpdateType.CREATED, index=reverb2.index, origin=pedalboard) pedalboard.connect(reverb.outputs[0], filter.inputs[0]) observer.on_connection_updated.assert_called_with( Connection(reverb.outputs[0], filter.inputs[0]), UpdateType.CREATED, pedalboard=pedalboard ) pedalboard.connect(reverb.outputs[1], filter.inputs[0]) observer.on_connection_updated.assert_called_with( Connection(reverb.outputs[1], filter.inputs[0]), UpdateType.CREATED, pedalboard=pedalboard ) pedalboard.connect(filter.outputs[0], reverb2.inputs[0]) observer.on_connection_updated.assert_called_with( Connection(filter.outputs[0], reverb2.inputs[0]), UpdateType.CREATED, pedalboard=pedalboard ) pedalboard.connect(reverb.outputs[0], reverb2.inputs[0]) observer.on_connection_updated.assert_called_with( Connection(reverb.outputs[0], reverb2.inputs[0]), UpdateType.CREATED, pedalboard=pedalboard ) filter.toggle() observer.on_effect_status_toggled.assert_called_with(filter) filter.params[0].value = (filter.params[0].maximum - filter.params[0].minimum) / 2 observer.on_param_value_changed.assert_called_with(filter.params[0]) del bank.pedalboards[0] observer.on_pedalboard_updated.assert_called_with(pedalboard, UpdateType.DELETED, index=0, origin=bank) bank2 = Bank('Bank 2') old_bank = manager.banks[0] manager.banks[0] = bank2 observer.on_bank_updated.assert_called_with(bank2, UpdateType.UPDATED, index=0, origin=manager, old=old_bank) manager.banks.remove(bank2) observer.on_bank_updated.assert_called_with(bank2, UpdateType.DELETED, index=0, origin=manager)
def bank_with_pedalboard(self): bank = Bank('A bank') pedalboard = Pedalboard('A pedalboard') bank.append(pedalboard) return bank
from pluginsmanager.model.lv2.lv2_effect_builder import Lv2EffectBuilder from pluginsmanager.model.system.system_effect import SystemEffect if __name__ == '__main__': manager = BanksManager() bank = Bank('Bank 1') manager.append(bank) mod_host = ModHost('raspberrypi.local') mod_host.connect() manager.register(mod_host) pedalboard = Pedalboard('Rocksmith') bank.append(pedalboard) mod_host.pedalboard = pedalboard builder = Lv2EffectBuilder() reverb = builder.build('http://calf.sourceforge.net/plugins/Reverb') fuzz = builder.build( 'http://guitarix.sourceforge.net/plugins/gx_fuzz_#fuzz_') reverb2 = builder.build('http://calf.sourceforge.net/plugins/Reverb') pedalboard.append(reverb) pedalboard.append(fuzz) pedalboard.append(reverb2) sys_effect = SystemEffect('system', ['capture_1'],