Skip to main content

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

Project description

DAWNet

DAWNet is a DAW (digit audio workstation) plugin that connects to a remote Google Colab or Script. A user can send audio files from the plugin for remote processing. Hence, perform computationally expensive tasks such as text-2-audio or stem separation without leaving the DAW.

For more information visit: https://dawnet.tools/

dawnet-client

The DAWNet client (this repo) is a python3 pip package. It is used to create DAWNet remotes. The client is responsible for moving data and files backand forth from the plugin (and server). The client allows a user to register python 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 --upgrade

Tests

from the root of the source code dir run:

pip uninstall dawnet-client -y && pip install -e . && pytest -s

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.

For thorough documentation and tutorials visit: https://dawnet.tools/client/

import dawnet_client.core as dawnet 
from dawnet_client import DAWNetFilePath, ui_param

# 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: 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.

# The `ui_param` is an optional decorator. It is used to define how the parameter input UI will be rendered in the plugin.  
# If the decorator is not used, the parameter will be rendered as a text input field. 
@ui_param('a', 'DAWNetNumberSlider', min=0, max=10, step=1, default=5)
@ui_param('c', 'DAWNetMultiChoice', options=['cherries', 'oranges', 'grapes'], default='grapes')
async def arbitrary_method(a: int, b: DAWNetFilePath, c: str):
    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.results().add_file(b) 
        # This message is displayed in the plugin.
        await dawnet.results().add_message("This is a message XYZ") 

        return True
    except Exception as e: 
        #explicitly send an error message back to the plugin
        await dawnet.results().add_error(f"Method encountered an error: {e}")
        return False


# The token generated by the plugin. 
dawnet.set_token(token=TOKEN)
# The name of the remote.  This is displayed in the plugin.
dawnet.set_name("My Remote Code")
# The description of the remote.  This is displayed in the plugin.
dawnet.set_description("This is not a real description.")
# Register the method with the discovery server.
dawnet.register_method(arbitrary_method)

# When a file is sent to the remote as a DAWNetFilePath, it will become available at this sample rate. 
dawnet.set_input_target_sample_rate(44100) #supported values [22050, 32000, 44100, 48000]
# When a file is sent to the remote as a DAWNetFilePath, it will become available at this bit rate. 
dawnet.set_input_target_bit_depth(16) #supported values [16, 24, 32]
# When a file is sent to the remote as a DAWNetFilePath, it will become available with this number of channels.
dawnet.set_input_target_channels(2) #supported values [1, 2] mono/stereo respectively
# When a file is sent to the remote as a DAWNetFilePath, it will become available in this format.
dawnet.set_input_target_format('wav') #supported values ["wav", "mp3", "aif", "flac"]

# When results are sent back to the plugin, they will be sent at this sample rate.
dawnet.set_output_target_sample_rate(44100)
# When results are sent back to the plugin, they will be sent at this bit rate.
dawnet.set_output_target_bit_depth(16)
# When results are sent back to the plugin, they will be sent with this number of channels.
dawnet.set_output_target_channels(2)
# When results are sent back to the plugin, they will be sent in this format.
dawnet.set_output_target_format('wav')

# This should be the last line of the script.  It connects to the discovery server and waits for a remote trigger.
dawnet.connect_to_server()

CONFIGURATION:

Note: If the following environment variables are not set, the client will use the default values. The default values will point to the public DAWNet server. If you wish to host your own instance you will need to configure the following environment variables.

export DN_CLIENT_API_BASE_URL='http://localhost:8081'
export DN_CLIENT_SOCKET_IP='0.0.0.0'
export DN_CLIENT_SOCKET_PORT='8765'
export DN_CLIENT_SENTRY_API_KEY='XXX'
"DN_CLIENT_STORAGE_BUCKET", "https://storage.googleapis.com/your_gcp_bucket/"

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.6.1.tar.gz (32.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.6.1-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

File details

Details for the file dawnet-client-0.6.1.tar.gz.

File metadata

  • Download URL: dawnet-client-0.6.1.tar.gz
  • Upload date:
  • Size: 32.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.2

File hashes

Hashes for dawnet-client-0.6.1.tar.gz
Algorithm Hash digest
SHA256 4dc14c37c3218238c46fe7587e008d9dcd8b6a58ff0c8e28777a0281b98c39d4
MD5 86c022ad374cef80db453af209cca99a
BLAKE2b-256 eea7d93018a323f4102dd1b8c85db5f5e85dcc5d11ab37f0b3a377813400f828

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dawnet_client-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 35.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.2

File hashes

Hashes for dawnet_client-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 13fc0a087e5a5defc0eb534fc58e2f3da6b431bf780cf6fbb1a30d3319f7bbac
MD5 ef3aaa7776e9d89e5853c83123f0c69a
BLAKE2b-256 84cc943953f259c78a9804869c31bf7e97c2dfea1d4f1d27e10b9a639e1f7f92

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