https://github.com/rustaudio/time_calc
A library for music/DSP time conversions! Provides functions and methods for converting between ticks, ms, samples, bars, beats and measures.
https://github.com/rustaudio/time_calc
Last synced: 5 months ago
JSON representation
A library for music/DSP time conversions! Provides functions and methods for converting between ticks, ms, samples, bars, beats and measures.
- Host: GitHub
- URL: https://github.com/rustaudio/time_calc
- Owner: RustAudio
- License: other
- Created: 2014-12-05T17:30:21.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2025-02-03T14:58:04.000Z (12 months ago)
- Last Synced: 2025-08-13T21:51:53.210Z (5 months ago)
- Language: Rust
- Homepage:
- Size: 56.6 KB
- Stars: 53
- Watchers: 16
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# time_calc [](https://travis-ci.org/RustAudio/time_calc)
A library for music/DSP time conversions!
`time_calc` provides functions and methods for converting between ticks, ms, samples, bars, beats and measures.
It looks like this:
```Rust
const SAMPLE_HZ: SampleHz = 44_100.0;
let bpm: Bpm = 120.0;
let time_sig = TimeSig { top: 4, bottom: 4 };
println!("Convert 4 bars to samples where the tempo is 120bpm, the time signature is 4/4
and the sample rate is 44,100 samples per second: {}",
Bars(4).samples(bpm, time_sig, SAMPLE_HZ))
```
Usage
-----
Add time_calc to your cargo dependencies like this:
```
[dependencies]
time_calc = "*"
```
See [the example](https://github.com/RustAudio/time_calc/blob/master/examples/test.rs) for a better demo.