Git Product home page Git Product logo

meyda-rs's Introduction

meyda-rs

Build Status Code coverage

It's like meyda, but for Rust.

This project is heavily WIP and it's not wise to use it in production yet.

The plan is to initially provide a set of pure functions which operate on 64-bit float vectors, each vector being a frame of audio.

Later on, meyda-rs should support file loading, configuration, overlapping frames, etc. to approach the API of Meyda.

Usage

This example creates a 1024-sample frame of white noise, and calculates its features.

extern crate meyda;
extern crate rand;

use rand::Rng;

fn main() {
  const BUFFER_SIZE: usize = 1024;
  const SAMPLE_RATE: f64 = 44100.0;

  // create a vector of white noise
  let mut generator = rand::thread_rng();
  let signal: Vec<f64> = vec![0; BUFFER_SIZE]
    .iter()
    .map(|&_sample| generator.gen_range(-1_f64..1_f64))
    .collect();

  // compute features
  let rms = meyda::get_rms(&signal);
  let energy = meyda::get_energy(&signal);
  let zcr = meyda::get_zcr(&signal);
  // let power_spectrum = meyda::get_power_spectrum(&signal);
  let spectral_centroid = meyda::get_spectral_centroid(&signal);
  let spectral_flatness = meyda::get_spectral_flatness(&signal);
  let spectral_kurtosis = meyda::get_spectral_kurtosis(&signal);
  let spectral_rolloff = meyda::get_spectral_rolloff(&signal, SAMPLE_RATE, Some(0.95));
  let bark_loudness = meyda::get_bark_loudness(&signal, SAMPLE_RATE);

  println!("RMS is {} \n energy is {:?}, zcr is {:?},\n spectral centroid is {},\n spectral flatness is {},\n spectral kurtosis is {},\n spectral rolloff is {},\n Bark loudness is {:?}", rms, energy, zcr, spectral_centroid, spectral_flatness, spectral_kurtosis,
   spectral_rolloff, bark_loudness);
}

Development

Contributions are always welcome. The library should be test-driven and all new features should have accompanying tests.

Tests can be run with cargo test โ€“ each extractor function should have a test module in the same file, and should make use of meyda/gauge, which is submodule'd in /src/utils. The deserialized gauge data is provided by utils::test as a vector of TestDataSet structures.

meyda-rs's People

Contributors

jakubfiala avatar hughrawlinson avatar dependabot[bot] avatar cmaher avatar

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.