audio-recorder-polyfill
Advanced tools
Comparing version 0.3.4 to 0.3.5
# Change Log | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
## 0.3.5 | ||
* Fix `mpegEncoder` sample rate (by Joe Krill). | ||
## 0.3.4 | ||
@@ -5,0 +8,0 @@ * Better fix for `createWorker` error (by @jiyonghong). |
@@ -93,2 +93,5 @@ import waveEncoder from './wave-encoder/index.js' | ||
let recorder = this | ||
recorder.encoder.postMessage(['init', context.sampleRate]) | ||
processor.onaudioprocess = function (e) { | ||
@@ -95,0 +98,0 @@ if (recorder.state === 'recording') { |
@@ -8,5 +8,5 @@ export default () => { | ||
let KBPS = 128 | ||
let SAMPLE_RATE = 44100 | ||
let DEFAULT_SAMPLE_RATE = 44100 | ||
let encoder = new lamejs.Mp3Encoder(CHANNELS, SAMPLE_RATE, KBPS) | ||
let encoder | ||
let recorded = new Int8Array() | ||
@@ -24,2 +24,10 @@ | ||
function init (sampleRate) { | ||
encoder = new lamejs.Mp3Encoder( | ||
CHANNELS, | ||
sampleRate || DEFAULT_SAMPLE_RATE, | ||
KBPS | ||
) | ||
} | ||
function encode (buffer) { | ||
@@ -43,3 +51,5 @@ for (let i = 0; i < buffer.length; i++) { | ||
onmessage = e => { | ||
if (e.data[0] === 'encode') { | ||
if (e.data[0] === 'init') { | ||
init(e.data[1]) | ||
} else if (e.data[0] === 'encode') { | ||
encode(e.data[1]) | ||
@@ -46,0 +56,0 @@ } else { |
{ | ||
"type": "module", | ||
"main": "index.cjs", | ||
"module": "index.js" | ||
"module": "index.js", | ||
"react-native": "index.js" | ||
} |
{ | ||
"name": "audio-recorder-polyfill", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "MediaRecorder polyfill to record audio in Edge and Safari", | ||
@@ -21,9 +21,8 @@ "keywords": [ | ||
"repository": "ai/audio-recorder-polyfill", | ||
"eslintIgnore": [ | ||
"test/demo/build/" | ||
], | ||
"type": "module", | ||
"main": "index.cjs", | ||
"module": "index.js", | ||
"react-native": "index.js", | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": { | ||
@@ -33,2 +32,3 @@ "require": "./index.cjs", | ||
}, | ||
"./mpeg-encoder/package.json": "./mpeg-encoder/package.json", | ||
"./mpeg-encoder": { | ||
@@ -38,2 +38,3 @@ "require": "./mpeg-encoder/index.cjs", | ||
}, | ||
"./wave-encoder/package.json": "./wave-encoder/package.json", | ||
"./wave-encoder": { | ||
@@ -40,0 +41,0 @@ "require": "./wave-encoder/index.cjs", |
@@ -216,2 +216,6 @@ # Audio Recorder Polyfill | ||
module.exports = () => { | ||
function init (sampleRate) { | ||
… | ||
} | ||
function encode (input) { | ||
@@ -227,5 +231,7 @@ … | ||
onmessage = e => { | ||
if (e.data[0] === 'encode') { | ||
if (e.data[0] === 'init') { | ||
init(e.data[1]) | ||
} else if (e.data[0] === 'encode') { | ||
encode(e.data[1]) | ||
} else { | ||
} else if (e.data[0] === 'dump') { | ||
dump(e.data[1]) | ||
@@ -232,0 +238,0 @@ } |
@@ -71,3 +71,3 @@ // Copied from https://github.com/chris-rudmin/Recorderjs | ||
encode(e.data[1]) | ||
} else { | ||
} else if (e.data[0] === 'dump') { | ||
dump(e.data[1]) | ||
@@ -74,0 +74,0 @@ } |
{ | ||
"type": "module", | ||
"main": "index.cjs", | ||
"module": "index.js" | ||
"module": "index.js", | ||
"react-native": "index.js" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
29351
726
240