Coder Social home page Coder Social logo

lichen-community-systems / flocking-core Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 45 KB

An abandoned experiment to develop a successor to Flocking using Rust. This effort has been superseded by Signaletic (https://github.com/continuing-creativity/signaletic).

License: MIT License

Rust 100.00%

flocking-core's People

Contributors

colinbdclark avatar gtirloni avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

colinbdclark

flocking-core's Issues

Implement an automated release process

We now having a working CI system using Github Actions. The next step is to create a process that will build release artifacts, package them up, and post them to the Github release page whenever code is pushed to a tag.

Convert this repository into in a workspace for all libflock-related crates

Ultimately, I think it will be easiest to co-locate all libflock-related libraries in the same repository, configured as a monorepo (or workspace in Cargo terms, I think) for, at least:

  • libflock itself
    • the fully platform-agnostic signal generation library
  • the platform-specific Hosts (responsible for handling input and output devices, opening/saving/decoding/encoding files, etc.)
    • CPAL
    • Bela
    • wasm Web Audio API

Establish the infrastructure needed to build an Environment implementation for Daisy

The Daisy boards are increasingly used for hardware musical instruments and Eurorack modules. While there are third-party Rust bindings available, it looks like they are still in the relatively early stage of development. My impression is that the best approach is to develop an Environment implementation in C++ using libDaisy, and to use Flocking via bindgen-created C bindings.

In order to determine if this is viable and sustainable, we should create a simple Environment implementation based on one of Daisy's examples, and implement a stub function in Flocking in order to establish the appropriate build supports for calling Rust code from C++. We'll also want to choose a platform on which to manage the cross-compilation process in CI (I'm tempted to use macOS for symmetry with my own current development environment, but Linux would be fine too).

Remove support for ASIO from flocking-cpal, because it's more trouble than it's worth at this point

At this point, we've encountered a number of issues with ASIO support in CPAL:

  1. It causes panics at runtime when enumerating WASAPI devices and then ASIO devices
  2. It makes local builds more difficult, because the ASIO SDK and LLVM have to be installed
  3. It's not clear how to conditionally include its required dependencies only on Windows, which otherwise causing builds to fail on Apple Silicon

Given this, it simply doesn't seem worth supporting ASIO until the whole system is more mature and (hopefully) our third-party dependencies have sorted out some of their bugs.

Restructure the repository as a monorepo with multiple Cargo builds/workspaces

This new version of Flocking will have to be carefully partitioned into the portions of the system that are designed to run without a memory allocator or standard library (particularly, the unit generators and graph evaluator) and the portions that provide dynamic runtime supports (e.g. parsing and interpreting Composition JSON files, instantiating unit generators and wiring them dynamically, etc.).

Given that Cargo doesn't seem to provide good support for mixing no-std modules with those that require the standard library, we should divide up the repository into multiple directories that can contain fully separate Cargo workspaces/builds as needed.

This issue relates to #21.

Add support for ASIO on Windows

CPAL supports ASIO as a host on Windows, but it requires installing the ASIO SDK and LLVM, and specifying a compile feature. We should add support for this.

Migrate from Rust to C

For various reasons, I've come to the conclusion that Rust isn't the right fit for this project. Most prominently, the difficulty of writing graph-based systems in Rust, particularly without a full std environment, as well as the complexity of managing integration with Daisy's GCC-compiled C++ code, represent significant barriers.

Since Flocking's unit generators are written in a very C-like dialect of JavaScript, and with C's stability and ubiquity, plain old seems like the best option for a radically interoperable system like libflock.

Provide a means for users to specify audio and Environment-specific settings

A user should be able to specify generic audio settings such as sample rate, number of channels, buffer size and block size. They should also be able to specify Environment-specific settings such as the host to use (if appropriate) and which input and output devices to use.

In most cases, these will need to be treated as hints to Flocking, since not all Environments will support these being customizable (especially the web, which can't support user-specified input/output devices or sample rates, and which may provide constraints on the size of buffers).

Don't panic when devices aren't available

Currently, we panic (using the expect() method) when a Host does not have any devices, or if it doesn't have default input or output devices registered. This will be rare in practice, but at very least Github's Windows-based Actions Runners have no audio devices setup. We should gracefully note the lack of devices and exit successfully.

Builds fail on my Apple Silicon MacBook

This may be an issue with Big Sur or with running on M1 hardware, I'm not sure. However, when I try to build flocking-cpal, I get the following error

The following warnings were emitted during compilation:

warning: couldn't execute `llvm-config --prefix` (error: No such file or directory (os error 2))
warning: set the LLVM_CONFIG_PATH environment variable to the full path to a valid `llvm-config` executable (including the executable itself)

error: failed to run custom build command for `coreaudio-sys v0.2.6`

Caused by:
  process didn't exit successfully: `~/code/flocking-core/target/debug/build/coreaudio-sys-ba8cad63afa3ce94/build-script-build` (exit code: 101)
  --- stdout
  cargo:rerun-if-env-changed=COREAUDIO_SDK_PATH
  cargo:rustc-link-lib=framework=AudioToolbox
  cargo:rustc-link-lib=framework=AudioToolbox
  cargo:rustc-link-lib=framework=CoreAudio
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS
  cargo:warning=couldn't execute `llvm-config --prefix` (error: No such file or directory (os error 2))
  cargo:warning=set the LLVM_CONFIG_PATH environment variable to the full path to a valid `llvm-config` executable (including the executable itself)

  --- stderr
  thread 'main' panicked at 'libclang error; possible causes include:
  - Invalid flag syntax
  - Unrecognized flags
  - Invalid flag arguments
  - File I/O errors
  - Host vs. target architecture mismatch
  If you encounter an error missing from this list, please file an issue or a PR!', /Users/colin/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.3/src/ir/context.rs:573:15
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This seems to have to with the ASIO feature being turned on by default, and the Windows-specific specification of an older version of clang in flocking-cpal's Cargo.toml. Why this is the case only on M1, I'm not sure.

Come up with a strategy for integration testing libflock-cpal

At least on some platforms, it should be possible to set up a virtual audio device so that we can write tests that verify that audio is correctly being written to a device—and hopefully even read.

On macOS, Blackhole should do the trick and seems to be installable with homebrew so hopefully will work within a Github Actions runner. On Linux, ALSA seems to have the ability to create virtual devices. On Windows, ASIO is our ideal host, but I'm not sure what's available there for virtual devices (and which can be installed with Chocolatey).

It seems like ffmpeg should be available on all these platforms and could be used to record the output from the virtual device or play back audio files into it.

Convert libflock-cpal from a binary to a library crate

At the moment, libflock-cpal is a configured as a binary crate, but it's ultimately intended to be used as a library by others who are building applications. To this end, we should convert the project to a library, and move the implementation that is currently in main() into a public function and create an example for it. Cargo seems to have nice support for building examples that are separate from a library but contained in the same repository.

Add continuous integration support using Github Actions

My goal with the libflock-related repositories is to have a fully automated build, testing, and release process. Whenever someone creates a PR or pushes to a branch, the build and test process should be run. Whenever a tag is pushed, the release artifacts for each platform should be created and published.

Separate the cross-platfrom flocking crate from the workspace

Currently this project is set up as a Cargo workspace. This means that all common dependencies are shared. However, the cross-platform essential "core" of flocking-core (in the flocking directory) is intended to support usage in a no-std environment. However, since (as I understand it) features in Cargo are additive, this means that the whole workspace has to either support no-std or not, as there are cases otherwise where a transitive dependency (in our case, CPAL) may require a common dependency (Serde) with std=true which will override its inclusion in flocking with std=false. Presumably in a release build, this would work fine, but I've already experienced problems with Serde between the two environments. The best solution I can think of is just to take the flocking crate out of the workspace and manage it separately with it's own self-contained Cargo workflow.

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.