<p>You can do this with the <code>normalize</code> function from the <code>tuneR</code> package. By default it will rescale your wav files to the maximum range (which is possibly too loud), but you can change it to a percentage of maximum with the <code>level</code> argument. Here's an example rescaling all wav files to 50% of the maximum level (seemed reasonable to my ear, you may want more or less). Creates a new version of each wav file with <code>Louder_</code> appended to the file name so you can tell the difference.</p>
<pre><code>library(tuneR)
wavDir &lt;- './WhistleClips'
# first list all wav files
wavFiles &lt;- list.files(wavDir, full.names=TRUE, pattern='.wav$')

# go through each, read in, adjust to 50% of max
for(i in seq_along(wavFiles)) {
    original &lt;- readWave(wavFiles[i])
    # change level to your liking, .5 seemed reasonable
    louder &lt;- normalize(original, unit=as.character(original@bit), level = .5)
    louderFile &lt;- file.path(wavDir, paste0('Louder_', basename(wavFiles[i])))
    writeWave(louder, filename = louderFile)
}
</code></pre>

CC BY-SA 4.0
2022-07-22T23:14:36.090Z
2022-07-22T23:14:36.090Z
Taiki Sakai
<p>I am preparing short sound clips to upload to a citizen science data analysis project, and realize that the sound levels are all too low for users to hear properly. I'm familiar with the <a href="https://cran.r-project.org/web/packages/tuneR/tuneR.pdf" rel="noreferrer">tuneR</a> and <a href="https://cran.r-project.org/web/packages/seewave/seewave.pdf" rel="noreferrer">seewave</a> packages for audio analysis in R, but I haven't found any functions to simply amplify the entire sound file. I know Audacity can do this for individual files, but I'd prefer to process all sound files at one time in R.</p>
<p>What R functions exist to amplify sound clips?</p>

<r><signal-processing>
How do you amplify all sounds in a directory in R?
# How do you amplify all sounds in a directory in R?

(Asked by: username_0 on 2022-07-22)

I am preparing short sound clips to upload to a citizen science data analysis project, and realize that the sound levels are all too low for users to hear properly. I'm familiar with the [tuneR](https://cran.r-project.org/web/packages/tuneR/tuneR.pdf) and [seewave](https://cran.r-project.org/web/packages/seewave/seewave.pdf) packages for audio analysis in R, but I haven't found any functions to simply amplify the entire sound file. I know Audacity can do this for individual files, but I'd prefer to process all sound files at one time in R.

What R functions exist to amplify sound clips?

**Tags:** r, signal-processing


---

## 1 answers

### Answer by username_1 on 2022-07-22. Score: 9 | Accepted answer

You can do this with the `normalize` function from the `tuneR` package. By default it will rescale your wav files to the maximum range (which is possibly too loud), but you can change it to a percentage of maximum with the `level` argument. Here's an example rescaling all wav files to 50% of the maximum level (seemed reasonable to my ear, you may want more or less). Creates a new version of each wav file with `Louder_` appended to the file name so you can tell the difference.

```
library(tuneR)
wavDir <- './WhistleClips'
# first list all wav files
wavFiles <- list.files(wavDir, full.names=TRUE, pattern='.wav$')

# go through each, read in, adjust to 50% of max
for(i in seq_along(wavFiles)) {
    original <- readWave(wavFiles[i])
    # change level to your liking, .5 seemed reasonable
    louder <- normalize(original, unit=as.character(original@bit), level = .5)
    louderFile <- file.path(wavDir, paste0('Louder_', basename(wavFiles[i])))
    writeWave(louder, filename = louderFile)
}

```


---

