Skip to content
This repository has been archived by the owner on Dec 27, 2021. It is now read-only.

Commit

Permalink
Allow nodes to have dynamic list of ports.
Browse files Browse the repository at this point in the history
- Currently only used for CustomCSound nodes.
- Bring back node parameters
- Add a ObjectListEditor widget.
  • Loading branch information
odahoda committed Apr 6, 2019
1 parent 9f4dbd2 commit c3e5c3a
Show file tree
Hide file tree
Showing 74 changed files with 1,978 additions and 484 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/protoc/setup.py
Expand Up @@ -29,7 +29,7 @@
import time
import zipfile

VERSION = '3.0.2'
VERSION = '3.7.1'
FILENAME = 'v%s.zip' % VERSION
DOWNLOAD_URL = 'https://github.com/google/protobuf/archive/%s' % FILENAME

Expand Down
12 changes: 7 additions & 5 deletions 3rdparty/typeshed/PyQt5/QtWidgets.pyi
Expand Up @@ -444,6 +444,7 @@ class QAbstractButton(QWidget):


class QAbstractItemDelegate(QtCore.QObject):
commitData = ... # type: PYQT_SIGNAL

class EndEditHint(int): ...
NoHint = ... # type: 'QAbstractItemDelegate.EndEditHint'
Expand All @@ -456,7 +457,7 @@ class QAbstractItemDelegate(QtCore.QObject):

def sizeHintChanged(self, a0: QtCore.QModelIndex) -> None: ...
def closeEditor(self, editor: QWidget, hint: 'QAbstractItemDelegate.EndEditHint' = ...) -> None: ...
def commitData(self, editor: QWidget) -> None: ...
#def commitData(self, editor: QWidget) -> None: ...
def helpEvent(self, event: QtGui.QHelpEvent, view: 'QAbstractItemView', option: 'QStyleOptionViewItem', index: QtCore.QModelIndex) -> bool: ...
def editorEvent(self, event: QtCore.QEvent, model: QtCore.QAbstractItemModel, option: 'QStyleOptionViewItem', index: QtCore.QModelIndex) -> bool: ...
def destroyEditor(self, editor: QWidget, index: QtCore.QModelIndex) -> None: ...
Expand Down Expand Up @@ -1581,6 +1582,7 @@ class QColumnView(QAbstractItemView):

class QComboBox(QWidget):
currentIndexChanged = ... # type: PYQT_SIGNAL
activated = ... # type: PYQT_SIGNAL

class SizeAdjustPolicy(int): ...
AdjustToContents = ... # type: 'QComboBox.SizeAdjustPolicy'
Expand Down Expand Up @@ -1624,10 +1626,10 @@ class QComboBox(QWidget):
@typing.overload
def highlighted(self, a0: str) -> None: ...
def currentTextChanged(self, a0: str) -> None: ...
@typing.overload
def activated(self, index: int) -> None: ...
@typing.overload
def activated(self, a0: str) -> None: ...
# @typing.overload
# def activated(self, index: int) -> None: ...
# @typing.overload
# def activated(self, a0: str) -> None: ...
def editTextChanged(self, a0: str) -> None: ...
def setCurrentText(self, text: str) -> None: ...
def setEditText(self, text: str) -> None: ...
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Expand Up @@ -41,7 +41,7 @@ pkg_check_modules(LIBSNDFILE REQUIRED sndfile)
pkg_check_modules(LIBFLUIDSYNTH REQUIRED fluidsynth>=1.1.6)
pkg_check_modules(LIBAVUTIL REQUIRED libavutil)
pkg_check_modules(LIBSWRESAMPLE REQUIRED libswresample)
pkg_check_modules(LIBPROTOBUF REQUIRED protobuf>=3.0)
pkg_check_modules(LIBPROTOBUF REQUIRED protobuf>=3.7)
pkg_check_modules(LIBPORTAUDIO REQUIRED portaudio-2.0>=19)
pkg_check_modules(LIBUNWIND REQUIRED libunwind-generic>=1.1)

Expand Down Expand Up @@ -105,7 +105,7 @@ macro(py_proto src)
string(REGEX REPLACE "\\.proto$" "" base ${src})
add_custom_command(
OUTPUT ${base}_pb2.py
COMMAND LD_LIBRARY_PATH=$ENV{VIRTUAL_ENV}/lib protoc --python_out=${CMAKE_BINARY_DIR} --mypy_out=${CMAKE_BINARY_DIR} --proto_path=${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_LIST_DIR}/${src}
COMMAND LD_LIBRARY_PATH=$ENV{VIRTUAL_ENV}/lib $ENV{VIRTUAL_ENV}/bin/protoc --python_out=${CMAKE_BINARY_DIR} --mypy_out=${CMAKE_BINARY_DIR} --proto_path=${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_LIST_DIR}/${src}
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/${src}
)
file(RELATIVE_PATH pkg_path ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_LIST_DIR})
Expand All @@ -117,7 +117,7 @@ macro(cpp_proto src)
string(REGEX REPLACE "\\.proto$" "" base ${src})
add_custom_command(
OUTPUT ${base}.pb.cc ${base}.pb.h
COMMAND LD_LIBRARY_PATH=$ENV{VIRTUAL_ENV}/lib protoc --cpp_out=${CMAKE_BINARY_DIR} --proto_path=${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_LIST_DIR}/${src}
COMMAND LD_LIBRARY_PATH=$ENV{VIRTUAL_ENV}/lib $ENV{VIRTUAL_ENV}/bin/protoc --cpp_out=${CMAKE_BINARY_DIR} --proto_path=${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_LIST_DIR}/${src}
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/${src}
)
endmacro(cpp_proto)
Expand Down
20 changes: 9 additions & 11 deletions listdeps
Expand Up @@ -57,15 +57,15 @@ PIP_DEPS = {
PKG('numpy'),
PKG('portalocker'),
PKG('posix_ipc'),
PKG('protobuf'),
PKG('protobuf==3.7.1'),
PKG('psutil'),
PKG('pyaudio'),
PKG('quamash'),
PKG('toposort'),
PKG('urwid'),
],
'build': [
PKG('./3rdparty/protoc/', 'ubuntu', '<17.10'),
PKG('./3rdparty/protoc/'),
PKG('cssutils'),
PKG('cython'),
PKG('pkgconfig'),
Expand Down Expand Up @@ -138,15 +138,13 @@ SYS_DEPS = {
PKG('libcsound64-dev', 'ubuntu', '>=17.10'),

# protocol buffers
PKG('autoconf', 'ubuntu', '<17.10'),
PKG('automake', 'ubuntu', '<17.10'),
PKG('libtool', 'ubuntu', '<17.10'),
PKG('curl', 'ubuntu', '<17.10'),
PKG('make', 'ubuntu', '<17.10'),
PKG('g++', 'ubuntu', '<17.10'),
PKG('unzip', 'ubuntu', '<17.10'),
PKG('libprotobuf-dev', 'ubuntu', '>=17.10'),
PKG('protobuf-compiler', 'ubuntu', '>=17.10'),
PKG('autoconf'),
PKG('automake'),
PKG('libtool'),
PKG('curl'),
PKG('make'),
PKG('g++'),
PKG('unzip'),

# libswresample
PKG('libswresample-dev'),
Expand Down
3 changes: 3 additions & 0 deletions noisicaa/audioproc/__init__.py
Expand Up @@ -29,6 +29,8 @@
SetControlValue,
SetPluginState,
SetNodePortProperties,
SetNodeDescription,
SetNodeParameters,
)
from .audioproc_client import (
AbstractAudioProcClient,
Expand Down Expand Up @@ -57,4 +59,5 @@
BackendSettings,
HostParameters,
NodePortProperties,
NodeParameters,
)
13 changes: 13 additions & 0 deletions noisicaa/audioproc/audioproc.proto
Expand Up @@ -27,6 +27,7 @@ import "noisicaa/node_db/node_description.proto";
import "noisicaa/audioproc/public/backend_settings.proto";
import "noisicaa/audioproc/public/control_value.proto";
import "noisicaa/audioproc/public/host_parameters.proto";
import "noisicaa/audioproc/public/node_parameters.proto";
import "noisicaa/audioproc/public/node_port_properties.proto";
import "noisicaa/audioproc/public/player_state.proto";
import "noisicaa/audioproc/public/plugin_state.proto";
Expand Down Expand Up @@ -77,6 +78,16 @@ message SetNodePortProperties {
required noisicaa.pb.NodePortProperties port_properties = 2;
}

message SetNodeDescription {
required string node_id = 1;
required noisicaa.pb.NodeDescription description = 2;
}

message SetNodeParameters {
required string node_id = 1;
required noisicaa.pb.NodeParameters parameters = 2;
}

message Mutation {
oneof type {
AddNode add_node = 1;
Expand All @@ -86,6 +97,8 @@ message Mutation {
SetControlValue set_control_value = 5;
SetPluginState set_plugin_state = 6;
SetNodePortProperties set_node_port_properties = 7;
SetNodeDescription set_node_description = 8;
SetNodeParameters set_node_parameters = 9;
}
}

Expand Down
13 changes: 13 additions & 0 deletions noisicaa/audioproc/audioproc_process.py
Expand Up @@ -270,6 +270,8 @@ async def __handle_pipeline_mutation(
request: audioproc_pb2.PipelineMutationRequest,
response: empty_message_pb2.EmptyMessage
) -> None:
logging.info("Pipeline mutation:\n%s", request)

realm = self.__engine.get_realm(request.realm)
graph = realm.graph

Expand Down Expand Up @@ -350,6 +352,17 @@ async def __handle_pipeline_mutation(
node.set_port_properties(set_node_port_properties.port_properties)
realm.update_spec()

elif mutation_type == 'set_node_description':
set_node_description = request.mutation.set_node_description
node = graph.find_node(set_node_description.node_id)
if await node.set_description(set_node_description.description):
realm.update_spec()

elif mutation_type == 'set_node_parameters':
set_node_parameters = request.mutation.set_node_parameters
node = graph.find_node(set_node_parameters.node_id)
node.set_parameters(set_node_parameters.parameters)

else:
raise ValueError(request.mutation)

Expand Down
6 changes: 3 additions & 3 deletions noisicaa/audioproc/engine/CMakeLists.txt
Expand Up @@ -72,11 +72,11 @@ set(LIB_SRCS
plugin_ui_host.cpp
plugin_ui_host_lv2.cpp
processor.cpp
processor.pb.cc
processor_null.cpp
processor_csound_base.cpp
processor_csound.cpp
processor_plugin.cpp
processor_plugin.pb.cc
processor_sound_file.cpp
profile.cpp
realtime.cpp
Expand All @@ -94,8 +94,8 @@ set(TEST_SRCS
py_proto(plugin_host.proto)
cpp_proto(plugin_host.proto)

py_proto(processor.proto)
cpp_proto(processor.proto)
py_proto(processor_plugin.proto)
cpp_proto(processor_plugin.proto)

add_library(noisicaa-audioproc-engine SHARED ${LIB_SRCS})
target_compile_options(noisicaa-audioproc-engine PRIVATE -fPIC -std=c++11 -Wall -Werror -pedantic -DHAVE_PTHREAD_SPIN_LOCK)
Expand Down
15 changes: 12 additions & 3 deletions noisicaa/audioproc/engine/csound_util.cpp
Expand Up @@ -22,6 +22,7 @@

#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "noisicaa/core/logging.h"
#include "noisicaa/core/perf_stats.h"
Expand Down Expand Up @@ -188,8 +189,16 @@ Status CSoundUtil::process_block(
return ERROR_STATUS(
"Excepted sequence in port '%s', got %d.", port.name.c_str(), seq->atom.type);
}

LV2_Atom_Event* event = lv2_atom_sequence_begin(&seq->body);
int instr = 1; // TODO: use port.csound_instr

char *e = nullptr;
int instr = strtol(port.csound_name.c_str(), &e, 10);
if (e == port.csound_name.c_str()) {
_logger->error("Invalid instrument name '%s'", port.csound_name.c_str());
instr = 1;
}

_event_input_ports[port_idx] = {seq, event, instr};
}
}
Expand Down Expand Up @@ -250,7 +259,7 @@ Status CSoundUtil::process_block(
RTUnsafe rtu; // csound might do RT unsafe stuff internally.
int rc = csoundScoreEvent(_csnd, 'i', p, 5);
if (rc < 0) {
return ERROR_STATUS("csoundScoreEvent failed (code %d).", rc);
_logger->warning("csoundScoreEvent failed (code %d).", rc);
}
} else if ((midi[0] & 0xf0) == 0x80) {
MYFLT p[3] = {
Expand All @@ -262,7 +271,7 @@ Status CSoundUtil::process_block(
RTUnsafe rtu; // csound might do RT unsafe stuff internally.
int rc = csoundScoreEvent(_csnd, 'i', p, 3);
if (rc < 0) {
return ERROR_STATUS("csoundScoreEvent failed (code %d).", rc);
_logger->warning("csoundScoreEvent failed (code %d).", rc);
}
} else {
_logger->warning("Ignoring unsupported midi event %d.", midi[0] & 0xf0);
Expand Down
1 change: 1 addition & 0 deletions noisicaa/audioproc/engine/csound_util.h
Expand Up @@ -55,6 +55,7 @@ class CSoundUtil {
string name;
pb::PortDescription::Type type;
pb::PortDescription::Direction direction;
string csound_name;
};

Status setup(const string& orchestra, const string& score, const vector<PortSpec>& ports);
Expand Down

0 comments on commit c3e5c3a

Please sign in to comment.