Skip to content
Permalink
Browse files

Add some new node types.

Metronome, MIDI Monitor, Control Value Mapper, MIDI Velocity Mapper and Osciloscope.

Also simplify tests for processors.
  • Loading branch information...
odahoda committed Jul 6, 2019
1 parent 1eea0de commit a00e72ed49650be1859b1ac910f150976d214713
Showing with 6,026 additions and 863 deletions.
  1. +1 −0 data/icons/CMakeLists.txt
  2. +81 −0 data/icons/warning.svg
  3. +2 −0 noisicaa/audioproc/__init__.py
  4. +8 −0 noisicaa/audioproc/public/CMakeLists.txt
  5. +6 −0 noisicaa/audioproc/public/__init__.py
  6. +55 −0 noisicaa/audioproc/public/transfer_function.cpp
  7. +41 −0 noisicaa/audioproc/public/transfer_function.h
  8. +51 −0 noisicaa/audioproc/public/transfer_function.proto
  9. +24 −0 noisicaa/audioproc/public/transfer_function.pxd
  10. +29 −0 noisicaa/audioproc/public/transfer_function.pyi
  11. +33 −0 noisicaa/audioproc/public/transfer_function.pyx
  12. +10 −0 noisicaa/builtin_nodes/CMakeLists.txt
  13. +29 −79 noisicaa/builtin_nodes/control_track/processor_test.py
  14. +22 −59 noisicaa/builtin_nodes/custom_csound/processor_test.py
  15. +42 −0 noisicaa/builtin_nodes/cv_mapper/CMakeLists.txt
  16. +21 −0 noisicaa/builtin_nodes/cv_mapper/__init__.py
  17. +31 −0 noisicaa/builtin_nodes/cv_mapper/model.desc.pb
  18. +83 −0 noisicaa/builtin_nodes/cv_mapper/model.py
  19. +40 −0 noisicaa/builtin_nodes/cv_mapper/model_test.py
  20. +49 −0 noisicaa/builtin_nodes/cv_mapper/node_description.py
  21. +101 −0 noisicaa/builtin_nodes/cv_mapper/node_ui.py
  22. +45 −0 noisicaa/builtin_nodes/cv_mapper/node_ui_test.py
  23. +152 −0 noisicaa/builtin_nodes/cv_mapper/processor.cpp
  24. +68 −0 noisicaa/builtin_nodes/cv_mapper/processor.h
  25. +36 −0 noisicaa/builtin_nodes/cv_mapper/processor.proto
  26. +44 −0 noisicaa/builtin_nodes/cv_mapper/processor_test.py
  27. +19 −52 noisicaa/builtin_nodes/instrument/processor_test.py
  28. +42 −0 noisicaa/builtin_nodes/metronome/CMakeLists.txt
  29. +21 −0 noisicaa/builtin_nodes/metronome/__init__.py
  30. +30 −0 noisicaa/builtin_nodes/metronome/model.desc.pb
  31. +73 −0 noisicaa/builtin_nodes/metronome/model.py
  32. +40 −0 noisicaa/builtin_nodes/metronome/model_test.py
  33. +49 −0 noisicaa/builtin_nodes/metronome/node_description.py
  34. +127 −0 noisicaa/builtin_nodes/metronome/node_ui.py
  35. +44 −0 noisicaa/builtin_nodes/metronome/node_ui_test.py
  36. +205 −0 noisicaa/builtin_nodes/metronome/processor.cpp
  37. +79 −0 noisicaa/builtin_nodes/metronome/processor.h
  38. +37 −0 noisicaa/builtin_nodes/metronome/processor.proto
  39. +46 −0 noisicaa/builtin_nodes/metronome/processor_test.py
  40. +15 −36 noisicaa/builtin_nodes/midi_cc_to_cv/processor_test.py
  41. +8 −57 noisicaa/builtin_nodes/midi_looper/processor_test.py
  42. +39 −0 noisicaa/builtin_nodes/midi_monitor/CMakeLists.txt
  43. +21 −0 noisicaa/builtin_nodes/midi_monitor/__init__.py
  44. +25 −0 noisicaa/builtin_nodes/midi_monitor/model.desc.pb
  45. +37 −0 noisicaa/builtin_nodes/midi_monitor/model.py
  46. +40 −0 noisicaa/builtin_nodes/midi_monitor/model_test.py
  47. +44 −0 noisicaa/builtin_nodes/midi_monitor/node_description.py
  48. +222 −0 noisicaa/builtin_nodes/midi_monitor/node_ui.py
  49. +45 −0 noisicaa/builtin_nodes/midi_monitor/node_ui_test.py
  50. +111 −0 noisicaa/builtin_nodes/midi_monitor/processor.cpp
  51. +66 −0 noisicaa/builtin_nodes/midi_monitor/processor.h
  52. +31 −0 noisicaa/builtin_nodes/midi_monitor/processor_test.py
  53. +16 −39 noisicaa/builtin_nodes/midi_source/processor_test.py
  54. +42 −0 noisicaa/builtin_nodes/midi_velocity_mapper/CMakeLists.txt
  55. +21 −0 noisicaa/builtin_nodes/midi_velocity_mapper/__init__.py
  56. +31 −0 noisicaa/builtin_nodes/midi_velocity_mapper/model.desc.pb
  57. +79 −0 noisicaa/builtin_nodes/midi_velocity_mapper/model.py
  58. +40 −0 noisicaa/builtin_nodes/midi_velocity_mapper/model_test.py
  59. +49 −0 noisicaa/builtin_nodes/midi_velocity_mapper/node_description.py
  60. +101 −0 noisicaa/builtin_nodes/midi_velocity_mapper/node_ui.py
  61. +45 −0 noisicaa/builtin_nodes/midi_velocity_mapper/node_ui_test.py
  62. +180 −0 noisicaa/builtin_nodes/midi_velocity_mapper/processor.cpp
  63. +70 −0 noisicaa/builtin_nodes/midi_velocity_mapper/processor.h
  64. +36 −0 noisicaa/builtin_nodes/midi_velocity_mapper/processor.proto
  65. +43 −0 noisicaa/builtin_nodes/midi_velocity_mapper/processor_test.py
  66. +15 −54 noisicaa/builtin_nodes/mixer/processor_test.py
  67. +2 −0 noisicaa/builtin_nodes/model.tmpl.py
  68. +20 −0 noisicaa/builtin_nodes/model_registry.proto
  69. +15 −0 noisicaa/builtin_nodes/model_registry.py
  70. +10 −0 noisicaa/builtin_nodes/node_description_registry.py
  71. +11 −42 noisicaa/builtin_nodes/noise/processor_test.py
  72. +10 −45 noisicaa/builtin_nodes/oscillator/processor_test.py
  73. +42 −0 noisicaa/builtin_nodes/oscilloscope/CMakeLists.txt
  74. +21 −0 noisicaa/builtin_nodes/oscilloscope/__init__.py
  75. +49 −0 noisicaa/builtin_nodes/oscilloscope/model.desc.pb
  76. +63 −0 noisicaa/builtin_nodes/oscilloscope/model.py
  77. +40 −0 noisicaa/builtin_nodes/oscilloscope/model_test.py
  78. +45 −0 noisicaa/builtin_nodes/oscilloscope/node_description.py
  79. +660 −0 noisicaa/builtin_nodes/oscilloscope/node_ui.py
  80. +46 −0 noisicaa/builtin_nodes/oscilloscope/node_ui_test.py
  81. +159 −0 noisicaa/builtin_nodes/oscilloscope/processor.cpp
  82. +76 −0 noisicaa/builtin_nodes/oscilloscope/processor.h
  83. +36 −0 noisicaa/builtin_nodes/oscilloscope/processor.proto
  84. +39 −0 noisicaa/builtin_nodes/oscilloscope/processor_test.py
  85. +39 −94 noisicaa/builtin_nodes/pianoroll/processor_test.py
  86. +20 −0 noisicaa/builtin_nodes/processor_registry.cpp
  87. +33 −96 noisicaa/builtin_nodes/sample_track/processor_test.py
  88. +11 −36 noisicaa/builtin_nodes/step_sequencer/processor_test.py
  89. +10 −0 noisicaa/builtin_nodes/ui_registry.py
  90. +10 −51 noisicaa/builtin_nodes/vca/processor_test.py
  91. +17 −0 noisicaa/lv2/atom.pyx
  92. +2 −0 noisicaa/music/CMakeLists.txt
  93. +3 −0 noisicaa/music/__init__.py
  94. +8 −6 noisicaa/music/graph.py
  95. +64 −0 noisicaa/music/model.desc.pb
  96. +3 −0 noisicaa/music/project.proto
  97. +2 −0 noisicaa/music/project.py
  98. +80 −0 noisicaa/music/transfer_function.py
  99. +49 −0 noisicaa/music/transfer_function_test.py
  100. +4 −0 noisicaa/ui/CMakeLists.txt
  101. +180 −0 noisicaa/ui/base_dial.py
  102. +10 −104 noisicaa/ui/control_value_dial.py
  103. +111 −0 noisicaa/ui/int_dial.py
  104. +70 −2 noisicaa/ui/property_connector.py
  105. +354 −0 noisicaa/ui/transfer_function_editor.py
  106. +49 −0 noisicaa/ui/transfer_function_editor_test.py
  107. +1 −1 noisicaa/value_types/__init__.py
  108. +1 −0 noisidev/CMakeLists.txt
  109. +10 −10 noisidev/unittest_engine_utils.pyx
  110. +153 −0 noisidev/unittest_processor_mixins.py
@@ -58,4 +58,5 @@ install_files(
track-type-sample.svg
track-type-score.svg
track-visible.svg
warning.svg
)
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="30"
id="svg2"
version="1.1"
viewBox="147 151 60 60"
width="30"
sodipodi:docname="warning.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<metadata
id="metadata3495">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="2560"
inkscape:window-height="1373"
id="namedview3493"
showgrid="false"
inkscape:zoom="16.000001"
inkscape:cx="-6.3115405"
inkscape:cy="25.123386"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer2" />
<defs
id="defs10" />
<g
id="layer2"
style="display:inline"
transform="translate(0,-637.6694)"
inkscape:groupmode="layer"
inkscape:label="Symbol">
<g
id="layer1"
transform="matrix(0.05920137,0,0,-0.05920137,128.73324,826.15201)">
<path
id="path11039"
style="fill:#ee1c23;fill-rule:nonzero;stroke:none"
d="m 840.83969,544.41993 c -14.03378,24.29258 -37.01519,24.29258 -51.06339,0 L 321.28695,-265.67834 c -14.03379,-24.29257 -2.55029,-44.16176 25.5317,-44.16176 l 936.94985,-0.0144 c 28.0964,0 39.5799,19.86919 25.5317,44.16177 z"
inkscape:connector-curvature="0" />
<path
id="path10308"
style="fill:#ffffff;fill-rule:nonzero;stroke:none"
d="m 1154.4675,-205.95549 -678.31899,0.0144 339.15949,586.4942 339.1595,-586.50861"
inkscape:connector-curvature="0" />
</g>
<g
aria-label="!"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:33.58262253px;line-height:125%;font-family:'Arial Black';-inkscape-font-specification:'Arial Black, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3.3582623pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="text955">
<path
d="m 173.43348,812.48346 h 7.13303 v 5.47685 l -1.37741,11.0029 h -4.411 l -1.34462,-11.0029 z m 0.24597,18.15233 h 6.65749 v 5.88679 h -6.65749 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:33.58262253px;font-family:'Arial Black';-inkscape-font-specification:'Arial Black, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:3.3582623pt"
id="path825" />
</g>
</g>
</svg>
@@ -61,4 +61,6 @@
NodePortProperties,
NodeParameters,
MidiEvent,
TransferFunction,
TransferFunctionSpec,
)
@@ -21,6 +21,7 @@
add_python_package(
time_mapper.pyi
musical_time.pyi
transfer_function.pyi
)

set(LIB_SRCS
@@ -40,6 +41,8 @@ set(LIB_SRCS
processor_message.pb.cc
project_properties.pb.cc
time_mapper.cpp
transfer_function.cpp
transfer_function.pb.cc
)

set(TEST_SRCS
@@ -75,6 +78,8 @@ cpp_proto(node_parameters.proto)
py_proto(node_parameters.proto)
cpp_proto(midi_event.proto)
py_proto(midi_event.proto)
cpp_proto(transfer_function.proto)
py_proto(transfer_function.proto)

add_library(noisicaa-audioproc-public SHARED ${LIB_SRCS})
target_compile_options(noisicaa-audioproc-public PRIVATE -fPIC -std=c++11 -Wall -Werror -pedantic -DHAVE_PTHREAD_SPIN_LOCK)
@@ -90,6 +95,9 @@ target_link_libraries(${musical_time.so} PRIVATE noisicaa-audioproc-public)
add_cython_module(time_mapper CXX)
target_link_libraries(${time_mapper.so} PRIVATE noisicaa-audioproc-public)

add_cython_module(transfer_function CXX)
target_link_libraries(${transfer_function.so} PRIVATE noisicaa-audioproc-public)

foreach(TEST_SRC ${TEST_SRCS})
string(REGEX REPLACE "\.pyx$" "" TEST_MOD ${TEST_SRC})
add_cython_module(${TEST_MOD} CXX)
@@ -72,3 +72,9 @@
from .midi_event_pb2 import (
MidiEvent,
)
from .transfer_function import (
TransferFunction,
)
from .transfer_function_pb2 import (
TransferFunctionSpec,
)
@@ -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 comments on commit a00e72e

Please sign in to comment.
You can’t perform that action at this time.