#frame #decoding #audio-samples #time #queue #linear #decoder

ltc

A crate for decoding Linear/Longitudinal Timecode data from audio samples, potentially in real time

2 unstable releases

0.2.0 Apr 16, 2020
0.1.1 Apr 16, 2020
0.1.0 Apr 16, 2020

#2288 in Parser implementations

22 downloads per month

BSD-3-Clause

23KB
235 lines

ltc

This library allows for decoding linear time code audio into individual timecode frames. Encoding support is not currently offered.

Decoding centers around the LTCDecoder struct, representing the state of a single decoding process that produces a series of LTCFrame into an internal queue. Frames can be extracted from this queue using LTCDecoder's IntoIterator implementation.

Examples

use ltc::LTCDecoder;

// First argument specifies "samples per frame" which should
// be the approximate number of audio samples that a single
// frame takes up. Automatically adjusted to the rate of the
// data internally with an exponential smoothing function.
let decoder = LTCDecoder::with_capacity(48000.0 / 30.0, 10);

let buffer: &[f32] = ...;

if decoder.write_samples(buffer) {
    println!("Decoded LTC frames!")

    for frame in &mut decoder {
        println!("Got frame with time {}", frame.format_time())
    }
}

License

Copyright (c) 2020, Danny Wensley
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the the copyright holder nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Danny Wensley BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

No runtime deps