New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

upsample

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

upsample - npm Package Compare versions

Comparing version
1.1.1
to
1.2.0
+1
-1
package.json
{
"name": "upsample",
"version": "1.1.1",
"version": "1.2.0",
"description": "upsample your wav file!",

@@ -5,0 +5,0 @@ "main": "upSample.js",

# What is this?
module to upsample your wav file from 2000hz to 4000hz.
module to upsample your wav file.

@@ -11,7 +11,8 @@ # Installation

let upSampledData = upsample(orginalData)
let upSampledData = upsample(data, UPSAMPLE_RATIO)
# Inputs
orginalData: the orginal data of wav file without header wav file([more info for wav format](http://soundfile.sapp.org/doc/WaveFormat/) )
data: the data of wav file with int16 type.
UPSAMPLE_RATIO: ratio of upsampling

@@ -23,7 +24,6 @@ Then...

var codes = new Int16Array(<your_wav_arraybuffer>);
var data = new Int16Array(<your_wav_arraybuffer>);
let orginalData = codes.slice(22)
let upSampledData = upsample(orginalData)
let upSampledData = upsample(data)
```
let INITIAL_NUMERATOR_UPSAMPLE = [0, 1.6344e-06, -1.3929e-20, -1.5509e-05, -4.0224e-05, -4.5982e-05, 4.7602e-19, 9.7257e-05, 0.00018729, 0.00017511, -3.9189e-19, -0.00028703, -0.00050711, -0.00044227, 8.4101e-19, 0.000652, 0.0011049, 0.00092935, -1.5214e-18, -0.0012896, -0.0021302, -0.0017506, 2.4551e-18, 0.0023329, 0.0037859, 0.0030611, -3.6255e-18, -0.0039651, -0.0063562, -0.0050829, 4.9681e-18, 0.006465, 0.01029, 0.0081824, -6.3721e-18, -0.010341, -0.016455, -0.013111, 7.6941e-18, 0.016784, 0.027032, 0.021913, -8.7808e-18, -0.029691, -0.050039, -0.043226, 9.4959e-18, 0.07394, 0.15813, 0.22471, 0.25, 0.22471, 0.15813, 0.07394, 9.4959e-18, -0.043226, -0.050039, -0.029691, -8.7808e-18, 0.021913, 0.027032, 0.016784, 7.6941e-18, -0.013111, -0.016455, -0.010341, -6.3721e-18, 0.0081824, 0.01029, 0.006465, 4.9681e-18, -0.0050829, -0.0063562, -0.0039651, -3.6255e-18, 0.0030611, 0.0037859, 0.0023329, 2.4551e-18, -0.0017506, -0.0021302, -0.0012896, -1.5214e-18, 0.00092935, 0.0011049, 0.000652, 8.4101e-19, -0.00044227, -0.00050711, -0.00028703, -3.9189e-19, 0.00017511, 0.00018729, 9.7257e-05, 4.7602e-19, -4.5982e-05, -4.0224e-05, -1.5509e-05, -1.3929e-20, 1.6344e-06, 0];
let INITIAL_WAVEHEADER = [18770, 17990, 14500, 1, 16727, 17750, 28006, 8308, 16, 0, 1, 1, 4000, 0, 8000, 0, 2, 16, 24932, 24948, 14464, 1]
let UPSAMPLE_RATIO = 2
export const upSample = (originalDoublesData, NUMERATOR_UPSAMPLE = INITIAL_NUMERATOR_UPSAMPLE, DENOMINATOR_UPSAMPLE = [1]) => {
const upSample = (data, UPSAMPLE_RATIO = 2, NUMERATOR_UPSAMPLE = INITIAL_NUMERATOR_UPSAMPLE, DENOMINATOR_UPSAMPLE = [1]) => {
//start upSampling
// let dataLen = data.length
// let sub = (dataLen - 22) * 2
let wavheader = data.slice(0, 22);
console.log(data.length)
let originalDoublesData = data.slice(22)
let len = originalDoublesData.length * UPSAMPLE_RATIO - UPSAMPLE_RATIO + 1;

@@ -19,4 +28,31 @@ let upSampledDoublesData = new Float64Array(len);

let orginalUpSampledData = new Int16Array(convertedUpSample)
let upSampled = new Int16Array([...INITIAL_WAVEHEADER, ...orginalUpSampledData])
const int32toint16 = (x) => {
let int32 = new Int32Array([x])
return new Int16Array(int32.buffer)
}
let chunkSize = int32toint16((orginalUpSampledData.length * 2) + 44 - 8)
let subChunk2Size = int32toint16(orginalUpSampledData.length * 2)
wavheader[2] = chunkSize[0]
wavheader[3] = chunkSize[1]
wavheader[12] = wavheader[12] * UPSAMPLE_RATIO
wavheader[14] = wavheader[14] * UPSAMPLE_RATIO
wavheader[20] = subChunk2Size[0]
wavheader[21] = subChunk2Size[1]
// let str = ''
// for (let i of wavheader) {
// str += i + '\n';
// }
// let a = document.createElement('a');
// a.href = "data:application/octet-stream," + encodeURIComponent(str);
// a.download = 'abc.txt';
// a.click();
console.log(wavheader)
let upSampled = new Int16Array([...wavheader, ...orginalUpSampledData])
return upSampled;

@@ -144,2 +180,2 @@ }

return filteredData;
}
}