# -*- coding: utf-8 -*- """ This file illustrates how to use the python binding of Ossia library. This is a low level approach to integrate Ossia architecture into a python program. For higher level features use pyossia module. """ import pyossia.ossia_python as ossia import time print("OSSIA LIBRARY EXAMPLE") ### LOCAL DEVICE SETUP # create a device for this python program local_device = ossia.LocalDevice("newDevice") print("\nlocal device name: " + local_device.name) # enable OSCQuery communication for our device without messages logging local_device.create_oscquery_server(3456, 5678, False) # enable OSC communication for that device without messages logging local_device.create_osc_server("127.0.0.1", 9997, 9996, False) # list all devices on the network print('\nSCAN FOR OSCQUERY DEVICES\n') for data in ossia.list_oscquery_devices(): print(data.name + ": host = " + data.host + ", port = " + str(data.port)) # create a node, create a boolean parameter and initialize it
# -*- coding: utf-8 -*- """ This file illustrates how to use the python binding of Ossia library. This is a low level approach to integrate Ossia architecture into a python program. For higher level features use pyossia module. """ import pyossia.ossia_python as ossia import time print("OSSIA LIBRARY EXAMPLE") ### LOCAL DEVICE SETUP # create a device for this python program local_device = ossia.LocalDevice("PythonExample") print("\nlocal device name: " + local_device.name) # enable OSCQuery communication for our device without messages logging local_device.create_oscquery_server(3456, 5678, False) # enable OSC communication for that device without messages logging local_device.create_osc_server("127.0.0.1", 9997, 9996, False) # list all devices on the network print('\nSCAN FOR OSCQUERY DEVICES\n') for data in ossia.list_oscquery_devices(): print(data.name + ": host = " + data.host + ", port = " + str(data.port)) # create a node, create a boolean parameter and initialize it
when="midnight", backupCount=3) # Format each log message like this formatter = logging.Formatter('%(asctime)s %(levelname)-8s %(message)s') # Attach the formatter to the handler handler.setFormatter(formatter) # Attach the handler to the logger logger.addHandler(handler) # Replace stdout with logging to file at INFO level #sys.stdout = MyLogger(logger, logging.INFO) # Replace stderr with logging to file at ERROR level #sys.stderr = MyLogger(logger, logging.ERROR) # setup OSCQuery device local_device = ossia.LocalDevice("countdown") print("local device name: " + local_device.name) local_device.create_oscquery_server(1234, 5678, False) # create a node, create a float parameter, set its properties and initialize it node = local_device.add_node("/color") parameter_color = node.create_parameter(ossia.ValueType.Vec3f) parameter_color.access_mode = ossia.AccessMode.Bi parameter_color.bounding_mode = ossia.BoundingMode.Clip parameter_color.make_domain(0, 255) parameter_color.apply_domain() parameter_color.value = [255, 255, 255] node = local_device.add_node("/text") parameter_text = node.create_parameter(ossia.ValueType.String)
#! /usr/bin/env python # -*- coding: utf-8 -*- """ This file illustrates how to use the python binding of Ossia library. This is a low level approach to integrate Ossia architecture into a python program. For higher level features use pyossia module. """ import pyossia.ossia_python as ossia import time print("OSSIA LIBRARY PRESET EXAMPLE") ### LOCAL DEVICE SETUP # create a device for this python program local_device = ossia.LocalDevice("PythonPreset") print("\nlocal device name: " + local_device.name) # create a node, create a boolean parameter and initialize it bool_node = local_device.add_node("/test/numeric/bool") bool_parameter = bool_node.create_parameter(ossia.ValueType.Bool) bool_parameter.access_mode = ossia.AccessMode.Get bool_parameter.value = True bool_parameter.default_value = True bool_node.description = "it could be used to enable/disable an effect" bool_node.tags = ["example", "numeric"] bool_node.priority = 1 bool_node.refresh_rate = 100
import pyossia.ossia_python as ossia import os, sys, time ### LOCAL DEVICE SETUP local_device = ossia.LocalDevice("PythonConsole") local_device.create_oscquery_server(3456, 5678, False) # PARAMETER : display text in python console text_parameter = local_device.add_node("/text").create_parameter( ossia.ValueType.String) text_parameter.access_mode = ossia.AccessMode.Set def text_callback(v): print(v) text_parameter.add_callback(text_callback) # PARAMETER : display a prompt text in python console and wait for input prompt_parameter = local_device.add_node("/prompt").create_parameter( ossia.ValueType.String) prompt_parameter.access_mode = ossia.AccessMode.Set # PARAMETER : input comming from a prompt prompt_input_parameter = local_device.add_node( "/prompt/input").create_parameter(ossia.ValueType.String) prompt_input_parameter.access_mode = ossia.AccessMode.Get def prompt_callback(v):