Crates.io | twang |
lib.rs | twang |
version | 0.9.0 |
source | src |
created_at | 2018-08-13 05:15:49.331901 |
updated_at | 2022-10-23 18:20:56.224093 |
description | Library for pure Rust advanced audio synthesis. |
homepage | https://aldaronlau.github.io/twang |
repository | https://github.com/AldaronLau/twang |
max_upload_size | |
id | 79196 |
size | 57,019 |
Library for pure Rust advanced audio synthesis.
Links to examples for each will be provided as they are implemented.
Oscillators:
"Voltage" Controlled filter:
Envelope (example: ADSR):
"Voltage" Controlled amplifier (multiplication)
Reverb without reflections.
Reverb is just echo that takes place in less than 50 milliseconds, so you can use the same APIs.
When generating waveforms you may want to normalize by the volume of the wave, which the amplitude doesn't always accurately approximate. First, calculate the RMS (Root Mean Square).
let sum = 0
for sample in samples {
sum += sample * sample
}
sum /= samples.len()
let rms = sum.sqrt()
Now the peak value:
let mut peak_amplitude = 0
for sample in samples {
peak_amplitude = peak_amplitude.max(sample.abs())
}
Next the crest factor:
let crest_factor = peak_amplitude / rms
Then decibels:
let papr = 20 * log10(crest_factor)
Crest Factor Post-processed Recording 4–8 / 12–18 dB headroom Crest Factor Unprocessed Recording 8–10 / 18–20 dB headroom
And actual perceived volume should be calculated with ITU-R BS.1770-4
Examples can be found in the Documentation and the examples folder.
The minimum supported Rust version of twang is 1.60.0. MSRV may only be updated when increasing the leftmost version number of twang.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Anyone is more than welcome to contribute! Don't be shy about getting involved, whether with a question, idea, bug report, bug fix, feature request, feature implementation, or other enhancement. Other projects have strict contributing guidelines, but this project accepts any and all formats for pull requests and issues. For ongoing code contributions, if you wish to ensure your code is used, open a draft PR so that I know not to write the same code. If a feature needs to be bumped in importance, I may merge an unfinished draft PR into it's own branch and finish it (after a week's deadline for the person who openned it). Contributors will always be notified in this situation, and given a choice to merge early.