csounddart 0.0.12 copy "csounddart: ^0.0.12" to clipboard
csounddart: ^0.0.12 copied to clipboard

Dart unified interface to Csound API for Web, Desktop and Mobile. It allows to use Csound audio synthesis engine, with a simple and unified API.

csounddart #

An Dart interface to Csound API. The intention of this project is to provide an unified API for creating applications with Flutter and Csound - whatever the target is (Linux, MacOS, Windows, Web, Android, iOS... and probably Fushia in the future). It is currently under development. It has been tested on Linux, MacOS, Windows and Android. The web version is not working currently.

On desktop platforms, it assumes Csound is already installed on your computer. On Android it will download and install Csound library in the application bundle.

Getting Started #

import 'package:csounddart/csound.dart';

//Create the Csound object in a new Isolate (sort of Dart thread).
//Due to current implementation, all transaction with
// Csound is done asynchronously by sending a message to the isolate.
Csound _cs = Csound();

// Compiles Csound CSD text and gets the return value
int res = await _cs.compileCsdText(_myCsdText);

// Reads a piece of score
int res = await _cs.readScore(_myScore);

// Compiles from path
int res = await _cs.compileCsd(_myCsd);

// Compiles Orchestra
int res = await _cs.compileOrc(_orchestra);

// threaded performance
_cs.perform();

// pauses or restart performance
_cs.pause(bool);

// set a channel value
_cs.setControlChannel("channelName", (double)value);

// set a callback. The passed method will be called at every k-pass.
_cs.setControlChannelCallback("channelName",
    (double v) {
        // do something with callback
    }
);

// Audio callback
_cs.setAudioChannelCallback("audioChannelName",
    (ConcurrentBuffer buf) {
        for(int i = 0; i < buf.length; i++) {
            double value = buf.get(i);
        }
    }
);

// retrieves a control channel value
double channel = _cs.getControlChannel("channemName");

// Gets values from Csound
int ksmps = await _cs.getKsmps();
int nchnls = await _cs.getNchnls();
int sr = await _cs.getSr();
int dbfs = await _cs.get0dbfs();

// Stops Csound, clears all callback memory, and destroys Csound internal instance, killing the working
// Isolate. Then, starts a new isolate and creates a new instance.
_cs.stop();

Platforms #

Desktop #

The desktop implementation assumes Csound is already installed on your system. It uses a path resolution based on the usual Csound library location.

Linux

  • All done

Windows

  • Working fine.

MacOS

  • Working too. Very slow at startup (to investigate).

Web #

  • The project is working in a Flutter application, if the user adds CsoundObj.js and CsoundDart.js as scripts in the index.html file. Though, dynamic loading those files from the plugin still doesn't work.
  • It probably works if copying CsoundObj.js and CsoundDart.js in web folder of the application, and including them as <script> in html.

Mobile #

Mobile implementation will install the Csound binaries and bundle it with the application.

Android

  • Working fine with Oboe. Currently no input possible (outputs only).

iOS

  • Not even tried yet.

TODO : #

  • Unify ConcurrentBuffer so that it can be easy to use from user side

DONE : #

  • Modify the native and mobile API so that the main isolates creates the Csound State, and immediatly give it to the Isolate (it is already the case on Android).
  • Since Main Isolate will have access to the Csound pointer, create a Sync version for each getter method (getKsmpsSync, evalCodeSync ...).
  • Stop method must only stop performance. Reset must reset. It is destroy method that should kill isolate.
9
likes
90
pub points
17%
popularity

Publisher

unverified uploader

Dart unified interface to Csound API for Web, Desktop and Mobile. It allows to use Csound audio synthesis engine, with a simple and unified API.

Repository

Documentation

API reference

License

unknown (LICENSE)

Dependencies

ffi, flutter, flutter_web_plugins, js, path

More

Packages that depend on csounddart