Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Networking with osc #122

Open
wants to merge 373 commits into
base: master
Choose a base branch
from

Conversation

dvzrv
Copy link
Contributor

@dvzrv dvzrv commented Dec 15, 2018

As announced in #85, I now rebased my native OSC interface against HEAD and merged all relevant other branches (e.g. configuration-client-server, sclang-workflows and osc-tests).

This requires liblo > 0.29 and adds quite an extensive framework on how to deal with multiple renderers in a network, acting as clients and servers.
As I haven't added any use-case documentation besides the SuperCollider scripts for testing yet, it's easiest to have a look into my MT for further details.

I know this is quite an extensive chunk of work, but I tried hard not to interact with the current code base (e.g. removing other components) and basically stuck to implementing the publisher-subscriber interface for all of this.
I'm quite sure there are better ways of doing certain things in my additions, so please let me know what you think and do review (I know it's a really a lot and I'm sorry about that...).

In any case: I just build this and it works, but I bet there are still some bugs! ;-)

dvzrv added 30 commits June 1, 2017 20:10
…message_level() (friend function for OscHandler). Changing add_client to use a MessageLevel parameter. Line wraps. src/networking/oscreceiver.cpp: Style changes for string compare in start(). Updating callback handler for /subscribe message to also be able to set an inital message_level for the client subscribing. Prettifying VERBOSE output in /subscribe callback handler. Adding callback handler for /message_level, enabling clients to set their own message_level (the amount of messages received from the server, defaults to MessageLevel::CLIENT - which is a lot of messages (some unneeded probably) already).
…client() to use an additional parameter for MessageLevel. Adding set_client_message_level(). src/networking/oscsender.cpp: Adding implementation of set_client_message_level(). Changing add_client() to use the MessageLevel provided as parameter. Updating VERBOSE output for add_client().
…evel. Updating friend function add_client() to include MessageLevel parameter. adding friend function set_message_level(). src/networking/oschandler.cpp: Updating call to add_client() in constructor and implementation of add_client() to incorporate MessageLevel parameter. Adding implementation of friend function set_message_level().
…) into several functions, so they can be applied to server objects as well. src/networking/oscreceiver.cpp: Splitting the implementation of callback handler adding into several functions, so they can be more easily applied fine-grained to server objects as well.
…2string representations. Adding bool_to_message_type() and bool_to_string() to public interface for VERBOSE messages used throughout OscSender and OscReceiver. src/networking/oschandler.cpp: Adding implementation of bool_to_message_type() and bool_to_string().
… bool_to_message_type. src/networking/oscsender.cpp: Removing implementation of bool_to_message_type() and replacing all calls to it by the version now held by OscHandler.
…ty of all source related VERBOSE messages by adding more relevant output derived from incoming message.
…_client() by the versions from OscHandler. Removing is_client() and is_server() declarations and implementations.
…start(). Improving VERBOSE output of reference, reference_offset, scene, processing and transport message handlers by adding information on caller and displaying whole message sent properly.
…all source related mentions of volume to gain to be consistent with the Publisher/Subscriber interface.
…eption handling in is_new_source(). Erasing source information from _new_sources after the /source/new message has been sent to clients.
…he assembled /source/new message has been sent out to clients. TODO about exception handling in is_new_source().
…rking-with-osc

* 'networking-with-osc' of github.com:dvzrv/ssr:
  src/networking/oscreceiver.cpp: Minor fixes in comments. TODO for exception handling in is_new_source(). Erasing source information from _new_sources after the /source/new message has been sent to clients.
…ll message frequency in milliseconds. Removing commented, now obsolete function bool_to_message_type().
…file_channel. Renaming all channel variables to file_channel for consistency. src/networking/oscsender.cpp: Renaming all channel variables to file_channel for consistency.
…back handlers more readable, adhering to the output of the other handlers. Fixing line wraps.
…lback...' instead of 'Added method...' for each callback add.
…etically for readability. Unifying output style of message types.
…() to alphabetical location. Changing VERBOSE messages in /subscribe and /message_level callbacks to adhere to style standard. Raising VERBOSE messages for /transport/seek and /transport/state messages to VERBOSE3.
…s call to unitialized variable in /message_level callback handler. Adding First prototype of variable string for client/server VERBOSE message.
…t in set_message_level(). src/networking/oscreceiver.cpp: Adding /message_level ssi callback handler. src/networking/oschandler.h: Changing definition of set_message_level friend function to use std::string types for hostname and port instead of a lo::Address. src/networking/oschandler.cpp: Changing OscReceiver::set_message_level() parameters to use std::strings for hostname and port instead of a lo::Address and updating documentation for the function.
… Rewriting add_client() and deactivate_client() to use std::string for hostname and port instead of a lo::Address object.
…type OscClient, to have easier control over MessageLevel of the server for clients, using the same functionality. Refactoring all involved functions. Making all setters for the lo::Address fields use reference type parameters.
…cing all calls to it by calls to _clients. Adding set_server_message_level(), to set the MessageLevel of a clients representation of a server. Minor fixes.
…level() in OscHandler/OscReceiver in alignment with set_client_message_level() in OscSender for better readability.
…scReceiver::client_has_message_level() friend function implementation.
… with MessageLevel GUI_CLIENT. Adding callback for /source/file_name_or_port_number. Adding callback for /source/level. Adding callback for /scene/amplitude_reference_distance, /scene/auto_rotate_sources, /scene/decay_exponent. Adding callback for /update/scene/master_signal_level. src/networking/oscsender.cpp: Updating check for MessageLevel in ssr:OscSender::client_has_message_level() to check if client is active. Adding server-side implementation to ssr::OscSender::set_cpu_load(). Removing server-side implementation from ssr::OscSender::set_sample_rate(). Sending messages only to GUI_CLIENT clients in set_source_signal_level(), set_master_signal_level(). Removing obsolete TODOs. Minor fixes.
…essageLevel. Moving SERVER and GUI_SERVER to the top values.
…te and /update/source/position_fixed more robust. Switching to VERBOSE2 (from VERBOSE3) in callback handlers for all non-rapid messages.
…er property to within statement checking for new_source in OscSender::set_source_mute (preventing accidental sending on server, before source is created). Moving check for file_channel property to within statement checking for new source in OscSender::set_source_properties_file (preventing accidental sending on server, before source is created). Moving check for file_channel > 0 to within statement checking for new source in OscSender::set_source_file_channel to prevent an unfinished source in _new_sources. Setting client check to <= GUI_CLIENT for OscSender::set_transport_state and to == GUI_CLIENT for OscSender::set_source_signal_level. Using std::string reference directly in VERBOSE messages of functions having string parameters and c_str() representation for sending OSC messages to not initialize an unneeded variable every time.
…a source on the logarithmic scale (to be coherent with the IP interface and how /source/gain handles things).
… about hostname:port in ''. Minor linewrap fixes.
…tomatically after 10 seconds. No more messages will be sent to them, as long as they don't subscribe again.
src/networking/*: Making assignment of client/server MessageLevel sane.
… the ServerThread could not be initialized (most likely due to port already being in use).
…garithmic scale for setting source gain. A range form 0.0 - inf is used, where 1.0 signifies 100% source level.
…g-with-osc

* 'networking-with-osc' of github:dvzrv/ssr: (165 commits)
  src/networking/oscreceiver.cpp: Using the linear scale, instead of logarithmic scale for setting source gain. A range form 0.0 - inf is used, where 1.0 signifies 100% source level.
  Revert "Merge remote-tracking branch 'origin/gitignore-entries' into networking-with-osc"
  src/networking/oscreceiver.cpp: Adding check, if id > 0 to all source related callbacks.
  src/networking/oschandler.cpp: Adding exit with EXIT_FAILURE, in case the ServerThread could not be initialized (most likely due to port already being in use).
  src/ssr_global.h: Extending MessageLevel by MAX_VALUE. src/networking/*: Making assignment of client/server MessageLevel sane.
  src/networking/*: Let calls to increment_client_alive_counter in OSCReceiver implicitely copy by value.
  src/networking/*: Adding functionality to discard inactive clients automatically after 10 seconds. No more messages will be sent to them, as long as they don't subscribe again.
  src/networking/oscsender.cpp: Wrapping all VERBOSE output information about hostname:port in ''. Minor linewrap fixes.
  src/networking/oscreceiver.cpp: Switching to setting initial gain of a source on the logarithmic scale (to be coherent with the IP interface and how /source/gain handles things).
  src/networking/oscsender.cpp: Moving check for file_name_or_port_number property to within statement checking for new_source in OscSender::set_source_mute (preventing accidental sending on server, before source is created). Moving check for file_channel property to within statement checking for new source in OscSender::set_source_properties_file (preventing accidental sending on server, before source is created). Moving check for file_channel > 0 to within statement checking for new source in OscSender::set_source_file_channel to prevent an unfinished source in _new_sources. Setting client check to <= GUI_CLIENT for OscSender::set_transport_state and to == GUI_CLIENT for OscSender::set_source_signal_level. Using std::string reference directly in VERBOSE messages of functions having string parameters and c_str() representation for sending OSC messages to not initialize an unneeded variable every time.
  src/networking/oscreceiver.cpp: Making callback for /update/source/mute and /update/source/position_fixed more robust. Switching to VERBOSE2 (from VERBOSE3) in callback handlers for all non-rapid messages.
  src/ssr_global.h: Removing unused field THIN_CLIENT from enum class MessageLevel. Moving SERVER and GUI_SERVER to the top values.
  src/networking/oscreceiver.h: Remove obsolete todo.
  src/networking/oscreceiver.cpp: Adding client callbacks for /cpu_load with MessageLevel GUI_CLIENT. Adding callback for /source/file_name_or_port_number. Adding callback for /source/level. Adding callback for /scene/amplitude_reference_distance, /scene/auto_rotate_sources, /scene/decay_exponent. Adding callback for /update/scene/master_signal_level. src/networking/oscsender.cpp: Updating check for MessageLevel in ssr:OscSender::client_has_message_level() to check if client is active. Adding server-side implementation to ssr::OscSender::set_cpu_load(). Removing server-side implementation from ssr::OscSender::set_sample_rate(). Sending messages only to GUI_CLIENT clients in set_source_signal_level(), set_master_signal_level(). Removing obsolete TODOs. Minor fixes.
  src/networking/oschandler.cpp: Fix missing return statement in ssr::OscReceiver::client_has_message_level() friend function implementation.
  src/publisher.h: Adding set_source_file_name() to public Publisher interface.
  src/networking/oscreceiver.cpp: Removing obsolete TODOs.
  src/networking/*: Adding client_has_message_level() to OscSender (and to OscReceiver by OscHandler friend function) to check for MessageLevel of a client defined by hostname and port. Applying checks to whether caller of a message is the server currently setup (client mode) or if a client exists with a MessageLevel::SERVER (server mode) to be able to shut out unsolicited OSC messages to clients and servers. This way clients only listen to servers subscribed to and servers only to clients with a MessageLevel of SERVER.
  src/networking/*: Implementing from_is() functionality in OscHandler, returning a const std::string, depending on whether the handler is server or client. Implementing from_is() in all VERBOSE messages in client/server callbacks.
  src/networking/oscsender.cpp: Fixing broken string line wrap in VERBOSE.
  ...
… client controlling the server' and 'sclang mimics a server, controls a client'.
…rence orientation through orientation sensor and two sources through multi-touch interface.
… Introducing /alive message on receiving /poll from server. Controlling /reference/orientation with /orientation/X from Sensors2OSC. Deactivating verbose printout on each received message.
…lows

* 'sclang-workflows' of github:dvzrv/ssr:
  supercollider/workflows.scd: Fixing input creation and source volume. Introducing /alive message on receiving /poll from server. Controlling /reference/orientation with /orientation/X from Sensors2OSC. Deactivating verbose printout on each received message.
  supercollider/workflows.scd: Adding Sensors2OSC example, setting reference orientation through orientation sensor and two sources through multi-touch interface.
  supercollider/workflows.scd: Adding workflow example for 'sclang is a client controlling the server' and 'sclang mimics a server, controls a client'.
* configuration-client-server: (24 commits)
  src/configuration.*: Adding function to retrieve a valid network port from a char. If chosen port is < 0, a well-known port, or not in the range of IANA suggested ephemeral ports, the standard port 50001 will be used.
  data/ssr.conf.example: Dropping NETWORK_PORT_{SEND,RECEIVE} in favor of OSC_PORT (which defaults to 50001). Updating NETWORK_CLIENTS example accordingly. Clarifying NETWORK_MODE comment.
  src/configuration.h: Dropping network_port_{send,receive} in favor of osc_port.
  src/configuration.cpp: Dropping network-port-{send,receive} in favor of osc-port. Using only hyphen instead of underscore for option strings.
  data/ssr.conf.example: Fixing the example string used for clients.
  src/configuration.cpp: Using the multimap of client information by reference. Fixing a missing comma in the help output of ssr.
  src/configuration.cpp: parse_network_clients removing printouts of names, adding VERBOSE2 messages about which clients are added. Moving remove_whitespace to ssr namespace. src/configuration.h: Defining remove_whitespace in ssr namespace.
  src/configuration.cpp: Renaming trim to remove_whitespace. Moving curly bracket to next line in parse_network_clients.
  src/configuration.cpp: First version of functionality to parse network clients and ports from flag or configuration file. Adding flags for network-mode, network-port-receive, network-port-send and network-clients.
  src/configuration.h: Turning network_clients field into a multimap to have unique keys.
  src/configuration.h: Adding struct members for networking mode.
  data/ssr.conf.example: Adding networking configuration.
  src/configuration.*: Adding function to retrieve a valid network port from a char. If chosen port is < 0, a well-known port, or not in the range of IANA suggested ephemeral ports, the standard port 50001 will be used.
  data/ssr.conf.example: Dropping NETWORK_PORT_{SEND,RECEIVE} in favor of OSC_PORT (which defaults to 50001). Updating NETWORK_CLIENTS example accordingly. Clarifying NETWORK_MODE comment.
  src/configuration.h: Dropping network_port_{send,receive} in favor of osc_port.
  src/configuration.cpp: Dropping network-port-{send,receive} in favor of osc-port. Using only hyphen instead of underscore for option strings.
  data/ssr.conf.example: Fixing the example string used for clients.
  src/configuration.cpp: Using the multimap of client information by reference. Fixing a missing comma in the help output of ssr.
  src/configuration.cpp: parse_network_clients removing printouts of names, adding VERBOSE2 messages about which clients are added. Moving remove_whitespace to ssr namespace. src/configuration.h: Defining remove_whitespace in ssr namespace.
  src/configuration.cpp: Renaming trim to remove_whitespace. Moving curly bracket to next line in parse_network_clients.
  ...
…dding sourceTestAdding to source movement test. Making sourceTestMoving function use a Routine to move n sources randomly for 100 seconds, each 100ms.
* 'osc-tests' of github:dvzrv/ssr:
  supercollider/tests.scd: Adding separate function to add n sources. Adding sourceTestAdding to source movement test. Making sourceTestMoving function use a Routine to move n sources randomly for 100 seconds, each 100ms.
  supercollider/tests.scd: Adding tests for server and client (subscribed and not subscribed).
* osc-tests:
  supercollider/tests.scd: Adding separate function to add n sources. Adding sourceTestAdding to source movement test. Making sourceTestMoving function use a Routine to move n sources randomly for 100 seconds, each 100ms.
  supercollider/tests.scd: Adding tests for server and client (subscribed and not subscribed).
  supercollider/tests.scd: Adding separate function to add n sources. Adding sourceTestAdding to source movement test. Making sourceTestMoving function use a Routine to move n sources randomly for 100 seconds, each 100ms.
  supercollider/tests.scd: Adding tests for server and client (subscribed and not subscribed).
* sclang-workflows:
  supercollider/workflows.scd: Fixing input creation and source volume. Introducing /alive message on receiving /poll from server. Controlling /reference/orientation with /orientation/X from Sensors2OSC. Deactivating verbose printout on each received message.
  supercollider/workflows.scd: Adding Sensors2OSC example, setting reference orientation through orientation sensor and two sources through multi-touch interface.
  supercollider/workflows.scd: Adding workflow example for 'sclang is a client controlling the server' and 'sclang mimics a server, controls a client'.
  supercollider/workflows.scd: Fixing input creation and source volume. Introducing /alive message on receiving /poll from server. Controlling /reference/orientation with /orientation/X from Sensors2OSC. Deactivating verbose printout on each received message.
  supercollider/workflows.scd: Adding Sensors2OSC example, setting reference orientation through orientation sensor and two sources through multi-touch interface.
  supercollider/workflows.scd: Adding workflow example for 'sclang is a client controlling the server' and 'sclang mimics a server, controls a client'.
@mgeier
Copy link
Member

mgeier commented Dec 17, 2018

Thanks a lot @dvzrv!

As discussed in person, we will first try to make the existing network more modular, and then the OSC interface suggested here can be implemented as one of the modules. The other modules will initially be the legacy XML-based protocol and a new, yet to be implemented WebSockets-based protocol. Later, other protocols might be added (or not).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants