Crates.io | periodicsynth |
lib.rs | periodicsynth |
version | 0.1.6 |
source | src |
created_at | 2019-11-09 17:50:27.830596 |
updated_at | 2020-05-15 16:54:55.388741 |
description | Simple pereodic function snythesizer for Sine, Square, Triangle, Sawtooth waves with arbitary frequency. |
homepage | |
repository | |
max_upload_size | |
id | 179737 |
size | 4,466 |
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); }
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.