#api-bindings #colorchord

rustchord

Colorchord bindings for Rust

8 releases (4 breaking)

0.5.0 Jan 24, 2022
0.4.1-alpha.0 Jan 24, 2022
0.4.0 Jun 26, 2021
0.3.1 Feb 8, 2021
0.1.0 Dec 25, 2020

#517 in Audio

Custom license

15MB
66K SLoC

C 57K SLoC // 0.4% comments Objective-C 2.5K SLoC // 0.1% comments JavaScript 2K SLoC // 0.0% comments GNU Style Assembly 776 SLoC // 0.2% comments Shell 623 SLoC // 0.1% comments C++ 610 SLoC // 0.1% comments Prolog 578 SLoC Bitbake 536 SLoC // 0.3% comments Rust 352 SLoC // 0.0% comments Batch 292 SLoC Python 269 SLoC // 0.3% comments Forge Config 65 SLoC // 0.4% comments

Contains (static library, 5MB) libc.a, (static library, 605KB) libgcc.a, (static library, 690KB) libmbedtls.a, (ar library, 350KB) WS2_32.Lib, (ar library, 350KB) WS2_32.Lib, (static library, 430KB) libat.a and 24 more.

Rustchord (Colorchord2 bindings for Rust)

These are simple bindings around the Notefinder construct in Colorchord. Colorchord is an amazing piece of software written by CNLohr. I've been wanting to use the algorithm in different projects and decided to write a easy Rust bindings that allows you to run the algorithm against audio acquired in Rust.

Using the binding

The Notefinder expects to read samples from a ringbuffer in order to generate the bucketed notes. For this reason you need to provide a simple ringbuffer with audio samples in f32 format. The audioinput showcases how to do this.

First create a new instance of the Notefinder with the samplerate that's expected:

let mut notefinder = rustchord::Notefinder::new(48000)

Then provide samples in a buffer as you process them:

notefinder.run(&samplevec)

After Notefinder has ran you can get the folded notes by doing:

notefinder.get_notes()

Configuring Notefinder

You can configure parameters of the Notefinder using the set_ methods. For example, to change the input amplification you can use:

notefinder.set_amplification(10.0)

Building from Git

git clone https://github.com/coral/rustchord.git
cd rustchord
git submodule update --init --recursive
cargo build

To run the audio input example, just do

cargo run --example audioinput

License

ColorChord is Copyright 2015 Charles Lohr, Under the MIT/x11 License.

All other code is licensed under the MIT license.

Dependencies

~2.7–5MB
~108K SLoC