periodicsynth

Crates.ioperiodicsynth
lib.rsperiodicsynth
version0.1.6
sourcesrc
created_at2019-11-09 17:50:27.830596
updated_at2020-05-15 16:54:55.388741
descriptionSimple pereodic function snythesizer for Sine, Square, Triangle, Sawtooth waves with arbitary frequency.
homepage
repository
max_upload_size
id179737
size4,466
Santanu (tripulse)

documentation

README

periodicsynth

A periodic waveform generator which calls arbitrary functions for generating waveforms with an arbitrary samplerate which is translated into time-position between (0..1) and provided to the generator.

Some functions are provided by default (eg. sine, cosine, square, null). To implement a one follow this kind of syntax:

struct YourData;  // v  you can use your own type.
fn gen(t: f64, dat: YourData) -> f64 { 1.0 }

Using a default function packed (sin):

use periodicsynth::{synth, sin};

fn main()
{ let samp = synth(sin, &mut 440f64, 8000); }

Using our own and handcrafted function:

use periodicsynth::synth;

struct YourData;  // you can use any type at here.
fn gen(t: f64, dat: YourData) -> f64 { 1.0 }

fn main()
{ let samp = synth(gen, &mut YourData{}, 8000); }

Motivation

The WebAudio API's OscillatorNode generates periodic waveforms with different functions. Something like that doesn't exist so this is created to do just that or even further to that by allowing end-users to define custom functions to generate waveforms.

Commit count: 0

cargo fmt