Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

130
Visualizações
Modify AudioBuffer volume in JavaScript

How can modify AudioBuffer volume in javascript ? I just wanna modify AudioBuffer volume without play any sound and without use any gain. Finally , I wanna to have a new AudioBuffer with modified volume.

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

Let's say you want to multiply all values within an existing AudioBuffer by 2. You could do that by looping over all values to apply the computation.

for (let channel = 0; channel < audioBuffer.numberOfChannels; channel += 1) {
    const channelData = audioBuffer.getChannelData(channel);

    for (let sample = 0; sample < channelData.length; sample += 1) {
        channelData[sample] *= 2;
    }
}

This will edit all values in place. If you want to copy all values to a new AudioBuffer instead you can do it as follows.

const copiedAudioBuffer = new AudioBuffer({
    length: audioBuffer.length,
    numberOfChannels: audioBuffer.numberOfChannels,
    sampleRate: audioBuffer.sampleRate
});

for (let channel = 0; channel < audioBuffer.numberOfChannels; channel += 1) {
    const channelData = audioBuffer.getChannelData(channel);
    const copiedChannelData = copiedAudioBuffer.getChannelData(channel);

    for (let sample = 0; sample < channelData.length; sample += 1) {
        copiedChannelData[sample] = channelData[sample] * 2;
    }
}

The example above creates an AudioBuffer with the exact same properties as the existing one. It will leave the existing AudioBuffer untouched.

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda