1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-06-17 07:36:01 +00:00
This commit is contained in:
MatteZ02
2020-03-03 22:30:50 +02:00
parent edfcc6f474
commit 30022c7634
11800 changed files with 1984416 additions and 1 deletions

17
node_modules/node-opus/examples/mp3-to-ogg.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
"use strict";
var fs = require( 'fs' );
var lame = require( 'lame' );
var opus = require( '../' );
var ogg = require( 'ogg' );
var opusFile = fs.createWriteStream( 'test.opus' );
var mp3Decoder = new lame.Decoder();
var opusEncoder = new opus.Encoder( 48000, 2 );
var oggEncoder = new ogg.Encoder();
process.stdin.pipe( mp3Decoder ).pipe( opusEncoder ).pipe( oggEncoder.stream() );
oggEncoder.pipe( process.stdout );

56
node_modules/node-opus/examples/stream-to-alsa.js generated vendored Normal file
View File

@ -0,0 +1,56 @@
'use strict';
// replace username and password with speech to text credentials
// audio.wav can be found here: https://github.com/watson-developer-cloud/nodejs-wrapper/blob/master/test/resources/audio.wav?raw=true
var fs = require('fs');
var opus = require('node-opus');
var ogg = require('ogg');
var cp = require('child_process');
var oggDecoder = new ogg.Decoder();
oggDecoder.on('stream', function (stream) {
var opusDecoder = new opus.Decoder();
// the "format" event contains the raw PCM format
opusDecoder.on('format', function (format) {
// format example:
//{
// channels: 1,
// sampleRate: 24000,
// bitDepth: 16,
// float: false,
// signed: true,
// gain: 0,
// preSkip: 156,
// version: 1
//}
// convert the signed & bitDepth to an alsa compatible format (`aplay --help format` for full list)
var alsaFormat;
if (format.signed && format.bitDepth == 16) {
alsaFormat = 'S16_LE'; // assume Little Endian
} else {
throw new Error('unexpected format: ' + JSON.stringify(format));
}
// set up aplay to accept data from stdin
var aplay = cp.spawn('aplay',['--format=' + alsaFormat, '--rate=' + format.sampleRate, '--channels='+format.channels, '--']);
// send the raw PCM data to aplay
opusDecoder.pipe(aplay.stdin);
// or pipe to node-speaker, a file, etc
});
// an "error" event will get emitted if the stream is not a Vorbis stream
// (i.e. it could be a Theora video stream instead)
opusDecoder.on('error', console.error);
stream.pipe(opusDecoder);
});
fs.createReadStream('input.opus').pipe(oggDecoder);