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

View File

@@ -0,0 +1,25 @@
-----BEGIN CERTIFICATE-----
MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEU
MBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFs
IFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290
MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFowbzELMAkGA1UEBhMCU0Ux
FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5h
bCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9v
dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvt
H7xsD821+iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9
uMq/NzgtHj6RQa1wVsfwTz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzX
mk6vBbOmcZSccbNQYArHE504B4YCqOmoaSYYkKtMsE8jqzpPhNjfzp/haW+710LX
a0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy2xSoRcRdKn23tNbE7qzN
E0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv77+ldU9U0
WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYD
VR0PBAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0
Jvf6xCZU7wO94CTLVBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQw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Q5QxG
V/Iz2tDIY+3GH5QFlkoakdH368+PUq4NCNk+qKBR6cGHdNXJ93SrLlP7u3r7l+L4
HyaPs9Kg4DdbKDsx5Q5XLVq4rXmsXiBmGqW5prU5wfWYQ//u+aen/e7KJD2AFsQX
j4rBYKEMrltDR5FL1ZoXX/nUh8HCjLfn4g8wGTeGrODcQgPmlKidrv0PJFGUzpII
0fxQ8ANAe4hZ7Q7drNJ3gjTcBpUC2JD5Leo31Rpg0Gcg19hCC0Wvgmje3WYkN5Ap
lBlGGSW4gNfL1IYoakRwJiNiqZ+Gb7+6kHDSVneFeO/qJakXzlByjAA6quPbYzSf
+AZxAeKCINT+b72x
-----END CERTIFICATE-----

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;