GithubHelp home page GithubHelp logo

Comments (13)

shanewho avatar shanewho commented on June 16, 2024
mp3encoder.encodeBuffer(samples);
    var mp3Data = mp3encoder.flush();
    console.log(mp3Data);

You get encoded data from the encodeBuffer call AND the flush call. You are only logging the result of the flush, which is just a tiny bit of the data. You need to capture the array returned from encodeBuffer as well.

from lamejs.

rehoehle avatar rehoehle commented on June 16, 2024

What? That is exact the sample from the page? And that is working in my current version its only not working with the RecordRTC data and what do you suggest to get the correct data and the complete data?

lib = new lamejs();
mp3encoder = new lib.Mp3Encoder(1, 44100, 128); //mono 44.1khz encode to 128kbps
samples = new Int16Array(44100); //one second of silence
var mp3 = mp3encoder.encodeBuffer(samples); //encode mp3
//write mp3 here
mp3 = mp3encoder.flush();
//write mp3 here

This is the example from the Readme. What is the difference to my version?

from lamejs.

shanewho avatar shanewho commented on June 16, 2024

I could be wrong, but looking at this code I'm not sure how it would work at all:

Here you call encodeMP3(buffer) and use the result in the blob:

var mp3Blob = new Blob([encodeMP3(buffer)], {type: 'audio/mp3'});

But the encodeMP3 function doesn't actually return any value (i.e., there is no return statement in the function). So the value of the blob is created with an array whose only value is undefined.

The encodeMP3 function needs to use the result of encodeBuffer var data = mp3encoder.encodeBuffer(samples) as well as the result of .flush(). These will be 2 different arrays but you need the data from both of them to get your full mp3.

Here is some code I use, you can hopefully see the difference:
#7 (comment)

from lamejs.

rehoehle avatar rehoehle commented on June 16, 2024

Yes i know ;) its for debugging... i know that there is no return... that is not the problem... the problem is that the output from the lame lib is empty... and to short. In my old version i use

mp3encoder = new lame.Mp3Encoder(1, 44100, 192);
mp3data = mp3encoder.encodeBuffer(e.data.buf);

that code. And its working well. That make not so much sense because encode buffer and the flush result is stored in the same variable and overwrite the preview one. So how should that work? Then flush have to return the complete data and overwrite the previews data its not appending i think or what do you think?

I think the for loop and iteration over the chunks is to show a progress vor example. I had tested that but it was not working.

Ok i see what you mean. In the other Issue they write both in the blocks array. Ok i will try that. But the questions is why is it working in my current code?

from lamejs.

rehoehle avatar rehoehle commented on June 16, 2024

Ok i have tested some more and your right now i get the data but i sound like Darth Vader :D any suggestions on that? The record has the double length and is slower.

from lamejs.

shanewho avatar shanewho commented on June 16, 2024

My only guess is that the buffer you are recording is stereo and you are encoding it as mono/single channel. If that's the case, you'd have to figure out how to split the buffer into 2 arrays, and pass them both to lame encodeBuffer (and make the Mp3Encoder constructor specify 2 channel). This may not be correct but that is my best guess.

from lamejs.

rehoehle avatar rehoehle commented on June 16, 2024

Ok i found in the documentation, that the recording from RecordRTC is stereo only. So i have a blob where i have the stereo data. I try to find how to get the left and right channel separately.

from lamejs.

zhuker avatar zhuker commented on June 16, 2024

Stereo is interleaved that is you have one 16 bit sample of left followed
by a sample of right.
You essentially split the stereo into two putting every i-th item into left
array and every i+1-th item into right.
They call it deinterleave.
On Aug 27, 2015 11:02 PM, "René H." [email protected] wrote:

Ok i found in the documentation, that the recording from RecordRTC is
stereo only. So i have a blob where i have the stereo data. I try to find
how to get the left and right channel separately.


Reply to this email directly or view it on GitHub
#8 (comment).

from lamejs.

rehoehle avatar rehoehle commented on June 16, 2024

Thx for your reply. Then i try to implement that. Do you know some code where the interleave is implemented?

from lamejs.

zhuker avatar zhuker commented on June 16, 2024

You mean deinterleave?
It's easy:
Stereo = array...
Left = new array
Right = new array
For(i=0;i<stereo.length;i+=2) {
Left.push(stereo[i])
Right.push(stereo[i+1])
}

Interleave is the opposite of this operation

Sent from my iPhone

On Aug 31, 2015, at 17:01, René H. [email protected] wrote:

Thx for your reply. Then i try to implement that. Do you know some code where the interleave is implemented?


Reply to this email directly or view it on GitHub.

from lamejs.

rehoehle avatar rehoehle commented on June 16, 2024

Yes i ment that :) thx then i can close that ticket :)

from lamejs.

shamseerahammedm avatar shamseerahammedm commented on June 16, 2024

@rehoehle do u have any implemented sameple code of this recordrtc to mp3?

from lamejs.

rehoehle avatar rehoehle commented on June 16, 2024

@shamseerahammedm this is an older post and i don't use this anymore so i can't give you some code. But in the end it was working.

from lamejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.