Simulator first commit

This commit is contained in:
2019-09-18 11:11:16 +03:00
commit 6e1686be67
5028 changed files with 985331 additions and 0 deletions

64
node_modules/node-opus/test/Decoder.js generated vendored Normal file
View File

@ -0,0 +1,64 @@
var ogg = require( 'ogg' );
var util = require( 'util' );
var opus = require( '../' );
var path = require( 'path' );
var streamEqual = require( 'stream-equal' );
var fs = require( 'fs' );
describe( 'Decoder', function() {
var SERIALNO = 1;
[ 'random', 'sine' ].forEach( function( file ) {
[ 8000, 48000 ].forEach( function( hzEncode ) {
[ 1, 2 ].forEach( function( chanEncode ) {
[ 8000, 48000 ].forEach( function( hzDecode ) {
[ 1, 2 ].forEach( function( chanDecode ) {
it( util.format(
'should decode %d:%d %s audio in %d:%d Hz',
hzEncode, chanEncode, file, hzDecode, chanDecode ),
function( done ) {
var inputPath = path.join(
path.basename( __dirname ),
'data',
util.format( '%s-%d-%d-%d.opus',
file, hzEncode, chanEncode, 20 ) );
var input = fs.createReadStream( inputPath );
var refPath = path.join(
path.basename( __dirname ),
'data',
util.format( '%s-%d-%d-%d-%d-%d.raw',
file, hzEncode, chanEncode, 20,
hzDecode, chanDecode ) );
var reference = fs.createReadStream( refPath );
var decoder = new opus.Decoder( hzDecode, chanDecode );
var oggDecoder = new ogg.Decoder();
oggDecoder.on( 'stream', function( stream ) {
stream.pipe( decoder );
});
input.pipe( oggDecoder )
streamEqual( decoder, reference, function( err, equal ) {
if( err )
throw err;
if( ! equal ) {
throw new Error( util.format(
"Streams not equal (%s, %d:%d, %d:%d)",
file, hzEncode, chanEncode,
hzDecode, chanDecode ) );
}
done();
} );
} );
} ) } ) } ) } ) } );
} );

52
node_modules/node-opus/test/Encoder.js generated vendored Normal file
View File

@ -0,0 +1,52 @@
require( 'chai' ).should();
var ogg = require( 'ogg' );
var util = require( 'util' );
var opus = require( '../' );
var path = require( 'path' );
var streamEqual = require( 'stream-equal' );
var fs = require( 'fs' );
describe( 'Encoder', function() {
var SERIALNO = 1;
[ 'random', 'sine' ].forEach( function( file ) {
[ 8000, 48000 ].forEach( function( hz ) {
[ 1, 2 ].forEach( function( channels ) {
it( util.format(
'should encode %d Hz, %d channel %s audio',
hz, channels, file ),
function( done ) {
var inputPath = path.join(
path.basename( __dirname ),
'data',
util.format( '%s.raw', file ) );
var input = fs.createReadStream( inputPath );
var refPath = path.join(
path.basename( __dirname ),
'data',
util.format( '%s-%d-%d-%d.opus',
file, hz, channels, 20 ) );
var reference = fs.createReadStream( refPath );
var bytes = hz * 20 / 1000;
var encoder = new opus.Encoder( hz, channels, bytes );
var oggEncoder = new ogg.Encoder();
input.pipe( encoder ).pipe( oggEncoder.stream( SERIALNO ) );
streamEqual( oggEncoder, reference, function( err, equal ) {
if( err )
throw err;
equal.should.be.true;
done();
} );
} );
} ) } ) } );
} );

12
node_modules/node-opus/test/data/README.md generated vendored Normal file
View File

@ -0,0 +1,12 @@
## Test data
These files are used as the reference data for the tests.
They are generated with the `generate_data.sh` script.
Note: The `generate_data.sh` script should NOT be invoked without first
verifying that the current functionality is flawless. Generating new test files
will essentially test the current implementation against itself.
These tests will detect whether there are changes in the bitstreams but they
will NOT detect whether the current functionality matches the OPUS spec.

56
node_modules/node-opus/test/data/generate_audio.sh generated vendored Normal file
View File

@ -0,0 +1,56 @@
#!/bin/sh
OPUSENC="../../bin/opusenc-js.js --serial 1"
OPUSDEC="../../bin/opusdec-js.js"
sox -n -c 1 -b 16 -e unsigned -r 48000 sine.raw synth 0.1 sine 500 gain -0.01
dd if=/dev/urandom bs=1024 count=64 of=random.raw
$OPUSENC --raw-chan 1 --raw-rate 48000 random.raw random-48000-1-20.opus
$OPUSENC --raw-chan 2 --raw-rate 48000 random.raw random-48000-2-20.opus
$OPUSENC --raw-chan 1 --raw-rate 8000 random.raw random-8000-1-20.opus
$OPUSENC --raw-chan 2 --raw-rate 8000 random.raw random-8000-2-20.opus
$OPUSENC --raw-chan 1 --raw-rate 48000 sine.raw sine-48000-1-20.opus
$OPUSENC --raw-chan 2 --raw-rate 48000 sine.raw sine-48000-2-20.opus
$OPUSENC --raw-chan 1 --raw-rate 8000 sine.raw sine-8000-1-20.opus
$OPUSENC --raw-chan 2 --raw-rate 8000 sine.raw sine-8000-2-20.opus
$OPUSDEC --rate 48000 --channels 2 random-48000-1-20.opus random-48000-1-20-48000-2.raw
$OPUSDEC --rate 48000 --channels 2 random-48000-2-20.opus random-48000-2-20-48000-2.raw
$OPUSDEC --rate 48000 --channels 2 random-8000-1-20.opus random-8000-1-20-48000-2.raw
$OPUSDEC --rate 48000 --channels 2 random-8000-2-20.opus random-8000-2-20-48000-2.raw
$OPUSDEC --rate 48000 --channels 1 random-48000-1-20.opus random-48000-1-20-48000-1.raw
$OPUSDEC --rate 48000 --channels 1 random-48000-2-20.opus random-48000-2-20-48000-1.raw
$OPUSDEC --rate 48000 --channels 1 random-8000-1-20.opus random-8000-1-20-48000-1.raw
$OPUSDEC --rate 48000 --channels 1 random-8000-2-20.opus random-8000-2-20-48000-1.raw
$OPUSDEC --rate 8000 --channels 2 random-48000-1-20.opus random-48000-1-20-8000-2.raw
$OPUSDEC --rate 8000 --channels 2 random-48000-2-20.opus random-48000-2-20-8000-2.raw
$OPUSDEC --rate 8000 --channels 2 random-8000-1-20.opus random-8000-1-20-8000-2.raw
$OPUSDEC --rate 8000 --channels 2 random-8000-2-20.opus random-8000-2-20-8000-2.raw
$OPUSDEC --rate 8000 --channels 1 random-48000-1-20.opus random-48000-1-20-8000-1.raw
$OPUSDEC --rate 8000 --channels 1 random-48000-2-20.opus random-48000-2-20-8000-1.raw
$OPUSDEC --rate 8000 --channels 1 random-8000-1-20.opus random-8000-1-20-8000-1.raw
$OPUSDEC --rate 8000 --channels 1 random-8000-2-20.opus random-8000-2-20-8000-1.raw
$OPUSDEC --rate 48000 --channels 2 sine-48000-1-20.opus sine-48000-1-20-48000-2.raw
$OPUSDEC --rate 48000 --channels 2 sine-48000-2-20.opus sine-48000-2-20-48000-2.raw
$OPUSDEC --rate 48000 --channels 2 sine-8000-1-20.opus sine-8000-1-20-48000-2.raw
$OPUSDEC --rate 48000 --channels 2 sine-8000-2-20.opus sine-8000-2-20-48000-2.raw
$OPUSDEC --rate 48000 --channels 1 sine-48000-1-20.opus sine-48000-1-20-48000-1.raw
$OPUSDEC --rate 48000 --channels 1 sine-48000-2-20.opus sine-48000-2-20-48000-1.raw
$OPUSDEC --rate 48000 --channels 1 sine-8000-1-20.opus sine-8000-1-20-48000-1.raw
$OPUSDEC --rate 48000 --channels 1 sine-8000-2-20.opus sine-8000-2-20-48000-1.raw
$OPUSDEC --rate 8000 --channels 2 sine-48000-1-20.opus sine-48000-1-20-8000-2.raw
$OPUSDEC --rate 8000 --channels 2 sine-48000-2-20.opus sine-48000-2-20-8000-2.raw
$OPUSDEC --rate 8000 --channels 2 sine-8000-1-20.opus sine-8000-1-20-8000-2.raw
$OPUSDEC --rate 8000 --channels 2 sine-8000-2-20.opus sine-8000-2-20-8000-2.raw
$OPUSDEC --rate 8000 --channels 1 sine-48000-1-20.opus sine-48000-1-20-8000-1.raw
$OPUSDEC --rate 8000 --channels 1 sine-48000-2-20.opus sine-48000-2-20-8000-1.raw
$OPUSDEC --rate 8000 --channels 1 sine-8000-1-20.opus sine-8000-1-20-8000-1.raw
$OPUSDEC --rate 8000 --channels 1 sine-8000-2-20.opus sine-8000-2-20-8000-1.raw

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
node_modules/node-opus/test/data/random.raw generated vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
node_modules/node-opus/test/data/sine.raw generated vendored Normal file

Binary file not shown.

76
node_modules/node-opus/test/old/app.js generated vendored Normal file
View File

@ -0,0 +1,76 @@
"use strict";
var opus = require('../../');
var fs = require('fs');
//
// Generate a sin tone.
//
var freq = 123;
var time = 5;
var rate = 48000;
// Allocate a buffer for the tone. We use 16-bit samples.
var samples = rate*time;
var length = samples*2;
var b = new Buffer(length);
// Generate the tone.
for( var i = 0; i < rate*time; i++ ) {
var value = Math.round( Math.sin( 2*Math.PI*i*freq/rate ) * Math.pow( 2, 14 ) );
b.writeInt16LE( value, i*2 );
}
//
// Create the encoder.
//
// Use 20ms frames.
var frame_size = rate * 0.02;
var encoder = new opus.OpusEncoder( rate );
// Open the output streams.
var output = fs.createWriteStream( 'out.opus' );
var input_raw = fs.createWriteStream( 'in.pcm' );
var output_raw = fs.createWriteStream( 'out.pcm' );
var read = 0;
while( b.length > 0 ) {
var size = Math.min( b.length, frame_size );
// If the input buffer is smaller than the frame_size, copy it into a new 0-padded buffer.
if( size < frame_size ) {
var temp = new Buffer( frame_size );
temp.fill(0);
b.copy( temp );
b = temp;
}
// We encode frame_size 16-bit samples. This requires a frame_size*2 buffer of bytes.
var bufferSize = frame_size * 2;
var toEncode = b.slice(0, bufferSize);
console.log( frame_size );
// Encode and decode.
var encoded = encoder.encode( toEncode );
var decoded = encoder.decode( encoded );
// Write the results in the output files.
input_raw.write( toEncode );
output.write( encoded );
output_raw.write( decoded );
// Move the buffer forward by the buffer size.
b = b.slice( bufferSize );
}
output.end();
input_raw.end();
output_raw.end();
console.log( 'Wrote following files.' );
console.log( 'in.pcm : Input PCM signal' );
console.log( 'out.opus : OPUS encoded input signal' );
console.log( 'out.pcm : Decoded PCM signal' );

22
node_modules/node-opus/test/old/decode-file.js generated vendored Normal file
View File

@ -0,0 +1,22 @@
var ogg = require( 'ogg' );
var opus = require( '../../' );
var oggDecoder = new ogg.Decoder();
oggDecoder.on( 'stream', function( stream ) {
var opusDecoder = new opus.Decoder();
opusDecoder.on( 'format', function( format ) {
opusDecoder.pipe( process.stdout );
});
opusDecoder.on( 'error', function( err ) {
console.log( err );
});
stream.pipe( opusDecoder );
});
process.stdin.pipe( oggDecoder );

12
node_modules/node-opus/test/old/encode-file.js generated vendored Normal file
View File

@ -0,0 +1,12 @@
var ogg = require( 'ogg' );
var opus = require( '../../' );
var oggEncoder = new ogg.Encoder();
var opusEncoder = new opus.Encoder();
process.stdin.pipe( opusEncoder );
opusEncoder.pipe( oggEncoder.stream() );
oggEncoder.pipe( process.stdout );