Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a problem with the sound quality in the node environment #80

Open
TDL-sys opened this issue Apr 9, 2021 · 0 comments
Open

Comments

@TDL-sys
Copy link

TDL-sys commented Apr 9, 2021

`
async function getBase64() {
const result = await axios.get(request.params.arrbu, { responseType: 'arraybuffer' });
return result.data
}
let arrayBuffer = await getBase64()
console.log(arrayBuffer)
var samples = new Uint16Array(arrayBuffer);
encodeMono(1, 32000, samples);

function encodeMono(channelNum, sampleRate, samples) {

    var buffer = [];
    var mp3enc = new lamejs.Mp3Encoder(channelNum, sampleRate, 192);
    var remaining = samples.length;
    var maxSamples = 1152;
    for (var i = 0; remaining >= maxSamples; i += maxSamples) {
        var mono = samples.subarray(i, i + maxSamples);
        var mp3buf = mp3enc.encodeBuffer(mono);
        if (mp3buf.length > 0) {
            buffer.push(new Uint8Array(mp3buf));
        }
        remaining -= maxSamples;
    }
    var flushData = mp3enc.flush();
    if (flushData.length > 0) {
        buffer.push(new Uint8Array(flushData));
    }
    const buf3 = Buffer.concat(buffer);
    
}

`

The sound quality in node environment is not good. How can I improve it

@TDL-sys TDL-sys changed the title How to use in node There is a problem with the sound quality in the node environment Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant