How to use the flac-bindings.StreamEncoder function in flac-bindings

To help you get started, weโ€™ve selected a few flac-bindings examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github melchor629 / chromecaster-gui / app / main.js View on Github external
}

    tray.startCastingVisibility = false;
    tray.setStatusMessage('Starting internal things...');
    let Client = browser.createClient(name);
    let contentType;

    let audioConfig;
    if(quality === 'flac') {
        audioConfig = { deviceName: audioDevice, bps: 16, samplerate: 44100 };
        enc = new flac.StreamEncoder();
        contentType = 'audio/flac';
        logger.info('Using FLAC encoder');
    } else if(quality === 'flac-hd') {
        audioConfig = { deviceName: audioDevice, bps: 24, samplerate: 96000 };
        enc = new flac.StreamEncoder({ bitsPerSample: 24, samplerate: 96000 });
        contentType = 'audio/flac';
        logger.info('Using FLAC encoder with 96KHz and 24bit');
    } else if(quality === 'wav') {
        audioConfig = { deviceName: audioDevice, bps: 16, samplerate: 44100 };
        enc = new wav.Writer();
        contentType = 'audio/wav';
        logger.info('Using WAV container, no encoding done');
    } else if(quality === 'wav-hd') {
        audioConfig = { deviceName: audioDevice, bps: 24, samplerate: 96000 };
        enc = new wav.Writer({ sampleRate: 96000, bitDepth: 24 });
        contentType = 'audio/wav';
        logger.info('Using WAV container, no encoding done');
    } else {
        audioConfig = { deviceName: audioDevice, bps: 16, samplerate: 44100 };
        contentType = 'audio/mpeg';
        logger.info('Using lame encoder');
github dmooney65 / fmradio / app / src / audio / player.js View on Github external
module.exports.Player = function () {

    function writeSamples(leftSamples, rightSamples) {
        let out = new Int16Array(leftSamples.length * 2);
        for (var i = 0; i < leftSamples.length; ++i) {
            out[i * 2] =
                Math.floor(Math.max(-1, Math.min(1, leftSamples[i])) * 32767);
            out[i * 2 + 1] =
                Math.floor(Math.max(-1, Math.min(1, rightSamples[i])) * 32767);
        }

        return Buffer.from(out.buffer);
    }

    let writer = new flac.StreamEncoder({ samplerate: 48000, bitsPerSample: 16, compressionLevel: 0 });
    let fileWriter;

    let audioElement;
    let recording = false;
    let muted = false;
    let server = httpServer.Server(1337, writer);

    const pause = () => {
        server.stop();
        if (userSettings.get('localPlayer') && audioElement) {
            audioElement.pause();
        }
    };

    const start = () => {
        server.start();

flac-bindings

libflac bindings to node.js with easy to use API

ISC
Latest version published 6 months ago

Package Health Score

63 / 100
Full package analysis