Skip to main content

DAWNet client enables remote execution of python code triggered from a DAW.

Project description

dawnet_client

The DAWNet client is a python3 pip package. It is used to create DAWNet remotes. Remotes are scripts created with the python client. The client allows a user to register remote functions with the DAWNet discovery server. After a function has been registered it can then be triggered remotely from `DAWNet plugin.

::: warning NOTE: The plugin is in an active, pre-alpha state. It has only been tested on Ableton 11 on MAC M1. :::

Installation

pip install dawnet_client

Usage

This is a simple example of a DAWNet remote script created using the dawnet_client. The script defines an arbitrary function that takes two arguments, an integer and a DAWNetFilePath. The function is registered with the DAWNet discovery server. The script then connects to the DAWNet discovery server and waits for a remote trigger.

from dawnet_client import DAWNetFilePath, dawnet_client

# The token is generated by the DAWNet plugin.  
# It is used by the discovery server to associate the remote with the plugin.
TOKEN="0715c132-0b31-406e-b562-9206c479a48a" 

# The registered method can be named anything. Note that the method must be `async`.  
# All parameters must be type hinted.  
# 4 parameter types are supported: int, float, str, DAWNetFilePath
# DAWNetFilePath is a special type. When the file is sent to the remote, it is intercepted by the system and 
# transported to a temp dir on the remote.  In this case the variable `b` is local path to the file.
async def arbitrary_method(a: int, b: DAWNetFilePath):
    try: 
        # -----------------------------------------
        # This is where you can write custom code to operate on the input params.
        # ex param `a` could be the number of variations created from param `b` using something like MusicLM
        # -----------------------------------------
        
        # This is how you send results back to the plugin, when processing is complete.
        await dawnet_client.results().add_file(b, "wav") 
        # This message is displayed in the plugin.
        await dawnet_client.results().add_message("This is a message XYZ")
        # The send method begins the transfer of results data back to the plugin.
        await dawnet_client.results().send()

        return True
    except Exception as e:
        print(f"Error in arbitrary_method: {e}")
        return f"Method encountered an error: {e}"


# The token generated by the plugin. 
dawnet_client.set_token(token=TOKEN)
# The name of the remote.  This is displayed in the plugin.
dawnet_client.set_name("My Remote Code")
# The description of the remote.  This is displayed in the plugin.
dawnet_client.set_description("This is not a real description.")
# Register the method with the discovery server.
dawnet_client.register_method("arbitrary_method", arbitrary_method) 
 
# This should be the last line of the script.  It connects to the discovery server and waits for a remote trigger.
dawnet_client.connect_to_server()

CONFIGURATION:

export DAWNET_API_BASE_URL='http://localhost:8000'
export DAWNET_SOCKET_IP='0.0.0.0'
export DAWNET_SOCKET_PORT='8765'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dawnet_client-0.0.11.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dawnet_client-0.0.11-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file dawnet_client-0.0.11.tar.gz.

File metadata

  • Download URL: dawnet_client-0.0.11.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for dawnet_client-0.0.11.tar.gz
Algorithm Hash digest
SHA256 f121064c5cd716603843fd9ffedc301cdc735487e07846a25c09ff43cfc8b3e1
MD5 c1ba707b006b94aadfef3336dd27cd74
BLAKE2b-256 376f8bc2dca8619eeb8e83c402ef871725a7c6506d2b0ad31aa2307d268545e0

See more details on using hashes here.

File details

Details for the file dawnet_client-0.0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for dawnet_client-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 076d819b84276336ae26a594a5d2831fe0af968fae177801389fb6c41a100d3d
MD5 a6b02cb7d6bdf793f8f1b03864274254
BLAKE2b-256 a1caabbf6a40ed1891323f02ae6c94c6a0d41a002c49b27aa6147fb8881e3599

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page