Git Product home page Git Product logo

ex_osc's Introduction

ExOSC

Hex.pm Version

ExOSC is a library for sending and receiving messages to/from audio hardware that supports the OpenSoundControl 1.0 protocol.

The exact capabilities of this library will depend on what hardware it's talking to. For example, when talking to an audio mixer, you'll likely be able to control the volume levels of the various faders, what audio gets routed to what outputs, etc.

x32_remote is an example of a library that uses ExOSC to talk to Behringer X32/M32 digital mixing consoles.

What is OSC?

OSC is a stateless protocol that typically operates over UDP. Messages have an address pattern string (or path, for short) that typically points to a resource or a command, and an arguments list comprised of zero or more supported OSC datatypes.

The OSC protocol is the same in both directions, i.e. simply passing messages back and forth. While there is no explicit request-reply mechanism — nor any built-in acknowledgement of requests — a typical pattern is for the local agent to issue a request with a given path, and the remote agent to respond using a message with an identical path.

A partial list of devices that support OSC can be found on the OSC Wikipedia page.

Installation

ExOSC requires Elixir v1.14. To use it, add :ex_osc to your list of dependencies in mix.exs:

def deps do
  [
    {:ex_osc, "~> 0.1.1"}
  ]
end

Usage

Here's an example of using ExOSC to request some basic info from a Behringer X32 digital rackmount mixer:

defmodule MyConsumer do
  use GenStage

  def init(:ok) do
    {:consumer, nil}
  end

  def handle_events(events, {_, _}, state) do
    events |> Enum.each(&IO.inspect/1)
    {:noreply, [], state}
  end
end

{:ok, client} = ExOSC.Client.start_link(ip: {192, 168, 1, 123}, port: 10023)
{:ok, consumer} = GenStage.start_link(MyConsumer, :ok, [])
{:ok, _} = GenStage.sync_subscribe(consumer, to: client)

ExOSC.Client.send_message(client, %OSC.Message{path: "/info"})
ExOSC.Client.send_message(client, %OSC.Message{path: "/ch/01/mix/fader"})
ExOSC.Client.send_message(client, %OSC.Message{path: "/ch/01/mix/pan"})
Process.sleep(100) # give it some time to reply

Output:

%OSC.Message{path: "/info", args: ["V2.07", "osc-server", "X32RACK", "4.06-8"]}
%OSC.Message{path: "/ch/01/mix/fader", args: [1.0]}
%OSC.Message{path: "/ch/01/mix/pan", args: [0.5]}

Of course, for this particular hardware, you should probably use x32_remote instead.

Documentation

Full documentation can be found at https://hexdocs.pm/ex_osc.

Legal stuff

Copyright © 2023, Adrian Irving-Beer.

ExOSC is released under the MIT license and is provided with no warranty. Be careful with what commands you issue to your (usually expensive) audio hardware.

ex_osc's People

Contributors

wisq avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

kentaro

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.