npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

libltc-wrapper

v1.1.2

Published

libltc wrapper for nodejs

Downloads

359

Readme

libltc wrapper

Build

This module gives you access to the libltc library from node.js.

Bits per sample

Internally libltc uses 8 bit unsigned audio data, but the decoder supports reading uint16, sint16 and float too. The encoder however only supports uint8.

Installation

The following architectures are supported:

  • linux-x64
  • linux-armhf
  • linux-arm64
  • macos-x64
  • macos-arm64 (M1)
  • windows-x64

Add the module to your project:

npm i libltc-wrapper
# or
yarn add libltc-wrapper

State

  • Successfully encodes and decodes LTC audio
  • Tested successfully on Macbook Pro M1 (arm64) and Ubuntu 20.04 (x64)

Examples

Decoding

    const { LTCDecoder } = require('libltc-wrapper');
    const decoder = new LTCDecoder(48000, 25, "u8"); // 48khz, 25 fps, unsigned 8 bit

    // Write audio buffer to the decoder
    decoder.write(audioframes);

    // Check if there is any ltc frames ready
    let frame = decoder.read();

    if (frame !== undefined) {
        // found a valid frame
        console.log("Frame: ", frame);
    }

Encoding

    const { LTCEncoder, LTC_USE_DATE } = require('libltc-wrapper');

    const encoder = new LTCEncoder(48000, 25, LTC_USE_DATE); // 48khz, 25 fps, LTC_USE_DATE flag
    
    let time = new Date();

    encoder.setTimecode({
      hours: time.getHours(),
      minutes: time.getMinutes(),
      seconds: time.getSeconds(),
      frame: time.getMilliseconds() / (1000 / 25),
      days: time.getDate(),
      months: time.getMonth() + 1,
      years: time.getFullYear() % 100,
      timezone: "+0000"
    })

    // Every frame (25 times per second) increase the current frame
    encoder.incrementTimecode();

    // Get 1 frame worth of LTC audio (48khz 25fps would be 40ms audio)
    let buffer = encoder.getBuffer();

Class methods

LTCDecoder instance methods

constructor(sampleRate: number, framerate: number, audioFormat: string)

Samplerate in hz, for example 48000. Framerate should be less than or equal to 30 fps. Audioformat must be one of u8 for unsigned 8 bit, u16 for unsigned 16 bit, s16 for signed 16 bit, or float for 32 bit float.

write(buffer: Buffer)

Write audio data to the decoder, should be full frames, but any number of frames. They will be buffered up until it finds a LTC frame

read()

Reads the next frame from the decoder queue. If there are no frames in the queue it returns undefined. When a valid frame is found, it returns a LTCFrame object.

LTCEncoder instance methods

constructor(sampleRate: number, framerate: number, flags?: number);

Samplerate in hz, for example 48000. Framerate should be less than or equal to 30. Flags should be one, or a combination of the following flags: LTC_USE_DATE, LTC_TC_CLOCK, LTC_BGF_DONT_TOUCH, LTC_NO_PARITY. See the librtc documentation for more information about the flags. The default flag is LTC_USE_DATE.

setVolume(dBFS: number)

Set the volume of the generated LTC signal, in dBFs

setFilter(riseTime: number)

Set encoder signal rise-time / signal filtering, in uS. Default is 40.

setTimecode(timecode: LTCTimecode)

Set encoder timecode, expects a LTCTimecode object. You only need to specify non-zero parameters. The default is 0 for any omitted object parameters.

getTimecode()

Get the current encoder timecode. Returns a LTCTimecode object with the current position.

encodeFrame()

Write the next frame to the audio buffer. Fetch the buffer using getBuffer().

incrementTimecode()

Increment the current timecode by one frame.

decrementTimecode()

Decrement the timecode by one frame

getBuffer()

Returns the audio buffer for the current frame. The size of this buffer would be sample_rate / fps. So at 48000 khz, 25fps, that would be 1920 bytes of unsigned 8 bit audio.

License

This node module is licensed under the MIT license. And libltc is licensed under the GNU LGPL 3 license, but is included in this project in binary form and dynamically linked. So this module should in theory be safe to use in any open source or closed source commercial products. I am not a lawyer. This must not be construed as legal advice. Read more here http://answers.google.com/answers/threadview/id/439136.html