<p>Here's a solution using the tuneR package in R. The function will map across all your stereo recordings and extract audio from the 1st channel in the listed directory</p>
<pre><code>library(tuneR)
library(purrr)
</code></pre>
<p>List all stereo .wav files that needs to be converted</p>
<pre><code>file_paths &lt;- list.files(&quot;E:/test&quot;, pattern = &quot;\\.wav$&quot;, full.names = TRUE)
</code></pre>
<p>Creating a function to extract left (channel 1) from a stereo audio file and save it in the working directory</p>
<pre><code>extract_channel1 &lt;- function(file_path) {
  audio &lt;- readWave(file_path)
  channel_1 &lt;- channel(audio, &quot;left&quot;)
  writeWave(channel_1, paste0(&quot;mono_&quot;, basename(file_path)))
}
</code></pre>
<p>Applying the function to each file path in the list using purrr</p>
<pre><code>map(file_paths, ~ extract_channel1(.))
</code></pre>

CC BY-SA 4.0
2024-02-22T14:51:06.833Z
2024-02-22T14:51:06.833Z
indobatrachus
<p>Is there a way to batch convert them in R - almost certainly yes; Audacity - probably; Raven Pro - not that I'm aware of, but possibly.</p>
<p>However, I tend to use the free open-source program SoX (<a href="https://sourceforge.net/projects/sox/" rel="nofollow noreferrer">https://sourceforge.net/projects/sox/</a>) for this task with a little bit of shell scripting.</p>
<p>There are entire StackExchange sites dedicated to this sort of shell scripting, and I almost certainly adapted code from one of these. I'll leave searching for that as an exercise for the reader and I won't attempt to duplicate here.</p>
<p>Instead, I will post the recipe and script that I use to do this on the windows command line.</p>
<ol>
<li>Install <a href="https://(https://sourceforge.net/projects/sox/)" rel="nofollow noreferrer">SoX</a></li>
<li>Add SoX installation to windows path</li>
<li>Create a windows batch file (e.g. named splitStereo.bat) with the following content:</li>
</ol>
<blockquote>
<pre><code>for %%n in (*.wav) do (
sox %%n -c 1 %%n_left.wav remix 1
sox %%n -c 2 %%n_right.wav remix 2)
PAUSE
</code></pre>
</blockquote>
<ol start="4">
<li>Place stereo wav files to split in a folder with this batch file.</li>
<li>Run the batch file from the file manager.</li>
</ol>
<p>This script will batch convert all wav files in a folder splitting channel 1 into files with the suffix with _left.wav and channel 2 into files with the suffix '_right.wav'.</p>

CC BY-SA 4.0
2024-02-20T11:51:21.807Z
Scripting is OK, but in my windows11 system the cmd.exe does not work/exist anymore and all is replaced by Powershell and WindowsTerminal (only a sidenote).
WMXZ
CC BY-SA 4.0
2024-02-21T07:37:55.173Z
Thanks for the alternate solution. I think I figured out a way using the tuneR package in R
indobatrachus
CC BY-SA 4.0
2024-02-21T21:14:41.963Z
Glad you found a solution indobatrachus. Would be great if you could post as an answer here.

@WMXZ: I'm still on Windows 10, and surprised to hear that there's no cmd.exe. According to this link https://www.minitool.com/news/open-command-prompt-windows-11.html, it looks like cmd.exe still exists on Windows 11, it's just a little harder to find.
Brian Miller
CC BY-SA 4.0
2024-02-19T22:20:31.533Z
2024-02-19T22:20:31.533Z
Brian Miller
<p>I have multiple stereo .wav recordings which I want to convert into mono files for further analysis. Is there a way in RavenPro/R/Audacity to batch convert them to mono sound files (channel 1 or channel 2)?</p>

CC BY-SA 4.0
2024-02-20T07:44:37.767Z
What is special to "further analysis" that inhibits you to read stereo but process selected channel?
WMXZ
CC BY-SA 4.0
2024-02-20T10:22:38.527Z
Hi, I'm a bit confused about reading and processing stereo audio files directly (for example, creating annotations in one channel in a stereo audio file as a training data for a ML model)
indobatrachus
<r><pam><raven>
How to convert stereo audio files to mono?
# How to convert stereo audio files to mono?

(Asked by: username_0 on 2024-02-19)

I have multiple stereo .wav recordings which I want to convert into mono files for further analysis. Is there a way in RavenPro/R/Audacity to batch convert them to mono sound files (channel 1 or channel 2)?

**Tags:** r, pam, raven

> **Comments:**
> **username_1**: What is special to "further analysis" that inhibits you to read stereo but process selected channel?  
> **username_0**: Hi, I'm a bit confused about reading and processing stereo audio files directly (for example, creating annotations in one channel in a stereo audio file as a training data for a ML model)  

---

## 2 answers

### Answer by username_0 on 2024-02-22. Score: 3 | Accepted answer

Here's a solution using the tuneR package in R. The function will map across all your stereo recordings and extract audio from the 1st channel in the listed directory

```
library(tuneR)
library(purrr)

```

List all stereo .wav files that needs to be converted

```
file_paths <- list.files("E:/test", pattern = "\\.wav$", full.names = TRUE)

```

Creating a function to extract left (channel 1) from a stereo audio file and save it in the working directory

```
extract_channel1 <- function(file_path) {
  audio <- readWave(file_path)
  channel_1 <- channel(audio, "left")
  writeWave(channel_1, paste0("mono_", basename(file_path)))
}

```

Applying the function to each file path in the list using purrr

```
map(file_paths, ~ extract_channel1(.))

```


---

### Answer by username_2 on 2024-02-19. Score: 4

Is there a way to batch convert them in R - almost certainly yes; Audacity - probably; Raven Pro - not that I'm aware of, but possibly.

However, I tend to use the free open-source program SoX (<https://sourceforge.net/projects/sox/>) for this task with a little bit of shell scripting.

There are entire StackExchange sites dedicated to this sort of shell scripting, and I almost certainly adapted code from one of these. I'll leave searching for that as an exercise for the reader and I won't attempt to duplicate here.

Instead, I will post the recipe and script that I use to do this on the windows command line.

1. Install [SoX](https://(https://sourceforge.net/projects/sox/))
2. Add SoX installation to windows path
3. Create a windows batch file (e.g. named splitStereo.bat) with the following content:

> ```
> for %%n in (*.wav) do (
> sox %%n -c 1 %%n_left.wav remix 1
> sox %%n -c 2 %%n_right.wav remix 2)
> PAUSE
>
> ```

4. Place stereo wav files to split in a folder with this batch file.
5. Run the batch file from the file manager.

This script will batch convert all wav files in a folder splitting channel 1 into files with the suffix with \_left.wav and channel 2 into files with the suffix '\_right.wav'.

> **Comments:**
> **username_1**: Scripting is OK, but in my windows11 system the cmd.exe does not work/exist anymore and all is replaced by Powershell and WindowsTerminal (only a sidenote).  
> **username_0**: Thanks for the alternate solution. I think I figured out a way using the tuneR package in R  
> **username_2**: Glad you found a solution username_0. Would be great if you could post as an answer here.  @username_1: I'm still on Windows 10, and surprised to hear that there's no cmd.exe. According to this link https://www.minitool.com/news/open-command-prompt-windows-11.html, it looks like cmd.exe still exists on Windows 11, it's just a little harder to find.  

---

