Comments (16)
i cant tell from looking at the code
but it looks like you are not feeding the encoder properly
from lamejs.
Please let me help what i need to be code for encoder properly
from lamejs.
sounds like you are calling flush()
too often, try calling it only at the end of encode
from lamejs.
Can I share the code file with you? You want me to call flush after sending to the server or before.
from lamejs.
Can I share the code file with you? You want me to call flush after sending to the server or before.
Post the most relevant snippet here, i'll take a look
from lamejs.
from lamejs.
var data = new Float32Array(arrayBuffer);
var out = new Int16Array(arrayBuffer.length);
change to
var data = new Float32Array(arrayBuffer);
var out = new Int16Array(data.length);
from lamejs.
I have tried by replace this code but still facing same issue. Please let me know where i am doing wrong with code.
from lamejs.
can you create an end-to-end example i can reproduce here?
i mean no worker code, no messages
from lamejs.
Above is my file please let me know which code i need to remove from it.
from lamejs.
from lamejs.
arrayBuffer
passed to your var encode = function (arrayBuffer) {
must be of size divisible by 1152 * 4
if size is different encoder will produce the clicks you are hearing
from lamejs.
What i need to do for 1152 * 4 into my encode function so it will ignore
from lamejs.
@durgadp I'm testing lamejs as fallback for vmsgjs right now.
Here is my handling of this limitation (mono sound example).
// assumes that t - is some sort of object, in my case it's vmsgjs Recorder instance
t.len = 0;
// List of valid buffSize values can be found here:
// https://developer.mozilla.org/en-US/docs/Web/API/BaseAudioContext/createScriptProcessor
// To use buffSize = 256 change t.samplesInFrame to 18. In other cases you don't change it
t.buffSize = 1024;
t.samplesInFrame = 9;
t.sampleFrameSize = t.buffSize * t.samplesInFrame;
t.unsentSamples = [];
function startRecording(){
// assumes that
// t.encNode = (t.audioCtx.createScriptProcessor || t.audioCtx.createJavaScriptNode)
// .call(t.audioCtx, t.buffSize, inputChannelsNumber, outputChannelsNumber)
t.encNode.onaudioprocess = function(e){
// create new array so data won't be corrupted, references suck sometimes
t.unsentSamples[t.len++] = new Float32Array(e.inputBuffer.getChannelData(0));
if (!(t.len % t.samplesInFrame)){
t.worker.postMessage({
cmd: 'encode',
data: { buf: concatSamples(t.unsentSamples, t.sampleFrameSize) }
});
t.len = 0;
t.unsentSamples = [];
}
}
t.encNode.connect(t.audioCtx.destination);
}
function stopRecording(){
t.len = 0;
t.unsentSamples = [];
t.encNode.onaudioprocess = null;
t.unsentSamples && t.unsentSamples.length && t.worker.postMessage({
cmd: 'encode',
data: {
buf: concatSamples(t.unsentSamples, t.sampleFrameSize)
}
});
t.worker.postMessage({ cmd: 'finish' });
// disconnect Nodes, destroy stuff
}
// concatenate audio samples
// if not enough samples passed we will still return valid Float32Array
// when totalLength passed divisible by 4608 = 1152*4
// samples - array of Float32Arrays
// totalLength - combined length of Float32Arrays in samples
function concatSamples(samples, totalLength){
var l = samples.length,
len = 0,
res = new Float32Array(totalLength);
for (var i = 0; i < l; i++){
res.set(samples[i], len);
len += samples[i].length;
}
return res;
}
Hope this helps others to work around this limitation.
from lamejs.
sounds like you are calling
flush()
too often, try calling it only at the end of encode
What do you mean by calling flush() too often?
from lamejs.
t.sampleFrameSize
var remaining = samplesMono.length;
I am getting 2048 length here which is divisible by 4. Help me if i am doing any thing wrong.
from lamejs.
Related Issues (20)
- Working With MediaRecorder API HOT 1
- Dependency on module mic-recorder-to-mp3 HOT 1
- lamejs not working with angular 8 -- Uncaught ReferenceError: Lame is not defined HOT 3
- Silent MP3 file when converting output from Azure Speech-to-Text javascript SDK HOT 2
- Is it possible to use VBR (variable bit rate) HOT 1
- Blob to MP3 HOT 1
- lamejs.WavHeader.readHeader - Uncaught (in promise) TypeError: Cannot read property 'dataOffset' of undefined HOT 3
- There is a problem with the sound quality in the node environment
- Deleted
- recorder wavdata to mp3 causes ui rendering block HOT 2
- window not defined
- "MPEGMode is not defined" HOT 21
- [Firefox] Data from right channel is not passed to encoder despite there are expected two channels
- MPEGMode is not defined HOT 5
- No sound in trimmed & encoded audio blob, Vue 2. Why?
- wav转mp3的时候lampjs报"ReferenceError: MPEGMode is not defined" HOT 10
- Cannot read properties of undefined (reading 'println') HOT 1
- can i convert amr to mp3?
- License clarification
- zhuker/lamejs 打包报错 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lamejs.