audio-time 0.0.1-alpha.2

Encode and convert audio time spans between representations in number of samples, number of bytes and time duration.
Documentation

Encode and convert audio time spans between representations in number of samples, number of bytes and time duration.

# #![feature(const_option)]
# use std::time::Duration;
# use audio_time::*;
#
// the Audio CD standard defines the encoding system as follows:
// 2 channels of LPCM audio, each signed 16-bit values sampled at 44100 Hz
let samples = Samples::<AUDIO_CD>::from_duration(Duration::from_secs(1));
assert_eq!(44_100, samples.get());
let bytes = samples.into_bytes();
assert_eq!(176_400, bytes.get());

// both `Samples` and `Bytes` can be converted back into `Duration`s:
assert_eq!(bytes.into_duration(), Duration::from_secs(1));
assert_eq!((samples * 2).into_duration(), Duration::from_secs(2));

// let's define our own `System`
const SYSTEM: System = system!(8_000, Mono, i16);
let samples = Samples::<SYSTEM>::from_duration(Duration::from_secs(1));
assert_eq!(8_000, samples.get());
let bytes = samples.into_bytes();
assert_eq!(16_000, bytes.get());