Pushing changes

This commit is contained in:
2017-03-23 23:52:08 -05:00
parent 6075860b82
commit ac667ec74f
1465 changed files with 345149 additions and 3 deletions

14
node_modules/discordie/deps/nopus/index.js generated vendored Normal file
View File

@ -0,0 +1,14 @@
var ex = "uncaughtException";
var pl = process.listeners(ex);
var opus = require("./opus-js/opus");
var resampler = require("./opus-js/resampler");
process.removeAllListeners(ex);
for (var i = 0; i < pl.length; i++) process.on(ex, pl[i]);
module.exports.Opus = opus.Opus;
module.exports.OpusApplication = opus.OpusApplication;
module.exports.OpusEncoder = opus.OpusEncoder;
module.exports.OpusDecoder = opus.OpusDecoder;
module.exports.Resampler = resampler.SpeexResampler;

View File

@ -0,0 +1,28 @@
Copyright (c) 1994-2013 Xiph.Org Foundation and contributors
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 Xiph.Org Foundation 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 THE FOUNDATION
OR CONTRIBUTORS 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.

View File

@ -0,0 +1,35 @@
Copyright 2002-2008 Xiph.org Foundation
Copyright 2002-2008 Jean-Marc Valin
Copyright 2005-2007 Analog Devices Inc.
Copyright 2005-2008 Commonwealth Scientific and Industrial Research
Organisation (CSIRO)
Copyright 1993, 2002, 2006 David Rowe
Copyright 2003 EpicGames
Copyright 1992-1994 Jutta Degener, Carsten Bormann
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 Xiph.org Foundation 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 THE FOUNDATION OR
CONTRIBUTORS 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.

View File

@ -0,0 +1,29 @@
Copyright (c) 2013-2014, Kazuki Oikawa
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. 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.
3. Neither the name of 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 THE COPYRIGHT
HOLDER OR CONTRIBUTORS 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.

File diff suppressed because one or more lines are too long

217
node_modules/discordie/deps/nopus/opus-js/opus.js generated vendored Normal file
View File

@ -0,0 +1,217 @@
///<reference path="d.ts/asm.d.ts" />
///<reference path="d.ts/libopus.d.ts" />
var native = require("./libopus_libspeexdsp");
var OPUS_SET_BITRATE_REQUEST = 4002;
var OpusApplication;
(function (OpusApplication) {
OpusApplication[OpusApplication["VoIP"] = 2048] = "VoIP";
OpusApplication[OpusApplication["Audio"] = 2049] = "Audio";
OpusApplication[OpusApplication["RestrictedLowDelay"] = 2051] = "RestrictedLowDelay";
})(OpusApplication || (OpusApplication = {}));
var OpusError;
(function (OpusError) {
OpusError[OpusError["OK"] = 0] = "OK";
OpusError[OpusError["BadArgument"] = -1] = "BadArgument";
OpusError[OpusError["BufferTooSmall"] = -2] = "BufferTooSmall";
OpusError[OpusError["InternalError"] = -3] = "InternalError";
OpusError[OpusError["InvalidPacket"] = -4] = "InvalidPacket";
OpusError[OpusError["Unimplemented"] = -5] = "Unimplemented";
OpusError[OpusError["InvalidState"] = -6] = "InvalidState";
OpusError[OpusError["AllocFail"] = -7] = "AllocFail";
})(OpusError || (OpusError = {}));
var Opus = (function () {
function Opus() {
}
Opus.getVersion = function () {
var ptr = native._opus_get_version_string();
return Pointer_stringify(ptr);
};
Opus.getMaxFrameSize = function (numberOfStreams) {
if (numberOfStreams === void 0) { numberOfStreams = 1; }
return (1275 * 3 + 7) * numberOfStreams;
};
Opus.getMinFrameDuration = function () {
return 2.5;
};
Opus.getMaxFrameDuration = function () {
return 60;
};
Opus.validFrameDuration = function (x) {
return [2.5, 5, 10, 20, 40, 60].some(function (element) {
return element == x;
});
};
Opus.getMaxSamplesPerChannel = function (sampling_rate) {
return sampling_rate / 1000 * Opus.getMaxFrameDuration();
};
return Opus;
})();
var OpusEncoder = (function () {
function OpusEncoder(sampling_rate, channels, app, frame_duration) {
if (frame_duration === void 0) { frame_duration = 20; }
this.handle = 0;
this.frame_size = 0;
this.in_ptr = 0;
this.in_off = 0;
this.out_ptr = 0;
if (!Opus.validFrameDuration(frame_duration))
throw 'invalid frame duration';
this.frame_size = sampling_rate * frame_duration / 1000;
var err_ptr = native.allocate(4, 'i32', native.ALLOC_STACK);
this.handle = native._opus_encoder_create(sampling_rate, channels, app, err_ptr);
if (native.getValue(err_ptr, 'i32') != 0 /* OK */)
throw 'opus_encoder_create failed: ' + native.getValue(err_ptr, 'i32');
this.in_ptr = native._malloc(this.frame_size * channels * 4);
this.in_len = this.frame_size * channels;
this.in_i16 = native.HEAP16.subarray(this.in_ptr >> 1, (this.in_ptr >> 1) + this.in_len);
this.in_f32 = native.HEAPF32.subarray(this.in_ptr >> 2, (this.in_ptr >> 2) + this.in_len);
this.out_bytes = Opus.getMaxFrameSize();
this.out_ptr = native._malloc(this.out_bytes);
this.out_buf = native.HEAPU8.subarray(this.out_ptr, this.out_ptr + this.out_bytes);
}
OpusEncoder.prototype.set_bitrate = function (bitrate) {
var bitrate_ptr = native.allocate(4, 'i32', native.ALLOC_STACK);
native.setValue(bitrate_ptr, bitrate, 'i32');
var ret = native._opus_encoder_ctl(this.handle, OPUS_SET_BITRATE_REQUEST, bitrate_ptr);
if (ret < 0)
throw 'opus_encoder_ctl failed: ' + ret;
};
OpusEncoder.prototype.encode = function (pcm) {
var output = [];
var pcm_off = 0;
while (pcm.length - pcm_off >= this.in_len - this.in_off) {
if (this.in_off > 0) {
this.in_i16.set(pcm.subarray(pcm_off, pcm_off + this.in_len - this.in_off), this.in_off);
pcm_off += this.in_len - this.in_off;
this.in_off = 0;
}
else {
this.in_i16.set(pcm.subarray(pcm_off, pcm_off + this.in_len));
pcm_off += this.in_len;
}
var ret = native._opus_encode(this.handle, this.in_ptr, this.frame_size, this.out_ptr, this.out_bytes);
if (ret <= 0)
throw 'opus_encode failed: ' + ret;
var packet = new ArrayBuffer(ret);
new Uint8Array(packet).set(this.out_buf.subarray(0, ret));
output.push(packet);
}
if (pcm_off < pcm.length) {
this.in_i16.set(pcm.subarray(pcm_off));
this.in_off = pcm.length - pcm_off;
}
return output;
};
OpusEncoder.prototype.encode_float = function (pcm) {
var output = [];
var pcm_off = 0;
while (pcm.length - pcm_off >= this.in_len - this.in_off) {
if (this.in_off > 0) {
this.in_f32.set(pcm.subarray(pcm_off, pcm_off + this.in_len - this.in_off), this.in_off);
pcm_off += this.in_len - this.in_off;
this.in_off = 0;
}
else {
this.in_f32.set(pcm.subarray(pcm_off, pcm_off + this.in_len));
pcm_off += this.in_len;
}
var ret = native._opus_encode_float(this.handle, this.in_ptr, this.frame_size, this.out_ptr, this.out_bytes);
if (ret <= 0)
throw 'opus_encode failed: ' + ret;
var packet = new ArrayBuffer(ret);
new Uint8Array(packet).set(this.out_buf.subarray(0, ret));
output.push(packet);
}
if (pcm_off < pcm.length) {
this.in_f32.set(pcm.subarray(pcm_off));
this.in_off = pcm.length - pcm_off;
}
return output;
};
OpusEncoder.prototype.encode_final = function () {
if (this.in_off == 0)
return new ArrayBuffer(0);
for (var i = this.in_off; i < this.in_len; ++i)
this.in_i16[i] = 0;
var ret = native._opus_encode(this.handle, this.in_ptr, this.frame_size, this.out_ptr, this.out_bytes);
if (ret <= 0)
throw 'opus_encode failed: ' + ret;
var packet = new ArrayBuffer(ret);
new Uint8Array(packet).set(this.out_buf.subarray(0, ret));
return packet;
};
OpusEncoder.prototype.encode_float_final = function () {
if (this.in_off == 0)
return new ArrayBuffer(0);
for (var i = this.in_off; i < this.in_len; ++i)
this.in_f32[i] = 0;
var ret = native._opus_encode_float(this.handle, this.in_ptr, this.frame_size, this.out_ptr, this.out_bytes);
if (ret <= 0)
throw 'opus_encode failed: ' + ret;
var packet = new ArrayBuffer(ret);
new Uint8Array(packet).set(this.out_buf.subarray(0, ret));
return packet;
};
OpusEncoder.prototype.destroy = function () {
if (!this.handle)
return;
native._opus_encoder_destroy(this.handle);
native._free(this.in_ptr);
this.handle = this.in_ptr = 0;
};
return OpusEncoder;
})();
var OpusDecoder = (function () {
function OpusDecoder(sampling_rate, channels) {
this.handle = 0;
this.in_ptr = 0;
this.out_ptr = 0;
this.channels = channels;
var err_ptr = native.allocate(4, 'i32', native.ALLOC_STACK);
this.handle = native._opus_decoder_create(sampling_rate, channels, err_ptr);
if (native.getValue(err_ptr, 'i32') != 0 /* OK */)
throw 'opus_decoder_create failed: ' + native.getValue(err_ptr, 'i32');
this.in_ptr = native._malloc(Opus.getMaxFrameSize(channels));
this.in_buf = native.HEAPU8.subarray(this.in_ptr, this.in_ptr + Opus.getMaxFrameSize(channels));
this.out_len = Opus.getMaxSamplesPerChannel(sampling_rate);
var out_bytes = this.out_len * channels * 4;
this.out_ptr = native._malloc(out_bytes);
this.out_i16 = native.HEAP16.subarray(this.out_ptr >> 1, (this.out_ptr + out_bytes) >> 1);
this.out_f32 = native.HEAPF32.subarray(this.out_ptr >> 2, (this.out_ptr + out_bytes) >> 2);
}
OpusDecoder.prototype.decode = function (packet) {
this.in_buf.set(new Uint8Array(packet));
var ret = native._opus_decode(this.handle, this.in_ptr, packet.byteLength, this.out_ptr, this.out_len, 0);
if (ret < 0)
throw 'opus_decode failed: ' + ret;
var samples = new Int16Array(ret * this.channels);
samples.set(this.out_i16.subarray(0, samples.length));
return samples;
};
OpusDecoder.prototype.decode_float = function (packet) {
this.in_buf.set(new Uint8Array(packet));
var ret = native._opus_decode_float(this.handle, this.in_ptr, packet.byteLength, this.out_ptr, this.out_len, 0);
if (ret < 0)
throw 'opus_decode failed: ' + ret;
var samples = new Float32Array(ret * this.channels);
samples.set(this.out_f32.subarray(0, samples.length));
return samples;
};
OpusDecoder.prototype.destroy = function () {
if (!this.handle)
return;
native._opus_decoder_destroy(this.handle);
native._free(this.in_ptr);
native._free(this.out_ptr);
this.handle = this.in_ptr = this.out_ptr = 0;
};
return OpusDecoder;
})();
module.exports.Opus = Opus;
module.exports.OpusApplication = OpusApplication;
module.exports.OpusEncoder = OpusEncoder;
module.exports.OpusDecoder = OpusDecoder;

152
node_modules/discordie/deps/nopus/opus-js/resampler.js generated vendored Normal file
View File

@ -0,0 +1,152 @@
///<reference path="d.ts/asm.d.ts" />
///<reference path="d.ts/libspeexdsp.d.ts" />
var native = require("./libopus_libspeexdsp");
var SpeexResampler = (function () {
function SpeexResampler(channels, in_rate, out_rate, bits_per_sample, is_float, quality) {
if (quality === void 0) { quality = 5; }
this.handle = 0;
this.in_ptr = 0;
this.out_ptr = 0;
this.in_capacity = 0;
this.in_len_ptr = 0;
this.out_len_ptr = 0;
this.channels = channels;
this.in_rate = in_rate;
this.out_rate = out_rate;
this.bits_per_sample = bits_per_sample;
var bytes = bits_per_sample / 8;
if (bits_per_sample % 8 != 0 || bytes < 1 || bytes > 4)
throw 'argument error: bits_per_sample = ' + bits_per_sample;
if (is_float && bits_per_sample != 32)
throw 'argument error: if is_float=true, bits_per_sample must be 32';
var err_ptr = native.allocate(4, 'i32', native.ALLOC_STACK);
this.handle = native._speex_resampler_init(channels, in_rate, out_rate, quality, err_ptr);
if (native.getValue(err_ptr, 'i32') != 0)
throw 'speex_resampler_init failed: ret=' + native.getValue(err_ptr, 'i32');
if (!is_float) {
if (bits_per_sample == 8)
this.copy_to_buf = this._from_i8;
else if (bits_per_sample == 16) {
this.copy_to_buf = this._from_i16;
}
else if (bits_per_sample == 24)
this.copy_to_buf = this._from_i24;
else if (bits_per_sample == 32)
this.copy_to_buf = this._from_i32;
}
else {
this.copy_to_buf = this._from_f32;
}
this.in_len_ptr = native._malloc(4);
this.out_len_ptr = native._malloc(4);
}
SpeexResampler.prototype.process = function (raw_input) {
if (!this.handle)
throw 'disposed object';
var samples = (raw_input.byteLength / (this.bits_per_sample / 8) / this.channels);
var outSamples = Math.ceil(samples * this.out_rate / this.in_rate);
var requireSize = samples * 4;
if (this.in_capacity < requireSize) {
if (this.in_ptr)
native._free(this.in_ptr);
if (this.out_ptr)
native._free(this.out_ptr);
this.in_ptr = native._malloc(requireSize);
this.out_ptr = native._malloc(outSamples * 4);
this.in_capacity = requireSize;
}
var results = [];
for (var ch = 0; ch < this.channels; ++ch) {
this.copy_to_buf(raw_input, ch, samples);
native.setValue(this.in_len_ptr, samples, 'i32');
native.setValue(this.out_len_ptr, outSamples, 'i32');
var ret = native._speex_resampler_process_float(this.handle, ch, this.in_ptr, this.in_len_ptr, this.out_ptr, this.out_len_ptr);
if (ret != 0)
throw 'speex_resampler_process_float failed: ' + ret;
var ret_samples = native.getValue(this.out_len_ptr, 'i32');
var ary = new Float32Array(ret_samples);
ary.set(native.HEAPF32.subarray(this.out_ptr >> 2, (this.out_ptr >> 2) + ret_samples));
results.push(ary);
}
return results;
};
SpeexResampler.prototype.process_interleaved = function (raw_input) {
if (!this.handle)
throw 'disposed object';
var samples = raw_input.byteLength / (this.bits_per_sample / 8);
var outSamples = Math.ceil(samples * this.out_rate / this.in_rate);
var requireSize = samples * 4;
if (this.in_capacity < requireSize) {
if (this.in_ptr)
native._free(this.in_ptr);
if (this.out_ptr)
native._free(this.out_ptr);
this.in_ptr = native._malloc(requireSize);
this.out_ptr = native._malloc(outSamples * 4);
this.in_capacity = requireSize;
}
this.copy_to_buf(raw_input, -1, samples);
native.setValue(this.in_len_ptr, samples / this.channels, 'i32');
native.setValue(this.out_len_ptr, outSamples / this.channels, 'i32');
var ret = native._speex_resampler_process_interleaved_float(this.handle, this.in_ptr, this.in_len_ptr, this.out_ptr, this.out_len_ptr);
if (ret != 0)
throw 'speex_resampler_process_interleaved_float failed: ' + ret;
var ret_samples = native.getValue(this.out_len_ptr, 'i32') * this.channels;
var result = new Float32Array(ret_samples);
result.set(native.HEAPF32.subarray(this.out_ptr >> 2, (this.out_ptr >> 2) + ret_samples));
return result;
};
SpeexResampler.prototype.destroy = function () {
if (!this.handle)
return;
native._speex_resampler_destroy(this.handle);
this.handle = 0;
native._free(this.in_len_ptr);
native._free(this.out_len_ptr);
if (this.in_ptr)
native._free(this.in_ptr);
if (this.out_ptr)
native._free(this.out_ptr);
this.in_len_ptr = this.out_len_ptr = this.in_ptr = this.out_ptr = 0;
};
SpeexResampler.prototype._from_i8 = function (raw_input, ch, samples) {
var input = new Int8Array(raw_input);
};
SpeexResampler.prototype._from_i16 = function (raw_input, ch, samples) {
var input = new Int16Array(raw_input);
var off = this.in_ptr >> 2;
if (ch >= 0) {
var tc = this.channels;
for (var i = 0; i < samples; ++i)
native.HEAPF32[off + i] = input[i * tc + ch] / 32768.0;
}
else {
for (var i = 0; i < samples; ++i)
native.HEAPF32[off + i] = input[i] / 32768.0;
}
};
SpeexResampler.prototype._from_i24 = function (raw_input, ch, samples) {
var input = new Uint8Array(raw_input);
};
SpeexResampler.prototype._from_i32 = function (raw_input, ch, samples) {
var input = new Int32Array(raw_input);
};
SpeexResampler.prototype._from_f32 = function (raw_input, ch, samples) {
var input = new Float32Array(raw_input);
var off = this.in_ptr >> 2;
if (ch >= 0) {
var tc = this.channels;
for (var i = 0; i < samples; ++i)
native.HEAPF32[off + i] = input[i * tc + ch];
}
else {
for (var i = 0; i < samples; ++i)
native.HEAPF32[off + i] = input[i];
}
};
return SpeexResampler;
})();
module.exports.SpeexResampler = SpeexResampler;