Compare commits
28 Commits
main
...
more-nodes
Author | SHA1 | Date |
---|---|---|
|
400c782903 | 3 years ago |
|
a8c916e91f | 3 years ago |
|
cee374c403 | 3 years ago |
|
daabaee6b2 | 3 years ago |
|
93d9f7ab58 | 3 years ago |
|
08a8fdc39c | 3 years ago |
|
57853f4009 | 3 years ago |
|
b39194a3f8 | 3 years ago |
|
2743cac468 | 3 years ago |
|
61e9670fbf | 3 years ago |
|
ddf34346da | 3 years ago |
|
9a28daff24 | 3 years ago |
|
e67bffc5b4 | 3 years ago |
|
9506433653 | 3 years ago |
|
2c4f691ac8 | 3 years ago |
|
4240ad0ec9 | 3 years ago |
|
251ed48527 | 3 years ago |
|
ded2879831 | 3 years ago |
|
6c80505cf7 | 3 years ago |
|
b36257b915 | 3 years ago |
|
596247f11c | 3 years ago |
|
01d754d350 | 3 years ago |
|
7a17e27f84 | 3 years ago |
|
98a715faa9 | 3 years ago |
|
937daafa9a | 3 years ago |
|
0d33e536b2 | 3 years ago |
|
a3accbfea2 | 3 years ago |
|
6863a64013 | 3 years ago |
110 changed files with 6026 additions and 863 deletions
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* @begin:license |
||||
* |
||||
* Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License along |
||||
* with this program; if not, write to the Free Software Foundation, Inc., |
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
* |
||||
* @end:license |
||||
*/ |
||||
|
||||
#include <math.h> |
||||
|
||||
#include "noisicaa/audioproc/public/transfer_function.h" |
||||
#include "noisicaa/audioproc/public/transfer_function.pb.h" |
||||
|
||||
namespace noisicaa { |
||||
|
||||
float apply_transfer_function(const pb::TransferFunctionSpec& spec, float value) { |
||||
switch (spec.type_case()) { |
||||
case pb::TransferFunctionSpec::kFixed: |
||||
value = spec.fixed().value(); |
||||
break; |
||||
case pb::TransferFunctionSpec::kLinear: { |
||||
value = (spec.linear().right_value() - spec.linear().left_value()) * (value - spec.input_min()) / (spec.input_max() - spec.input_min()) + spec.linear().left_value(); |
||||
break; |
||||
} |
||||
case pb::TransferFunctionSpec::kGamma: |
||||
value = (spec.output_max() - spec.output_min()) * powf((value - spec.input_min()) / (spec.input_max() - spec.input_min()), spec.gamma().value()) + spec.output_min(); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
return value; |
||||
} |
||||
|
||||
float apply_transfer_function(const std::string& serialized_spec, float value) { |
||||
pb::TransferFunctionSpec spec; |
||||
assert(spec.ParseFromString(serialized_spec)); |
||||
return apply_transfer_function(spec, value); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,41 @@
|
||||
// -*- mode: c++ -*-
|
||||
|
||||
/*
|
||||
* @begin:license |
||||
* |
||||
* Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License along |
||||
* with this program; if not, write to the Free Software Foundation, Inc., |
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
* |
||||
* @end:license |
||||
*/ |
||||
|
||||
#ifndef _NOISICAA_AUDIOPROC_PUBLIC_TRANSFER_FUNCTION_H |
||||
#define _NOISICAA_AUDIOPROC_PUBLIC_TRANSFER_FUNCTION_H |
||||
|
||||
#include <string> |
||||
|
||||
namespace noisicaa { |
||||
|
||||
namespace pb { |
||||
class TransferFunctionSpec; |
||||
} |
||||
|
||||
float apply_transfer_function(const pb::TransferFunctionSpec& spec, float value); |
||||
float apply_transfer_function(const std::string& serialized_spec, float value); |
||||
|
||||
} // namespace noisicaa
|
||||
|
||||
#endif |
@ -0,0 +1,51 @@
|
||||
/* |
||||
* @begin:license |
||||
* |
||||
* Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License along |
||||
* with this program; if not, write to the Free Software Foundation, Inc., |
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
* |
||||
* @end:license |
||||
*/ |
||||
|
||||
syntax = "proto2"; |
||||
|
||||
package noisicaa.pb; |
||||
|
||||
message TransferFunctionSpec { |
||||
required float input_min = 1; |
||||
required float input_max = 2; |
||||
required float output_min = 3; |
||||
required float output_max = 4; |
||||
|
||||
message Fixed { |
||||
required float value = 1; |
||||
} |
||||
|
||||
message Linear { |
||||
required float left_value = 1; |
||||
required float right_value = 2; |
||||
} |
||||
|
||||
message Gamma { |
||||
required float value = 1; |
||||
} |
||||
|
||||
oneof type { |
||||
Fixed fixed = 5; |
||||
Linear linear = 6; |
||||
Gamma gamma = 7; |
||||
} |
||||
} |
@ -0,0 +1,24 @@
|
||||
# @begin:license |
||||
# |
||||
# Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de> |
||||
# |
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation; either version 2 of the License, or |
||||
# (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License along |
||||
# with this program; if not, write to the Free Software Foundation, Inc., |
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
# |
||||
# @end:license |
||||
|
||||
from libcpp.string cimport string |
||||
|
||||
cdef extern from "noisicaa/audioproc/public/transfer_function.h" namespace "noisicaa" nogil: |
||||
cdef float apply_transfer_function(const string& spec, float value) |
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/python3 |
||||
|
||||
# @begin:license |
||||
# |
||||
# Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de> |
||||
# |
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation; either version 2 of the License, or |
||||
# (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License along |
||||
# with this program; if not, write to the Free Software Foundation, Inc., |
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
# |
||||
# @end:license |
||||
|
||||
from . import transfer_function_pb2 |
||||
|
||||
|
||||
class TransferFunction(object): |
||||
def __init__(self, spec: transfer_function_pb2.TransferFunctionSpec) -> None: ... |
||||
def __call__(self, value: float) -> float: ... |
||||
|
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/python3 |
||||
|
||||
# @begin:license |
||||
# |
||||
# Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de> |
||||
# |
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation; either version 2 of the License, or |
||||
# (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License along |
||||
# with this program; if not, write to the Free Software Foundation, Inc., |
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
# |
||||
# @end:license |
||||
|
||||
from . import transfer_function_pb2 |
||||
|
||||
|
||||
cdef class TransferFunction(object): |
||||
cdef bytes __serialized_spec |
||||
|
||||
def __init__(self, spec: transfer_function_pb2.TransferFunctionSpec) -> None: |
||||
self.__serialized_spec = spec.SerializeToString() |
||||
|
||||
def __call__(self, value: float) -> float: |
||||
return apply_transfer_function(self.__serialized_spec, value) |
@ -0,0 +1,42 @@
|
||||
# @begin:license |
||||
# |
||||
# Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de> |
||||
# |
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation; either version 2 of the License, or |
||||
# (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License along |
||||
# with this program; if not, write to the Free Software Foundation, Inc., |
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
# |
||||
# @end:license |
||||
|
||||
add_python_package( |
||||
node_description.py |
||||
model.py |
||||
model_test.py |
||||
node_ui.py |
||||
node_ui_test.py |
||||
processor_test.py |
||||
) |
||||
|
||||
build_model(model.desc.pb _model.py noisicaa/builtin_nodes/model.tmpl.py) |
||||
|
||||
py_proto(model.proto) |
||||
add_dependencies(noisicaa.builtin_nodes.cv_mapper.model.proto model-noisicaa.builtin_nodes.cv_mapper) |
||||
cpp_proto(model.proto) |
||||
py_proto(processor.proto) |
||||
cpp_proto(processor.proto) |
||||
add_dependencies(noisicaa.builtin_nodes.cv_mapper.processor.proto model-noisicaa.builtin_nodes.cv_mapper) |
||||
|
||||
add_library(noisicaa-builtin_nodes-cv_mapper-processor SHARED processor.cpp processor.pb.cc) |
||||
target_compile_options(noisicaa-builtin_nodes-cv_mapper-processor PRIVATE -fPIC -std=c++11 -Wall -Werror -pedantic -DHAVE_PTHREAD_SPIN_LOCK) |
||||
target_link_libraries(noisicaa-builtin_nodes-cv_mapper-processor PRIVATE noisicaa-audioproc-public) |
||||
target_link_libraries(noisicaa-builtin_nodes-cv_mapper-processor PRIVATE noisicaa-host_system) |
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/python3 |
||||
|
||||
# @begin:license |
||||
# |
||||
# Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de> |
||||
# |
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation; either version 2 of the License, or |
||||
# (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License along |
||||
# with this program; if not, write to the Free Software Foundation, Inc., |
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
# |
||||
# @end:license |
@ -0,0 +1,31 @@
|
||||
# @begin:license |
||||
# |
||||
# Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de> |
||||
# |
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation; either version 2 of the License, or |
||||
# (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License along |
||||
# with this program; if not, write to the Free Software Foundation, Inc., |
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
# |
||||
# @end:license |
||||
|
||||
classes { |
||||
name: "CVMapper" |
||||
super_class: "noisicaa.music.graph.BaseNode" |
||||
proto_ext_name: "cv_mapper" |
||||
properties { |
||||
name: "transfer_function" |
||||
type: OBJECT |
||||
obj_type: "noisicaa.music.transfer_function.TransferFunction" |
||||
proto_id: 1 |
||||
} |
||||
} |
@ -0,0 +1,83 @@
|
||||
#!/usr/bin/python3 |
||||
|
||||
# @begin:license |
||||
# |
||||
# Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de> |
||||
# |
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation; either version 2 of the License, or |
||||
# (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License along |
||||
# with this program; if not, write to the Free Software Foundation, Inc., |
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
# |
||||
# @end:license |
||||
|
||||
import logging |
||||
from typing import Any, Iterator |
||||
|
||||
from noisicaa import audioproc |
||||
from noisicaa import music |
||||
from noisicaa import node_db |
||||
from noisicaa import value_types |
||||
from . import node_description |
||||
from . import processor_pb2 |
||||
from . import _model |
||||
|
||||
logger = logging.getLogger(__name__) |
||||
|
||||
|
||||
class CVMapper(_model.CVMapper): |
||||
def create(self, **kwargs: Any) -> None: |
||||
super().create(**kwargs) |
||||
|
||||
self.transfer_function = self._pool.create( |
||||
music.TransferFunction, |
||||
input_min=-1.0, |
||||
input_max=1.0, |
||||
output_min=-1.0, |
||||
output_max=1.0, |
||||
type=music.TransferFunction.FIXED, |
||||
fixed_value=0.0, |
||||
linear_left_value=-1.0, |
||||
linear_right_value=1.0) |
||||
|
||||
def setup(self) -> None: |
||||
super().setup() |
||||
|
||||
self.transfer_function.object_changed.add(lambda _: self.update_spec()) |
||||
|
||||
def default_port_properties(self, port_name: str) -> value_types.NodePortProperties: |
||||
return value_types.NodePortProperties(port_name, exposed=True) |
||||
|
||||
def get_initial_parameter_mutations(self) -> Iterator[audioproc.Mutation]: |
||||
yield from super().get_initial_parameter_mutations() |
||||
yield self.__get_spec_mutation() |
||||
|
||||
def update_spec(self) -> None: |
||||
if self.attached_to_project: |
||||
self.project.handle_pipeline_mutation( |
||||
self.__get_spec_mutation()) |
||||
|
||||
def __get_spec_mutation(self) -> audioproc.Mutation: |
||||
params = audioproc.NodeParameters() |
||||
spec = params.Extensions[processor_pb2.cv_mapper_spec] |
||||
spec.transfer_function.CopyFrom(self.transfer_function.get_function_spec()) |
||||
|
||||
return audioproc.Mutation( |
||||
set_node_parameters=audioproc.SetNodeParameters( |
||||
node_id=self.pipeline_node_id, |
||||
parameters=params)) |
||||
|
||||
@property |
||||
def description(self) -> node_db.NodeDescription: |
||||
node_desc = node_db.NodeDescription() |
||||
node_desc.CopyFrom(node_description.CVMapperDescription) |
||||
return node_desc |
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/python3 |
||||
|
||||
# @begin:license |
||||
# |
||||
# Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de> |
||||
# |
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation; either version 2 of the License, or |
||||
# (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License along |
||||
# with this program; if not, write to the Free Software Foundation, Inc., |
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
# |
||||
# @end:license |
||||
|
||||
from typing import cast |
||||
|
||||
from noisidev import unittest |
||||
from noisidev import unittest_mixins |
||||
from . import model |
||||
|
||||
|
||||
class CVMapperTest(unittest_mixins.ProjectMixin, unittest.AsyncTestCase): |
||||
|
||||
async def _add_node(self) -> model.CVMapper: |
||||
with self.project.apply_mutations('test'): |
||||
return cast( |
||||
model.CVMapper, |
||||
self.project.create_node('builtin://cv-mapper')) |
||||
|
||||
async def test_add_node(self): |
||||
node = await self._add_node() |
||||
self.assertIsInstance(node, model.CVMapper) |
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/python3 |
||||
|
||||
# @begin:license |
||||
# |
||||
# Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de> |
||||
# |
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation; either version 2 of the License, or |
||||
# (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License along |
||||
# with this program; if not, write to the Free Software Foundation, Inc., |
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
# |
||||
# @end:license |
||||
|
||||
from noisicaa import node_db |
||||
|
||||
|
||||
CVMapperDescription = node_db.NodeDescription( |
||||
uri='builtin://cv-mapper', |
||||
display_name='Control Value Mapper (a-rate)', |
||||
type=node_db.NodeDescription.PROCESSOR, |
||||
node_ui=node_db.NodeUIDescription( |
||||
type='builtin://cv-mapper', |
||||
), |
||||
builtin_icon='node-type-builtin', |
||||
processor=node_db.ProcessorDescription( |
||||
type='builtin://cv-mapper', |
||||
), |
||||
ports=[ |
||||
node_db.PortDescription( |
||||
name='in', |
||||
direction=node_db.PortDescription.INPUT, |
||||
type=node_db.PortDescription.ARATE_CONTROL, |
||||
), |
||||
node_db.PortDescription( |
||||
name='out', |
||||
direction=node_db.PortDescription.OUTPUT, |
||||
type=node_db.PortDescription.ARATE_CONTROL, |
||||
), |
||||
] |
||||
) |
@ -0,0 +1,101 @@
|
||||
#!/usr/bin/python3 |
||||
|
||||
# @begin:license |
||||
# |
||||
# Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de> |
||||
# |
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation; either version 2 of the License, or |
||||
# (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License along |
||||
# with this program; if not, write to the Free Software Foundation, Inc., |
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
# |
||||
# @end:license |
||||
|
||||
import logging |
||||
from typing import Any |
||||
|
||||
from PyQt5.QtCore import Qt |
||||
from PyQt5 import QtWidgets |
||||
|
||||
from noisicaa import core |
||||
from noisicaa import music |
||||
from noisicaa.ui import ui_base |
||||
from noisicaa.ui import transfer_function_editor |
||||
from noisicaa.ui.graph import base_node |
||||
from . import model |
||||
|
||||
logger = logging.getLogger(__name__) |
||||
|
||||
|
||||
class CVMapperNodeWidget(ui_base.ProjectMixin, core.AutoCleanupMixin, QtWidgets.QWidget): |
||||
def __init__(self, node: model.CVMapper, session_prefix: str, **kwargs: Any) -> None: |
||||
super().__init__(**kwargs) |
||||
|
||||
self.__node = node |
||||
|
||||
self.__transfer_function_editor = transfer_function_editor.TransferFunctionEditor( |
||||
transfer_function=self.__node.transfer_function, |
||||
mutation_name_prefix=self.__node.name, |
||||
context=self.context) |
||||
self.add_cleanup_function(self.__transfer_function_editor.cleanup) |
||||
|
||||
l1 = QtWidgets.QVBoxLayout() |
||||
l1.setContentsMargins(0, 0, 0, 0) |
||||
l1.addWidget(self.__transfer_function_editor) |
||||
self.setLayout(l1) |
||||
|
||||
|
||||
class CVMapperNode(base_node.Node): |
||||
has_window = True |
||||
|
||||
def __init__(self, *, node: music.BaseNode, **kwargs: Any) -> None: |
||||
assert isinstance(node, model.CVMapper), type(node).__name__ |
||||
self.__widget = None # type: QtWidgets.QWidget |
||||
self.__node = node # type: model.CVMapper |
||||
|
||||
super().__init__(node=node, **kwargs) |
||||
|
||||
def createBodyWidget(self) -> QtWidgets.QWidget: |
||||
assert self.__widget is None |
||||
|
||||
body = CVMapperNodeWidget( |
||||
node=self.__node, |
||||
session_prefix='inline', |
||||
context=self.context) |
||||
self.add_cleanup_function(body.cleanup) |
||||
body.setAutoFillBackground(False) |
||||
body.setAttribute(Qt.WA_NoSystemBackground, True) |
||||
|
||||
self.__widget = QtWidgets.QScrollArea() |
||||
self.__widget.setWidgetResizable(True) |
||||
self.__widget.setFrameShape(QtWidgets.QFrame.NoFrame) |
||||
self.__widget.setWidget(body) |
||||
|
||||
return self.__widget |
||||
|
||||
def createWindow(self, **kwargs: Any) -> QtWidgets.QWidget: |
||||
window = QtWidgets.QDialog(**kwargs) |
||||
window.setAttribute(Qt.WA_DeleteOnClose, False) |
||||
window.setWindowTitle("Control Value Mapper") |
||||
|
||||
body = CVMapperNodeWidget( |
||||
node=self.__node, |
||||
session_prefix='window', |
||||
context=self.context) |
||||
self.add_cleanup_function(body.cleanup) |
||||
|
||||
layout = QtWidgets.QVBoxLayout() |
||||
layout.setContentsMargins(0, 0, 0, 0) |
||||
layout.addWidget(body) |
||||
window.setLayout(layout) |
||||
|
||||
return window |
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/python3 |
||||
|
||||
# @begin:license |
||||
# |
||||
# Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de> |
||||
# |
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License as published by |
||||
# the Free Software Foundation; either version 2 of the License, or |
||||
# (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License along |
||||
# with this program; if not, write to the Free Software Foundation, Inc., |
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
# |
||||
# @end:license |
||||
|
||||
from noisidev import uitest |
||||
from . import node_ui |
||||
|
||||
|
||||
class CVMapperNodeTest(uitest.ProjectMixin, uitest.UITestCase): |
||||
async def setup_testcase(self): |
||||
with self.project.apply_mutations('test'): |
||||
self.node = self.project.create_node('builtin://cv-mapper') |
||||
|
||||
async def test_init(self): |
||||
widget = node_ui.CVMapperNode(node=self.node, context=self.context) |
||||
widget.cleanup() |
||||
|
||||
|
||||
class CVMapperNodeWidgetTest(uitest.ProjectMixin, uitest.UITestCase): |
||||
async def setup_testcase(self): |
||||
with self.project.apply_mutations('test'): |
||||
self.node = self.project.create_node('builtin://cv-mapper') |
||||
|
||||
async def test_init(self): |
||||
widget = node_ui.CVMapperNodeWidget( |
||||
node=self.node, session_prefix='test', context=self.context) |
||||
widget.cleanup() |
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* @begin:license |
||||
* |
||||
* Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License along |
||||
* with this program; if not, write to the Free Software Foundation, Inc., |
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||||
* |
||||
* @end:license |
||||
*/ |
||||
|
||||
#include <math.h> |
||||
|
||||
#include "noisicaa/audioproc/engine/misc.h" |
||||
#include "noisicaa/audioproc/public/engine_notification.pb.h" |
||||
#include "noisicaa/audioproc/public/transfer_function.h" |
||||
#include "noisicaa/audioproc/engine/message_queue.h" |
||||
#include "noisicaa/host_system/host_system.h" |
||||
#include "noisicaa/builtin_nodes/cv_mapper/processor.h" |
||||
#include "noisicaa/builtin_nodes/cv_mapper/processor.pb.h" |
||||
|
||||
namespace noisicaa { |
||||
|
||||
ProcessorCVMapper::ProcessorCVMapper( |
||||
const string& realm_name, const string& node_id, HostSystem *host_system, |
||||
const pb::NodeDescription& desc) |
||||
: Processor( |
||||
realm_name, node_id, "noisicaa.audioproc.engine.processor.cv_mapper", host_system, desc), |
||||
_next_spec(nullptr), |
||||
_current_spec(nullptr), |
||||
_old_spec(nullptr) { |
||||
} |
||||
|
||||
Status ProcessorCVMapper::setup_internal() { |
||||
RETURN_IF_ERROR(Processor::setup_internal()); |
||||
|
||||
_buffers[0] = nullptr; |
||||
_buffers[1] = nullptr; |
||||
|
||||
return Status::Ok(); |
||||
} |
||||
|
||||
void ProcessorCVMapper::cleanup_internal() { |
||||
pb::CVMapperSpec* spec = _next_spec.exchange(nullptr); |
||||
if (spec != nullptr) { |
||||
delete spec; |
||||
} |
||||
spec = _current_spec.exchange(nullptr); |
||||
if (spec != nullptr) { |
||||
delete spec; |
||||
} |
||||
spec = _old_spec.exchange(nullptr); |
||||